Skip to content

[Bug] Add missing close function in MCPServer #246

@alnzng

Description

@alnzng

Search before asking

  • I searched in the issues and found nothing similar.

Description

The MCPServer hasn't implemented the close function, however the agent_plan call the close function in _add_mcp_server method.

2025-10-03 10:23:15,749 - INFO - HTTP Request: DELETE http://127.0.0.1:8000/mcp "HTTP/1.1 200 OK"
Traceback (most recent call last):
  File "/Users/alazhang/Workspaces/Java/flink-agents/python/flink_agents/e2e_tests/mcp/mcp_example.py", line 142, in <module>
    output_list = env.from_list(input_list).apply(agent).to_list()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alazhang/Workspaces/Java/flink-agents/python/flink_agents/runtime/local_execution_environment.py", line 67, in apply
    self.__runner = LocalRunner(agent, self.__config)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alazhang/Workspaces/Java/flink-agents/python/flink_agents/runtime/local_runner.py", line 202, in __init__
    self.__agent_plan = AgentPlan.from_agent(agent, config)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alazhang/Workspaces/Java/flink-agents/python/flink_agents/plan/agent_plan.py", line 136, in from_agent
    for provider in _get_resource_providers(agent):
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alazhang/Workspaces/Java/flink-agents/python/flink_agents/plan/agent_plan.py", line 317, in _get_resource_providers
    _add_mcp_server(name, resource_providers, mcp_server)
  File "/Users/alazhang/Workspaces/Java/flink-agents/python/flink_agents/plan/agent_plan.py", line 375, in _add_mcp_server
    mcp_server.close()
    ^^^^^^^^^^^^^^^^
  File "/Users/alazhang/Workspaces/Java/flink-agents/python/.venv/lib/python3.11/site-packages/pydantic/main.py", line 989, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'MCPServer' object has no attribute 'close'

How to reproduce

Run an end-to-end MCP example

Version and environment

0.1.0

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

Labels

bug[Issue Type] Something isn't working as expected.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions