Testing MCP servers with MCP Inspector
Date published:
If you’re building tools, resources, or prompts with the Model Context Protocol (MCP), the fastest feedback loop is MCP Inspector. It connects to your server over stdio or WebSocket, lets you invoke tools, fetch resources, and preview prompts—without writing any client code.
This post shows a practical, end‑to‑end workflow I use to validate an MCP server (Python or Node.js), plus common pitfalls and fixes.
What you’ll test
- Tool: add(a, b) → returns a sum
- Resource: file://path → returns file contents (or a readable error)
- Prompt: review-code(code) → returns a single user message
Use your own server or drop in a minimal example. The goal is to prove the contract works before wiring it into apps and agents.
Why MCP Inspector
- Zero client code — iterate on the server contract first
- Faster feedback — tools/resources/prompts are one click away
- Transparent — Inspector streams your server’s stderr for instant debugging
Install or launch MCP Inspector
https://github.com/modelcontextprotocol/inspector
Connect a stdio server
- In Inspector, click Add Server → Transport: stdio
- Command: the executable that starts your server
- Args: any arguments your server needs
- Working Directory: folder where your server expects to run
- Save → Connect
Inspector will start your process and stream stderr for visibility. If your server speaks MCP over stdio, you’ll see Tools, Resources, and Prompts populate.
Connect a WebSocket server
- Add Server → Transport: WebSocket
- URL: ws://localhost:PORT (or wss:// for TLS)
- Save → Connect
If your server requires auth headers or query params, add them as needed.
Using the Inspector
- Tools — See your tools with parameters. Provide inputs and execute to view the result and timing.
- Resources — Browse or request resources (e.g., file:// paths, http(s)://). Content shows inline when supported.
- Prompts — Preview prompt templates with variables. Render and inspect the final user message.
Below gist contains a tiny Python server with one tool, one resource
Wrap‑up
MCP Inspector is the quickest way to validate an MCP server contract: wire up stdio/WebSocket, run a few calls, and iterate fast with live logs. Once everything looks good, plug the same server into your app with confidence.
References
- MCP Inspector (GitHub): https://github.com/modelcontextprotocol/inspector
