Blog / Test MCP servers with agents
See exactly what your agent sends to the model: wire-capturing Claude Code, Codex and Grok
Most of what we know about how agent apps load MCP tools came from looking at the actual requests. Here's the method, minus the scripts, and the traps that change what you see.
Why capture the wire
Agent apps change fast and their docs lag. The only reliable way to know what reaches the model is to look at the requests. That's how we found that Claude Code sends no MCP definitions up front, that Codex writes JavaScript to find tools, and that a lab flag had silently turned tool search off. See Claude Code tool search, seen from the wire.
The method
- Start an HTTPS proxy (we use mitmproxy) on a local port, with a fresh CA in a temporary config folder.
- Trust the CA only in the child process: set
HTTPS_PROXYplus the app's CA variable (NODE_EXTRA_CA_CERTSfor Node apps,SSL_CERT_FILEor the app's own setting for others) in that process's environment only. - Run the app normally, with its usual login and endpoint, against your MCP server.
- Delete the CA when the process exits (a shell trap), so nothing stays trusted.
- Tokenize the saved bodies with a fixed tokenizer (we use o200k_base) and keep each provider's own usage for per-request input.
Want to see what agents send with your server attached?
We capture each agent app's real requests with your MCP server and show what's loaded, searched, cut and resent.
Redaction
- Strip
Authorization,x-api-keyand cookie headers. - Mask token patterns in bodies: API-key prefixes, JWTs, Bearer strings.
- Grep excerpts again before sharing. Keep raw dumps local and out of git.
- For MCP traffic, record JSON-RPC bodies only, never headers.
What the first requests contained
| App | First request | Tools in it | MCP tools |
|---|---|---|---|
| Claude Code 2.1.301 | 17,564 tokens | 13, incl. ToolSearch | 0 (113 names in a reminder) |
| Codex 0.161.0 | 15,383 tokens | Namespaces: one code tool with a 6,471-token description | 0; found via ALL_TOOLS in code |
| Grok Build 1.0.60 | 19,674 tokens | 28, incl. search_tool and use_tool | 0; server names and counts in a reminder |
Same prompt and 99-tool server; all three called the right tool. Totals for the task: about 76k (Claude Code), 137k (Codex), 158k (Grok Build) input tokens.
Traps
- Base-URL proxies change Claude Code. With a custom
ANTHROPIC_BASE_URL, first-request input jumped to 143,357 tokens with tool search off; settingENABLE_TOOL_SEARCH=truebrought it back to 22,446. See Claude Code can't see your MCP tools? - Lab flags change defaults.
--tools ""also removed ToolSearch: 110,998 tokens, and the env var couldn't restore it. Check your lab command against a default run. - Untrusted folders. Grok Build dropped a project MCP server silently in headless mode until the folder was trusted.
- Async connections. Grok connects servers asynchronously; in about 1 of 8 preflight runs the first request didn't yet list the server.
Go deeper: How Codex finds MCP tools, How agents load MCP tools, Test against production read-only.
Back to testing MCP servers with agents.
How we measured
- Captures: one prompt per app against a local 99-tool stub, 16 Oct 2026, normal logins.
- Config matrix: Claude Code 2.1.301, “say hi” with the 99-tool mock, first-request input tokens, single runs per config.
- We don't publish our capture scripts; this page describes the method only.
FAQ
How can I see what tools and context Claude Code or Codex sends to the model?
Run the app behind an HTTPS proxy scoped to that process, with a temporary CA trusted only by the child process, and record request bodies. Redact credentials before saving. Avoid changing the app's API base URL, which can change its behaviour.
Is it safe to MITM my own agent app?
It can be, if the CA is temporary, trusted only by that process, deleted afterwards, and every credential is redacted before anything is written. Never commit raw captures.
Does a capture change what the app does?
It can. With a custom ANTHROPIC_BASE_URL, Claude Code turned tool search off and sent all 99 tool definitions. With an HTTPS proxy and the normal endpoint, tool search stayed on.
Want to see what agents send with your server attached?
We capture each agent app's real requests with your MCP server and show what's loaded, searched, cut and resent.