This repository contains two LiveKit voice AI agents demonstrating different capabilities and integrations.
basic_livekit_agent.py- A Valorant-themed voice agent with function tools for match searching and scrim bookingmcp_livekit_agent.py- An advanced voice agent with MCP (Model Context Protocol) server integration
Create a .env file in the project root with the following environment variables:
# OpenAI API Key (required for both agents)
OPENAI_API_KEY=your_openai_api_key_here
# Deepgram API Key (required for both agents)
DEEPGRAM_API_KEY=your_deepgram_api_key_here
# LiveKit credentials (get from your LiveKit Cloud dashboard)
LIVEKIT_URL=your_livekit_url_here
LIVEKIT_API_KEY=your_livekit_api_key_here
LIVEKIT_API_SECRET=your_livekit_api_secret_here
# Optional: LLM model choice (defaults to gpt-4.1-mini for MCP agent)
LLM_CHOICE=gpt-4.1-mini# Install dependencies
pip install -r requirements.txt
# Or using uv (recommended)
uv syncThe basic agent demonstrates:
- Voice interaction with function tools
- Match searching by map
- Scrim booking functionality
- Simple conversational AI
uv run basic_livekit_agent.py console- Match Search: "Show me matches on Ascent"
- Join Scrims: "I want to join match asc001 as Phoenix, I'm a Duelist"
- Time Queries: "What time is it?"
The MCP agent demonstrates:
- Integration with external MCP servers
- Enhanced tool capabilities through Model Context Protocol
- Advanced voice pipeline configuration
- Real-time transcription
CRITICAL: Before running the MCP LiveKit agent, you must start the Docker MCP gateway:
docker mcp gateway --transport=streaming --port=80This command starts the MCP gateway that the agent connects to at http://localhost:80/mcp.
uv run mcp_livekit_agent.py console- MCP Server Integration: Connects to external MCP servers for enhanced capabilities
- Advanced Voice Pipeline: Uses Deepgram Nova-2 STT and OpenAI TTS with Echo voice
- Transcription: Real-time conversation transcription
- Enhanced Instructions: Specialized for Airbnb MCP server tool usage (ignores robots.txt)
User Voice Input → Deepgram STT → OpenAI LLM → Function Tools → OpenAI TTS → Voice Output
User Voice Input → Deepgram STT → OpenAI LLM → MCP Servers → Function Tools → OpenAI TTS → Voice Output
Both agents support the following configurations:
- STT: Deepgram Nova-2 model
- LLM: OpenAI GPT models (configurable via
LLM_CHOICEenv var) - TTS: OpenAI TTS with various voices
- VAD: Silero Voice Activity Detection
The MCP agent connects to MCP servers via HTTP at:
mcp_servers=[mcp.MCPServerHTTP(url="http://localhost:80/mcp")]-
MCP Gateway Connection Failed
- Ensure Docker MCP gateway is running:
docker mcp gateway --transport=streaming --port=80 - Check that port 80 is available and not blocked
- Ensure Docker MCP gateway is running:
-
API Key Errors
- Verify all API keys are correctly set in
.env - Check API key permissions and quotas
- Verify all API keys are correctly set in
-
Voice Pipeline Issues
- Ensure microphone permissions are granted
- Test with different voice models if audio quality is poor
Both agents include comprehensive logging. Set log level via:
logging.basicConfig(level=logging.INFO) # or DEBUG for verbose outputAdd new tools by decorating methods with @function_tool:
@function_tool
async def my_new_tool(self, context: RunContext, param: str) -> str:
"""Tool description for the LLM."""
# Implementation here
return "Tool result"To add new MCP servers, update the mcp_servers list in the agent configuration:
mcp_servers=[
mcp.MCPServerHTTP(url="http://localhost:80/mcp"),
# Add additional MCP servers here
]This project is provided as an example implementation for LiveKit voice agents.