MCP interactions involve network communication, subprocess management, and protocol negotiation. Definable provides specific exception types for each failure mode so you can handle errors precisely.
Error Hierarchy
All MCP errors inherit from MCPError:
Handling Connection Errors
Handling Server Not Found
Automatic Reconnection
By default, MCP connections automatically reconnect on failure:
Reconnection uses exponential backoff. If all attempts fail, an MCPConnectionError is raised.
Timeout Configuration
Set timeouts at the server level:
Graceful Degradation
When using multiple MCP servers, handle failures for individual servers:
Protocol Errors
Protocol errors indicate a bug in the MCP server or an incompatible protocol version:
If you encounter MCPProtocolError consistently, check that the MCP server is using a compatible version of the protocol and that the transport type matches the server’s expectations.