qingfei1994 opened a new issue, #412:
URL: https://github.com/apache/flink-agents/issues/412

   ### Search before asking
   
   - [x] I searched in the 
[issues](https://github.com/apache/flink-agents/issues) and found nothing 
similar.
   
   ### Description
   
   I customized a ReactAgent with a remote mcp server something like this.
   ```class ReActAgentWithMCP(ReActAgent):
       """ReAct Agent with MCP integration."""
       @mcp_server
       @staticmethod
       def my_mcp_server() -> MCPServer:
           """Define MCP server connection."""
           return MCPServer(endpoint="https://xxxx/mcp/";)````
   
   But fail to use MCP server. 
   ```
   2026-01-06 14:31:37,332 - INFO - Using Any for unsupported type: 
typing.Sequence[~T]
   2026-01-06 14:31:37,400 - INFO - No module named 
google.cloud.bigquery_storage_v1. As a result, the ReadFromBigQuery transform 
*CANNOT* be used with `method=DIRECT_READ`.
   2026-01-06 14:31:37,619 - INFO - HTTP Request: POST https://test.work/mcp/ 
"HTTP/1.1 200 OK"
   2026-01-06 14:31:37,619 - INFO - Negotiated protocol version: 2025-03-26
   2026-01-06 14:31:37,661 - INFO - HTTP Request: POST https://test.work/mcp/ 
"HTTP/1.1 202 Accepted"
   2026-01-06 14:31:37,841 - INFO - HTTP Request: POST https://test.work/mcp/ 
"HTTP/1.1 200 OK"
     + Exception Group Traceback (most recent call last):
     |   File 
"/flink-agents/python/flink_agents/examples/react_agent_diagnose.py", line 140, 
in <module>
     |     main()
     |   File 
"/flink-agents/python/flink_agents/examples/react_agent_diagnose.py", line 128, 
in main
     |     .apply(log_analysis_react_agent)
     |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/flink_agents/runtime/remote_execution_environment.py",
 line 97, in apply
     |     self.__agent_plan = AgentPlan.from_agent(agent, self.__config)
     |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/flink_agents/plan/agent_plan.py",
 line 137, in from_agent
     |     for provider in _get_resource_providers(agent):
     |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/flink_agents/plan/agent_plan.py",
 line 330, in _get_resource_providers
     |     _add_mcp_server(name, resource_providers, mcp_server)
     |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/flink_agents/plan/agent_plan.py",
 line 380, in _add_mcp_server
     |     for prompt in mcp_server.list_prompts()
     |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/flink_agents/api/tools/mcp.py",
 line 259, in list_prompts
     |     return asyncio.run(self._list_prompts_async())
     |   File 
"/opt/homebrew/Cellar/[email protected]/3.10.19_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py",
 line 44, in run
     |     return loop.run_until_complete(main)
     |   File 
"/opt/homebrew/Cellar/[email protected]/3.10.19_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py",
 line 649, in run_until_complete
     |     return future.result()
     |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/flink_agents/api/tools/mcp.py",
 line 263, in _list_prompts_async
     |     async with self._get_session() as session:
     |   File 
"/opt/homebrew/Cellar/[email protected]/3.10.19_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py",
 line 217, in __aexit__
     |     await self.gen.athrow(typ, value, traceback)
     |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/flink_agents/api/tools/mcp.py",
 line 175, in _get_session
     |     async with streamablehttp_client(
     |   File 
"/opt/homebrew/Cellar/[email protected]/3.10.19_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py",
 line 217, in __aexit__
     |     await self.gen.athrow(typ, value, traceback)
     |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/mcp/client/streamable_http.py",
 line 480, in streamablehttp_client
     |     async with anyio.create_task_group() as tg:
     |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py",
 line 781, in __aexit__
     |     raise BaseExceptionGroup(
     | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 
sub-exception)
     +-+---------------- 1 ----------------
       | Exception Group Traceback (most recent call last):
       |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/mcp/client/streamable_http.py",
 line 504, in streamablehttp_client
       |     yield (
       |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/flink_agents/api/tools/mcp.py",
 line 175, in _get_session
       |     async with streamablehttp_client(
       |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py",
 line 781, in __aexit__
       |     raise BaseExceptionGroup(
       | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 
sub-exception)
       +-+---------------- 1 ----------------
         | Traceback (most recent call last):
         |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/flink_agents/api/tools/mcp.py",
 line 186, in _get_session
         |     yield session
         |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/flink_agents/api/tools/mcp.py",
 line 264, in _list_prompts_async
         |     prompts_response = await session.list_prompts()
         |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/mcp/client/session.py",
 line 423, in list_prompts
         |     return await self.send_request(
         |   File 
"/flink-1.20.3/bin/test_venv/lib/python3.10/site-packages/mcp/shared/session.py",
 line 288, in send_request
         |     raise McpError(response_or_error.error)
         | mcp.shared.exceptions.McpError: prompts not supported
   ```
   
   I guess the reason is that the mcp server I used doesn't provide 
list_prompts interface. 
   is it possible for Users to manually defining them in the MCPServer 
constructor instead of fetching it thru the mcp server? 
   
   ### How to reproduce
   
   defining an agent with  a defined MCP server without list_prompts interface
   
   ### Version and environment
   
   master, flink version 1.20.6
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to