Skip to main content

lash_plugin_mcp/
error.rs

1use lash_core::ReconfigureError;
2
3/// Errors surfaced by `lash-plugin-mcp` when a server fails to connect,
4/// when a tool call errors out, or when the registry rejects the new
5/// surface.
6#[derive(Debug, thiserror::Error)]
7pub enum McpError {
8    #[error("{0}")]
9    Config(String),
10    #[error("MCP transport I/O error: {0}")]
11    Io(#[from] std::io::Error),
12    #[error("invalid MCP JSON message: {0}")]
13    Json(#[from] serde_json::Error),
14    #[error("MCP protocol error: {0}")]
15    Protocol(String),
16    #[error("MCP startup timed out for `{server}` after {timeout_ms}ms")]
17    StartupTimeout { server: String, timeout_ms: u64 },
18    #[error("MCP tool call timed out for `{server}` after {timeout_ms}ms")]
19    CallTimeout { server: String, timeout_ms: u64 },
20    #[error("failed to decode MCP image payload: {0}")]
21    Decode(#[from] base64::DecodeError),
22    #[error("tool registration failed: {0}")]
23    Reconfigure(#[from] ReconfigureError),
24}