class TemporalMCPClient(ToolProvider): (source)
Constructor: TemporalMCPClient(server, cache_tools, task_queue, schedule_to_close_timeout, ...)
Workflow-side handle to an MCP server registered on the worker.
The transport factory lives worker-side via StrandsPlugin(mcp_clients={"server": lambda: ...}). This handle carries the server name (which selects the registered factory) and the per-call activity options. Tool discovery runs as the {server}-list-tools activity, dispatched from inside the workflow by TemporalAgent before each model call.
cache_tools controls how often that listing happens. When False (the default) the tools are re-listed on every agent turn, so an MCP server restarted mid-workflow (with tools added, removed, or renamed) is picked up. When True the tools are listed once at the beginning of the workflow and reused for its lifetime.
Construct once at module level and pass to TemporalAgent(tools=[...]) inside the workflow. Multiple handles may reference the same server name with different activity options.
| Method | __init__ |
Configure the server name and activity options. |
| Method | add |
No-op; consumer tracking is handled by the underlying MCP client. |
| Async Method | load |
Return the tools fetched by the most recent _refresh. |
| Method | remove |
No-op; consumer tracking is handled by the underlying MCP client. |
| Property | server |
MCP server name used as the activity prefix. |
| Async Method | _refresh |
List the server's tools via the {server}-list-tools activity. |
| Instance Variable | _cache |
Undocumented |
| Instance Variable | _fetched |
Undocumented |
| Instance Variable | _options |
Undocumented |
| Instance Variable | _server |
Undocumented |
| Instance Variable | _tools |
Undocumented |
str, *, cache_tools: bool = False, task_queue: str | None = None, schedule_to_close_timeout: timedelta | None = None, schedule_to_start_timeout: timedelta | None = None, start_to_close_timeout: timedelta | None = None, heartbeat_timeout: timedelta | None = None, retry_policy: RetryPolicy | None = None, cancellation_type: ActivityCancellationType = ActivityCancellationType.TRY_CANCEL, versioning_intent: VersioningIntent | None = None, summary: str | None = None, priority: Priority = Priority.default):
(source)
¶
Configure the server name and activity options.
Return the tools fetched by the most recent _refresh.
This must stay free of any workflow API: Strands invokes it once at Agent construction on a separate run_async thread that has no workflow runtime. TemporalAgent populates the tools by calling _refresh from a BeforeModelCallEvent hook before the registry is first read.