Debugging Your MCP Server
This guide helps you identify and fix common issues when building an MCP server for Dedalus.Common Issues and Solutions
1. Server Not Responding
Connection Refused Error
Connection Refused Error
Symptom:
Error: connect ECONNREFUSED or Connection refusedSolutions:- Verify your server is running on the correct port
- Check firewall settings aren’t blocking the port
- Ensure you’re using the correct URL (http://localhost:8000/mcp)
404 Not Found
404 Not Found
Symptom: Getting 404 errors when calling the endpointSolutions:
- Verify the endpoint path is exactly
/mcp(case-sensitive) - Check your server routing configuration
- Ensure POST method is allowed
CORS Errors
CORS Errors
Symptom:
Access-Control-Allow-Origin errors in browser consoleSolutions:2. Protocol Handshake Failures
Invalid Protocol Version
Invalid Protocol Version
Symptom: Error about unsupported protocol versionSolution: Use a supported protocol version:
Missing Server Info
Missing Server Info
Symptom: Initialization fails with missing serverInfo errorSolution: Always include serverInfo in initialize response:
Capabilities Mismatch
Capabilities Mismatch
Symptom: Tools not appearing or not workingSolution: Declare capabilities correctly:
3. Tool Execution Problems
Tools Not Listed
Tools Not Listed
Symptom:
tools/list returns empty array or errorDebug Steps:- Check method name is exactly
tools/list - Verify tools array format:
Tool Call Fails
Tool Call Fails
Symptom: Tool execution returns error or wrong formatCommon Issues:
- Wrong parameter extraction:
- Invalid response format:
Missing Tool Parameters
Missing Tool Parameters
Symptom: Tool gets undefined or missing parametersSolution: Check parameter schema matches what you expect:
Testing Tools
MCP Test Client
Create a simple test client to debug your server:Debug Logging
Add comprehensive logging to understand what’s happening:Validation Checklist
Use this checklist to validate your MCP server:1
Basic Connectivity
2
Protocol Compliance
Check response includes:
jsonrpc: "2.0"resultorerrorfield- Same
idas request (if provided)
3
Tool Discovery
4
Tool Execution
5
Error Handling
Performance Issues
Slow Response Times
Quick fixes:- Add async/await for I/O operations
- Implement caching for expensive operations
- Use connection pooling for database/API calls
- Return partial results with streaming
Memory Leaks
Common causes:- Not closing database connections
- Accumulating data in global variables
- Not cleaning up async tasks
Getting Help
MCP Specification
Official protocol documentation
Example Servers
Reference implementations
Community
Get help from the community
Quick Debug Commands
Remember: Most issues come from incorrect JSON-RPC formatting or missing required fields. Always validate your responses match the expected format.