Using the CLI as an MCP host

Run local MCP servers from the CLI so the cloud Ask AI agent can call your tools during a turn, with Claude-Code-compatible .mcp.json config.

Like Claude Code, the TestRelic CLI is a full MCP host. It spawns your local MCP servers, lists their tools, and advertises them to the cloud agent. When the agent calls one, the CLI executes it locally and posts the result back — the agent's stream continues with your local tool's output.

Terminal~/shop-e2e

$ testrelic mcp add everything -- npx -y @modelcontextprotocol/server-everything

✓ added ‘everything’ (stdio) to ./.mcp.json

$ testrelic mcp list

everything stdio · project · npx -y @modelcontextprotocol/server-everything

.mcp.json

{
  "mcpServers": {
    "everything": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-everything"]
    }
  }
}

A hand-recreated slice of the real host — connecting a server, the /mcp health panel, the mode-scoped capability set, and secret masking in a tool result.

Manage servers

Use testrelic mcp add | list | remove to manage the local MCP servers the agent can call:

# stdio child process
testrelic mcp add everything -- npx -y @modelcontextprotocol/server-everything

# streamable HTTP (HTTPS endpoints supported)
testrelic mcp add --transport http myserver https://example.com/mcp

# write to the global config instead of the project file
testrelic mcp add --global everything -- npx -y @modelcontextprotocol/server-everything

testrelic mcp list
testrelic mcp remove everything
  • --transport http adds a streamable-HTTP server; HTTPS endpoints are supported.
  • --global writes to ~/.testrelic/mcp.json instead of the project-local ./.mcp.json.
  • Presets — /mcp in the interactive UI lists framework presets (Playwright, Appium, Maestro) you can toggle on and off without typing a command. Playwright and Appium are on by default; Maestro is opt-in.

Config files

Project config lives in ./.mcp.json (the Claude-Code-compatible format); global config in ~/.testrelic/mcp.json. On a name collision, the project config wins.

.mcp.json
{
  "mcpServers": {
    "everything": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-everything"]
    }
  }
}

Project servers need your trust

A project's ./.mcp.json can run any local command, so its servers aren't started until you trust the file. The interactive CLI asks once; testrelic mcp trust or --trust-mcp trusts it up front, and TESTRELIC_TRUST_PROJECT_MCP=1 does the same for CI. Trust is pinned to the file's content, so editing the file asks again. Where nothing can answer the prompt (piped input), untrusted project servers simply don't load. Files the CLI writes itself during setup or init are trusted automatically.

Per-run server and tool flags

FlagEffect
--mcp-config <file>Also load servers from this .mcp.json.
--strict-mcp-configWith --mcp-config, load only that file's servers.
--disable-mcp-server <a,b>Don't start these servers at all.
--no-mcpStart no MCP servers.
--allowed-tools <patterns>Tools that run without asking, e.g. mcp__playwright__*. Replaces the default allow list.
--disallowed-tools <patterns>Tools the agent may not call; the server keeps running.

Put these flags before the prompt: anything after the prompt is read as prompt text.

How a tool call flows

On startup the CLI spawns every configured (and, for project files, trusted) server, lists its tools, and advertises them to the cloud agent as <server>__<tool> (for example everything__echo). When the agent decides to call one:

  1. The cloud agent emits a client_tool_use request.
  2. The CLI executes the tool locally against the matching MCP server.
  3. The CLI posts the result back, and the agent's stream resumes with that output.

Use /mcp in the interactive UI to see live server health and each server's tool list.

Capabilities and limits

The host advertises a set of capabilities to the cloud agent via TESTRELIC_MCP_CAPS. These must be valid server capability values, and which set is available depends on your mode:

  • Cloud mode — the full capability set is available.
  • Local mode — capabilities are read-only.

A single turn can surface up to 200 client tools to the cloud agent, matching the deployed server's limit. See Capabilities for what each one covers.

Secret values are masked in tool results

Some MCP servers hand back more than you asked for — a browser-automation server's page snapshot, for example, inlines the live value of every form field, including anything typed into a password box. The host masks these before they go anywhere:

  • Any form control that reads as a credential (by label, placeholder, or the value's own shape) is replaced with [hidden] in the tool result — detection doesn't depend on recognizing the secret, so an ordinary-looking password is hidden too.
  • Once a value has been hidden once in a session, it's remembered and stripped from every later tool result, from any server — a console log line, a network body, or a direct field read.
  • Masking runs on every harness result, independent of tool name, so a new MCP tool is covered automatically without a CLI update.

Refs, roles, names, and everything else in the result survive untouched, so the agent can still see and act on the field — it just never sees, echoes, or persists the value.

Next steps

→ Slash commands · Configuration

Was this page helpful?

On this page