use thiserror::Error;
pub type Result<T> = std::result::Result<T, McpError>;
#[derive(Debug, Error)]
pub enum McpError {
#[error("unauthorized: {0}")]
Unauthorized(String),
#[error("capability not enabled: {0}")]
CapabilityNotEnabled(String),
#[error("tool not found: {0}")]
ToolNotFound(String),
#[error("invalid request: {0}")]
InvalidRequest(String),
#[error("tool execution failed: {0}")]
ToolExecution(String),
#[error("transport error: {0}")]
Transport(String),
#[error("internal mcp error: {0}")]
Internal(String),
}
impl McpError {
pub fn unauthorized(msg: impl Into<String>) -> Self {
McpError::Unauthorized(msg.into())
}
pub fn invalid_request(msg: impl Into<String>) -> Self {
McpError::InvalidRequest(msg.into())
}
}