GeekCoding101 make your way to geek

MCP Inspector CLI: Test a Local Python MCP Server Step by Step

Use the MCP Inspector CLI to debug an MCP server locally: list tools, call them, read resources, get prompts and catch bad arguments before any AI host.

8 min read
Terminal screenshot showing the Node, Python, mcp package and MCP Inspector versions used for the lab
On this pageWhat you need before starting

MCP Inspector is the official tool for testing an MCP server on its own, and its CLI mode (--cli) lets you list tools, call them, read resources and fetch prompts from a terminal with no AI host, model, account or API key. To debug an MCP server locally, run the Inspector with your flags first, then --, then the command that starts your server.

This guide uses a small Python notes server and walks through every CLI method against it, including one deliberately bad call. If you want background on what the server itself is, read What Is an MCP Server? first.

What this covers, and what it does not: the official Inspector repository ships a browser UI (the default), a CLI, a TUI and an experimental mcpdo. I only cover the CLI here, and I did not test the browser flow. A passing CLI run shows that your server speaks the protocol and behaves correctly. It does not prove anything about a host’s permission policy, OAuth, production security or how a model will use your tools.

What you need before starting

  • git, uv, and Node.js with npm.
  • A supported Node version. Inspector 2.16.0 (the release used here) declares ^22.23.4 || ^24.22.1 || >=26.12.1 in its package engines. “Node 22+” is not enough: Node 22.23.1 and 24.18.0 do not satisfy that range.
  • Python 3.12 and the mcp package, pinned to 2.3.0 below.

The lab ran Node 24.22.1, Python 3.12.12 and mcp 2.3.0.

Set up the notes server

Clone the example server, add the pinned MCP package, and install the Inspector locally with an exact version:

Terminal window
git clone https://github.com/geekcoding101/mcp-server-python-notes.git notes-inspector-lab
cd notes-inspector-lab
uv add "mcp[cli]==2.3.0"
npm install --save-exact @modelcontextprotocol/inspector@2.16.0

The server exposes add_note(title, body), search_notes(query), a notes://{title} resource template and a summarize_note(title) prompt. It is the same server as in the earlier tutorial, not a new framework.

Keep notes inside the project

The original source stores notes in a folder under your home directory. For an isolated lab, change that one line so notes live in a notes folder next to server.py:

Terminal window
uv run python - <<'PYCODE'
from pathlib import Path
p = Path("server.py")
p.write_text(p.read_text().replace('Path.home() / "mcp-notes"', 'Path(__file__).resolve().parent / "notes"'))
PYCODE

Nothing else in the file changes. Each CLI call starts and stops its own session, but notes are written to disk, so what you add in one command is still there in the next.

Check your versions

Terminal window
node --version
uv run python --version
uv run python -c 'from importlib.metadata import version; print("mcp", version("mcp"))'
npx --no-install @modelcontextprotocol/inspector --version
Node 24.22.1, Python 3.12.12, mcp 2.3.0 and MCP Inspector 2.16.0 in the terminal

--no-install tells npx to use the copy in your project instead of downloading something new, so the version you pinned is the version that runs.

How the command is built

Every call has the same shape:

npx --no-install @modelcontextprotocol/inspector --cli <inspector flags> -- <server command>

Inspector flags go before the --. The command that launches your server goes after it. Mixing them up can send Inspector options to your server instead. The flags below come from the official CLI documentation.

Run everything from the project root, where server.py lives. A relative uv run server.py depends on the working directory. If you later move to a host that launches servers for you, it may need absolute paths, so check that host’s documentation rather than assuming.

List the server’s tools

Terminal window
npx --no-install @modelcontextprotocol/inspector --cli --method tools/list -- uv run server.py

The result is JSON describing each tool, including its name, description and input schema. In the lab run this returned both add_note and search_notes along with their input and output schemas. The schema is long, so scan for the tool names and the required fields rather than reading all of it.

This is the cheapest health check you have. If tools/list works, the server started, the handshake succeeded and your tools are registered.

Call a tool: add a note

Use tools/call with --tool-name and pass the arguments as JSON in --tool-args-json:

Terminal window
npx --no-install @modelcontextprotocol/inspector --cli --method tools/call --tool-name add_note --tool-args-json '{"title":"mcp","body":"MCP connects apps to tools."}' -- uv run server.py
MCP Inspector calls add_note and returns Saved mcp.md with isError false

Put single quotes around the whole JSON string. The double quotes inside stay as they are, and the shell does not try to interpret them. Without the outer quotes, the shell strips the inner quotes and the Inspector can no longer parse the argument object.

Because the note was written to notes/ on disk, a brand new session can find it:

Terminal window
npx --no-install @modelcontextprotocol/inspector --cli --method tools/call --tool-name search_notes --tool-args-json '{"query":"tools"}' -- uv run server.py
A separate MCP Inspector session finds the saved mcp note with structured output

Two separate processes just ran, and the second still saw the first one’s data. That is the point of testing against real storage.

Read the resource and fetch the prompt

Resources and prompts are separate parts of the protocol, and the CLI has a method for each. Start by listing resource templates:

Terminal window
npx --no-install @modelcontextprotocol/inspector --cli --method resources/templates/list -- uv run server.py

You should see the notes://{title} template. If you ran resources/list instead and got an empty list, that does not mean the notes resource is missing. A template describes a family of URIs, and it appears under resources/templates/list, not in the fixed resource list.

Now read the note you created through that template:

Terminal window
npx --no-install @modelcontextprotocol/inspector --cli --method resources/read --uri notes://mcp -- uv run server.py

Then fetch the prompt, passing its argument with --prompt-args:

Terminal window
npx --no-install @modelcontextprotocol/inspector --cli --method prompts/get --prompt-name summarize_note --prompt-args title=mcp -- uv run server.py
MCP Inspector reads notes://mcp and returns the summarize_note prompt

prompts/get returns the prompt messages your server would hand to a host. It does not call a model, so you are checking the template and its arguments, not any model’s answer.

Debug a failing call on purpose

A good debugging habit is to break something and see what the output looks like. Send a number where the schema expects a string:

Terminal window
npx --no-install @modelcontextprotocol/inspector --cli --method tools/call --tool-name search_notes --tool-args-json '{"query":123}' -- uv run server.py

Then read the exit status in a separate command:

Terminal window
echo $?
A numeric query fails string validation and MCP Inspector exits with status 5

In the tested run, the result contained isError: true, the CLI reported tool_is_error, and echo $? printed 5. This is a type mismatch, and it is the server’s input validation doing its job. The connection was fine: the server started, the handshake completed and the tool was found. Only the arguments were rejected. Telling those two situations apart saves a lot of time. If tools/list works but tools/call fails, look at your arguments and tool code, not your launch command.

When something goes wrong

  • Nothing happens or the session fails to start. Check that you are in the project root and that uv run server.py runs on its own. Check the Node version against the engines range above.
  • Invalid JSON errors. Re-check the single quotes around --tool-args-json.
  • Flags seem ignored. Make sure they come before --, not after it.
  • Mysterious protocol errors after you add logging. With a stdio server, standard output is the MCP transport. A stray print() writes into the protocol stream and corrupts it. Send debug output to standard error instead:
import sys
print("debug: searching notes", file=sys.stderr)

Optional: the browser UI

The same server can be opened in the Inspector’s graphical interface:

Terminal window
npx --no-install @modelcontextprotocol/inspector -- uv run server.py

I have not tested this flow for this article, so I make no assumptions about ports or access tokens. Follow the official Inspector repository for how it starts and what it prints.

Where this fits

Local stdio testing like this has no authentication step at all. Remote HTTP servers are a different case, covered in MCP Authorization and OAuth 2.1. For the bigger picture of how MCP differs from a normal API, see MCP vs API.

FAQ

Do I need an AI model or API key to use MCP Inspector?

No. With a local stdio server, the Inspector launches your server directly and talks to it over the protocol. There is no model, account or API key involved, which is why it is a good first step before connecting a host.

Why do I put -- before my server command?

The -- separates the Inspector’s own flags from the command that starts your server. Everything before it, such as --cli and --method, is read by the Inspector. Everything after it, such as uv run server.py, is the server launch command.

Why does resources/list return nothing when my server has a resource?

Your resource is probably a template such as notes://{title}, which is listed by resources/templates/list. Use that method to see it, then call resources/read with a concrete URI like notes://mcp.

Does a successful CLI run mean my server is ready for production?

No. It shows the server starts, advertises its capabilities and handles the calls you tried. It says nothing about a host’s permission rules, OAuth, hardening or how a model will choose and use your tools.

Thanks for reading my blog post! Feel free to check out my other posts or contact me via the social links in the footer.

Keep reading

All posts