elegant-optician-29026
08/29/2025, 4:07 PMrefined-appointment-81829
08/29/2025, 4:16 PMelegant-optician-29026
08/29/2025, 4:29 PMFile "/home/avinish/.pyenv/versions/3.12.11/lib/python3.12/site-packages/livekit/agents/voice/generation.py", line 517, in _traceable_fnc_tool
val = await function_callable()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/avinish/.pyenv/versions/3.12.11/lib/python3.12/site-packages/livekit/agents/llm/mcp.py", line 100, in _tool_called
tool_result = await self._client.call_tool(name, raw_arguments)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/avinish/.pyenv/versions/3.12.11/lib/python3.12/site-packages/mcp/client/session.py", line 293, in call_tool
result = await self.send_request(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/avinish/.pyenv/versions/3.12.11/lib/python3.12/site-packages/mcp/shared/session.py", line 261, in send_request
await self._write_stream.send(SessionMessage(message=JSONRPCMessage(jsonrpc_request), metadata=metadata))
File "/home/avinish/.pyenv/versions/3.12.11/lib/python3.12/site-packages/anyio/streams/memory.py", line 243, in send
self.send_nowait(item)
File "/home/avinish/.pyenv/versions/3.12.11/lib/python3.12/site-packages/anyio/streams/memory.py", line 212, in send_nowait
raise ClosedResourceError
anyio.ClosedResourceError {"function": "Create_an_event_in_Google_Calendar", "speech_id": "speech_670b2897b588", "pid": 248170, "job_id": "AJ_AtVvn9vzbZxA"}elegant-optician-29026
08/29/2025, 4:35 PMrefined-appointment-81829
08/29/2025, 4:40 PMMCPServerHTTP connection to your n8n MCP server, specifically related to the ClosedResourceError. This error typically indicates that the connection to the MCP server has been closed unexpectedly, which can happen for various reasons, such as network issues, server unavailability, or incorrect configurations.
Here are a few steps you can take to troubleshoot and potentially resolve the issue:
1. Check Server Availability: Ensure that your n8n MCP server is running and accessible from the machine where your LiveKit agent is running. You can do this by trying to access the server URL directly in a web browser or using a tool like curl.
2. Verify URL and Configuration: Double-check the server_url you are using to instantiate MCPServerHTTP. Make sure it is correctly formatted and points to the right endpoint of your n8n server.
3. Connection Handling: Since you mentioned that it works intermittently, consider implementing retry logic in your code to handle transient connection issues. You can wrap your connection logic in a try-except block and attempt to reconnect a few times before failing.
4. Logging: Add logging around your MCP server connection and tool calls to capture more details about the state of the connection when the error occurs. This can help you identify patterns or specific conditions that lead to the error.
5. Check MCP Tool Availability: Ensure that the tools you are trying to call on the MCP server are available and correctly configured. You can list the available tools from the MCP server to verify this.
Make sure to replace "http://your-n8n-server-url" with your actual server URL.
If the problem persists, you may want to check the logs of your n8n server for any errors or warnings that could provide more insight into why the connection is being closed.
Notes:
• The ClosedResourceError indicates that the connection to the MCP server was unexpectedly closed, which could be due to various reasons.
• Ensure that the MCP server is running and accessible, and verify the configuration of the tools you are trying to use.refined-appointment-81829
08/29/2025, 4:41 PMelegant-optician-29026
08/30/2025, 10:05 AMelegant-optician-29026
08/30/2025, 10:08 AMelegant-optician-29026
08/30/2025, 3:19 PM