How to Test an MCP Server with the MCP Inspector
The MCP Inspector is the official visual tool for testing MCP servers. You point it at a server, and it acts as a client so you can list tools, call them with your own arguments, read resources, fetch prompts and view the JSON-RPC messages. Testing with the Inspector before connecting to an AI app saves a lot of guesswork, because it removes the model from the loop.
Why test without a model first
When a tool does not work inside a chat app, many things could be wrong: the server could crash, the schema could be wrong, the config could be wrong, or the model could simply choose not to call the tool. The Inspector isolates the server. If it works there, you know the server is fine and any remaining problem is in the client config or the tool descriptions.
Start the Inspector
The Inspector runs through npx and needs Node.js. Pass it the command that starts your server. For a built TypeScript server:
npx @modelcontextprotocol/inspector node build/index.js
For a Python server:
npx @modelcontextprotocol/inspector python server.py
With a server that needs arguments or environment variables, put them after the command. The Inspector prints a local URL; open it in your browser. Some versions include an access token in the URL for protection, so use the link exactly as printed.
The main areas of the interface
- Connection pane. Choose the transport (stdio or Streamable HTTP), set the command, arguments, environment variables or the server URL, and click Connect.
- Tools tab. Lists tools with their descriptions and input schemas. Select one, fill in a form generated from the schema, and run it.
- Resources tab. Lists resources and templates. Read one to see its contents and MIME type.
- Prompts tab. Lists prompts, lets you fill arguments and shows the messages they produce.
- Notifications and history. Shows server notifications and the log of requests and responses so you can inspect the raw messages.
A testing routine
- Connect. If connection fails, the problem is the command or the handshake. Look at the error output pane for stderr from your server.
- List tools. Check each name, description and schema. Read the descriptions as if you were the model. Would you know when to use the tool?
- Call the happy path. Run each tool with normal input and check the content.
- Call the edge cases. Try empty strings, very large values, missing optional fields and wrong types. The form helps with types, but you can still send surprising values.
- Check errors. Cause a failure on purpose, such as a missing file, and confirm the message is clear.
- Look at the history. Open the request and response entries to see exactly what a real client would receive.
Testing a remote server
For a server running over Streamable HTTP, start it first, then in the Inspector choose the Streamable HTTP transport and enter its URL, such as http://localhost:3000/mcp. If the server needs a bearer token, the connection pane has a place for authentication headers.
The command-line mode
The Inspector also offers a non-interactive CLI mode, which is handy in scripts and continuous integration. Its flags have changed between releases, so check npx @modelcontextprotocol/inspector --help for the options your installed version supports before relying on any particular flag in automation.
Using the Python helper
If you use the Python SDK with the cli extra, mcp dev server.py starts the Inspector and your server in one step. It is a convenience wrapper around the same tool.
Typical problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Connect fails at once | Wrong command or missing dependency | Run the command in a terminal and fix the error |
| Connects, but JSON parse errors appear | Output on stdout that is not protocol | Move logging to stderr |
| Tool call returns a validation error | Arguments do not match the schema | Check types and required fields |
| HTTP connection refused | Server not running or wrong port or path | Check the URL, including the path such as /mcp |
| 401 Unauthorized | Missing or wrong token | Add the correct authentication header |
The Inspector is a development tool. Do not expose it on a public network, because it can launch commands on your machine and call your server's tools.
Add it to your workflow
A useful habit is to add an npm script or Makefile target that launches the Inspector with your server, such as "inspect": "npx @modelcontextprotocol/inspector node build/index.js" in package.json. New contributors can then check their changes with one command. Later posts in this course show how to turn the same checks into automated tests.
Comments
No comments yet. Have a question or a tip? Be the first to share it.