Errors
Exceptions
Domain-specific error types raised by the MCP server and components.
arcade_mcp_server.exceptions
MCP Exception Hierarchy
Provides domain-specific exceptions for better error handling and debugging.
AuthorizationError
Bases: MCPContextError
Authorization failure.
LifespanError
Bases: ServerError
Error in lifespan management.
MCPContextError
Bases: MCPError
Error in context management.
MCPError
Bases: Exception
Base error for all MCP-related exceptions.
MCPRuntimeError
Bases: MCPError
Runtime error for all MCP-related exceptions.
NotFoundError
Bases: MCPContextError
Requested entity not found.
PromptError
Bases: MCPContextError
Error in prompt management.
ProtocolError
Bases: MCPRuntimeError
Error in MCP protocol handling.
RequestError
Bases: ServerError
Error in request processing from client to server
ResourceError
Bases: MCPContextError
Error in resource management.
ResponseError
Bases: ServerError
Error in request processing from server -> client
ServerError
Bases: MCPRuntimeError
Error in server operations.
ServerRequestError
Bases: RequestError
Error in sending request from server -> client initiated by the server
SessionError
Bases: ServerError
Error in session management
TransportError
Bases: MCPRuntimeError
Error in transport layer (stdio, HTTP, etc).
Examples
from arcade_mcp_server.exceptions import (
MCPError,
NotFoundError,
DuplicateError,
ValidationError,
ToolError,
)
# Raising a not-found when a resource is missing
async def read_resource_or_fail(uri: str) -> str:
if not await exists(uri):
raise NotFoundError(f"Resource not found: {uri}")
return await read(uri)
# Validating input
def validate_age(age: int) -> None:
if age < 0:
raise ValidationError("age must be non-negative")
# Handling tool execution errors in middleware or handlers
async def call_tool_safely(call):
try:
return await call()
except ToolError as e:
# Convert to an error result or re-raise
raise MCPError(f"Tool failed: {e}")