@@ -163,6 +163,52 @@ async def _list_tools_async() -> ListToolsResult:
163
163
mcp_tools = [MCPAgentTool (tool , self ) for tool in list_tools_response .tools ]
164
164
self ._log_debug_with_thread ("successfully adapted %d MCP tools" , len (mcp_tools ))
165
165
return PaginatedList [MCPAgentTool ](mcp_tools , token = list_tools_response .nextCursor )
166
+
167
+ def list_prompts_sync (self ) -> ListPromptsResult :
168
+ """Synchronously retrieves the list of available prompts from the MCP server.
169
+
170
+ This method calls the asynchronous list_prompts method on the MCP session
171
+ and adapts the returned prompts to the AgentTool interface.
172
+
173
+ Returns:
174
+ ListPromptsResult: A list of available prompts
175
+ """
176
+ self ._log_debug_with_thread ("listing MCP prompts synchronously" )
177
+ if not self ._is_session_active ():
178
+ raise MCPClientInitializationError ("the client session is not running" )
179
+
180
+ async def _list_prompts_async () -> ListPromptsResult :
181
+ return await self ._background_thread_session .list_prompts ()
182
+
183
+ list_prompts_response : ListPromptsResult = self ._invoke_on_background_thread (_list_prompts_async ())
184
+ self ._log_debug_with_thread ("received %d prompts from MCP server:" )
185
+ for prompt in list_prompts_response .prompts :
186
+ self ._log_debug_with_thread (prompt .name )
187
+
188
+ return list_prompts_response
189
+
190
+ def get_prompt_sync (self , prompt_id : str , args : dict [Any , Any ]) -> GetPromptResult :
191
+ """Synchronously retrieves a prompt from the MCP server.
192
+
193
+ Args:
194
+ prompt_id: The ID of the prompt to retrieve
195
+ args: Optional arguments to pass to the prompt
196
+
197
+ Returns:
198
+ GetPromptResult: The prompt response from the MCP server
199
+ """
200
+ self ._log_debug_with_thread ("getting MCP prompt synchronously" )
201
+ if not self ._is_session_active ():
202
+ raise MCPClientInitializationError ("the client session is not running" )
203
+
204
+ async def _get_prompt_async ():
205
+ return await self ._background_thread_session .get_prompt (
206
+ prompt_id , arguments = args
207
+ )
208
+ get_prompt_response : GetPromptResult = self ._invoke_on_background_thread (_get_prompt_async ())
209
+ self ._log_debug_with_thread ("received prompt from MCP server:" , get_prompt_response )
210
+
211
+ return get_prompt_response
166
212
167
213
def call_tool_sync (
168
214
self ,
0 commit comments