Documentation / @agentick/mcp / protocolError
Function: protocolError()
protocolError(
code,message,data?):never
Defined in: protocol/errors.ts:130
Throw-shape for JSON-RPC protocol errors emitted from server handlers.
SDK quirk: new McpError(code, message) calls super("MCP error {code}: {message}"), meaning error.message carries a prefix at construction time. The SDK serialization layer then ships error.message verbatim, and the receiving client SDK reconstructs an McpError adding ANOTHER prefix — yielding a doubled "MCP error -32601: MCP error -32601: ..." in the client's caught error.
protocolError sidesteps this by throwing a plain Error with code and data properties on it. The SDK's error serialization at shared/protocol.js reads error['code'] and error.message directly (no instanceof check on McpError), so the client receives a clean message and the client SDK adds exactly one prefix.
Parameters
code
number
message
string
data?
unknown
Returns
never