Testing and Debugging
8.1 MCP Inspector
The official interactive debugging tool that lets you test every capability of your Server in a browser.- View all tools, resources, and prompts exposed by the Server
- Manually enter parameters and execute tools
- Inspect the raw JSON-RPC requests and responses
- Validate inputSchema and outputSchema
- Test resource reading and subscriptions
- Test prompt retrieval (with argument filling)
- View the Server’s declared capabilities
Testing Remote Servers with Inspector
The Inspector also supports testing Streamable HTTP Servers:8.2 Unit Testing
Test each tool’s execution logic (without involving the MCP protocol layer):Testing Tool Error Handling
8.3 Integration Testing
Test the complete MCP protocol interaction, including initialization, capability negotiation, and tool calls:8.4 Protocol Compliance Verification
Key checkpoints to ensure your Server conforms to the MCP specification:| Checkpoint | Verification Method |
|---|---|
initialize responds correctly | Inspect initialization handshake in Inspector |
| Capability declarations are complete | Check that capabilities declare all provided primitives |
tools/list pagination is correct | Test cursor pagination with large tool sets |
isError is used correctly | Business errors use isError, not JSON-RPC error |
| Notification format is correct | Notification messages have no id field |
| Content types are correct | text/image/audio type fields are complete |
| structuredContent matches outputSchema | When outputSchema exists, return structuredContent |
8.5 Common Debugging Techniques
| Problem | Diagnosis | Solution |
|---|---|---|
| Server not responding | Check stderr output | Confirm the process started successfully |
| Tools missing from list | Check tools/list in Inspector | Review tool registration code |
| Parameter type errors | Check inputSchema in Inspector | Correct the JSON Schema |
| Incorrect return data format | Check raw response in Inspector | Ensure content array format is correct |
| Claude cannot see the Server | Check claude_desktop_config.json | Confirm the path and command are correct |
| Initialization timeout | Check Server startup time | Reduce blocking operations during startup |
| Streamable HTTP 401 | Check OAuth configuration | Confirm the token is valid and not expired |
| Session lost | Check Mcp-Session-Id header | Ensure Client includes it in every request |
stderr Logging
Logs from a stdio Server must be output to stderr:Log Levels
The MCP specification defines standard log levels. Servers can send log messages to the Client vianotifications/message:
logging/setLevel.
Debugging Streamable HTTP
For remote Servers, you can usecurl to manually send JSON-RPC requests:
Next Chapter: Deployment Guide — Local deployment vs remote deployment