@@ -227,6 +227,8 @@ async def list_tools(
227
227
run_context : Optional [RunContextWrapper [Any ]] = None ,
228
228
agent : Optional [AgentBase ] = None ,
229
229
) -> list [MCPTool ]:
230
+ if not self ._connect_handle :
231
+ raise ApplicationError ("Stateful MCP Server not connected. Call connect first." )
230
232
return await workflow .execute_activity (
231
233
self .name + "-list-tools" ,
232
234
args = [],
@@ -238,6 +240,8 @@ async def list_tools(
238
240
async def call_tool (
239
241
self , tool_name : str , arguments : Optional [dict [str , Any ]]
240
242
) -> CallToolResult :
243
+ if not self ._connect_handle :
244
+ raise ApplicationError ("Stateful MCP Server not connected. Call connect first." )
241
245
return await workflow .execute_activity (
242
246
self .name + "-call-tool" ,
243
247
args = [tool_name , arguments ],
@@ -247,6 +251,8 @@ async def call_tool(
247
251
248
252
@_handle_worker_failure
249
253
async def list_prompts (self ) -> ListPromptsResult :
254
+ if not self ._connect_handle :
255
+ raise ApplicationError ("Stateful MCP Server not connected. Call connect first." )
250
256
return await workflow .execute_activity (
251
257
self .name + "-list-prompts" ,
252
258
args = [],
@@ -258,6 +264,8 @@ async def list_prompts(self) -> ListPromptsResult:
258
264
async def get_prompt (
259
265
self , name : str , arguments : Optional [dict [str , Any ]] = None
260
266
) -> GetPromptResult :
267
+ if not self ._connect_handle :
268
+ raise ApplicationError ("Stateful MCP Server not connected. Call connect first." )
261
269
return await workflow .execute_activity (
262
270
self .name + "-get-prompt" ,
263
271
args = [name , arguments ],
0 commit comments