跳到主内容

MCP错误处理

The Casdoor MCP server reports protocol errors as JSON-RPC 2.0 errors. This page lists the codes and shows example responses.

错误代码​

CodeNameCause
-32700Parse errorThe request isn't valid JSON
-32600Invalid RequestA required field is missing
-32601Method not foundThe method name is unknown
-32602Invalid paramsThe parameters are malformed
-32001Unauthorized or insufficient scopeThe request has no valid credentials, or the token lacks the scope of the tool

Example responses​

Missing scope. The error names the scope that the tool requires and the scopes of the token:

{
"jsonrpc": "2.0",
"id": 5,
"error": {
"code": -32001,
"message": "insufficient_scope",
"data": {
"tool": "add_application",
"granted_scopes": ["read:application"],
"required_scope": "write:application"
}
}
}

Invalid JSON:

{
"jsonrpc": "2.0",
"id": null,
"error": {
"code": -32700,
"message": "Parse error",
"data": "unexpected character at position 12"
}
}

Unknown method:

{
"jsonrpc": "2.0",
"id": 8,
"error": {
"code": -32601,
"message": "Method not found",
"data": "Method 'unknown_method' not found"
}
}

Errors that happen while a tool runs aren't JSON-RPC errors. The tool returns a result with the isError flag. See Result format.

Other protocol features​

  • Notifications: The server accepts requests without an id field and doesn't answer them.

  • Batch requests: The server accepts an array of requests.

  • Health check: The ping method returns an empty result:

    {
    "jsonrpc": "2.0",
    "id": 9,
    "method": "ping"
    }
  • Demo mode: When Casdoor runs in demo mode, the server rejects write operations and allows read operations and authentication.

See also​