Hey, I have implemented a connection of my agent w...
# ask-ai
s
Hey, I have implemented a connection of my agent with an mcp server. I just added the mcp_servers=[mcp.MCPServerHTTP(url="...", timeout=5.0)] Is there a way to log call and responses to and from mcp servers? I have no visibility what the agent is send to the server nor what is receiving
t
Thanks for reaching out, Roman. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — you're asking how to log requests and responses between your agent and the MCP server (so you can see what the agent sends and what the server returns). You do have visibility options. What you can do • Enable debug-level logging for the agent. The framework emits MCP interactions (HTTP requests, responses, discovery and tool call events) at DEBUG level. Start your agent with
--log-level=DEBUG
(or set your logger to DEBUG) to capture those entries. • Add custom logging around MCP calls. Wrap or decorate the code that constructs/sends MCP requests to log the request payload before sending and the response body/status when received. This is useful if you need structured or persisted logs. If you want, tell me: • which language/runtime you're using (Python?), • how you start the agent (CLI command or in‑process), and • whether you prefer console logs or persistent logging (file, JSON, external logger). I’ll give the exact commands/snippet to enable DEBUG logs or a small wrapper you can drop in to log request/response payloads. Sources: Agents (Python) | livekit/livekit_composite | DeepWiki | Job lifecycle | LiveKit docs
s
Seems like my logger is broker. This error was introduced by installing
Copy code
uv pip install "livekit-agents[mcp]"
211134.373 DEBUG livekit.agents http_session(): creating a new httpclient ctx {"room": "voice_assistant_room_5127", "agent": "assistant", "lang": "es", "pid": 14509, "job_id": "AJ_NTgrbbVqDBaa", "room_id": "RM_LkFTNZ54hkQ3"} VAAPI is supported. Exception in thread ipc_log_listener: Traceback (most recent call last): File "/home/roman/.pyenv/versions/3.12.12/lib/python3.12/threading.py", line 1075, in _bootstrap_inner self.run() File "/home/roman/.pyenv/versions/3.12.12/lib/python3.12/threading.py", line 1012, in run self._target(*self._args, **self._kwargs) File "/home/roman/Documents/projects/wil-livekit-worker/.venv/lib/python3.12/site-packages/livekit/agents/ipc/log_queue.py", line 53, in _monitor record = pickle.loads(data) ^^^^^^^^^^^^^^^^^^ TypeError: HTTPStatusError.__init__() missing 2 required keyword-only arguments: 'request' and 'response' ^C 211217.954 INFO livekit.agents shutting down worker {"id": "AW_L5NQbbQJjvm7"} 211218.220 INFO livekit.agents process exiting {"reason": "", "pid": 14509, "job_id": "AJ_NTgrbbVqDBaa", "room_id": "RM_LkFTNZ54hkQ3"}
t
Thanks — you're reporting the IPC logging crash after installing
livekit-agents[mcp]
and asking how to restore logging and capture MCP requests/responses. You're right: that TypeError indicates a version/serialization mismatch for
HTTPStatusError
. What to try next • Pin httpx to a compatible version:
Copy code
uv pip install "httpx==0.25.2"
If needed also pin httpcore:
Copy code
uv pip install "httpcore==1.0.5"
Then restart your agent process. • Avoid dev mode while debugging (dev uses IPC/pickle which triggers the error). Use:
Copy code
uv run agent.py start
• Fully restart your environment to clear any pickled state or lingering processes: ◦ Kill agent processes, stop hot-reload, then start fresh. • If you need immediate visibility regardless of the IPC issue, add a small wrapper around MCP calls to log requests and responses (example):
Copy code
import logging
  logger = logging.getLogger("mcp_debug")

  async def _wrap_call(method, *args, **kwargs):
      logger.debug("MCP CALL %s %s %s", method, args, kwargs)
      try:
          resp = await method(*args, **kwargs)
          logger.debug("MCP RESP %s", resp)
          return resp
      except Exception as e:
          logger.exception("MCP ERROR")
          raise
  # attach wrapper to the MCPServerHTTP methods you use (e.g. list_tools, call_tool)
If this doesn't fix it, please share these outputs: •
python --version
•
uv --version
•
uv pip list | grep -E "(httpx|httpcore|livekit)"
• How you run the agent (CLI command:
dev
vs
start
) I’ll give the exact next steps based on those details.
s
Still I wasn't able to make logs work. This are the versions I'm using:
Copy code
roman@roman-pc:~/Documents/projects/wil-livekit-worker$ python --version
Python 3.12.12
roman@roman-pc:~/Documents/projects/wil-livekit-worker$ uv --version
uv 0.9.17
roman@roman-pc:~/Documents/projects/wil-livekit-worker$ uv pip list | grep -E "(httpx|httpcore|livekit)"
agent-starter-python                     1.0.0           /home/roman/Documents/projects/wil-livekit-worker
httpcore                                 1.0.9
httpx                                    0.28.1
httpx-sse                                0.4.3
livekit                                  1.0.22
livekit-agents                           1.3.6
livekit-api                              1.1.0
livekit-blingfire                        1.1.0
livekit-plugins-inworld                  1.3.6
livekit-plugins-noise-cancellation       0.2.5
livekit-plugins-silero                   1.3.6
livekit-plugins-speechify                1.3.6
livekit-plugins-speechmatics             1.3.6
livekit-plugins-turn-detector            1.3.6
livekit-protocol                         1.1.1
Is there any recommended versions for this?
t
Thanks — I see your environment and versions, and you’re still not getting logs. The
httpx 0.28.1
/
httpcore 1.0.9
combo is incompatible with the agent IPC logging and causes the pickling/HTTPStatusError problem. What to do next 1. Pin compatible versions:
Copy code
uv pip install "httpx==0.27.2" "httpcore==1.0.7"
1. Restart clean: • Kill all agent processes. • Stop dev/hot-reload if you use it. • Start the agent with
uv run agent.py start
. 1. If you use uv-managed constraints, add these to your project (example
pyproject.toml
snippet):
Copy code
[tool.uv]
constraints = [
  "httpx==0.27.2",
  "httpcore==1.0.7"
]
then run:
Copy code
uv lock
uv sync --group dev
1. Optional: If you can, use Python 3.11 for best compatibility (3.12 may surface other issues). If logs still fail after the downgrade and restart, please paste the output of: •
uv pip list | grep -E "(httpx|httpcore|livekit)"
• How you run the agent (exact CLI command:
dev
or
start
) I’ll give the next troubleshooting step based on that. Sources: https://blog.livekit.io/streamline-troubleshooting-with-agent-observability/#/portal/signup| | Streamline Troubleshooting with Agent Observability | https://blog.livekit.io/streamline-troubleshooting-with-agent-observability/#/portal| | Tool definition and use | LiveKit docs | Voice AI quickstart | LiveKit docs
s
How do I make sure the livekit agent has access to the MCP server that I have connected to it?
t
You're asking how to make sure your LiveKit agent can reach and use the MCP server you connected. Here are concise, practical checks and actions you can run now. 1) Confirm configuration • Ensure you passed the MCP server into your session:
Copy code
from livekit.agents import mcp, AgentSession
session = AgentSession(mcp_servers=[mcp.MCPServerHTTP(url="<https://your-mcp-server.com>")])
2) Check network reachability from the agent host • Simple HTTP test:
Copy code
curl -v <https://your-mcp-server.com/>
# or, for tool listing endpoint:
curl -v -X POST <https://your-mcp-server.com/tools.list>
• If curl fails, check DNS, firewall, proxy, or container network settings. 3) Watch agent startup logs • On startup the agent lists/discovers MCP tools. Look for lines about MCP initialization, tool discovery, or HTTP errors. If you need logging, run with DEBUG once your httpx/httpcore versions are compatible:
Copy code
uv run agent.py start --log-level=DEBUG
4) Verify tool discovery at runtime • Inspect
session.tools
or the agent’s available tools in code or logs to confirm MCP-provided tools were merged with local tools. If MCP tools appear, connectivity is working. 5) Trigger a known MCP tool call • Ask the agent to call a tool that the MCP server provides (or invoke it directly). Successful invocation and a valid response confirm end-to-end access. 6) Use LiveKit Agent observability (if available) • In LiveKit Cloud, check Agent Insights: trace view for LLM tool call attempts, logs for HTTP errors, and transcripts for tool usage. 7) Authentication & headers • If your MCP requires auth or headers, ensure you provide them in
MCPServerHTTP(url=..., headers={...})
or via the server’s configuration. 8) If you see errors, capture and share: • Agent CLI command you run (exact
uv run ...
) • Agent logs around MCP init (DEBUG if possible) • Output of: ◦
curl -v <https://your-mcp-server.com/>
(or
tools.list
) ◦
uv pip list | grep -E "(httpx|httpcore|livekit)"
If you want, tell me how you currently run the agent and the MCP URL (or a curl output). I’ll suggest the next targeted steps. Sources: Tool definition and use | LiveKit docs | MCP Agent | LiveKit docs | Agents (Python) | livekit/livekit_composite | DeepWiki | https://blog.livekit.io/streamline-troubleshooting-with-agent-observability/#/portal/signup|