This is an automated email from the ASF dual-hosted git repository.
xtsong pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-agents.git
The following commit(s) were added to refs/heads/main by this push:
new 23f9a77d [hotfix][mcp][python] Check whether mcp server supports
prompts via server capabilities (#551)
23f9a77d is described below
commit 23f9a77d9f6f62233613e95564314b0c017befc2
Author: Xintong Song <[email protected]>
AuthorDate: Mon Mar 2 11:44:50 2026 +0800
[hotfix][mcp][python] Check whether mcp server supports prompts via server
capabilities (#551)
---
python/flink_agents/integrations/mcp/mcp.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/python/flink_agents/integrations/mcp/mcp.py
b/python/flink_agents/integrations/mcp/mcp.py
index 08066673..856be4a3 100644
--- a/python/flink_agents/integrations/mcp/mcp.py
+++ b/python/flink_agents/integrations/mcp/mcp.py
@@ -27,7 +27,6 @@ import cloudpickle
import httpx
from mcp.client.session import ClientSession
from mcp.client.streamable_http import streamablehttp_client
-from mcp.shared.exceptions import McpError
from mcp.types import PromptArgument, TextContent
from pydantic import (
ConfigDict,
@@ -272,16 +271,17 @@ class MCPServer(Resource, ABC):
def list_prompts(self) -> List[MCPPrompt]:
"""List available prompts from the MCP server."""
- try:
- return asyncio.run(self._list_prompts_async())
- except McpError as e:
- if "prompts not supported" in str(e).lower():
- return []
- raise
+ return asyncio.run(self._list_prompts_async())
async def _list_prompts_async(self) -> List[MCPPrompt]:
"""Async implementation of list_prompts."""
async with self._get_session() as session:
+ # Check if the server supports prompts capability
+ capabilities = session.get_server_capabilities()
+ if capabilities is None or capabilities.prompts is None:
+ # Server does not support prompts
+ return []
+
prompts_response = await session.list_prompts()
prompts = []