pub enum McpError {
Transport(TransportError),
Protocol(ProtocolError),
Validation(ValidationError),
Auth(AuthError),
Timeout {
operation: String,
duration_ms: u64,
},
Config(ConfigError),
Serialization {
source: Error,
},
Io {
source: Error,
},
Internal {
message: String,
},
}Expand description
The main error type for all MCP operations.
This enum covers all possible error conditions that can occur during MCP client operations, from transport failures to protocol violations.
§Examples
use mcp_probe_core::error::{McpError, TransportError};
let error = McpError::Transport(TransportError::ConnectionFailed {
transport_type: "stdio".to_string(),
reason: "Process exited unexpectedly".to_string(),
});
println!("Error: {}", error);Variants§
Transport(TransportError)
Transport-related errors (connection, communication, etc.)
Protocol(ProtocolError)
Protocol-level errors (invalid messages, unsupported versions, etc.)
Validation(ValidationError)
Validation errors (schema validation, capability mismatches, etc.)
Auth(AuthError)
Authentication and authorization errors
Timeout
Timeout errors for operations that exceed time limits
Fields
Config(ConfigError)
Configuration errors (invalid config files, missing parameters, etc.)
Serialization
Serialization/deserialization errors
Io
IO errors (file operations, network errors, etc.)
Internal
Generic errors for cases not covered by specific variants
Implementations§
Source§impl McpError
impl McpError
Sourcepub fn internal(message: impl Into<String>) -> Self
pub fn internal(message: impl Into<String>) -> Self
Create a new internal error with a custom message.
This is useful for creating errors from string messages when a more specific error type is not available.
§Examples
use mcp_probe_core::error::McpError;
let error = McpError::internal("Something went wrong");Sourcepub fn timeout(operation: impl Into<String>, duration: Duration) -> Self
pub fn timeout(operation: impl Into<String>, duration: Duration) -> Self
Create a new timeout error.
§Examples
use mcp_probe_core::error::McpError;
use std::time::Duration;
let error = McpError::timeout("server connection", Duration::from_secs(30));Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if this error is retryable.
Some errors (like network timeouts) may be worth retrying, while others (like invalid credentials) are permanent failures.
§Examples
use mcp_probe_core::error::{McpError, TransportError};
let timeout_error = McpError::timeout("connection", std::time::Duration::from_secs(30));
assert!(timeout_error.is_retryable());
let auth_error = McpError::Auth(
mcp_probe_core::error::AuthError::InvalidCredentials {
auth_type: "Bearer".to_string(),
reason: "Invalid token".to_string(),
}
);
assert!(!auth_error.is_retryable());