Debug an MCP Server with MCP Inspector
Run MCP Inspector against a stdio or HTTP MCP server, call one tool with exact arguments, and read the failure class from the exit code.
Updated · Markdown version
MCP Inspector lets you call a single tool on an MCP server with exact arguments, without a chat client in the loop, so a failing call can be reproduced and compared run to run. The steps below use CLI mode, which prints the result and exits with a code you can branch on.
Before you start
The Inspector requires Node.js 22.23.4+, 24.22.1+, or 26.12.1+ as of 2026-11-21, and it runs through npx with no install. Get the launch command for your server from that server's README, because each server needs different arguments.
Steps
- Confirm the server starts and the tool name is correct. Replace the path with your server's entry point:
npx @modelcontextprotocol/inspector --cli node path/to/server/index.js --method tools/list- Call the failing tool with the arguments that trigger the bug. Each
--tool-argtakes onekey=valuepair:
npx @modelcontextprotocol/inspector --cli node path/to/server/index.js \
--method tools/call --tool-name get_weather --tool-arg city=Boston- When you need to compare outputs, request JSON and extract the part you care about:
npx @modelcontextprotocol/inspector --cli node path/to/server/index.js \
--method tools/call --tool-name get_weather --tool-arg city=Boston --format json | jq .result- For a remote server, replace the command with the URL and pass the transport:
npx @modelcontextprotocol/inspector --cli https://api.example.com/mcp --transport http \
--method tools/call --tool-name get_weather --tool-arg city=Boston- If you need to watch the JSON-RPC exchange, drop
--cliand launch the web UI. It prints a URL with a per-launch token, which you open in the browser.
Check that it worked. Read the exit code right after the call (echo $? in bash, $LASTEXITCODE in PowerShell). Exit 0 means the call completed. Exit 5 means the tool returned an error result or does not exist, and the failure details appear on stderr as a single JSON line. Fix the server, rerun the identical command, and confirm the exit code and the result change in the expected direction.
Pitfalls
- Numeric-looking strings get converted.
--tool-argparses each value as JSON when it can, sozip=10001is sent as a number. A value such aszip=012is sent as a string and then converted to the type the tool's schema declares, so it can arrive as12. When the bug depends on the exact string, pass the whole object with--tool-args-json '{"zip":"012"}'instead. - A pipe hides the exit code. In a pipeline, the shell reports the status of the last command, which is
jq, not the Inspector. Runset -o pipefailfirst, or capture the Inspector's output and status separately. - Flags after the server command go to the server. Mode flags are read only at the front of the command line. A
--cliplaced after the server path is passed to your server as an argument. Put the mode flag first. - CI jobs can stall on sign-in. Without a terminal, the CLI fails fast with
auth_requiredrather than waiting on a callback. In a pipeline, add--stored-auth-onlyso the run never opens a browser and fails with exit3when no stored token exists. - Secrets can land in a plain file. On a machine without an OS keychain, OAuth tokens and stdio
env:values are saved to~/.mcp-inspector/secrets.json, unencrypted by default. Check that file on shared machines, and delete debug credentials when you finish.
When to use a skill instead
A one-off Inspector call answers "what does this server return for these inputs." It does not tell you whether the tool's schema, error contract, or transport choice is sound, and that is the job of a design-review skill. mcp-server-builder covers tool design, JSON Schema inputs, error handling, and transport choice, so use it when the failing call exposes a design problem rather than a typo. When the cause is still unknown after a few calls, systematic-debugging imposes an order on the work: reproduce, reduce the input, change one variable per experiment, and write the expected result before each run. Ad-hoc prompting can find a bug quickly, but it tends to skip the step that proves the fix.
FAQ
Do I need a full MCP client to test a server? No. The CLI mode connects, sends one request you name with --method, prints the result, and exits, which is enough to reproduce a single tool call.
Can I run the Inspector in a CI pipeline? Yes. Use --cli with --format json, add --stored-auth-only so no browser opens, and branch on the exit code. Exit 5 signals a tool error and exit 4 signals an unreachable server.
Where does the Inspector keep OAuth tokens? It uses the OS keychain when one is available. Otherwise it writes them to ~/.mcp-inspector/secrets.json, and the file is unencrypted unless you supply a key. Check the current storage options on the official docs page, since they can change between releases.
Related skills in this catalog
Platform Score is our assessment under a published method. It is not a safety guarantee.
Related guides
- MCP Server Examples: Learning From a Reference Server
- Chrome DevTools MCP: Debug a Live Page Through an Agent
- MCP Client vs MCP Server: Who Starts Calls and Holds Keys
- Python MCP server quickstart: build and connect one locally
- MCP Tools, Resources, and Prompts: Which to Use
- What Are MCP Apps? Interactive UI in AI Chats
Sources
- https://modelcontextprotocol.io/docs/tools/inspector (accessed 2026-11-21)
- https://modelcontextprotocol.io/docs/2026-07-28/tools/inspector/cli.md (accessed 2026-11-21)
- https://github.com/modelcontextprotocol/inspector (accessed 2026-11-21)
This page is not offered to search engines yet: The content file does not mark this page indexable yet.