# Debug an MCP Server with MCP Inspector

> Canonical: https://skillalmanac.com/learn/debug-an-mcp-server-with-inspector | Updated: 2026-11-21 | Index status: not offered to search engines

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.

## Facts

- 2026-11-21: MCP Inspector runs through npx @modelcontextprotocol/inspector and requires Node.js 22.23.4+, 24.22.1+, or 26.12.1+ (https://modelcontextprotocol.io/docs/tools/inspector)
- 2026-11-21: The package offers three clients behind one binary: web (default), --cli, and --tui (https://modelcontextprotocol.io/docs/tools/inspector)
- 2026-11-21: In CLI mode, tools/call takes --tool-name and repeated --tool-arg key=value pairs, and --format json prints one JSON object on stdout (https://modelcontextprotocol.io/docs/2026-07-28/tools/inspector/cli.md)
- 2026-11-21: CLI exit code 5 means a tool returned isError true or was not found, exit 3 means authentication is required, and exit 4 means the server is unreachable (https://modelcontextprotocol.io/docs/2026-07-28/tools/inspector/cli.md)
- 2026-11-21: Without a keychain, the Inspector stores OAuth tokens and stdio env values in ~/.mcp-inspector/secrets.json, unencrypted unless a key is supplied (https://modelcontextprotocol.io/docs/tools/inspector)

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

1. Confirm the server starts and the tool name is correct. Replace the path with your server's entry point:

   ```bash
   npx @modelcontextprotocol/inspector --cli node path/to/server/index.js --method tools/list
   ```

2. Call the failing tool with the arguments that trigger the bug. Each `--tool-arg` takes one `key=value` pair:

   ```bash
   npx @modelcontextprotocol/inspector --cli node path/to/server/index.js \
     --method tools/call --tool-name get_weather --tool-arg city=Boston
   ```

3. When you need to compare outputs, request JSON and extract the part you care about:

   ```bash
   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
   ```

4. For a remote server, replace the command with the URL and pass the transport:

   ```bash
   npx @modelcontextprotocol/inspector --cli https://api.example.com/mcp --transport http \
     --method tools/call --tool-name get_weather --tool-arg city=Boston
   ```

5. If you need to watch the JSON-RPC exchange, drop `--cli` and 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-arg` parses each value as JSON when it can, so `zip=10001` is sent as a number. A value such as `zip=012` is sent as a string and then converted to the type the tool's schema declares, so it can arrive as `12`. 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. Run `set -o pipefail` first, 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 `--cli` placed 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_required` rather than waiting on a callback. In a pipeline, add `--stored-auth-only` so the run never opens a browser and fails with exit `3` when 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](/skills/skill-almanac/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](/skills/skill-almanac/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

- [mcp-server-builder](https://skillalmanac.com/skills/skill-almanac/mcp-server-builder.md): Platform Score 56/100 (provisional)
- [systematic-debugging](https://skillalmanac.com/skills/skill-almanac/systematic-debugging.md): Platform Score 57/100 (provisional)

## Related guides

- [MCP Server Examples: Learning From a Reference Server](https://skillalmanac.com/learn/mcp-server-examples.md)
- [Chrome DevTools MCP: Debug a Live Page Through an Agent](https://skillalmanac.com/learn/chrome-devtools-mcp-guide.md)
- [MCP Client vs MCP Server: Who Starts Calls and Holds Keys](https://skillalmanac.com/learn/mcp-client-vs-mcp-server.md)
- [Python MCP server quickstart: build and connect one locally](https://skillalmanac.com/learn/python-mcp-server-quickstart.md)
- [MCP Tools, Resources, and Prompts: Which to Use](https://skillalmanac.com/learn/mcp-tools-resources-prompts.md)
- [What Are MCP Apps? Interactive UI in AI Chats](https://skillalmanac.com/learn/what-are-mcp-apps.md)

## Sources

- https://modelcontextprotocol.io/docs/tools/inspector
- https://modelcontextprotocol.io/docs/2026-07-28/tools/inspector/cli.md
- https://github.com/modelcontextprotocol/inspector

Platform Scores report our assessment under a published method. They are not a safety guarantee.
