tl_mcp/error.rs
1//! Shared error types for MCP client and server operations.
2
3/// Errors that can occur during MCP client or server operations.
4#[derive(Debug, thiserror::Error)]
5pub enum McpError {
6 /// Permission was denied for the requested operation.
7 #[error("Permission denied: {0}")]
8 PermissionDenied(String),
9
10 /// Failed to establish or maintain a connection.
11 #[error("Connection failed: {0}")]
12 ConnectionFailed(String),
13
14 /// A protocol-level error occurred (invalid messages, unexpected state, etc.).
15 #[error("Protocol error: {0}")]
16 ProtocolError(String),
17
18 /// A tool invocation returned an error result.
19 #[error("Tool error: {0}")]
20 ToolError(String),
21
22 /// The transport was closed unexpectedly.
23 #[error("Transport closed")]
24 TransportClosed,
25
26 /// An operation timed out.
27 #[error("Timeout")]
28 Timeout,
29
30 /// Failed to build or use the tokio runtime.
31 #[error("Runtime error: {0}")]
32 RuntimeError(String),
33}