Skip to main content
RapidDev - Software Development Agency
mcp-tutorial

How to test an MCP server with the MCP Inspector

The MCP Inspector is a browser-based testing tool that connects to your MCP server and lets you interactively call tools, read resources, use prompts, and view raw JSON-RPC messages. Run it with npx -y @modelcontextprotocol/inspector, point it at your server command, and debug issues before connecting to Claude Desktop or Cursor. It is the single most important debugging tool in the MCP ecosystem.

What you'll learn

  • How to launch the MCP Inspector and connect it to your server
  • How to test tools, resources, and prompts interactively
  • How to read JSON-RPC messages for protocol-level debugging
  • How to diagnose common MCP server issues using the Inspector
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner8 min read10 minAny MCP server (TypeScript, Python, or other), any OSMarch 2026RapidDev Engineering Team
TL;DR

The MCP Inspector is a browser-based testing tool that connects to your MCP server and lets you interactively call tools, read resources, use prompts, and view raw JSON-RPC messages. Run it with npx -y @modelcontextprotocol/inspector, point it at your server command, and debug issues before connecting to Claude Desktop or Cursor. It is the single most important debugging tool in the MCP ecosystem.

Debug MCP Servers with the Inspector Before Connecting to AI Hosts

The MCP Inspector eliminates guesswork from MCP server development. Instead of connecting your server to Claude Desktop, asking a question, and hoping it works, the Inspector lets you test each tool, resource, and prompt individually. You can see the exact JSON-RPC request and response for every interaction, which makes it trivial to spot schema errors, missing parameters, or malformed responses. Always test with the Inspector first — then connect to your AI host.

Prerequisites

  • A working MCP server (TypeScript or Python)
  • Node.js 18+ installed (the Inspector runs on Node.js)
  • A web browser for the Inspector UI

Step-by-step guide

1

Launch the MCP Inspector with your server

Run the Inspector using npx with the -y flag and pass your server command as arguments. The Inspector starts your server as a child process and connects to it via stdio. It then opens a browser-based UI where you can interact with your server.

typescript
1# For a TypeScript server using tsx
2npx -y @modelcontextprotocol/inspector tsx src/index.ts
3
4# For a compiled TypeScript server
5npx -y @modelcontextprotocol/inspector node dist/index.js
6
7# For a Python server
8npx -y @modelcontextprotocol/inspector python server.py
9
10# For a Python server using uv
11npx -y @modelcontextprotocol/inspector uv run server.py

Expected result: The Inspector starts your server and opens a browser window with the testing UI.

2

Explore the Inspector interface

The Inspector UI has several panels. The left sidebar shows your server's capabilities organized by type: Tools, Resources, and Prompts. The main panel shows the interaction area where you fill in parameters and see results. The bottom panel shows raw JSON-RPC messages. The connection status indicator at the top shows whether your server is connected and responding.

Expected result: You can see your server's tools, resources, and prompts listed in the sidebar.

3

Test a tool by calling it with parameters

Click on a tool in the sidebar to open it. The Inspector displays the tool's description and input schema. Fill in the parameter fields — the Inspector shows the parameter types and descriptions from your Zod schemas. Click 'Run Tool' to send a tools/call JSON-RPC request to your server. The response appears in the main panel, and the raw JSON-RPC messages appear at the bottom.

typescript
1// Example: testing a 'get_weather' tool
2// 1. Click 'get_weather' in the Tools list
3// 2. Fill in the 'city' parameter: "tokyo"
4// 3. Click 'Run Tool'
5// 4. See the response:
6// "Weather in Tokyo: 22°C, Clear sky, 55% humidity"
7// 5. Check the JSON-RPC tab to see the raw request/response

Expected result: The tool executes and returns a result. You can see both the formatted output and the raw JSON-RPC messages.

4

Test resources by reading them

Click on a resource in the sidebar. For static resources, click 'Read Resource' to fetch the data. For resource templates with URI parameters, fill in the parameter fields first. The Inspector shows the resource contents including the MIME type and raw data. This is useful for verifying that your resources return the expected data format.

typescript
1// Example: testing a 'weather://cities' resource
2// 1. Click 'weather://cities' in the Resources list
3// 2. Click 'Read Resource'
4// 3. See the JSON response with city data
5// 4. Verify MIME type is 'application/json'

Expected result: The resource data is displayed. You can verify the format, MIME type, and content are correct.

5

Use the JSON-RPC message log for debugging

The bottom panel of the Inspector shows every JSON-RPC message exchanged between the Inspector (acting as the client) and your server. This includes the initialization handshake, tool calls, resource reads, and error responses. When something goes wrong, the raw messages reveal exactly what the server received and what it returned. Look for malformed responses, missing fields, or unexpected error codes.

Expected result: You can read the JSON-RPC message log and identify protocol-level issues.

6

Test error handling by providing invalid inputs

Intentionally provide invalid inputs to your tools to verify error handling. Try empty strings, missing required parameters, out-of-range values, and completely wrong data types. Your server should return responses with isError: true and helpful error messages. The Inspector shows how the error propagates through the protocol.

typescript
1// Error handling tests to try:
2// 1. Call get_weather with city: "" (empty string)
3// 2. Call get_weather with city: "nonexistent_city"
4// 3. Call calculate with b: 0, operation: "divide" (division by zero)
5// 4. Omit required parameters entirely

Expected result: Your server handles all error cases gracefully with isError: true and descriptive error messages.

7

Pass environment variables to the Inspector

If your server needs environment variables (API keys, database URLs), pass them using the -e flag or set them in your shell before running the Inspector. The Inspector forwards environment variables to the server process it spawns.

typescript
1# Pass environment variables with -e flag
2npx -y @modelcontextprotocol/inspector -e API_KEY=sk-abc123 tsx src/index.ts
3
4# Or set them in your shell first
5export API_KEY=sk-abc123
6npx -y @modelcontextprotocol/inspector tsx src/index.ts

Expected result: Your server receives the environment variables and can use them for API calls or configuration.

Complete working example

src/index.ts
1// A server designed to demonstrate Inspector testing
2// Run: npx -y @modelcontextprotocol/inspector tsx src/index.ts
3
4import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6import { z } from "zod";
7
8const server = new McpServer({
9 name: "inspector-demo",
10 version: "1.0.0",
11});
12
13// Tool with comprehensive error handling
14server.tool(
15 "divide",
16 "Divide two numbers with proper error handling",
17 {
18 numerator: z.number().describe("The number to divide"),
19 denominator: z.number().describe("The number to divide by"),
20 },
21 async ({ numerator, denominator }) => {
22 if (denominator === 0) {
23 return {
24 content: [{ type: "text", text: "Error: Cannot divide by zero" }],
25 isError: true,
26 };
27 }
28 const result = numerator / denominator;
29 return {
30 content: [{ type: "text", text: `${numerator} / ${denominator} = ${result}` }],
31 };
32 }
33);
34
35// Tool that returns multiple content items
36server.tool(
37 "analyze_text",
38 "Analyze text and return statistics",
39 {
40 text: z.string().min(1).describe("Text to analyze"),
41 },
42 async ({ text }) => {
43 const words = text.split(/\s+/).length;
44 const chars = text.length;
45 const sentences = text.split(/[.!?]+/).filter(Boolean).length;
46 return {
47 content: [
48 { type: "text", text: `Word count: ${words}` },
49 { type: "text", text: `Character count: ${chars}` },
50 { type: "text", text: `Sentence count: ${sentences}` },
51 { type: "text", text: `Average word length: ${(chars / words).toFixed(1)} chars` },
52 ],
53 };
54 }
55);
56
57// Resource for Inspector to read
58server.resource(
59 "server-status",
60 "status://server",
61 { description: "Current server status and uptime" },
62 async (uri) => ({
63 contents: [{
64 uri: uri.href,
65 mimeType: "application/json",
66 text: JSON.stringify({
67 status: "running",
68 startedAt: new Date().toISOString(),
69 tools: ["divide", "analyze_text"],
70 }, null, 2),
71 }],
72 })
73);
74
75const transport = new StdioServerTransport();
76await server.connect(transport);
77console.error("Inspector demo server started");

Common mistakes when testing an MCP server with the MCP Inspector

Why it's a problem: Forgetting the -y flag with npx

How to avoid: Without -y, npx prompts for confirmation to install the Inspector package. In automated environments or CI, this causes the process to hang. Always use npx -y @modelcontextprotocol/inspector.

Why it's a problem: Server crashes but Inspector shows no error

How to avoid: Check your terminal (not the Inspector browser) for stderr output. Server crashes often print stack traces to stderr. If the server exits immediately, the Inspector shows a disconnection but not the reason.

Why it's a problem: Testing only happy-path inputs

How to avoid: Always test with invalid inputs: empty strings, null values, extreme numbers, special characters. The AI model will eventually send unexpected inputs, and your server needs to handle them gracefully.

Why it's a problem: Not checking the JSON-RPC message format

How to avoid: Even if the formatted output looks correct, check the raw JSON-RPC response. Ensure your responses have the correct structure: { content: [{ type: 'text', text: '...' }] }. Incorrect formats cause silent failures in AI hosts.

Best practices

  • Always test with the Inspector before connecting to any AI host — it is faster to iterate
  • Use the JSON-RPC message log to verify the exact protocol messages your server sends and receives
  • Test error cases: empty inputs, invalid types, missing parameters, and edge cases
  • Always use npx -y to avoid hanging on package installation prompts
  • Check the terminal for stderr output when the Inspector shows unexpected disconnections
  • Test all capabilities: tools, resources, and prompts — not just the tools
  • Pass environment variables with -e when your server needs API keys for testing
  • Keep the Inspector open during development for rapid test-fix cycles

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

Explain how to use the MCP Inspector to test an MCP server. Show me the command to launch it with a TypeScript server, how to test tools with parameters, how to read the JSON-RPC message log, and how to debug common issues like connection failures and malformed responses.

MCP Prompt

I built an MCP server but it is not working in Claude Desktop. Walk me through using the MCP Inspector to diagnose the issue. Show me how to launch the Inspector, test each tool, check the JSON-RPC messages, and identify common problems.

Frequently asked questions

Does the MCP Inspector work with Python servers?

Yes. Pass your Python command to the Inspector: npx -y @modelcontextprotocol/inspector python server.py. The Inspector communicates via stdio protocol regardless of the server's programming language.

Can I use the Inspector with a remote server?

Yes. For servers using Streamable HTTP transport, you can connect the Inspector to the server's HTTP URL instead of launching a local process. This is useful for testing deployed remote servers.

Why are my tool parameters not showing in the Inspector?

The Inspector displays parameters from your Zod schemas (TypeScript) or type hints (Python). If parameters are missing, your schema may not be defined correctly. Check that you are passing the schema object as the third argument to server.tool().

How is the Inspector different from testing in Claude Desktop?

The Inspector gives you direct access to tools with raw JSON-RPC visibility. Claude Desktop adds layers of AI reasoning, tool selection, and natural language — making it harder to isolate server issues. Always debug at the protocol level with the Inspector first.

Can I automate Inspector tests?

The Inspector is primarily a manual testing tool. For automated testing, use the MCP SDK's client library to write programmatic tests that connect to your server and verify tool responses. The Inspector is best for interactive debugging.

Does the Inspector cost anything?

No. The MCP Inspector is free and open source. It runs locally on your machine and does not require any API keys or accounts.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.