Reference

API Errors

Every MCPErrorCode the server returns, with the meaning and how to recover.


Errors are returned as JSON-RPC error objects with a code, a message, and (usually) a data field with structured detail. The codes come from src/mcp/MCPServer.ts:

Standard JSON-RPC codes

CodeNameWhen
-32700PARSE_ERRORThe request body wasn’t valid JSON.
-32600INVALID_REQUESTThe envelope was JSON but missing required fields (jsonrpc, method, id).
-32601METHOD_NOT_FOUNDThe method is not in the server’s method table.
-32602INVALID_PARAMSThe params failed Zod validation. The data.issues array lists each failed check.
-32603INTERNAL_ERRORAn unhandled exception in the server. The data.stack may be populated in development mode.

Custom MCP codes

CodeNameWhen
-32000TOOL_EXECUTION_ERRORThe tool was found, its input was valid, but execute() threw. data.message is the tool’s error message.
-32001VALIDATION_ERRORA request-level validation failed (e.g. payload too large, missing required header).
-32002RESOURCE_NOT_FOUNDA resources/read request named a resource URI that doesn’t exist.
-32003RESOURCE_BUSYA resource is locked by another in-flight request. Retry after a short delay.
-32004TIMEOUTThe tool or HA client took longer than its timeout (default 30 s for tools).
-32005CANCELEDThe client sent notifications/cancelled before the request finished.
-32006AUTHENTICATION_ERRORThe custom HTTP entry point saw no Authorization header or the JWT failed to verify.
-32007AUTHORIZATION_ERRORThe JWT is valid but doesn’t have the right scope for this endpoint. (Reserved; not currently used.)
-32008TRANSPORT_ERRORThe transport layer (HTTP, WS, STDIO) failed to read or write.
-32009STREAMING_ERRORThe streaming pipeline (SSE / WS) failed mid-stream. The client should reconnect.

Worked examples

Validation error (tool input)

{
  "code": -32001,
  "message": "Validation failed",
  "data": {
    "tool": "control_light",
    "issues": [
      {
        "path": ["action"],
        "message": "Invalid enum value. Expected 'turn_on' | 'turn_off' | 'toggle', received 'on'"
      }
    ]
  }
}

The client’s job: surface the path + message to the user or retry with a corrected value.

Tool execution error (HA rejected)

{
  "code": -32000,
  "message": "Home Assistant rejected the service call",
  "data": {
    "tool": "control_light",
    "hass_code": "home_assistant_error",
    "hass_message": "Entity light.living_room is currently unavailable"
  }
}

The hass_code matches the HA error type (see Architecture > HA Client).

Authentication error

{
  "code": -32006,
  "message": "Missing or invalid Authorization header",
  "data": {
    "expected": "Bearer <jwt>"
  }
}

The client should re-authenticate (see Configuration > Authentication) and retry.

Timeout

{
  "code": -32004,
  "message": "Tool execution exceeded 30000 ms",
  "data": {
    "tool": "analyze_audio",
    "timeout_ms": 30000
  }
}

If the tool is known to be slow, the client can pass meta.timeout to extend the per-request timeout (up to the server’s maxTimeout, default 120 s).

Error handling checklist for clients

  1. Parse the error code. A -32602 is a client bug (re-validate before retrying). A -32000 is a server-side or HA-side issue (may be transient). A -32006 means re-auth.
  2. Surface data.issues for validation errors. The Zod issues are machine-readable; you can use them to drive a form re-render.
  3. Retry -32003 and -32009 with backoff. These are transient.
  4. Don’t retry -32000 blindly. Look at the hass_code and decide.
  5. Log -32603 and report it. Internal errors are bugs in the server.

Next