mcpkit_core/error/codes.rs
1//! Standard JSON-RPC and MCP error codes.
2//!
3//! This module defines error code constants used in JSON-RPC 2.0 responses
4//! and MCP-specific error responses.
5
6/// Invalid JSON was received.
7pub const PARSE_ERROR: i32 = -32700;
8
9/// The JSON sent is not a valid Request object.
10pub const INVALID_REQUEST: i32 = -32600;
11
12/// The method does not exist.
13pub const METHOD_NOT_FOUND: i32 = -32601;
14
15/// Invalid method parameters.
16pub const INVALID_PARAMS: i32 = -32602;
17
18/// Internal JSON-RPC error.
19pub const INTERNAL_ERROR: i32 = -32603;
20
21/// Server error range start.
22pub const SERVER_ERROR_START: i32 = -32000;
23
24/// Server error range end.
25pub const SERVER_ERROR_END: i32 = -32099;
26
27// MCP-specific codes
28
29/// The user rejected the operation.
30///
31/// Spec-defined: the 2025-11-25 sampling flow names `-1` for
32/// "User rejected sampling request". It sits outside the JSON-RPC reserved
33/// range (-32768..-32000), so it is an application-level code by design.
34pub const USER_REJECTED: i32 = -1;
35
36/// Resource was not found.
37pub const RESOURCE_NOT_FOUND: i32 = -32002;
38
39/// The server requires a URL-mode elicitation before the request can proceed.
40pub const URL_ELICITATION_REQUIRED: i32 = -32042;