Skip to content

Latest commit

 

History

History
106 lines (77 loc) · 2.17 KB

File metadata and controls

106 lines (77 loc) · 2.17 KB

MCP Inspector Compatibility Fixes

Changes Made

1. Always Return JSON-RPC 2.0 Format

  • All responses now always return JSON-RPC 2.0 format, regardless of request format
  • Removed conditional logic that could return non-JSON-RPC format

2. ID Field Handling

  • Changed from id: id || null to id: id ?? 0
  • Ensures id is always present (defaults to 0 if not provided)

3. Capabilities Structure

  • Removed experimental: {} from capabilities
  • Now matches standard MCP spec exactly:
    {
      "tools": {},
      "prompts": {}
    }

4. Response Structure

All responses now follow this exact format:

{
  "jsonrpc": "2.0",
  "result": { ... },
  "id": <number>
}

Current Response Format

Initialize Response

{
  "jsonrpc": "2.0",
  "result": {
    "protocolVersion": "2024-11-05",
    "capabilities": {
      "tools": {},
      "prompts": {}
    },
    "serverInfo": {
      "name": "translation-helps-mcp",
      "version": "7.3.0"
    }
  },
  "id": 1
}

Testing Status

✅ All Node.js tests pass ✅ CORS headers are correct ✅ JSON-RPC 2.0 format is consistent ✅ Response structure matches MCP spec exactly

Inspector Connection Notes

The MCP Inspector has two connection modes:

  1. Direct HTTP Connection (what we're using)

    • URL: http://localhost:8177/api/mcp
    • No proxy required
    • Direct JSON-RPC 2.0 communication
  2. Via Proxy (alternative)

    • Inspector runs proxy on port 6277
    • Requires session token authentication
    • The 401 error on /config suggests Inspector might be trying proxy mode

Next Steps

  1. Restart the dev server to ensure changes are loaded:

    cd ui && npm run dev
  2. Try connecting the Inspector again to http://localhost:8177/api/mcp

  3. If still getting ZodError, the Inspector might be:

    • Using a different validation schema
    • Expecting additional fields
    • Having issues with the proxy connection
  4. Alternative: Test with direct HTTP client (our test scripts work perfectly)

Verification

Run the test script to verify everything works:

node test-mcp-endpoint.js

All tests should pass ✅