Skip to content

MCP Server

Tapsmith includes a built-in MCP server that lets AI coding agents run tests, interact with devices, and inspect results through a standardized tool interface. Both modes expose the same 16 tools for device interaction, test execution, result browsing, watch mode, and session info.

The MCP server operates in two modes:

When running tapsmith test --ui, a Streamable HTTP MCP endpoint is hosted alongside the UI. The agent shares the same daemon, device, and test session as the UI — test runs appear in the UI with full progress tracking, and both the agent and user share mutual exclusion (only one run at a time).

To connect, copy the MCP URL from the MCP panel in the UI into any MCP client that supports Streamable HTTP transport. Replace the example URL below with the URL shown in the UI.

Claude Code:

Terminal window
claude mcp add tapsmith --transport http http://localhost:9274/mcp

Codex CLI:

Terminal window
codex mcp add tapsmith http://localhost:9274/mcp

Generic MCP config:

{
"mcpServers": {
"tapsmith": {
"url": "http://localhost:9274/mcp"
}
}
}

The MCP panel in the UI shows the connection status and a live activity feed of all tool calls.

Configure your MCP client to launch tapsmith mcp-server over stdio. You normally do not run this command directly; Codex, Claude Code, or another MCP client starts it as a subprocess when needed. The agent gets its own headless test session, daemon, and device, fully independent from any UI session. Test files and projects are discovered lazily on the first test-management tool call.

Codex CLI:

Terminal window
codex mcp add tapsmith -- npx tapsmith mcp-server

Claude Code:

Terminal window
claude mcp add tapsmith -- npx tapsmith mcp-server

Generic MCP stdio config:

{
"mcpServers": {
"tapsmith": {
"command": "npx",
"args": ["tapsmith", "mcp-server"]
}
}
}

To use a non-default Tapsmith config, include the config flag in the command your MCP client launches:

Terminal window
codex mcp add tapsmith-ios -- npx tapsmith mcp-server --config tapsmith.config.ios.mjs
claude mcp add tapsmith-ios -- npx tapsmith mcp-server --config tapsmith.config.ios.mjs

If a UI server is already running, stdio mode will detect it and suggest connecting via HTTP instead. Use HTTP mode when you want the agent and browser UI to share one visible session; use stdio when you want a standalone agent-owned session.

Get the current screen’s accessibility tree with copy-paste-ready Tapsmith selectors for each interactive element. Use this first when writing tests to see what’s on screen.

ParameterTypeRequiredDescription
devicestringNoDevice serial from tapsmith_list_devices. Uses the default device when omitted.

Returns a text representation of the accessibility tree with suggested selectors like device.getByRole("button", { name: "Login" }) for each interactive element.

Capture a PNG screenshot of the device screen. Use when you need to visually verify what’s on screen or when the accessibility tree is insufficient.

ParameterTypeRequiredDescription
devicestringNoDevice serial. Uses the default device when omitted.

Returns a base64-encoded PNG image.

Test a Tapsmith selector against the current screen. Returns whether it matches, how many elements match, and details about each match. Use to validate selectors before putting them in test code.

ParameterTypeRequiredDescription
selectorstringYesTapsmith selector string, e.g. device.getByRole("button", { name: "Login" })
devicestringNoDevice serial. Uses the default device when omitted.

Returns a JSON object with matched (boolean), count (number), and elements (array of matched elements with role, text, and bounds).

Tap a UI element matching the given Tapsmith selector.

ParameterTypeRequiredDescription
selectorstringYesTapsmith selector, e.g. device.getByRole("button", { name: "Login" })
devicestringNoDevice serial. Uses the default device when omitted.

Type text into an element matching the selector.

ParameterTypeRequiredDescription
selectorstringYesTapsmith selector for the text field
textstringYesText to type
clearbooleanNoClear existing text before typing (default: false)
devicestringNoDevice serial. Uses the default device when omitted.

Swipe on the device screen in the given direction. Use to scroll or navigate between screens.

ParameterTypeRequiredDescription
directionstringYesOne of: up, down, left, right
devicestringNoDevice serial. Uses the default device when omitted.

Press a device key.

ParameterTypeRequiredDescription
keystringYesKey name: back, home, enter, tab, delete, etc.
devicestringNoDevice serial. Uses the default device when omitted.

Launch an app on the device.

ParameterTypeRequiredDescription
packagestringYesAndroid package name or iOS bundle ID
clear_databooleanNoClear app data before launching (default: false)
devicestringNoDevice serial. Uses the default device when omitted.

List all connected mobile devices and emulators across all platforms. Returns serial numbers needed for the device parameter on other tools.

No parameters.

Returns a JSON array of device objects with serial, model, platform (android/ios), os_version, is_emulator, and state.

Run Tapsmith test files and return structured results. Only one test run can execute at a time. In SSE mode, runs appear in the UI with full progress tracking. In stdio mode, runs execute in the headless MCP session and results are available through tapsmith_list_results.

ParameterTypeRequiredDescription
filesstring[]YesAbsolute file paths or glob patterns. Use tapsmith_list_tests to find available files.
teststringNoRun a specific test by its full name (e.g. "Login screen > submits form"). Only works with a single file.
projectstringNoProject name to target a specific platform/device (e.g. "android", "ios"). Required when the same test file runs on multiple platforms.
devicestringNoDevice serial (ignored in SSE mode — use project instead).

On success: returns a summary like “All tests passed: 5 passed, 0 skipped (12.3s)”.

On failure: returns a detailed report including:

  • Failed test names with error messages
  • Steps leading to the failure (from the trace)
  • Device logs around the failure time
  • Trace file path for further debugging with tapsmith_read_trace
  • A screenshot at the moment of failure

Read a Tapsmith trace archive (.zip) and return step-by-step test execution data. Use to debug why a test failed.

ParameterTypeRequiredDescription
pathstringYesPath to the trace .zip file
include_screenshotsbooleanNoInclude base64 screenshots for each step (default: false)
device_logsstringNoInclude device logs: errors (default, error/warn only), all, or none

Returns trace metadata (device, platform, test file, duration) followed by a step-by-step action list with status, selectors, durations, and error details.

These tools operate on the current MCP test session. In SSE mode that is the browser UI session; in stdio mode it is the standalone headless session created by the client-launched tapsmith mcp-server subprocess.

List all test files, projects, and test names discovered by the current MCP test session. Call this before tapsmith_run_tests to get exact file paths, test names, and project names.

No parameters.

Returns a hierarchical tree showing:

  • Available projects
  • Test files with absolute paths
  • Describe blocks (suites)
  • Individual test names with their full names (for use with tapsmith_run_tests)

Browse test results from the current session. Shows pass/fail/skip status, duration, and error messages.

ParameterTypeRequiredDescription
statusstringNoFilter by status: passed, failed, or skipped
filestringNoFilter by file path substring
detailsbooleanNoInclude trace steps for failed tests (default: false)

Returns a summary with counts, then per-test results including status, full name, duration, project, file path, and (when details: true) the steps and device logs leading to the failure.

Stop the currently running test execution. Works whether the run was started by the agent or by the user in the UI.

No parameters.

Get configuration and environment info for the current test session. Useful for understanding the test environment before writing or running tests.

No parameters.

Returns session details: device serial, platform, app package, timeout, retries, and per-project settings (name, platform, package, test file count, dependencies).

Toggle watch mode on a test file. When enabled, the file automatically re-runs on save.

ParameterTypeRequiredDescription
filestringYesAbsolute path to the test file
teststringNoSpecific test full name to watch (watches the whole file if omitted)
projectstringNoProject name to scope the watch to

Returns a message indicating whether watch mode was enabled or disabled.

  1. Start the UI: tapsmith test --ui
  2. Connect your agent to the MCP endpoint shown in the MCP panel
  3. Understand the environment: call tapsmith_session_info to see platform, device, package, and project configuration
  4. Discover tests: call tapsmith_list_tests to see the full test tree with file paths and test names
  5. Explore the screen: use tapsmith_snapshot to see the accessibility tree with suggested selectors, then tapsmith_test_selector to validate a selector before using it
  6. Run tests: call tapsmith_run_tests with file paths and optional test name / project filters. On failure, the response includes error details, trace steps, and a screenshot
  7. Review results: use tapsmith_list_results to browse all results, optionally filtering by status or file. Pass details: true to see trace steps for failures
  8. Debug failures: use tapsmith_read_trace with the trace file path from the failure report for step-by-step debugging
  9. Iterate: toggle tapsmith_watch on files being actively developed for automatic re-runs on save
  1. Add the MCP server config: codex mcp add tapsmith -- npx tapsmith mcp-server
  2. Understand the environment: call tapsmith_session_info to lazy-load config, connect a device, and show project settings
  3. Discover tests: call tapsmith_list_tests to get file paths, test names, and project names from the headless session
  4. Explore the screen: use tapsmith_snapshot and tapsmith_test_selector against the headless session’s selected device
  5. Run tests: call tapsmith_run_tests; results are stored in the headless session for tapsmith_list_results
  6. Iterate: use tapsmith_watch to re-run watched files on save, or tapsmith_stop_tests to terminate a running headless test run

Device action tools (tapsmith_tap, tapsmith_type, tapsmith_test_selector) expect Tapsmith selector strings. These are the same expressions you’d write in test code:

device.getByRole("button", { name: "Login" })
device.getByText("Welcome")
device.getByText("Sign In", { exact: true })
device.getByDescription("Close menu")
device.getByTestId("submit-button")
device.getByPlaceholder("Email")
device.locator({ id: "com.myapp:id/input" })

Use tapsmith_snapshot to see suggested selectors for every interactive element on screen.

When the config defines multiple projects (e.g. android and ios), all session-aware tools respect project scoping:

  • tapsmith_run_tests accepts a project parameter to target a specific project
  • tapsmith_list_tests shows the full tree grouped by project
  • tapsmith_list_results includes the project name for each result
  • tapsmith_watch accepts a project parameter to scope the watch

Use tapsmith_session_info to see available projects and their configuration.

The MCP server exposes a tapsmith://api-reference resource containing the complete Tapsmith API documentation. Agents can read this resource to understand available methods and their signatures without needing external documentation.