@@ -90,7 +90,9 @@ class TemporalMcpToolSetProvider:
9090 within Temporal workflows.
9191 """
9292
93- def __init__ (self , name : str , toolset_factory : Callable [[Any | None ], McpToolset ]):
93+ def __init__ (
94+ self , name : str , toolset_factory : Callable [[Any | None ], McpToolset ]
95+ ) -> None :
9496 """Initializes the toolset provider.
9597
9698 Args:
@@ -215,20 +217,28 @@ def __init__(
215217 name : str ,
216218 config : ActivityConfig | None = None ,
217219 factory_argument : Any | None = None ,
220+ not_in_workflow_toolset : Callable [[Any | None ], McpToolset ] | None = None ,
218221 ):
219222 """Initializes the Temporal MCP toolset.
220223
221224 Args:
222225 name: Name of the toolset (used for activity naming).
223226 config: Optional activity configuration.
224227 factory_argument: Optional argument passed to toolset factory.
228+ not_in_workflow_toolset: Optional factory that returns the
229+ underlying ``McpToolset`` to use when this wrapper executes
230+ outside ``workflow.in_workflow()``, such as local ADK runs.
231+ This is not needed during normal workflow execution, but
232+ ``get_tools()`` raises ``ValueError`` outside a workflow if it
233+ is omitted.
225234 """
226235 super ().__init__ ()
227236 self ._name = name
228237 self ._factory_argument = factory_argument
229238 self ._config = config or ActivityConfig (
230239 start_to_close_timeout = timedelta (minutes = 1 )
231240 )
241+ self ._not_in_workflow_toolset = not_in_workflow_toolset
232242
233243 async def get_tools (
234244 self , readonly_context : ReadonlyContext | None = None
@@ -241,6 +251,17 @@ async def get_tools(
241251 Returns:
242252 List of available tools wrapped as Temporal activities.
243253 """
254+ # If executed outside a workflow, like when doing local adk runs, use the mcp server directly
255+ if not workflow .in_workflow ():
256+ if self ._not_in_workflow_toolset is None :
257+ raise ValueError (
258+ "Attempted to use TemporalMcpToolSet outside a workflow, but "
259+ "no not_in_workflow_toolset was provided. Either use "
260+ "McpToolSet directly or pass a factory that returns the "
261+ "underlying McpToolset for non-workflow execution."
262+ )
263+ return await self ._not_in_workflow_toolset (None ).get_tools (readonly_context )
264+
244265 tool_results : list [_ToolResult ] = await workflow .execute_activity (
245266 self ._name + "-list-tools" ,
246267 _GetToolsArguments (self ._factory_argument ),
0 commit comments