@@ -227,6 +227,8 @@ async def list_tools(
227227 run_context : Optional [RunContextWrapper [Any ]] = None ,
228228 agent : Optional [AgentBase ] = None ,
229229 ) -> list [MCPTool ]:
230+ if not self ._connect_handle :
231+ raise ApplicationError ("Stateful MCP Server not connected. Call connect first." )
230232 return await workflow .execute_activity (
231233 self .name + "-list-tools" ,
232234 args = [],
@@ -238,6 +240,8 @@ async def list_tools(
238240 async def call_tool (
239241 self , tool_name : str , arguments : Optional [dict [str , Any ]]
240242 ) -> CallToolResult :
243+ if not self ._connect_handle :
244+ raise ApplicationError ("Stateful MCP Server not connected. Call connect first." )
241245 return await workflow .execute_activity (
242246 self .name + "-call-tool" ,
243247 args = [tool_name , arguments ],
@@ -247,6 +251,8 @@ async def call_tool(
247251
248252 @_handle_worker_failure
249253 async def list_prompts (self ) -> ListPromptsResult :
254+ if not self ._connect_handle :
255+ raise ApplicationError ("Stateful MCP Server not connected. Call connect first." )
250256 return await workflow .execute_activity (
251257 self .name + "-list-prompts" ,
252258 args = [],
@@ -258,6 +264,8 @@ async def list_prompts(self) -> ListPromptsResult:
258264 async def get_prompt (
259265 self , name : str , arguments : Optional [dict [str , Any ]] = None
260266 ) -> GetPromptResult :
267+ if not self ._connect_handle :
268+ raise ApplicationError ("Stateful MCP Server not connected. Call connect first." )
261269 return await workflow .execute_activity (
262270 self .name + "-get-prompt" ,
263271 args = [name , arguments ],
0 commit comments