1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum McpError {
8 #[error("Transport error: {0}")]
9 Transport(String),
10
11 #[error("Protocol error: {0}")]
12 Protocol(String),
13
14 #[error("JSON-RPC error {code}: {message}")]
15 JsonRpc { code: i32, message: String },
16
17 #[error("Tool not found: {0}")]
18 ToolNotFound(String),
19
20 #[error("Resource not found: {0}")]
21 ResourceNotFound(String),
22
23 #[error("Invalid response: {0}")]
24 InvalidResponse(String),
25
26 #[error("Connection closed")]
27 ConnectionClosed,
28
29 #[error("Timeout waiting for response")]
30 Timeout,
31
32 #[error("Version mismatch: client={client}, server={server}")]
33 VersionMismatch { client: String, server: String },
34
35 #[error("Capability not supported: {0}")]
36 CapabilityNotSupported(String),
37
38 #[error("Method not found: {0}")]
39 MethodNotFound(String),
40
41 #[error("Invalid params: {0}")]
42 InvalidParams(String),
43
44 #[error("Internal error: {0}")]
45 Internal(String),
46
47 #[error("IO error: {0}")]
48 Io(#[from] std::io::Error),
49
50 #[error("JSON error: {0}")]
51 Json(#[from] serde_json::Error),
52}