Hi, I have setup Livekit-agents sdk for python wit...
# ask-ai
p
Hi, I have setup Livekit-agents sdk for python with telephony integration via SIP for inbound calling. It uses a independently hosted MCP server for tool calls. The entire setup has been working fine till now, I am facing mcp connection issue with livekit sdk and rtc.engine stream closed issue for last 3 days. I haven't updated any packages. Livkeit=agents - 1.0.12, and mcp - 1.9.2, I am using OPENAI realtime model for voice-to-voice translation
t
Thanks for reaching out, Harsh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks for reaching out! To help you better with the MCP connection issue and the
rtc.engine stream closed
error, could you please share a bit more detail? For example: • Are there any specific error messages or logs that you've noticed? • Have there been any recent changes to your MCP server setup or network environment? • Is this happening with all calls, or just in certain situations? We're here to help you get this sorted out!
p
• ERRORmcp.client.sseError in post_writer: Client error '404 Not Found' for url • failed to list tools from MCP server MCPServerHTTP(url=) I am using SSE transport method • livekit.agents:rotate_segment called while previous segment is still being rotated • WARNINGlivekitlivekit:rtc engine453livekit:rtc_engine - received session close: "signal client closed: \"stream closed\"" UnknownReason Resume
I have't made any recent changes to MCP server setup, and this is not happening for all calls but most of the calls.
t
It looks like you're facing a few different errors, and I’m here to help you work through them step by step: • MCP Client SSE Error (404 Not Found): This means the resource you’re trying to reach on the MCP server isn’t available right now. It’s a good idea to double-check the URL configuration for the MCP server and make sure the endpoint is set up correctly to handle these requests. • Failed to List Tools from MCP Server: This might be connected to the SSE transport method. Taking a look at the MCP server logs could reveal some clues, and ensuring the server is configured properly to support SSE will help too. • LiveKit RTC Engine Session Close: The message "signal client closed: stream closed" hints at a session disconnection. This can happen due to network hiccups, signaling issues, or unexpected stream endings. Reviewing the disconnect reason in the logs should help pinpoint what’s going on. Often, it’s related to network instability or media stream problems. Since you mentioned this doesn’t happen every time, it might be tied to intermittent network conditions or specific situations. To help narrow things down, here are a few things you can check: 1. Take a look at the MCP server’s configuration and logs to spot any unusual activity. 2. Make sure your network is stable and that WebRTC traffic isn’t being blocked or slowed down. 3. Check the LiveKit dashboard for session details and any error messages. 4. Confirm that the LiveKit Agents SDK version (1.0.12) works well with the MCP server version (1.9.2). If you keep running into trouble, please don’t hesitate to reach out. We can dive deeper together and find the right solution for you.
p
All of this seems stable, since it was working earlier.
t
It’s great that your setup was stable before, so the issue might be due to some intermittent network hiccups, resource limits, or small configuration changes. Let’s work together to get this sorted out! Here are some steps you can try to help pinpoint and resolve the problem: 1. Verify Network Stability: Take a moment to check if there have been any network interruptions or changes in firewall rules that could be affecting WebRTC traffic. Also, make sure TURN over TLS is enabled, as it really helps in restrictive network environments. 2. Inspect MCP Server Logs: Have a look at the MCP server logs around the times when failures happen. Sometimes, those logs can reveal useful clues or errors. 3. Enable Diagnostic Logs: Try turning on detailed logging in the LiveKit SDK. This will give you insights into connection states, ICE candidate gathering, and reconnection attempts, which can be super helpful to find the root cause. 4. Review Resource Usage: It’s important to check that your MCP server and LiveKit deployment have enough resources like CPU and memory. If they’re running high, it might cause timeouts or disconnects. 5. Check SDK and Server Compatibility: Double-check that your LiveKit Agents SDK (1.0.12) and MCP server (1.9.2) versions are compatible and up to date to avoid any unexpected issues. If you’re still running into trouble, please feel free to share any extra logs or details about how the failures happen. I’m here to help and we can explore more troubleshooting steps together! Sources: SIP troubleshooting guide | LiveKit Docs | Getting Help | livekit/livekit_composite | DeepWiki | Connecting to LiveKit | LiveKit Docs | src/room/RTCEngine.ts | livekit/src/rtc_engine/rtc_session.rs