I tried giving my agent a mcp tool following the official documentation and got this :
"passing MCP servers to AgentSession or Agent is deprecated and will be removed in a future version. Use MCPToolset instead. "
Which is weird because I don’t see it anywhere. So for a few minutes the agent didn’t talk and I got this error before it started talking : Exception Group Traceback (most recent call last):
| File “C:\Users\ndoum\AppData\Roaming\Python\Python313\site-packages\livekit\agents\utils\log.py”, line 17, in async_fn_logs
| return await fn(*args, **kwargs)
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| File “C:\Users\ndoum\AppData\Roaming\Python\Python313\site-packages\livekit\agents\voice\agent_activity.py”, line 602, in _setup_toolset
| await toolset.setup()
| File “C:\Users\ndoum\AppData\Roaming\Python\Python313\site-packages\livekit\agents\llm\mcp.py”, line 407, in setup
| await self._mcp_server.initialize()
| File “C:\Users\ndoum\AppData\Roaming\Python\Python313\site-packages\livekit\agents\llm\mcp.py”, line 100, in initialize
| streams = await self._exit_stack.enter_async_context(self.client_streams())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File “C:\Python313\Lib\contextlib.py”, line 668, in enter_async_context
| result = await _enter(cm)
| ^^^^^^^^^^^^^^^^
| File “C:\Python313\Lib\contextlib.py”, line 214, in aenter
| return await anext(self.gen)
| ^^^^^^^^^^^^^^^^^^^^^
| File “C:\Users\ndoum\AppData\Roaming\Python\Python313\site-packages\mcp\client\sse.py”, line 63, in sse_client
| async with anyio.create_task_group() as tg:
| ~~~~~~~~~~~~~~~~~~~~~~~^^
| File “C:\Users\ndoum\AppData\Roaming\Python\Python313\site-packages\anyio_backends_asyncio.py”, line 781, in aexit
| raise BaseExceptionGroup(
| “unhandled errors in a TaskGroup”, self._exceptions
| ) from None
| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
±±--------------- 1 ----------------
| Traceback (most recent call last):
| File “C:\Users\ndoum\AppData\Roaming\Python\Python313\site-packages\mcp\client\sse.py”, line 154, in sse_client
| endpoint_url = await tg.start(sse_reader)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| File “C:\Users\ndoum\AppData\Roaming\Python\Python313\site-packages\anyio_backends_asyncio.py”, line 907, in start
| return await future
| ^^^^^^^^^^^^
| RuntimeError: Child exited without calling task_status.started()
±-----------------------------------
here is how I initiated the mcp server :
async def my_agent(ctx: agents.JobContext):
token = os.environ.get("ZAPIER_TOKEN")
zapier_url = f"https://mcp.zapier.com/api/v1/connect?token={token}"
mcp_server = mcp.MCPServerHTTP(
url=zapier_url,
transport_type="sse"
)
session = AgentSession(
mcp_servers=\[mcp_server\],
llm=openai.realtime.RealtimeModel(
voice="coral",
turn_detection=TurnDetection(
type="semantic_vad"
)
)
)