openagent-mcp · errors
Declared module signatures, types, configuration, and source documentation.
Source: openagent-sdk/integrations/mcp/rust/src/errors.rs. SHA-256: e79319eebdefb1f95676a8579a2e34cf8aee982a73d7bb530b47dcc5942f07c8.
This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.
errors::McpErrorCode
JSON-RPC + MCP error codes used by the middleware.
All entries lie inside the -32000..=-32099 server-error range
reserved by the JSON-RPC spec for application use.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[repr(i32)]
pub enum McpErrorCode {
/// Generic server error.
ServerError = -32000,
/// Identity verification failed (no envelope, bad proof, etc.).
AuthenticationFailed = -32001,
/// Caller does not hold the required scopes.
AuthorizationDenied = -32002,
/// Skills policy hook returned `allow: false`.
SkillsPolicyDenied = -32003,
/// Method or tool not found.
MethodNotFound = -32601,
/// Invalid parameters.
InvalidParams = -32602,
/// Internal error.
InternalError = -32603,
}Source line: 18.
errors::McpErrorCode::as_i32
Return the underlying integer code.
pub fn as_i32(self) -> i32;Source line: 37.
errors::McpAuthError
All errors produced by the middleware. Subclasses set a default
[McpErrorCode] that maps to a JSON-RPC error code.
#[derive(Debug, Error)]
pub enum McpAuthError {
/// `_meta.openagent.identity` was absent on a tool call.
#[error("Tool '{tool}' requires an OpenAgent identity in _meta.openagent.identity")]
MissingIdentity {
/// The tool name the call targeted.
tool: String,
},
/// The verifier rejected the supplied envelope.
#[error("Identity verification failed for tool '{tool}': {reason}")]
VerificationFailed {
/// The tool name.
tool: String,
/// Human-readable reason from the verifier.
reason: String,
},
/// The verified identity does not hold the required scopes.
#[error(
"Tool '{tool}' requires scopes [{required}], caller holds [{held}]"
)]
AuthorizationDenied {
/// The tool name.
tool: String,
/// Required scopes, comma-joined for display.
required: String,
/// Held scopes, comma-joined for display.
held: String,
},
/// The skills policy denied the call.
#[error("Skills policy denied tool '{tool}'{}", reason.as_ref().map(|r| format!(": {r}")).unwrap_or_default())]
SkillsPolicyDenied {
/// The tool name.
tool: String,
/// Optional reason from the policy hook.
reason: Option<String>,
},
/// Tool body or downstream component returned an error.
#[error("Tool '{tool}' failed: {source}")]
ToolFailed {
/// The tool name.
tool: String,
/// Underlying error type-erased to a string.
source: Box<dyn std::error::Error + Send + Sync>,
},
/// Generic internal error. Use sparingly — prefer one of the variants
/// above when the failure category is known.
#[error("Internal middleware error: {0}")]
Internal(String),
}Source line: 45.
errors::McpAuthError::code
Map the error to a JSON-RPC error code.
pub fn code(&self) -> McpErrorCode;Source line: 101.
errors::McpAuthError::to_json_rpc
Render the error as a JSON-RPC error envelope.
pub fn to_json_rpc(&self) -> JsonRpcError;Source line: 113.
errors::JsonRpcError
Serializable JSON-RPC error envelope.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JsonRpcError {
/// JSON-RPC error code.
pub code: i32,
/// Human-readable message.
pub message: String,
/// Optional structured data payload.
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>
}Source line: 147.