class TemporalMcpClientSession(ClientSession): (source)
Constructor: TemporalMcpClientSession(server_name, cache_tools, activity_config)
mcp.ClientSession whose tool discovery and calls run as activities.
Warning
This API is experimental and may change in future versions.
Construct inside a workflow and pass it in the tools list of a generate_content call. The matching server name must be registered on the worker via GoogleGenAIPlugin(mcp_servers={name: factory}).
cache_tools controls how often tools are listed. When False (the default) the {server}-list-tools activity runs each time the SDK discovers tools (i.e. per generate_content call), so a server whose tools changed mid-workflow is picked up. When True the first listing is cached on this instance and reused for its lifetime (replay-safe in-workflow state).
| Parameters | |
| server | Name selecting the worker-side factory; also the activity prefix ({server_name}-list-tools / {server_name}-call-tool). |
| cache | Cache the tool listing after the first call. |
| activity | Activity configuration (timeouts, retry policy, etc.) for the MCP activities. Defaults to a 60-second start_to_close_timeout. |
| Method | __init__ |
Initialize without calling super (no real streams exist here). |
| Async Method | call |
Call a tool via the {server}-call-tool activity. |
| Async Method | list |
List the server's tools via the {server}-list-tools activity. |
| Method | _config |
Undocumented |
| Instance Variable | _activity |
Undocumented |
| Instance Variable | _cache |
Undocumented |
| Instance Variable | _cached |
Undocumented |
| Instance Variable | _server |
Undocumented |
str, *, cache_tools: bool = False, activity_config: ActivityConfig | None = None):
(source)
¶
Initialize without calling super (no real streams exist here).
str, arguments: dict[ str, Any] | None = None, read_timeout_seconds: timedelta | None = None, progress_callback: ProgressFnT | None = None, *, meta: dict[ str, Any] | None = None) -> CallToolResult:
(source)
¶
Call a tool via the {server}-call-tool activity.