Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions python/flink_agents/integrations/mcp/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
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,
Expand Down Expand Up @@ -272,16 +271,17 @@ def get_tool_metadata(self, name: str) -> ToolMetadata:

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 = []
Expand Down