Environment
- google-genai: 2.9.0
- mcp: 1.28.1
- Python: 3.12.13
The issue
Passing a live MCP ClientSession as a tool works when config is a dict, but the same settings passed as a GenerateContentConfig object raise TypeError: cannot pickle '_asyncio.Future' object.
In AsyncModels.generate_content, the config is deep-copied before MCP sessions are extracted — google/genai/models.py (2.9.0)
Steps to reproduce
- Create a live MCP ClientSession and pass it as a tool to aio.models.generate_content, with config as a GenerateContentConfig object:
config=types.GenerateContentConfig(tools=[session]).
- The call raises TypeError: cannot pickle '_asyncio.Future' object before any network request.
- Pass the same settings as a dict instead — config={"tools": [session]} — and it works (session is extracted, request proceeds normally).
Environment
The issue
Passing a live MCP ClientSession as a tool works when config is a dict, but the same settings passed as a GenerateContentConfig object raise TypeError: cannot pickle '_asyncio.Future' object.
In AsyncModels.generate_content, the config is deep-copied before MCP sessions are extracted — google/genai/models.py (2.9.0)
Steps to reproduce
config=types.GenerateContentConfig(tools=[session]).