[BUG] Failed to connect DLL MCP tool
Required prerequisites
- [x] I have read the documentation https://camel-ai.github.io/camel/camel.html.
- [x] I have searched the Issue Tracker and Discussions that this hasn't already been reported. (+1 or comment there if it has.)
- [ ] Consider asking first in a Discussion.
What version of camel are you using?
0.2.78
System information
3.10.19 | packaged by Anaconda, Inc. | (main, Oct 21 2025, 16:41:31) [MSC v.1929 64 bit (AMD64)] win32 0.2.78 using conda as environment and pip install caml-ai[all]
Problem description
I am based on I wrote a document translation MCP tool (STDIO) in NET 8.0, but I couldn't connect to my MCP tool properly using the official example:
config_path = Path(__file__).parent / "mcp_test.json"
mcp_toolkit = MCPToolkit(config_path=str(config_path))
try:
await mcp_toolkit.connect()
MCP config json:
{
"mcpServers": {
"wordmcpro": {
"command": "dotnet",
"args": [
"D:/Project/CSharp/WordMCPro/bin/Debug/net8.0/WordMCPro.dll"
],
"timeout": 300000
}
}
}
I have test my mcp tool in cherry studio, it works fine.
Reproducible example code
The Python snippets:
config_path = Path(__file__).parent / "mcp_test.json"
mcp_toolkit = MCPToolkit(config_path=str(config_path))
try:
await mcp_toolkit.connect()
Steps to reproduce:
- compile C# mcp tools code as .dll file in .NET 8.0
- dotnet XXX.dll for testing mcp runing status, if OK, close it
- using offical code to connect mcp tools
Traceback
Traceback (most recent call last):
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\anyio\streams\memory.py", line 111, in receive
return self.receive_nowait()
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\anyio\streams\memory.py", line 106, in receive_nowait
raise WouldBlock
anyio.WouldBlock
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\240508\.conda\envs\owl\lib\asyncio\tasks.py", line 234, in __step
result = coro.throw(exc)
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\camel\utils\commons.py", line 998, in async_wrapper
return await func(*args, **kwargs)
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\camel\toolkits\mcp_toolkit.py", line 448, in _connect_all_clients
await self._exit_stack.enter_async_context(client)
File "C:\Users\240508\.conda\envs\owl\lib\contextlib.py", line 619, in enter_async_context
result = await _cm_type.__aenter__(cm)
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\camel\utils\mcp_client.py", line 288, in __aenter__
await self._establish_connection()
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\camel\utils\mcp_client.py", line 318, in _establish_connection
await self._session.initialize()
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\mcp\client\session.py", line 152, in initialize
result = await self.send_request(
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\mcp\shared\session.py", line 272, in send_request
response_or_error = await response_stream_reader.receive()
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\anyio\streams\memory.py", line 119, in receive
await receive_event.wait()
File "C:\Users\240508\.conda\envs\owl\lib\asyncio\locks.py", line 214, in wait
await fut
File "C:\Users\240508\.conda\envs\owl\lib\asyncio\futures.py", line 285, in __await__
yield self # This tells Task to wait for completion.
File "C:\Users\240508\.conda\envs\owl\lib\asyncio\tasks.py", line 304, in __wakeup
future.result()
File "C:\Users\240508\.conda\envs\owl\lib\asyncio\futures.py", line 196, in result
raise exc
asyncio.exceptions.CancelledError: Cancelled via cancel scope 17e78a55de0
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\camel\toolkits\mcp_toolkit.py", line 411, in connect
await asyncio.wait_for(
File "C:\Users\240508\.conda\envs\owl\lib\asyncio\tasks.py", line 445, in wait_for
return fut.result()
File "C:\Users\240508\.conda\envs\owl\lib\asyncio\futures.py", line 196, in result
raise exc
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Project\Python\owl-main\examples\run_mcp.py", line 178, in <module>
asyncio.run(main())
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\nest_asyncio.py", line 30, in run
return loop.run_until_complete(task)
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\nest_asyncio.py", line 98, in run_until_complete
return f.result()
File "C:\Users\240508\.conda\envs\owl\lib\asyncio\futures.py", line 201, in result
raise self._exception.with_traceback(self._exception_tb)
File "C:\Users\240508\.conda\envs\owl\lib\asyncio\tasks.py", line 232, in __step
result = coro.send(None)
File "D:\Project\Python\owl-main\examples\run_mcp.py", line 150, in main
await mcp_toolkit.connect()
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\camel\utils\commons.py", line 998, in async_wrapper
return await func(*args, **kwargs)
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\camel\toolkits\mcp_toolkit.py", line 433, in connect
raise MCPConnectionError(error_msg)
camel.toolkits.mcp_toolkit.MCPConnectionError: Connection timeout after 30.0s. One or more MCP servers are not responding. Please check if the servers are running and accessible.
Exception ignored in: <async_generator object MCPClient._create_transport at 0x0000017E3177BD40>
RuntimeError: async generator ignored GeneratorExit
Exception ignored in: <async_generator object stdio_client at 0x0000017E78980EC0>
Traceback (most recent call last):
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\mcp\client\stdio\__init__.py", line 182, in stdio_client
File "C:\Users\240508\.conda\envs\owl\lib\site-packages\anyio\_backends\_asyncio.py", line 745, in __aexit__
RuntimeError: no running event loop
Expected behavior
Normal connection and use. Looking forward that the developer can help me solve this problem. Thank you very much!
Additional context
No response
AnyBody here?
thanks @Charmnut for reporting this issue and sorry for the delayed response, we will check this and back to you ASAP
Thanks @Charmnut, it looks like the timeout is not properly setting up, from camel.toolkits.mcp_toolkit.MCPConnectionError: Connection timeout after 30.0s.
I suspect that he 30-second connection timeout might be too short for .NET DLL startup. This could be the main issue.
Could you try with
mcp_toolkit = MCPToolkit(
config_path=str(config_path),
timeout=300.0
)
Thanks @Charmnut, it looks like the timeout is not properly setting up, from
camel.toolkits.mcp_toolkit.MCPConnectionError: Connection timeout after 30.0s.I suspect that he 30-second connection timeout might be too short for .NET DLL startup. This could be the main issue. Could you try withmcp_toolkit = MCPToolkit( config_path=str(config_path), timeout=300.0 )
Firstly, the error time is very fast, less than 30 seconds; secondly, I have set a very long timeout in Json, does it work the same as the code you provided?