Problem
google/genai/_mcp_utils.py:31-36 (and the same pattern in types.py, _extra_utils.py, _transformers.py, live.py) eagerly imports mcp at module load whenever it's installed. Adds ~240ms cold start to every import google.genai, even for users who never touch MCP.
Repro
pip install google-genai mcp
python -X importtime -c "import google.genai" 2>&1 | grep -c "^import time:.*mcp"
# 60+ mcp.* modules loaded
Fix
Drop the eager import; keep McpTool/McpClientSession typed as Any and do isinstance checks behind if 'mcp' in sys.modules: in the few methods that actually need them. Same pattern works for the other 4 files.
Happy to send a PR if the approach sounds right.
Problem
google/genai/_mcp_utils.py:31-36(and the same pattern intypes.py,_extra_utils.py,_transformers.py,live.py) eagerly importsmcpat module load whenever it's installed. Adds ~240ms cold start to everyimport google.genai, even for users who never touch MCP.Repro
Fix
Drop the eager import; keep
McpTool/McpClientSessiontyped asAnyand doisinstancechecks behindif 'mcp' in sys.modules:in the few methods that actually need them. Same pattern works for the other 4 files.Happy to send a PR if the approach sounds right.