class TemporalStatefulMcpToolSet(BaseToolset): (source)
Constructor: TemporalStatefulMcpToolSet(name, config, server_session_config, factory_argument, not_in_workflow_toolset)
Workflow-side handle for a stateful MCP toolset.
Warning
This class is experimental and may change in future versions. Use with caution in production environments.
Use it as an async context manager inside a workflow so the dedicated -server-session worker is started on connect and torn down on cleanup:
async with TemporalStatefulMcpToolSet("my-tools") as toolset:
agent = Agent(..., tools=[toolset])
await runner.run(...)
The connection (and any MCP subprocess) lives for the duration of the async with block and is reused across every tool call in that block, then closed on exit. Callers must be prepared to handle ApplicationError(type="DedicatedWorkerFailure") should the dedicated worker die mid-run.
| Async Method | __aenter__ |
Connects the toolset and returns it for use as a context manager. |
| Async Method | __aexit__ |
Cleans up the toolset when exiting the context manager. |
| Method | __init__ |
Initializes the stateful Temporal MCP toolset handle. |
| Async Method | cleanup |
Cancels the dedicated session activity and awaits its teardown. |
| Async Method | close |
BaseToolset teardown hook; delegates to cleanup. |
| Async Method | connect |
Starts the dedicated -server-session activity for this run. |
| Async Method | get |
Retrieves available tools from the stateful MCP toolset. |
| Instance Variable | _config |
Undocumented |
| Instance Variable | _connect |
Undocumented |
| Instance Variable | _factory |
Undocumented |
| Instance Variable | _name |
Undocumented |
| Instance Variable | _not |
Undocumented |
| Instance Variable | _server |
Undocumented |
type[ BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None):
(source)
¶
Cleans up the toolset when exiting the context manager.
str, config: ActivityConfig | None = None, server_session_config: ActivityConfig | None = None, factory_argument: Any | None = None, not_in_workflow_toolset: Callable[ [ (Any | None)], McpToolset] | None = None):
(source)
¶
Initializes the stateful Temporal MCP toolset handle.
| Parameters | |
name:str | Base name of the toolset. Must match the name passed to
the TemporalStatefulMcpToolSetProvider (the
-stateful suffix is applied here automatically). |
config:ActivityConfig | None | Optional activity configuration for the per-operation (-list-tools/-call-tool) activities. A schedule_to_start_timeout is used to detect a dead dedicated worker. |
serverActivityConfig | None | Optional activity configuration for the long-running -server-session activity. |
factoryAny | None | Optional argument passed once to the toolset factory when the session connects. |
notCallable[ | Optional factory that returns the underlying McpToolset to use when this wrapper executes outside workflow.in_workflow(), such as local ADK runs. |