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