How sagar-tamang/friday-tony-stark-demo works
1. The repository is split into two cooperating runtimes
- MCP server: launched with uv run friday, backed by server.py and the friday/ package.
- Voice agent: launched with uv run friday_voice, backed by agent_friday.py.
- The architecture is intentionally bifurcated: one process provides tools and resources, the other handles real-time speech interaction and delegates tool calls over the network.
2. The MCP server is the “tool backend”
- It exposes capabilities over MCP via FastMCP and serves them over SSE on http://127.0.0.1:8000/sse.
- This is the boundary where the LLM-facing assistant can ask for external information or utility functions without embedding those concerns into the voice pipeline itself.
3. Tooling is organized by domain inside friday/tools/
- web.py contains internet-facing tools such as search/news/web fetch style capabilities.
- system.py contains local/environment utilities such as current time and system information.
- utils.py contains generic helper tools like formatting/counting logic.
- Each module is expected to register its tools against the MCP server, and friday/tools/__init__.py acts as the aggregation point.
4. The server also exposes prompts and resources, not just tools
- friday/prompts/templates.py holds reusable prompt templates for MCP clients.
- friday/resources/data.py exposes structured resources such as a friday://info-style knowledge resource.
- This means the server is more than an RPC tool host: it is also a content/prompt provider for downstream clients.
5. The voice agent is a real-time speech pipeline
- agent_friday.py builds the LiveKit-based assistant loop: microphone input → STT → LLM reasoning → TTS output.
- It runs as a LiveKit agent in dev mode and joins a room, so the “speaker/output” side is mediated through LiveKit rather than being a local CLI app.
6. The speech pipeline is provider-swappable
- STT defaults to Sarvam Saaras v3.
- LLM defaults to Google Gemini 2.5 Flash.
- TTS defaults to OpenAI TTS (nova voice).
- The README indicates alternative providers are supported for some stages, so the agent is designed with clear model-provider boundaries rather than hard-coding one vendor end-to-end.
7. Tool calls are remote and live, not bundled
- The voice agent connects to the MCP server at runtime and pulls tools “in real time.”
- This creates a clean separation: speech/LLM orchestration remains in the agent, while all operational capabilities live in the MCP server process.
- The practical effect is that tool changes can ship independently of the voice pipeline.
8. Configuration is centralized in environment variables
- friday/config.py is the server-side settings layer.
- .env.example shows the main operational dependencies: LiveKit credentials, STT/LLM/TTS provider keys, and optional integrations like Groq, Google credentials, Deepgram, and Supabase.
- The architecture assumes secrets and provider selection are externalized rather than compiled into code.
9. External services are core architectural dependencies
- LiveKit: room/session transport for the voice agent.
- Sarvam / Google / OpenAI / Groq: speech and model providers depending on configuration.
- Supabase: optional backing service for a ticketing-related tool path.
- These services materially shape the system: the repo is not self-contained; it orchestrates multiple cloud APIs.
10. The data flow is asymmetric
- Incoming audio goes only through the voice agent.
- LLM decisions may trigger MCP tool calls over SSE.
- Tool responses flow back into the agent’s reasoning loop, then synthesized speech returns to the user through LiveKit/TTS.
- This makes the MCP server a side-channel capability provider rather than part of the audio stream.
11. The main architectural boundary is process and transport
- The server/agent split is not just code organization; it is a runtime boundary.
- Communication between the two is networked (SSE/MCP), while the agent’s user interaction is streamed through LiveKit.
- That separation is the key diagram element: audio/session path on one side, tool/backend path on the other.
12. The repo is built for extensibility through modules
- New server capabilities are added by creating a tool module under friday/tools/ and registering it.
- New reusable prompt or resource material is added under friday/prompts/ or friday/resources/.
- So the MCP server behaves like a plugin host for assistant capabilities, while the voice agent stays comparatively stable.
13. Operationally, both processes must run together
- The README makes this explicit: start the MCP server first, then start the voice agent.
- For an architecture diagram, this is best represented as two independently deployed local processes or containers with a live dependency from agent → server.
Main entry points: __init__.py Tool registry · server.py Server entry · config.py Config · agent_friday.py Voice entry
Components 19
MCP Server
Tool backend exposed over MCP/SSE
- Server entry · Launches the MCP server process
server.py - FastMCP · Registers and serves tools, prompts, and resources
- Config · Server-side environment and provider settings
friday/config.py - Tool registry · Aggregates server tools for registration
friday/tools/__init__.py - Web tools · Internet-facing search and fetch capabilities
friday/tools/web.py - System tools · Local time and system/environment utilities
friday/tools/system.py - Utility tools · Generic helper tools such as formatting and counting
friday/tools/utils.py - Prompt templates · Reusable MCP prompt templates
friday/prompts/templates.py - Knowledge resource · Structured MCP resources like friday://info
friday/resources/data.py
Voice Agent
Real-time speech runtime
- Voice entry · Launches the LiveKit voice agent
agent_friday.py - LiveKit loop · Joins a room and manages the live session
- Audio input · Receives microphone audio from the room
- Speech-to-text · Converts incoming audio to text
- LLM reasoning · Chooses responses and decides when to call tools
- Speech synthesis · Synthesizes spoken output
- MCP client · Fetches server tools at runtime over SSE
External Services
Provider and transport dependencies
- LiveKit · Session and audio transport
- Model APIs · Sarvam, Google, OpenAI, and optional Groq/Deepgram
- Supabase · Optional backend for ticketing-related functionality
Connections 21
- Server entry → FastMCP: starts · Boots the MCP server process
- FastMCP → Tool registry: loads · Registers all tool modules
- FastMCP → Prompt templates: serves · Exposes reusable prompts to MCP clients
- FastMCP → Knowledge resource: serves · Exposes structured resources
- Tool registry → Web tools: includes · Aggregates web-facing tools
- Tool registry → System tools: includes · Aggregates system utilities
- Tool registry → Utility tools: includes · Aggregates helper utilities
- Config → FastMCP: configures · Provides server settings and endpoints
- Voice entry → LiveKit loop: starts · Boots the LiveKit agent runtime
- LiveKit loop → Audio input: receives · Consumes microphone audio from the session
- Audio input → Speech-to-text: transcribes · Audio is converted to text
- Speech-to-text → LLM reasoning: feeds · Transcribed text enters the reasoning loop
- LLM reasoning → Speech synthesis: speaks · Generated response is synthesized
- LiveKit loop → LiveKit: joins · Connects the agent to a room/session
- Speech-to-text → Model APIs: uses · Speech model provider selection is externalized
- LLM reasoning → Model APIs: uses · LLM provider selection is externalized
- Speech synthesis → Model APIs: uses · TTS provider selection is externalized
- LLM reasoning → MCP client: calls tools · Requests external capabilities when needed
- MCP client → FastMCP: SSE/MCP · Runtime network connection to the tool backend
- MCP client → Tool registry: discovers · Accesses registered tool surface
- FastMCP → Supabase: optional backend · Supports ticket-related tool paths when enabled