The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(mcp): rewrap re-export blocks (formatting only)
Teknium6517b2d1c418
diff --git a/tools/mcp_tool.py b/tools/mcp_tool.pyindex 6e1bda385f8..fb35a5e9ba5 100644--- a/tools/mcp_tool.py+++ b/tools/mcp_tool.py@@ -71,150 +71,75 @@ logger = logging.getLogger(__name__)# and ``mock.patch("tools.mcp_tool.X")`` keep working; the siblings read origin# state back through ``tools.mcp_tool`` at call time (never by value).from tools.mcp_tool_common import ( # noqa: F401- _DEFAULT_TOOL_TIMEOUT,- _env_ref_name,- _exc_str,- _get_lifecycle_seconds,- _jittered,- _parse_boolish,- _resolve_tool_timeout,- _safe_numeric,- _sanitize_error,- mcp_field,+ _DEFAULT_TOOL_TIMEOUT, _env_ref_name, _exc_str, _get_lifecycle_seconds,+ _jittered, _parse_boolish, _resolve_tool_timeout, _safe_numeric,+ _sanitize_error, mcp_field,)from tools.mcp_tool_schema import ( # noqa: F401- MCP_TOOL_NAME_PREFIX,- _build_utility_schemas,- _convert_mcp_schema,- _normalize_mcp_input_schema,- _scan_mcp_description,- matches_name_filter,- mcp_prefixed_tool_name,- sanitize_mcp_name_component,+ MCP_TOOL_NAME_PREFIX, _build_utility_schemas, _convert_mcp_schema,+ _normalize_mcp_input_schema, _scan_mcp_description, matches_name_filter,+ mcp_prefixed_tool_name, sanitize_mcp_name_component,)from tools.mcp_tool_content import ( # noqa: F401- _MCP_HARD_RESULT_CAP_CHARS,- _MCP_RESOURCE_MAX_B64_CHARS,- _MCP_RESOURCE_MAX_BYTES,- _cache_mcp_audio_block,- _cache_mcp_image_block,- _is_reserved_mcp_meta_key,- _mcp_image_extension_for_mime_type,- _mcp_resource_filename,- _render_mcp_resource_block,- _truncate_mcp_text_result,+ _MCP_HARD_RESULT_CAP_CHARS, _MCP_RESOURCE_MAX_B64_CHARS,+ _MCP_RESOURCE_MAX_BYTES, _cache_mcp_audio_block, _cache_mcp_image_block,+ _is_reserved_mcp_meta_key, _mcp_image_extension_for_mime_type,+ _mcp_resource_filename, _render_mcp_resource_block, _truncate_mcp_text_result,)from tools.mcp_tool_errors import ( # noqa: F401- InvalidMcpUrlError,- NonMcpEndpointError,- _EXC_TRAVERSAL_MAX_NODES,- _JSONRPC_UNSUPPORTED_PROTOCOL_VERSION,- _classify_mcp_failure,- _format_connect_error,- _handshake_rejected_as_modern,- _is_auth_error,- _is_method_not_found_error,- _is_session_expired_error,- _make_redirect_header_stripper,- _resolve_client_cert,- _resolve_identity_header,- _unwrap_exception_group,- _validate_remote_mcp_url,+ InvalidMcpUrlError, NonMcpEndpointError, _EXC_TRAVERSAL_MAX_NODES,+ _JSONRPC_UNSUPPORTED_PROTOCOL_VERSION, _classify_mcp_failure,+ _format_connect_error, _handshake_rejected_as_modern, _is_auth_error,+ _is_method_not_found_error, _is_session_expired_error,+ _make_redirect_header_stripper, _resolve_client_cert, _resolve_identity_header,+ _unwrap_exception_group, _validate_remote_mcp_url,)from tools.mcp_tool_config import ( # noqa: F401- _ENV_VAR_PATTERN,- _build_safe_env,- _filter_suspicious_mcp_servers,- _get_mcp_stderr_log,- _interpolate_env_vars,- _load_mcp_config,- _resolve_stdio_command,- _warn_hidden_whitespace,- _whitespace_warned,- _workspace_folder,- _wrap_command_with_watchdog,- _write_stderr_log_header,+ _ENV_VAR_PATTERN, _build_safe_env, _filter_suspicious_mcp_servers,+ _get_mcp_stderr_log, _interpolate_env_vars, _load_mcp_config,+ _resolve_stdio_command, _warn_hidden_whitespace, _whitespace_warned,+ _workspace_folder, _wrap_command_with_watchdog, _write_stderr_log_header,)from tools.mcp_tool_sampling import ( # noqa: F401- ElicitationHandler,- SamplingHandler,- _format_elicitation_schema_summary,+ ElicitationHandler, SamplingHandler, _format_elicitation_schema_summary,)from tools.mcp_tool_handlers import ( # noqa: F401- _handle_auth_error_and_retry,- _handle_session_expired_and_retry,- _make_check_fn,- _make_get_prompt_handler,- _make_list_prompts_handler,- _make_list_resources_handler,- _make_read_resource_handler,- _make_tool_handler,+ _handle_auth_error_and_retry, _handle_session_expired_and_retry, _make_check_fn,+ _make_get_prompt_handler, _make_list_prompts_handler,+ _make_list_resources_handler, _make_read_resource_handler, _make_tool_handler,)from tools.mcp_tool_registration import ( # noqa: F401- _annotation_read_only_hint,- _existing_tool_names,- _forget_mcp_tool_server,- _normalize_server_trust,- _register_from_cache_sync,- _register_server_tools,- _select_utility_schemas,- _track_mcp_tool_server,+ _annotation_read_only_hint, _existing_tool_names, _forget_mcp_tool_server,+ _normalize_server_trust, _register_from_cache_sync, _register_server_tools,+ _select_utility_schemas, _track_mcp_tool_server,)from tools.mcp_tool_lifecycle import ( # noqa: F401- _drain_and_stop_mcp_loop,- _drain_mcp_loop_tasks,- _filter_mcp_children,- _kill_orphaned_mcp_children,- _orphan_stdio_pid_servers,- _orphan_stdio_pids,- _snapshot_child_pids,- _stdio_pgids,- _stdio_pids,- _stop_mcp_loop_if_idle,+ _drain_and_stop_mcp_loop, _drain_mcp_loop_tasks, _filter_mcp_children,+ _kill_orphaned_mcp_children, _orphan_stdio_pid_servers, _orphan_stdio_pids,+ _snapshot_child_pids, _stdio_pgids, _stdio_pids, _stop_mcp_loop_if_idle,shutdown_mcp_servers,)from tools.mcp_tool_agent import ( # noqa: F401- _reinject_post_build_tools,- persist_agent_tool_names,- refresh_agent_mcp_tools,- reprobe_tool_availability,- restore_agent_tool_prefix,+ _reinject_post_build_tools, persist_agent_tool_names, refresh_agent_mcp_tools,+ reprobe_tool_availability, restore_agent_tool_prefix,)from tools.mcp_tool_transport import MCPServerTransportMixinfrom tools.mcp_tool_server_run import MCPServerRunMixinfrom tools.mcp_tool_health import MCPServerHealthMixinfrom tools.mcp_tool_loop import ( # noqa: F401 -- re-exported for callers and test patches- _LockCookie,- _acquire_lock_on_fh,- _try_acquire_mcp_discovery_lock,- _mcp_loop_exception_handler,- _wrap_with_home_override,- _wrap_with_dashboard_oauth_flow,- _run_on_mcp_loop,- _signal_reconnect,- reconnect_mcp_server,- _wait_for_server_session_ready,- _signal_reconnect_and_wait,- _ensure_mcp_loop,- _stop_mcp_loop,+ _LockCookie, _acquire_lock_on_fh, _try_acquire_mcp_discovery_lock,+ _mcp_loop_exception_handler, _wrap_with_home_override,+ _wrap_with_dashboard_oauth_flow, _run_on_mcp_loop, _signal_reconnect,+ reconnect_mcp_server, _wait_for_server_session_ready,+ _signal_reconnect_and_wait, _ensure_mcp_loop, _stop_mcp_loop,)from tools.mcp_tool_discovery import ( # noqa: F401 -- re-exported for callers and test patches- _record_connect_failure,- _clear_connect_failure,- _connect_cooldown_active,- _connect_server,- _request_lazy_reconnect,- _resolve_server_lazy,- _ensure_lazy_server_connected,- _get_connected_server_for_call,- _discover_and_register_server,- register_mcp_servers,- discover_mcp_tools,- is_mcp_tool_parallel_safe,- get_mcp_status,- probe_mcp_server_tools,- has_registered_mcp_tools,- get_registered_mcp_server_names,+ _record_connect_failure, _clear_connect_failure, _connect_cooldown_active,+ _connect_server, _request_lazy_reconnect, _resolve_server_lazy,+ _ensure_lazy_server_connected, _get_connected_server_for_call,+ _discover_and_register_server, register_mcp_servers, discover_mcp_tools,+ is_mcp_tool_parallel_safe, get_mcp_status, probe_mcp_server_tools,+ has_registered_mcp_tools, get_registered_mcp_server_names,)