victorious-monitor-50234
08/14/2025, 4:09 AMtall-airline-16756
08/14/2025, 4:09 AMtall-airline-16756
08/14/2025, 4:09 AMvictorious-monitor-50234
08/14/2025, 4:10 AMtall-airline-16756
08/14/2025, 4:11 AMpip install livekit-agents[mcp]~=1.0
2. Create an MCP Server Instance:
from livekit.agents import mcp
mcp_server = mcp.MCPServerHTTP("<https://your-mcp-server.com>")
3. Integrate MCP with Your Agent:
You’ve got two options here! You can either pass the MCP server directly to the AgentSession
or use the handy MCPToolsIntegration
helper class.
◦ Option 1: Pass MCP Server to `AgentSession`:
session = AgentSession(vad=silero.VAD.load(), stt=deepgram.STT(), llm=openai.LLM(), tts=openai.TTS(), mcp_servers=[mcp_server])
◦ Option 2: Use `MCPToolsIntegration`:
from mcp_client.agent_tools import MCPToolsIntegration
agent = await MCPToolsIntegration.create_agent_with_tools(agent_class=YourAgentClass, mcp_servers=[mcp_server])
1. Handle Tool Registration:
Make sure your agent is ready to handle tools from the MCP server by doing this:
tools = await MCPToolsIntegration.prepare_dynamic_tools(mcp_servers=[mcp_server])
If anything feels unclear or you want a hand with any of these steps, just give me a shout—I’m here to help!victorious-monitor-50234
08/14/2025, 4:27 AMtall-airline-16756
08/14/2025, 4:27 AMmcp_servers
parameter to the AgentSession
constructor is the right move to get MCP working smoothly with LiveKit. Your setup should do just what you need. Just make sure your MCP server instance is properly set up and included in the list.
Here’s a quick example:
from livekit.agents import mcp
import os
agent_session = AgentSession(
vad=ctx.proc.userdata["vad"],
min_interruption_words=0,
userdata=UserData(),
min_endpointing_delay=0.3,
max_tool_steps=10,
user_away_timeout=SILENCE_THRESHOLD,
mcp_servers=[
mcp.MCPServerHTTP(url="<https://your-mcp-server.com>")
]
)
If you have any questions or want to chat more about this, just let me know—I’m here to help!
Sources: Tool definition and use | LiveKit Docs | Tool definition and use | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_activity.pyvictorious-monitor-50234
08/14/2025, 4:28 AMtall-airline-16756
08/14/2025, 4:28 AMAgentSession
, it’ll automatically load and show the tools from those servers. LiveKit connects to the MCP servers you specify during the session setup, grabs the available tools, and gets them ready for the agent to use.
If you want to double-check which tools are loaded, you can easily access them like this:
# Here’s how to see the list of available tools
tools = agent.tools
Feel free to reach out if you have any questions or need a hand with anything else!victorious-monitor-50234
08/14/2025, 4:30 AMtall-airline-16756
08/14/2025, 4:30 AMMCPServerStdio
class. Here’s a simple example to get you started:
from mcp_client import MCPServerStdio
async def main():
# Set up the MCP server with stdio parameters
server = MCPServerStdio(
params={"command": "path_to_your_server_command"}
)
# Connect to the server
await server.connect()
# Check out the available tools
tools = await server.list_tools()
print(f"Available tools: {tools}")
# Use a tool
result = await server.call_tool("tool_name", {"arguments": "here"})
print(f"Tool result: {result}")
if __name__ == "__main__":
asyncio.run(main())
Just swap out path_to_your_server_command
with the actual command that starts your server. If you hit any bumps or have questions, feel free to ask—I’m here to help!victorious-monitor-50234
08/14/2025, 4:32 AMtall-airline-16756
08/14/2025, 4:32 AMpip install livekit-agents[mcp]
2. Create an MCPServerStdio Instance:
from livekit.agents.llm import mcp
mcp_server = mcp.MCPServerStdio(
command="path/to/your/mcp_server_command",
args=["--port", "5000"]
)
3. Pass the MCP Server to the Agent:
When you create your agent or session, just include the MCP server like this:
from livekit.agents import Agent, AgentSession
agent = Agent(
instructions="Your agent instructions here",
mcp_servers=[mcp_server]
)
session = AgentSession(
agent=agent,
mcp_servers=[mcp_server]
)
Don’t forget to swap out path/to/your/mcp_server_command
and args
with the actual command and arguments you use to start your MCP server. If you hit any bumps or have questions, just give me a shout—I’m here to help!victorious-monitor-50234
08/14/2025, 4:48 AMtall-airline-16756
08/14/2025, 4:49 AMagent.tools
property to see all the tools your agent has, including those from the MCP server.
3. Give Tool Execution a Try: Use commands that should activate MCP tools and watch the logs for messages like "Invoking tool '[tool name]'."
4. Keep an Eye on Execution Logs: This helps confirm the tools are running smoothly and were discovered properly.
From the tools you mentioned, it looks like your agent has found the tools successfully! If you want, I’m here to help you test them out or troubleshoot any hiccups.
Sources: README.md | livekit-agents/livekit/agents/voice/agent.py