1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum McpError {
8 #[error("Authentication failed: {0}")]
10 AuthenticationFailed(String),
11
12 #[error("Tool not found: {0}")]
14 ToolNotFound(String),
15
16 #[error("Invalid parameters: {0}")]
18 InvalidParameters(String),
19
20 #[error("Storage error: {0}")]
22 StorageError(#[from] crate::error::VibeTicketError),
23
24 #[error("MCP protocol error: {0}")]
26 ProtocolError(String),
27
28 #[error("Configuration error: {0}")]
30 ConfigError(String),
31
32 #[error("IO error: {0}")]
34 IoError(#[from] std::io::Error),
35
36 #[error("Serialization error: {0}")]
38 SerdeError(#[from] serde_json::Error),
39
40 #[error("Rate limit exceeded")]
42 RateLimitExceeded,
43
44 #[error("Connection error: {0}")]
46 ConnectionError(String),
47
48 #[error("Server error: {0}")]
50 ServerError(String),
51}
52
53pub type McpResult<T> = Result<T, McpError>;
55
56impl From<rmcp::service::ServerInitializeError> for McpError {
57 fn from(err: rmcp::service::ServerInitializeError) -> Self {
58 Self::ProtocolError(err.to_string())
59 }
60}
61
62impl From<tokio::task::JoinError> for McpError {
63 fn from(err: tokio::task::JoinError) -> Self {
64 Self::ServerError(err.to_string())
65 }
66}