-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Bug] MCP Tool freezes at __aexit__
on Windows
#3240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Further exploring shows that it stopped at:
DetailsAt agno/libs/agno/agno/tools/mcp.py Lines 188 to 199 in cb49ccd
The function stopped at Line 196 calling
agno/libs/agno/agno/tools/mcp.py Lines 153 to 176 in cb49ccd
|
I try to insert debug prints into the async def terminate_windows_process(process: Process):
"""
Terminate a Windows process.
Note: On Windows, terminating a process with process.terminate() doesn't
always guarantee immediate process termination.
So we give it 2s to exit, or we call process.kill()
which sends a SIGKILL equivalent signal.
Args:
process: The process to terminate
"""
try:
print("Calling process.terminate()")
process.terminate()
print("process.terminate() returned")
with anyio.fail_after(2.0):
print("Calling process.wait()")
await process.wait()
print("process.wait() returned")
except TimeoutError:
# Force kill if it doesn't terminate
print("Calling process.kill()")
process.kill()
print("process.kill() returned")
except Exception as e:
print("Unexpected error:", type(e), e)
finally:
print("finally!") The output when I run
This is quite confusing for me, as it is working in the simple test. In import asyncio
# run npx -y mongodb-mcp-server --connectionString mongodb://localhost:27017
from mcp.client.stdio.win32 import terminate_windows_process
from mcp.client.stdio import _create_platform_compatible_process
async def main():
print("hello main")
process = await _create_platform_compatible_process(
command="npx.cmd",
args=[
"-y",
"mongodb-mcp-server",
"--connectionString",
"mongodb://localhost:27017",
],
)
await terminate_windows_process(process)
asyncio.run(main()) Output:
|
call_tool
__aexit__
on Windows
Description
I wrote:
mongo_agent: agno.agent.Agent
withMCPTools(command=<run mongodb-mcp-server>)
andReasontool
team: agno.team.team.Team
withmode="coordinate"
andReasontool
Then I call
team.print_response("Check the mongo database list for me", stream=True)
.The passing from
team
tomongo_agent
is successful andmongo_agent
can calllist_database()
.However,
mongo_agent
cannot receive the data fromlist_database()
and the program finished with output"Sorry, I cannot ..."
.Furthermore, it freezes when exiting
async with MCPTools()
context. I have to enterCtrl+C
to force it stopping, then it tells me thatRuntimeWarning: coroutine 'get_entrypoint_for_tool.<locals>.call_tool' was never awaited
.I believe it is not the MCP's problem, since I have tested it manually by calling the API and it worked.
This is maybe relevant to #3238.
Steps to Reproduce
mongo_agent.py
:team.py
:__init__.py
:Agent Configuration (if applicable)
No response
Expected Behavior
None
Actual Behavior
None
Screenshots or Logs (if applicable)
After I force it stop using
Ctrl+C
:Environment
Possible Solutions (optional)
Check the using of
Function.entrypoint(...)
.In
mcp.py
:agno/libs/agno/agno/tools/mcp.py
Lines 233 to 243 in d7ba633
get_entrypoint_for_tool(...) -> AsyncCallable
is assigned toFunction.entrypoint: Optional[Callable]
.However,
Function.entrypoint
is called sync in some cases:agno/libs/agno/agno/tools/function.py
Lines 627 to 632 in cdc3811
It might need to check if these cases are calling correctly.
Additional Context
No response
The text was updated successfully, but these errors were encountered: