pub enum Error {
ConnectionFailed {
server: String,
source: Box<dyn Error + Send + Sync>,
},
SecurityViolation {
reason: String,
},
Timeout {
operation: String,
duration_secs: u64,
},
SerializationError {
message: String,
source: Option<Error>,
},
InvalidArgument(String),
ValidationError {
field: String,
reason: String,
},
ScriptGenerationError {
tool: String,
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
ResourceLimitExceeded {
resource: ResourceKind,
actual: usize,
limit: usize,
},
DuplicateGeneratedFilePath {
path: String,
},
}Expand description
Main error type for MCP Code Execution.
All errors in the system use this type, providing consistent error handling across all crates in the workspace.
Variants§
ConnectionFailed
MCP server connection failed.
This error occurs when attempting to connect to an MCP server and the connection fails due to network issues, authentication failures, or server unavailability.
Fields
SecurityViolation
Security policy violation.
Raised when an operation violates configured security policies, such as attempting to access forbidden resources or exceeding resource limits.
Timeout
Timeout error.
Occurs when an operation exceeds its configured timeout limit.
Fields
SerializationError
Serialization/deserialization error.
Raised when JSON or other data format conversion fails.
Fields
InvalidArgument(String)
Invalid argument error.
Raised when CLI arguments or function parameters are invalid.
ValidationError
Validation error for domain types.
Raised when creating or validating domain types like SkillName,
SkillDescription, etc. that have specific format requirements.
Fields
ScriptGenerationError
Script generation failed.
Raised when generating TypeScript scripts from tool schemas fails.
Fields
ResourceLimitExceeded
A server- or attacker-controlled quantity exceeded a configured upper bound.
Raised when a value that ultimately originates from an untrusted MCP server response
(tool count, a tool’s name/description length, its schema size, etc.) exceeds one of
the resource-exhaustion (CWE-400) protections in
mcp_execution_introspector or
mcp_execution_codegen.
Fields
resource: ResourceKindWhich bounded resource was exceeded.
DuplicateGeneratedFilePath
A generated file’s path collides with one already present in the same output.
Raised when adding a file to a generated-code collection would silently overwrite
a file already added at the same path — e.g. a tool name that sanitizes to a
generator’s own reserved output filename (like index) slipping past name
disambiguation and colliding with the fixed index.ts re-export (issue #312).
Implementations§
Source§impl Error
impl Error
Sourcepub const fn is_connection_error(&self) -> bool
pub const fn is_connection_error(&self) -> bool
Returns true if this is a connection error.
§Examples
use mcp_execution_core::Error;
let err = Error::ConnectionFailed {
server: "test".to_string(),
source: "connection refused".into(),
};
assert!(err.is_connection_error());Sourcepub const fn is_security_error(&self) -> bool
pub const fn is_security_error(&self) -> bool
Returns true if this is a security violation error.
§Examples
use mcp_execution_core::Error;
let err = Error::SecurityViolation {
reason: "Unauthorized access".to_string(),
};
assert!(err.is_security_error());Sourcepub const fn is_timeout(&self) -> bool
pub const fn is_timeout(&self) -> bool
Returns true if this is a timeout error.
§Examples
use mcp_execution_core::Error;
let err = Error::Timeout {
operation: "execute_code".to_string(),
duration_secs: 30,
};
assert!(err.is_timeout());Sourcepub const fn is_validation_error(&self) -> bool
pub const fn is_validation_error(&self) -> bool
Returns true if this is a validation error.
§Examples
use mcp_execution_core::Error;
let err = Error::ValidationError {
field: "skill_name".to_string(),
reason: "Invalid characters".to_string(),
};
assert!(err.is_validation_error());Sourcepub const fn is_script_generation_error(&self) -> bool
pub const fn is_script_generation_error(&self) -> bool
Returns true if this is a script generation error.
§Examples
use mcp_execution_core::Error;
let err = Error::ScriptGenerationError {
tool: "send_message".to_string(),
message: "Template rendering failed".to_string(),
source: None,
};
assert!(err.is_script_generation_error());Sourcepub const fn is_resource_limit_exceeded(&self) -> bool
pub const fn is_resource_limit_exceeded(&self) -> bool
Returns true if this is a resource-limit-exceeded error.
§Examples
use mcp_execution_core::{Error, ServerId};
use mcp_execution_core::ResourceKind;
let err = Error::ResourceLimitExceeded {
resource: ResourceKind::ToolCount {
server_id: ServerId::new("github").unwrap(),
},
actual: 1500,
limit: 1000,
};
assert!(err.is_resource_limit_exceeded());Sourcepub const fn is_duplicate_generated_file_path(&self) -> bool
pub const fn is_duplicate_generated_file_path(&self) -> bool
Returns true if this is a duplicate-generated-file-path error.
§Examples
use mcp_execution_core::Error;
let err = Error::DuplicateGeneratedFilePath {
path: "index.ts".to_string(),
};
assert!(err.is_duplicate_generated_file_path());Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()