helpers/mcp_handler.py.dox.md
mcp_handler.py helper module.mcp_handler.py because this directory is intentionally flat.mcp_handler.py owns the runtime implementation.mcp_handler.py.dox.md owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.MCPTool (Tool)
get_log_object(self) -> LogItemasync execute(self, **kwargs)async before_execution(self, **kwargs)async after_execution(self, response: Response, **kwargs)MCPServerRemote (BaseModel)
get_error(self) -> strget_log(self) -> strget_tools(self) -> List[dict[str, Any]]get_all_tools(self) -> List[dict[str, Any]]has_tool(self, tool_name: str) -> boolasync call_tool(self, tool_name: str, input_data: Dict[str, Any]) -> CallToolResultupdate(self, config: dict[str, Any]) -> 'MCPServerRemote'async initialize(self) -> 'MCPServerRemote'MCPServerLocal (BaseModel)
get_error(self) -> strget_log(self) -> strget_tools(self) -> List[dict[str, Any]]get_all_tools(self) -> List[dict[str, Any]]has_tool(self, tool_name: str) -> boolasync call_tool(self, tool_name: str, input_data: Dict[str, Any]) -> CallToolResultupdate(self, config: dict[str, Any]) -> 'MCPServerLocal'async initialize(self) -> 'MCPServerLocal'MCPConfig (BaseModel)
get_instance(cls) -> 'MCPConfig'clear_project_instances(cls)parse_config_string(cls, config_str: str) -> List[Dict[str, Any]]merge_config_strings(cls, global_config: str, project_config: str) -> tuple[List[Dict[str, Any]], str]get_project_instance(cls, project_name: str | None, *, force: bool = False) -> 'MCPConfig'refresh_project(cls, project_name: str) -> 'MCPConfig'get_for_agent(cls, agent: Any) -> 'MCPConfig'wait_for_lock(cls)update(cls, config_str: str) -> Anynormalize_config(cls, servers: Any)get_server_log(self, server_name: str) -> strget_servers_status(self) -> list[dict[str, Any]]get_server_detail(self, server_name: str) -> dict[str, Any]is_initialized(self) -> boolMCPClientBase (ABC)
async update_tools(self) -> 'MCPClientBase'has_tool(self, tool_name: str) -> boolget_tools(self) -> List[dict[str, Any]]async call_tool(self, tool_name: str, input_data: Dict[str, Any]) -> CallToolResultget_log(self)MCPClientLocal (MCPClientBase)CustomHTTPClientFactory (ABC)MCPClientRemote (MCPClientBase)
get_session_id(self) -> Optional[str]_mcp_get(item: Any, key: str, default: Any=...) -> Anynormalize_name(name: str) -> str_determine_server_type(config_dict: dict) -> str: Determine the server type based on configuration, with backward compatibility._is_streaming_http_type(server_type: str) -> bool: Check if the server type is a streaming HTTP variant._split_qualified_tool_name(tool_name: str) -> tuple[str, str]: Split server.tool names while preserving dots inside MCP tool names._normalize_disabled_tools(value: Any) -> list[str]: Normalize the optional per-server disabled tool list.initialize_mcp(mcp_servers_config: str)DEFAULT_MCP_SERVERS_CONFIG, MCP_MEDIA_TOKENS_ESTIMATE, MAX_MCP_RESOURCE_TEXT_CHARS, MCP_SESSION_CLEANUP_TIMEOUT_SECONDS, MCP_OPERATION_TIMEOUT_GRACE_SECONDS, T.MCPTool is a Tool.MCPTool defines execute(...).helpers.projects and merged with global config when an active agent context has context.project.MCPConfig cache key is derived from both config strings so project instances refresh when either scope changes.scope, and MCP tools resolve through MCPConfig.get_for_agent(agent) before execution.server_name.tool_name; server names are normalized without dots, and the tool portion may contain dots.disabled_tools as a list of MCP tool names. Disabled tools are omitted from agent-facing prompts, status counts, has_tool, and calls, while detail views can still retrieve them through get_all_tools() with a disabled flag so users can re-enable them.init_timeout and tool_timeout override global MCP client timeout settings for list-tools and call-tool operations.DeferredTask workers with an outer timeout. Normal AsyncExitStack cleanup is also bounded; if cleanup or transport shutdown does not finish, the operation reports failure or warning while Agent Zero keeps control of the agent loop.abc, anyio.streams.memory, asyncio, contextlib, datetime, helpers, helpers.defer, helpers.log, helpers.print_style, helpers.tool, httpx, json, mcp, mcp.client.sse, mcp.client.stdio, mcp.client.streamable_http, mcp.shared.message.TypeVar, name.strip.lower, re.sub, Field, PrivateAttr, threading.Lock, DeferredTask, _split_qualified_tool_name, config_dict.lower, server_type.lower, MCPConfig.get_instance.is_initialized, MCPConfig.get_for_agent, projects.validate_project_name, projects.load_project_mcp_servers, settings.get_settings, self.agent.context.log.log, str.strip, media_artifacts.guess_extension, callable, self._content_item_dump, join, Response, self.get_log_object, self._raw_tool_response, additional.pop, self._coerce_media_token_estimate.tests/test_mcp_handler_multimodal.pyNo child DOX files.