Published on npm

@turingspark/mcp-tracer

A CLI debugging and testing toolkit for AI agent developers who build on MCP. Record every tool call, inspect traces, diff runs, replay deterministically, and assert in CI — no code changes required.

$ npm install -g @turingspark/mcp-tracer

What mcpx does

Your agent makes dozens of tool calls per session. When something goes wrong you need to see exactly what was sent, what came back, and how long it took. mcpx gives you that visibility in five commands.

📹

Record

Transparent proxy captures every tools/call as an NDJSON trace file. Works with HTTP and stdio MCP servers.

🔍

Inspect

Call timeline with latency, retries detection, error flagging, and warnings — all in your terminal.

Replay

Serve recorded responses from a trace file. Identical behavior every run — no API keys, no network.

📊

Diff

Compare two trace files side by side. Catch which tool calls were added, removed, or changed between runs.

Assert

Write YAML assertion rules and run them against any trace. CI-friendly exit codes.

Quick Start

Install globally or run with npx — no config required.

# Install globally npm install -g @turingspark/mcp-tracer # Or run directly with npx npx @turingspark/mcp-tracer record --stdio "uvx your-mcp-server" npx @turingspark/mcp-tracer inspect --trace trace.ndjson

Commands

CommandDescription
mcpx recordRecord tool calls between your agent and an MCP server
mcpx inspectAnalyze a trace file — timeline, latency, warnings
mcpx replayServe recorded responses from a trace file
mcpx diffCompare two trace files, highlight changes
mcpx assertRun YAML assertion rules against a trace (CI-friendly)

Record flags

FlagDescription
--target <url>URL of an HTTP-based MCP server to proxy
--stdio <command>Command to start a stdio-based MCP server
--port <n>Proxy port (default: 4111, auto-detects free port)
--out <file>Output trace file path (default: timestamped filename)

Inspect flags

FlagDescription
--trace <file>Path to the NDJSON trace file
--verboseShow full JSON payloads for each call
--step-threshold <n>Warn when step count exceeds this value
--latency-threshold <ms>Warn when call latency exceeds this value

Examples

Real workflows showing how mcpx fits into your agent development cycle.

Example 1 — Record & Inspect

Recording tool calls from a live MCP server

Start a recording session against any MCP server. Here we use the alpaca-mcp-server (paper trading) via stdio transport.

mcpx record --stdio "uvx alpaca-mcp-server" --out alpaca-trace.ndjson

Starting stdio server: uvx alpaca-mcp-server

Connected to: Alpaca MCP Server v3.1.1

mcpx record

Proxy: http://localhost:4111/mcp

Target: uvx alpaca-mcp-server

Trace: alpaca-trace.ndjson

Waiting for connections... (Ctrl+C to stop)

Point your agent (or any MCP client) at http://localhost:4111/mcp and make tool calls. Everything is recorded transparently. Hit Ctrl+C when done.

Now inspect the recorded trace:

mcpx inspect --trace alpaca-trace.ndjson

mcpx inspect

Session: 9bdca698-4499-45eb-b4fe-8069610437f5

Target: uvx alpaca-mcp-server

Recorded: 2026-03-28T19:52:28.330Z

Duration: 230.5s

Calls: 6 total, 5 unique tools

-------------------------------------------------------

# Tool Latency Status

1 get_account_info 234ms ok

2 get_stock_bars n/a pending

3 get_clock 81ms ok

4 get_orders 97ms ok

5 get_account_info n/a pending RETRY

-------------------------------------------------------

Warnings (1):

! Retry: get_account_info called 2x with identical arguments

Summary: 6 calls, 0 errors, 1 warnings

mcpx inspect automatically detects retries (same tool + same arguments called multiple times), high latency, and error responses. Use --verbose to see full request/response payloads.
Example 2 — Replay

Deterministic replay without a live server

Serve recorded responses from a trace file. Your agent sees identical behavior every time — no API keys, no network, no rate limits.

mcpx replay --trace alpaca-trace.ndjson

Server: http://localhost:4111/mcp

Trace: alpaca-trace.ndjson

Calls: 6 recorded responses loaded

Serving replay... (Ctrl+C to stop)

Now send the same tool call and get the exact recorded response:

curl -s -X POST http://localhost:4111/mcp \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/call", "params":{"name":"get_clock","arguments":{}}}'

{

"jsonrpc": "2.0",

"id": 1,

"result": {

"content": [{

"type": "text",

"text": "{"is_open":false,"next_close":"2026-03-30T16:00:00-04:00",...}"

}],

"isError": false

}

}

Replay matches incoming requests by tool name + arguments. If the agent sends a call that wasn't in the recording, replay returns a clear JSON-RPC error — no silent failures.
Example 3 — Diff

Catching regressions between runs

Compare two traces to see what changed. Did the agent start making extra calls? Did a tool response change? Diff tells you.

mcpx diff trace-before.ndjson trace-after.ndjson

mcpx diff

Before: trace-before.ndjson (4 calls)

After: trace-after.ndjson (5 calls)

-------------------------------------------------------

get_account_info

~ get_stock_bars arguments changed

get_clock

+ get_positions added

get_orders

-------------------------------------------------------

Summary: 1 added, 0 removed, 1 changed, 3 unchanged

Diff uses an LCS (longest common subsequence) algorithm to align call sequences, so it handles reordering gracefully. Exit code is 1 if any differences are found — perfect for CI gates.
Example 4 — Assert

CI-friendly trace validation

Write YAML rules that define what a "good" trace looks like. Run them in CI to catch regressions automatically.

rules.yaml

assert: - tool_called: get_account_info - tool_called: get_clock - tool_order: - get_account_info - get_stock_bars - get_orders - no_errors: true - no_retries: true - max_steps: 10 - max_latency: 5000 - tool_called_times: tool: get_account_info times: 1 - tool_called_with: tool: get_stock_bars args: symbols: AAPL
mcpx assert --trace alpaca-trace.ndjson --rules rules.yaml

Trace: alpaca-trace.ndjson

Rules: rules.yaml

-------------------------------------------------------

[PASS] tool_called: get_account_info

[PASS] tool_called: get_clock

[PASS] tool_order: get_account_info > get_stock_bars > get_orders

[PASS] no_errors: true

[PASS] no_retries: true

[PASS] max_steps: 10

[PASS] max_latency: 5000

[PASS] tool_called_times: get_account_info = 1

[PASS] tool_called_with: get_stock_bars

9 passed, 0 failed (9 total)

Exit code is 0 when all assertions pass, 1 when any fail. Add mcpx assert to your CI pipeline to enforce agent behavior contracts.

Assertion Rules Reference

All available rule types for mcpx assert.

RuleValueDescription
tool_calledstringAssert a tool was called at least once
tool_not_calledstringAssert a tool was never called
tool_orderstring[]Assert tools were called in this order
tool_called_times{tool, times}Assert exact call count for a tool
tool_called_with{tool, args}Assert a tool was called with specific arguments
max_stepsnumberAssert total calls don't exceed a limit
min_stepsnumberAssert at least this many calls were made
no_errorstrueAssert no tool calls returned errors
no_retriestrueAssert no duplicate calls with identical arguments
max_latencynumber (ms)Assert no call exceeds this latency

Trace Format

Traces are NDJSON files (one JSON object per line). The first line is session metadata; every subsequent line is a trace event. You can process them with any tool that reads JSON — jq, Python, your own scripts.

Example trace file

{"type":"meta","traceId":"9bdc...","targetUrl":"uvx alpaca-mcp-server",...} {"step":1,"callId":2,"tool":"get_account_info","eventType":"request",...} {"step":1,"callId":2,"tool":"get_account_info","eventType":"response","latencyMs":234,...}
FieldDescription
stepAuto-incrementing counter per tool call
callIdJSON-RPC id — links request to response
toolTool name (e.g., get_stock_bars)
eventTyperequest, response, or error
latencyMsTime between request and response (on response events)
input / outputTool arguments (request) or result payload (response)

How it works

mcpx is a transparent HTTP reverse proxy with JSON-RPC awareness. It doesn't re-register tools or modify messages — it just observes.

# Record mode Agent --> mcpx proxy (localhost:4111) --> MCP Server | trace.ndjson # Replay mode Agent --> mcpx replay (localhost:4111) --> recorded responses
1

HTTP transport: mcpx forwards requests to the target URL using native fetch. It handles both JSON and SSE responses, tapping the stream without buffering.

2

Stdio transport: mcpx spawns the MCP server as a child process and connects via the SDK's StdioClientTransport. The agent still talks HTTP to the proxy.

3

Only tools/call is traced: Protocol messages (initialize, tools/list, notifications) pass through but aren't recorded. The trace captures what matters: which tools were called, with what arguments, and what came back.

Record. Inspect. Replay. Ship with confidence.

Add mcpx to your agent workflow and get full visibility into every tool call. Test deterministically. Catch regressions in CI.

npx @turingspark/mcp-tracer record --stdio "your-mcp-server"