RouterMCP
API Reference

Error Codes and HTTP Status Reference

Standard and custom error codes for RouterMCP APIs.

Error Codes

RouterMCP uses standard JSON-RPC 2.0 error codes plus custom codes for specific scenarios.

JSON-RPC 2.0 Standard Errors

CodeMessageDescription
-32700Parse errorInvalid JSON was received
-32600Invalid requestMissing required fields
-32601Method not foundUnknown method
-32602Invalid paramsInvalid method parameters
-32603Internal errorServer error

Example:

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32600,
    "message": "Invalid request"
  }
}

Custom Error Codes

CodeMessageDescription
-32000Project not foundInvalid project slug
-32001UnauthorizedMissing or invalid API key
-32002Tool not foundUnknown tool name
-32003Tool disabledTool exists but is disabled
-32004Upstream errorError from upstream MCP server
-32005Rate limit exceededToo many requests

HTTP Status Codes

StatusDescription
200 OKSuccess
201 CreatedResource created
400 Bad RequestInvalid request body or parameters
401 UnauthorizedMissing or invalid authentication
403 ForbiddenInsufficient permissions
404 Not FoundResource not found
429 Too Many RequestsRate limit exceeded
500 Internal Server ErrorServer error
502 Bad GatewayUpstream server error
503 Service UnavailableTemporary outage

Error Response Format

MCP Protocol Errors

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32001,
    "message": "Unauthorized",
    "data": {
      "reason": "Invalid API key"
    }
  }
}

Rate Limit Errors

{
  "error": "rate_limit_exceeded",
  "message": "Rate limit exceeded. Please try again later.",
  "retryAfter": 30
}

Handling Errors

JavaScript

async function callMcp(projectSlug, apiKey, method, params) {
  const response = await fetch(
    `https://gateway.routermcp.com/v1/mcp/${projectSlug}/request`,
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${apiKey}`
      },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: Date.now(),
        method,
        params
      })
    }
  );
  
  if (!response.ok) {
    if (response.status === 429) {
      const retryAfter = response.headers.get('Retry-After');
      throw new Error(`Rate limited. Retry after ${retryAfter}s`);
    }
    throw new Error(`HTTP ${response.status}`);
  }
  
  const data = await response.json();
  
  if (data.error) {
    switch (data.error.code) {
      case -32001:
        throw new Error('Invalid API key');
      case -32002:
        throw new Error(`Tool not found: ${params?.name}`);
      case -32004:
        throw new Error(`Upstream error: ${data.error.message}`);
      default:
        throw new Error(data.error.message);
    }
  }
  
  return data.result;
}

Python

import requests

class McpError(Exception):
    def __init__(self, code, message):
        self.code = code
        super().__init__(message)

def call_mcp(project_slug, api_key, method, params=None):
    response = requests.post(
        f'https://gateway.routermcp.com/v1/mcp/{project_slug}/request',
        headers={
            'Content-Type': 'application/json',
            'Authorization': f'Bearer {api_key}'
        },
        json={
            'jsonrpc': '2.0',
            'id': 1,
            'method': method,
            'params': params or {}
        }
    )
    
    if response.status_code == 429:
        retry_after = response.headers.get('Retry-After', 30)
        raise McpError(-32005, f'Rate limited. Retry after {retry_after}s')
    
    response.raise_for_status()
    data = response.json()
    
    if 'error' in data:
        raise McpError(data['error']['code'], data['error']['message'])
    
    return data['result']

Common Issues

401 Unauthorized

Check that your API key is correct and the project's authMode is set to api_key.

404 Not Found on /v1/mcp/...

Ensure you're using /v1/mcp/ (not /1/mcp/) and the path ends with /request for the JSON-RPC endpoint.

-32002 Tool not found

Tool names must include the server alias prefix, e.g., github.create_issue not just create_issue.

On this page