Handle connection failures, timeouts, and protocol errors.
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:
Exception
Reason
MCPConnectionError
Failed to connect to server
MCPTimeoutError
Request or connection timed out
MCPProtocolError
Invalid JSON-RPC or protocol violation
MCPToolNotFoundError
Requested tool does not exist
MCPServerNotFoundError
Server name not in configuration
MCPResourceNotFoundError
Resource URI not found
MCPPromptNotFoundError
Prompt name not found
Handling Connection Errors
from definable.mcp import MCPToolkit, MCPConfig, MCPServerConfigfrom definable.mcp.errors import MCPConnectionError, MCPTimeoutErrorconfig = MCPConfig(servers=[ MCPServerConfig(name="my-server", transport="stdio", command="my-mcp-server"),])try: async with MCPToolkit(config=config) as toolkit: agent = Agent(model=model, toolkits=[toolkit]) output = await agent.arun("Do something")except MCPConnectionError as e: print(f"Could not connect to MCP server: {e}")except MCPTimeoutError as e: print(f"Connection timed out: {e}")
Handling Tool Errors
from definable.mcp.errors import MCPToolNotFoundErrortry: result = await client.call_tool("my-server", "nonexistent_tool", {})except MCPToolNotFoundError as e: print(f"Tool not found: {e}")
Handling Server Not Found
from definable.mcp.errors import MCPServerNotFoundErrortry: tools = await client.list_tools("unknown-server")except MCPServerNotFoundError as e: print(f"Server not configured: {e}")
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:
MCPServerConfig( name="slow-server", transport="http", url="https://mcp.example.com/mcp", connect_timeout=60.0, # Time to establish connection request_timeout=120.0, # Time for each request)
Graceful Degradation
When using multiple MCP servers, handle failures for individual servers:
config = MCPConfig(servers=[ MCPServerConfig(name="primary", transport="stdio", command="server-a"), MCPServerConfig(name="fallback", transport="stdio", command="server-b"),])client = MCPClient(config)await client.connect()# Connect to servers individually for resiliencefor server_name in ["primary", "fallback"]: try: await client.connect_server(server_name) print(f"Connected to {server_name}") except MCPConnectionError: print(f"Failed to connect to {server_name}, skipping")
Protocol Errors
Protocol errors indicate a bug in the MCP server or an incompatible protocol version:
from definable.mcp.errors import MCPProtocolErrortry: result = await client.call_tool("server", "tool", {"arg": "value"})except MCPProtocolError as e: print(f"Protocol error: {e}") # This usually means the server returned an invalid JSON-RPC response
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.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Definable AI","colors":{"primary":"#FA8112","light":"#FA8112","dark":"#FA8112"},"logo":{"light":"https://mintcdn.com/definableaiprivatelimited/mDNvZulDI7LGheEl/logo/light.svg?fit=max\u0026auto=format\u0026n=mDNvZulDI7LGheEl\u0026q=85\u0026s=4b85977f6a03ffc7ceaa9b818e5d7990","dark":"https://mintcdn.com/definableaiprivatelimited/mDNvZulDI7LGheEl/logo/dark.svg?fit=max\u0026auto=format\u0026n=mDNvZulDI7LGheEl\u0026q=85\u0026s=88f4a2faa73881a1af38ae9e48f83c11"},"favicon":"/favicon.svg","background":{"color":{"light":"#FAF3E1","dark":"#222222"}},"navbar":{"links":[{"href":"https://github.com/definable-ai/definable","label":"GitHub"}]},"footer":{"socials":{"github":"https://github.com/definable-ai"}},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"GitHub","icon":"github","href":"https://github.com/definable-ai/definable"},{"anchor":"PyPI","icon":"cube","href":"https://pypi.org/project/definable-ai/"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"definableaiprivatelimited","hasAudioNarration":false,"actualSubdomain":"definableaiprivatelimited","customDomains":["docs.definable.ai"],"gitSource":{"type":"github","owner":"definableai","repo":"definable.ai","deployBranch":"main","contentDirectory":"definable/docs","isPrivate":true,"mountPath":"","label":""},"entitlements":{},"buildId":"6ae94795d69537c8ab6fa802:success","clientVersion":"0.0.4271","searchFilterCounts":[{"language":"default","tag":"Documentation","count":127},{"language":"default","tag":"Basics","count":48},{"language":"default","tag":"Capabilities","count":41},{"language":"default","tag":"Examples","count":36},{"language":"default","tag":"Advanced","count":34},{"language":"default","tag":"Models","count":19},{"language":"default","tag":"Usage","count":17},{"language":"default","tag":"Interfaces","count":17},{"language":"default","tag":"Tools","count":15},{"language":"default","tag":"Agents","count":12}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"mcp/error-handling","slug":"/mcp/error-handling","pageMetadata":{"title":"MCP Error Handling","sidebarTitle":"Error Handling","description":"Handle connection failures, timeouts, and protocol errors.","icon":"triangle-exclamation","href":"/mcp/error-handling","hidden":false},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Handle connection failures, timeouts, and protocol errors.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,p:`p`,pre:`pre`,span:`span`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,..._provideComponents(),...props.components},{CodeBlock,Heading,Mermaid,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Mermaid)_missingMdxReference(`Mermaid`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`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.`}),`\n`,_jsx(Heading,{level:`2`,id:`error-hierarchy`,children:`Error Hierarchy`}),`\n`,_jsxs(_components.p,{children:[`All MCP errors inherit from `,_jsx(_components.code,{children:`MCPError`}),`:`]}),`\n`,_jsx(Mermaid,{chart:`flowchart TD\n MCPError --> MCPConnectionError\n MCPError --> MCPTimeoutError\n MCPError --> MCPProtocolError\n MCPError --> MCPToolNotFoundError\n MCPError --> MCPServerNotFoundError\n MCPError --> MCPResourceNotFoundError\n MCPError --> MCPPromptNotFoundError`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Exception`}),_jsx(_components.th,{children:`Reason`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`MCPConnectionError`})}),_jsx(_components.td,{children:`Failed to connect to server`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`MCPTimeoutError`})}),_jsx(_components.td,{children:`Request or connection timed out`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`MCPProtocolError`})}),_jsx(_components.td,{children:`Invalid JSON-RPC or protocol violation`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`MCPToolNotFoundError`})}),_jsx(_components.td,{children:`Requested tool does not exist`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`MCPServerNotFoundError`})}),_jsx(_components.td,{children:`Server name not in configuration`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`MCPResourceNotFoundError`})}),_jsx(_components.td,{children:`Resource URI not found`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`MCPPromptNotFoundError`})}),_jsx(_components.td,{children:`Prompt name not found`})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`handling-connection-errors`,children:`Handling Connection Errors`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`15`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`15`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` definable.mcp `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPToolkit, MCPConfig, MCPServerConfig`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` definable.mcp.errors `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPConnectionError, MCPTimeoutError`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`config `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPConfig(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`servers`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPServerConfig(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"my-server\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`transport`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"stdio\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`command`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"my-mcp-server\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`])`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`try`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` with`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPToolkit(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`config`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`config) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` toolkit:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` agent `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Agent(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`model, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`toolkits`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[toolkit])`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` output `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` agent.arun(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Do something\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`except`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPConnectionError `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` e:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Could not connect to MCP server: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`e`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`except`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPTimeoutError `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` e:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Connection timed out: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`e`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`handling-tool-errors`,children:`Handling Tool Errors`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` definable.mcp.errors `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPToolNotFoundError`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`try`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.call_tool(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"my-server\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"nonexistent_tool\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, {})`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`except`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPToolNotFoundError `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` e:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Tool not found: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`e`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`handling-server-not-found`,children:`Handling Server Not Found`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` definable.mcp.errors `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPServerNotFoundError`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`try`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` tools `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.list_tools(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"unknown-server\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`except`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPServerNotFoundError `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` e:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Server not configured: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`e`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`automatic-reconnection`,children:`Automatic Reconnection`}),`\n`,_jsx(_components.p,{children:`By default, MCP connections automatically reconnect on failure:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`MCPServerConfig(`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"my-server\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` transport`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"stdio\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` command`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"my-mcp-server\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` reconnect_on_failure`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Default`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` max_reconnect_attempts`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`3`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Default`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Reconnection uses exponential backoff. If all attempts fail, an `,_jsx(_components.code,{children:`MCPConnectionError`}),` is raised.`]}),`\n`,_jsx(Heading,{level:`2`,id:`timeout-configuration`,children:`Timeout Configuration`}),`\n`,_jsx(_components.p,{children:`Set timeouts at the server level:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`MCPServerConfig(`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"slow-server\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` transport`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"http\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` url`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://mcp.example.com/mcp\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` connect_timeout`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`60.0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Time to establish connection`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` request_timeout`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`120.0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Time for each request`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`graceful-degradation`,children:`Graceful Degradation`}),`\n`,_jsx(_components.p,{children:`When using multiple MCP servers, handle failures for individual servers:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`15`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`15`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`config `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPConfig(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`servers`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPServerConfig(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"primary\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`transport`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"stdio\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`command`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"server-a\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPServerConfig(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"fallback\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`transport`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"stdio\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`command`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"server-b\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`])`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`client `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPClient(config)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.connect()`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Connect to servers individually for resilience`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`for`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` server_name `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`in`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"primary\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"fallback\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` try`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.connect_server(server_name)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Connected to `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`server_name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` except`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPConnectionError:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Failed to connect to `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`server_name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`, skipping\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`protocol-errors`,children:`Protocol Errors`}),`\n`,_jsx(_components.p,{children:`Protocol errors indicate a bug in the MCP server or an incompatible protocol version:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`7`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` definable.mcp.errors `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPProtocolError`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`try`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` result `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.call_tool(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"server\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"tool\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"arg\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"value\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`})`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`except`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MCPProtocolError `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` e:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Protocol error: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`e`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # This usually means the server returned an invalid JSON-RPC response`})}),`\n`]})})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`If you encounter `,_jsx(_components.code,{children:`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.`]})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"MCP Error Handling","sidebarTitle":"Error Handling","description":"Handle connection failures, timeouts, and protocol errors.","icon":"triangle-exclamation","href":"/mcp/error-handling","hidden":false}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Error Hierarchy","slug":"error-hierarchy","depth":2,"children":[]},{"title":"Handling Connection Errors","slug":"handling-connection-errors","depth":2,"children":[]},{"title":"Handling Tool Errors","slug":"handling-tool-errors","depth":2,"children":[]},{"title":"Handling Server Not Found","slug":"handling-server-not-found","depth":2,"children":[]},{"title":"Automatic Reconnection","slug":"automatic-reconnection","depth":2,"children":[]},{"title":"Timeout Configuration","slug":"timeout-configuration","depth":2,"children":[]},{"title":"Graceful Degradation","slug":"graceful-degradation","depth":2,"children":[]},{"title":"Protocol Errors","slug":"protocol-errors","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"definableaiprivatelimited","siteName":"Definable AI","title":"MCP Error Handling - Definable AI","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-02-11T11:44:55.954Z","originalFileLocation":"mcp/error-handling.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Handle connection failures, timeouts, and protocol errors.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Definable AI\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"MCP Error Handling - Definable AI\">\u003cmeta data-mint-head property=\"og:description\" content=\"Handle connection failures, timeouts, and protocol errors.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Definable AI\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.definable.ai/mcp/error-handling\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://definableaiprivatelimited.mintlify.site/_mintlify/api/og/v2?division=MCP\u0026amp;title=MCP+Error+Handling\u0026amp;description=Handle+connection+failures%2C+timeouts%2C+and+protocol+errors.\u0026amp;theme=292dbdbb8f2a2bd1ee1ab5df\u0026amp;signature=46d75a97a0aa2552cce2284392785ebaf52c585a5abb450c03eb7c9593e7045d\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"MCP Error Handling - Definable AI\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Handle connection failures, timeouts, and protocol errors.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://definableaiprivatelimited.mintlify.site/_mintlify/api/og/v2?division=MCP\u0026amp;title=MCP+Error+Handling\u0026amp;description=Handle+connection+failures%2C+timeouts%2C+and+protocol+errors.\u0026amp;theme=292dbdbb8f2a2bd1ee1ab5df\u0026amp;signature=46d75a97a0aa2552cce2284392785ebaf52c585a5abb450c03eb7c9593e7045d\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/definableaiprivatelimited/Kfj4AiUCcTNUUhqf/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Definable AI\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#FA8112\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.definable.ai/mcp/error-handling\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/mcp/error-handling.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.definable.ai/#organization\",\"name\":\"Definable AI\",\"url\":\"https://docs.definable.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/definableaiprivatelimited/mDNvZulDI7LGheEl/logo/light.svg?fit=max\u0026auto=format\u0026n=mDNvZulDI7LGheEl\u0026q=85\u0026s=4b85977f6a03ffc7ceaa9b818e5d7990\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.definable.ai#website\",\"name\":\"Definable AI\",\"url\":\"https://docs.definable.ai\",\"publisher\":{\"@id\":\"https://docs.definable.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.definable.ai/mcp/error-handling#webpage\",\"url\":\"https://docs.definable.ai/mcp/error-handling\",\"name\":\"MCP Error Handling\",\"description\":\"Handle connection failures, timeouts, and protocol errors.\",\"dateModified\":\"2026-02-11T11:44:55.954Z\",\"isPartOf\":{\"@id\":\"https://docs.definable.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.definable.ai/mcp/error-handling#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.definable.ai/mcp/error-handling#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Capabilities\",\"item\":\"https://docs.definable.ai/tools/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MCP\",\"item\":\"https://docs.definable.ai/mcp/overview\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MCP Error Handling\",\"item\":\"https://docs.definable.ai/mcp/error-handling\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.definable.ai/mcp/error-handling#article\",\"headline\":\"MCP Error Handling\",\"name\":\"MCP Error Handling\",\"description\":\"Handle connection failures, timeouts, and protocol errors.\",\"url\":\"https://docs.definable.ai/mcp/error-handling\",\"mainEntityOfPage\":{\"@id\":\"https://docs.definable.ai/mcp/error-handling#webpage\"},\"dateModified\":\"2026-02-11T11:44:55.954Z\",\"publisher\":{\"@id\":\"https://docs.definable.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.definable.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Definable AI\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Definable AI\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/mcp/error-handling.md","siteName":"Definable AI","nav":{"global":{"anchors":[{"anchor":"GitHub","icon":"github","href":"https://github.com/definable-ai/definable"},{"anchor":"PyPI","icon":"cube","href":"https://pypi.org/project/definable-ai/"}]},"tabs":[{"tab":"Documentation","groups":[{"group":"Get Started","pages":[{"title":"Definable","sidebarTitle":"Introduction","mode":"wide","href":"/introduction","hidden":false},{"title":"Your First Agent","mode":"wide","href":"/first-agent","hidden":false},{"title":"Quickstart","icon":"bolt","href":"/quickstart","hidden":false},{"title":"Installation","href":"/installation","hidden":false}]},{"group":"Basics","pages":[{"group":"Agents","pages":[{"title":"What are Agents?","sidebarTitle":"Overview","mode":"wide","href":"/agents/overview","hidden":false},{"title":"Building Agents","sidebarTitle":"Building Agents","mode":"wide","href":"/agents/building-agents","hidden":false},{"title":"Running Agents","sidebarTitle":"Running Agents","icon":"play","href":"/agents/running-agents","hidden":false},{"title":"Agent Configuration","sidebarTitle":"Configuration","icon":"gear","href":"/agents/configuration","hidden":false},{"group":"Usage","pages":[{"title":"Agent with Tools","href":"/agents/usage/agent-with-tools","hidden":false},{"title":"Agent with Knowledge","href":"/agents/usage/agent-with-knowledge","hidden":false},{"title":"Agent with Memory","href":"/agents/usage/agent-with-memory","hidden":false},{"title":"Agent with Structured Output","href":"/agents/usage/agent-with-structured-output","hidden":false},{"title":"Agent with Streaming","href":"/agents/usage/agent-with-streaming","hidden":false}]}]},{"group":"Teams","pages":[{"title":"What are Teams?","sidebarTitle":"Overview","mode":"wide","href":"/teams/overview","hidden":false},{"title":"Building Teams","sidebarTitle":"Building Teams","mode":"wide","href":"/teams/building-teams","hidden":false},{"title":"Running Teams","sidebarTitle":"Running Teams","href":"/teams/running-teams","hidden":false},{"title":"Delegation","sidebarTitle":"Delegation","href":"/teams/delegation","hidden":false},{"group":"Usage","pages":[{"title":"Coordinate Team","href":"/teams/usage/coordinate-team","hidden":false},{"title":"Route Team","href":"/teams/usage/route-team","hidden":false},{"title":"Collaborate Team","href":"/teams/usage/collaborate-team","hidden":false},{"title":"Tasks Team","href":"/teams/usage/tasks-team","hidden":false}]}]},{"group":"Workflows","pages":[{"title":"What are Workflows?","sidebarTitle":"Overview","mode":"wide","href":"/workflows/overview","hidden":false},{"title":"Building Workflows","sidebarTitle":"Building Workflows","mode":"wide","href":"/workflows/building-workflows","hidden":false},{"title":"Running Workflows","sidebarTitle":"Running Workflows","href":"/workflows/running-workflows","hidden":false},{"group":"Patterns","pages":[{"title":"Sequential Workflow","sidebarTitle":"Sequential","href":"/workflows/patterns/sequential","hidden":false},{"title":"Parallel Workflow","sidebarTitle":"Parallel","href":"/workflows/patterns/parallel","hidden":false},{"title":"Conditional Workflow","sidebarTitle":"Conditional","href":"/workflows/patterns/conditional","hidden":false},{"title":"Loop Workflow","sidebarTitle":"Loop","href":"/workflows/patterns/loop","hidden":false},{"title":"Router Workflow","sidebarTitle":"Router","href":"/workflows/patterns/router","hidden":false}]},{"group":"Usage","pages":[{"title":"Basic Workflow","href":"/workflows/usage/basic-workflow","hidden":false},{"title":"Nested Workflows","href":"/workflows/usage/nested-workflows","hidden":false}]}]},{"group":"Input \u0026 Output","pages":[{"title":"Structured Output","sidebarTitle":"Structured Output","href":"/input-output/structured-output","hidden":false},{"title":"Streaming","sidebarTitle":"Streaming","href":"/input-output/streaming","hidden":false},{"title":"Multimodal Input","sidebarTitle":"Multimodal","href":"/input-output/multimodal","hidden":false}]},{"group":"Models","pages":[{"title":"What are Models?","sidebarTitle":"Overview","icon":"microchip","mode":"wide","href":"/models/overview","hidden":false},{"title":"Model as String","sidebarTitle":"String Shorthand","href":"/models/model-as-string","hidden":false},{"group":"Providers","pages":[{"title":"OpenAI","icon":"brain","href":"/models/openai","hidden":false},{"title":"Anthropic","href":"/models/anthropic","hidden":false},{"title":"Google Gemini","href":"/models/google","hidden":false},{"title":"DeepSeek","icon":"bolt","href":"/models/deepseek","hidden":false},{"title":"Mistral","href":"/models/mistral","hidden":false},{"title":"Moonshot","icon":"moon","href":"/models/moonshot","hidden":false},{"title":"xAI","icon":"magnifying-glass","href":"/models/xai","hidden":false},{"title":"Perplexity","href":"/models/perplexity","hidden":false},{"title":"Ollama","href":"/models/ollama","hidden":false},{"title":"OpenRouter","href":"/models/openrouter","hidden":false},{"title":"OpenAI-Like Providers","sidebarTitle":"OpenAI-Like","icon":"plug","href":"/models/openai-like","hidden":false}]},{"title":"Model Resilience","sidebarTitle":"Resilience","href":"/models/resilience","hidden":false},{"title":"Streaming","icon":"bars-staggered","href":"/models/streaming","hidden":false},{"title":"Structured Output","icon":"code","href":"/models/structured-output","hidden":false},{"title":"Vision \u0026 Audio","icon":"image","href":"/models/vision-and-audio","hidden":false},{"title":"Metrics \u0026 Pricing","icon":"chart-line","href":"/models/metrics-and-pricing","hidden":false}]}]},{"group":"Capabilities","pages":[{"group":"Tools","pages":[{"title":"What are Tools?","sidebarTitle":"Overview","mode":"wide","href":"/tools/overview","hidden":false},{"title":"Creating Tools","sidebarTitle":"Overview","href":"/tools/creating-tools/overview","hidden":false},{"title":"Tool Parameters","sidebarTitle":"Parameters","icon":"list","href":"/tools/creating-tools/parameters","hidden":false},{"title":"Tool Hooks","sidebarTitle":"Hooks","icon":"anchor","href":"/tools/creating-tools/hooks","hidden":false},{"title":"Tool Caching","sidebarTitle":"Caching","icon":"database","href":"/tools/creating-tools/caching","hidden":false},{"title":"Async Tools","sidebarTitle":"Async Tools","icon":"rotate","href":"/tools/creating-tools/async-tools","hidden":false},{"title":"Tool Dependencies","sidebarTitle":"Dependencies","icon":"puzzle-piece","href":"/tools/creating-tools/dependencies","hidden":false},{"group":"Toolkits","pages":[{"title":"Toolkits Overview","sidebarTitle":"Overview","icon":"toolbox","href":"/toolkits/overview","hidden":false},{"title":"KnowledgeToolkit","icon":"book","href":"/toolkits/knowledge-toolkit","hidden":false},{"title":"MCPToolkit","icon":"plug","href":"/toolkits/mcp-toolkit","hidden":false}]},{"group":"Built-in Skills","pages":[{"title":"Skills Overview","sidebarTitle":"Overview","icon":"puzzle-piece","href":"/skills/overview","hidden":false},{"title":"Built-in Skills","sidebarTitle":"Built-in Skills","icon":"toolbox","href":"/skills/built-in","hidden":false},{"title":"MacOS Skill","sidebarTitle":"MacOS","icon":"apple","href":"/skills/macos","hidden":false},{"title":"Skill Registry","sidebarTitle":"Skill Registry","icon":"book","href":"/skills/registry","hidden":false}]}]},{"group":"Knowledge \u0026 RAG","pages":[{"title":"Knowledge Overview","sidebarTitle":"Overview","icon":"book","href":"/knowledge/overview","hidden":false},{"title":"Documents","icon":"file-lines","href":"/knowledge/documents","hidden":false},{"title":"Agent Integration","sidebarTitle":"Agent Integration","icon":"robot","href":"/knowledge/agent-integration","hidden":false},{"title":"Hybrid Search \u0026 Scoring","sidebarTitle":"Hybrid Search","icon":"magnifying-glass-chart","href":"/knowledge/hybrid-search","hidden":false},{"group":"Pipeline","pages":[{"title":"Readers","icon":"file-import","href":"/knowledge/pipeline/readers","hidden":false},{"title":"Chunkers","icon":"scissors","href":"/knowledge/pipeline/chunkers","hidden":false},{"title":"Embedders","icon":"vector-square","href":"/knowledge/pipeline/embedders","hidden":false},{"title":"Rerankers","icon":"ranking-star","href":"/knowledge/pipeline/rerankers","hidden":false},{"title":"Vector Databases","sidebarTitle":"Vector Databases","icon":"database","href":"/knowledge/pipeline/vector-databases","hidden":false}]},{"group":"Usage","pages":[{"title":"Basic RAG","href":"/knowledge/usage/basic-rag","hidden":false},{"title":"Hybrid Search","href":"/knowledge/usage/hybrid-search-example","hidden":false}]}]},{"group":"Memory","pages":[{"title":"Memory Overview","sidebarTitle":"Overview","icon":"brain","href":"/memory/overview","hidden":false},{"title":"Memory Stores","sidebarTitle":"Stores","icon":"database","href":"/memory/stores","hidden":false},{"title":"Agent Integration","sidebarTitle":"Agent Integration","icon":"link","href":"/memory/agent-integration","hidden":false}]},{"group":"Reasoning","pages":[{"title":"Thinking","sidebarTitle":"Thinking","href":"/reasoning/thinking","hidden":false},{"title":"Deep Research","sidebarTitle":"Deep Research","href":"/reasoning/deep-research","hidden":false}]},{"group":"MCP","pages":[{"title":"MCP Overview","sidebarTitle":"Overview","icon":"plug","href":"/mcp/overview","hidden":false},{"title":"Getting Started with MCP","sidebarTitle":"Getting Started","icon":"rocket","href":"/mcp/getting-started","hidden":false},{"title":"MCP Configuration","sidebarTitle":"Configuration","icon":"gear","href":"/mcp/configuration","hidden":false},{"title":"MCP Resources","sidebarTitle":"Resources","icon":"folder-open","href":"/mcp/resources","hidden":false},{"title":"MCP Prompts","sidebarTitle":"Prompts","description":"Use reusable prompt templates from MCP servers.","icon":"message","href":"/mcp/prompts","hidden":false},{"title":"MCP Error Handling","sidebarTitle":"Error Handling","icon":"triangle-exclamation","href":"/mcp/error-handling","hidden":false},{"title":"Mock MCP Servers","sidebarTitle":"Mock Servers","description":"Test MCP integrations without running real servers.","icon":"flask-vial","href":"/mcp/mock-servers","hidden":false}]},{"group":"Readers","pages":[{"title":"File Readers","sidebarTitle":"Overview","icon":"file-lines","href":"/readers/overview","hidden":false}]},{"group":"Browser","pages":[{"title":"Browser Toolkit","sidebarTitle":"Overview","icon":"globe","href":"/browser/overview","hidden":false}]},{"group":"Tracing","pages":[{"title":"Tracing","icon":"chart-gantt","href":"/agents/tracing","hidden":false}]},{"group":"Evaluation","pages":[{"title":"Evaluation","sidebarTitle":"Evaluation","icon":"chart-bar","href":"/agents/evaluation","hidden":false}]}]},{"group":"Advanced","pages":[{"group":"Interfaces","pages":[{"title":"Interfaces Overview","sidebarTitle":"Overview","icon":"message-bot","href":"/interfaces/overview","hidden":false},{"group":"Platforms","pages":[{"title":"Telegram","icon":"paper-plane","href":"/interfaces/telegram","hidden":false},{"title":"Discord","icon":"discord","href":"/interfaces/discord","hidden":false},{"title":"Slack","icon":"slack","href":"/interfaces/slack","hidden":false},{"title":"WebSocket","sidebarTitle":"WebSocket","href":"/interfaces/websocket","hidden":false},{"title":"WhatsApp","sidebarTitle":"WhatsApp","icon":"comment-dots","href":"/interfaces/whatsapp"},{"title":"Email","sidebarTitle":"Email","href":"/interfaces/email","hidden":false},{"title":"Call (Voice)","icon":"phone","href":"/interfaces/call","hidden":false},{"title":"Custom Interfaces","sidebarTitle":"Custom Interfaces","icon":"code","href":"/interfaces/custom-interfaces","hidden":false}]},{"group":"Usage","pages":[{"title":"Telegram Bot","href":"/interfaces/usage/telegram-bot","hidden":false},{"title":"Discord Bot","href":"/interfaces/usage/discord-bot","hidden":false},{"title":"Slack Bot","href":"/interfaces/usage/slack-bot","hidden":false},{"title":"Multi-Platform Agent","href":"/interfaces/usage/multi-platform","hidden":false}]},{"title":"Sessions","icon":"clock-rotate-left","href":"/interfaces/sessions","hidden":false},{"title":"Interface Hooks","sidebarTitle":"Hooks","icon":"anchor","href":"/interfaces/hooks","hidden":false},{"title":"Identity Resolution","sidebarTitle":"Identity","icon":"fingerprint","href":"/interfaces/identity","hidden":false},{"title":"Multi-Interface Serving","sidebarTitle":"Multi-Interface","icon":"server","href":"/interfaces/multi-interface","hidden":false}]},{"group":"Security","pages":[{"title":"Security","sidebarTitle":"Security","icon":"shield-halved","href":"/agents/security","hidden":false}]},{"group":"Guardrails","pages":[{"title":"Guardrails Overview","sidebarTitle":"Overview","icon":"shield","href":"/guardrails/overview","hidden":false}]},{"group":"Plugins","pages":[{"title":"Plugins","sidebarTitle":"Plugins","href":"/agents/plugins","hidden":false}]},{"group":"Scheduling","pages":[{"title":"Scheduling","sidebarTitle":"Scheduling","href":"/agents/scheduling","hidden":false}]},{"title":"Middleware","icon":"layer-group","href":"/agents/middleware","hidden":false},{"title":"Multi-Turn Conversations","sidebarTitle":"Multi-Turn","icon":"comments","href":"/agents/multi-turn","hidden":false},{"title":"Agentic Loop","sidebarTitle":"Agentic Loop","icon":"rotate","href":"/agents/agentic-loop","hidden":false},{"title":"Testing","icon":"flask-vial","href":"/agents/testing","hidden":false},{"title":"Authentication","sidebarTitle":"Authentication","icon":"lock","href":"/agents/auth","hidden":false},{"title":"Agent Runtime","sidebarTitle":"Runtime","icon":"server","href":"/agents/runtime","hidden":false},{"title":"Error Handling","icon":"shield","href":"/advanced/error-handling","hidden":false},{"title":"Cost Tracking","icon":"dollar-sign","href":"/advanced/cost-tracking","hidden":false},{"title":"Run Output \u0026 Events","sidebarTitle":"Run Output","icon":"square-poll-vertical","href":"/advanced/run-output","hidden":false},{"title":"Media Types","icon":"photo-film","href":"/advanced/media-types","hidden":false},{"title":"Replay Overview","sidebarTitle":"Overview","icon":"rotate","href":"/replay/overview","hidden":false},{"title":"Observability Dashboard","sidebarTitle":"Overview","icon":"chart-line","href":"/observability/overview","hidden":false},{"title":"Claude Code Agent","href":"/claude-code/overview","hidden":false}]}]},{"tab":"Examples","pages":[{"title":"Examples","href":"/examples/overview"}]},{"tab":"Reference","pages":[{"title":"Reference","href":"/reference/agents/agent"}]}]},"basePath":"","title":"MCP Error Handling - Definable AI","deploymentId":"dpl_Em2U4NQQ2N2DE3HPbPUJVZLnAtvc","buildId":"dpl_Em2U4NQQ2N2DE3HPbPUJVZLnAtvc","dynamics":[],"chunks":[]}