ShayneP/livekit-python-examples-mcp
If you are the rightful owner of livekit-python-examples-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The LiveKit Examples MCP Server provides a programmatic interface for exploring LiveKit Agents examples using the Model Context Protocol (MCP).
LiveKit Examples MCP Server
This repository wraps the in a Model Context Protocol (MCP) server so MCP-compatible clients can explore the catalog programmatically. The server can run either over HTTP (for hosted deployments) or stdio (for CLI integrations like Codex).
Project Layout
app.rb– CLI entrypoint. Parses flags / env vars, chooses the transport, and boots the MCP server.server.rb– Declares the MCP server and its tools for browsing the example catalog.http_server.rb– Small Sinatra app that exposes the MCP JSON-RPC endpoint atPOST /mcpplus a/healthprobe.transports/content_length_stdio_transport.rb– A stdio transport that understandsContent-Lengthframed messages so editors and CLIs can stream requests reliably.python-agents-examples/– Upstream LiveKit Agents examples, includingdocs/index.yamlwith the metadata the tools surface.config.ru– Rack entry forbundle exec rackupdeployments.
Setup
bundle install
The project depends on the mcp gem plus Sinatra/Rack components for the HTTP transport. Ensure your $GEM_HOME and $GEM_PATH are writable; app.rb attempts to fall back to standard per-user gem directories when they are unset.
Running the MCP Server
HTTP transport (default)
bundle exec ruby app.rb --http
- Listens on Sinatra's default
localhost:4567unless you override it. - Configure with
--port/--bindCLI flags or environment variablesPORT/BIND. POST /mcpaccepts JSON-RPC 2.0 requests targeting the MCP server.GET /healthreturns a JSON readiness payload:{ "status": "ok", "name": "livekit_examples_server" }.- Suitable for hosting behind a reverse proxy or running under Rack via
bundle exec rackup(usesconfig.ru).
Stdio transport
bundle exec ruby app.rb --stdio
- Streams JSON-RPC requests and responses via stdin/stdout, framing each payload with a
Content-Lengthheader when provided. - Designed for MCP clients that communicate over pipes (e.g., editors or terminal-based agents).
The transport mode can also be selected with --transport http|stdio or the MCP_TRANSPORT environment variable. When omitted, HTTP is used.
MCP Tools
server.rb registers four tools on an MCP::Server instance named livekit_examples_server:
- ReadExampleIndexFile – Returns the entire
docs/index.yamlcatalog as YAML so clients can inspect the available examples. - ReadExampleFile – Reads a specific example file by its
file_path(as listed in the index). Paths are sanitized to stay within thepython-agents-examplesdirectory. - ListExampleCategories – Extracts distinct categories from the index for quick discovery.
- SearchExamples – Performs a keyword search across example titles, descriptions, tags, and demonstrations, returning matching entries.
All tools wrap their responses in MCP::Tool::Response objects and include defensive error messages for missing files or malformed input.
Working With the Example Catalog
The bundled python-agents-examples directory is pulled from LiveKit's official examples repository. The tools expect the structure shipped here, particularly docs/index.yaml for metadata. If you update or replace the catalog, keep the directory layout consistent so the sanitization checks in ReadExampleFile continue to allow only in-repo paths.
Development Notes
- The stdio transport extends
MCP::Server::Transports::StdioTransport, adding support forContent-Lengthframed messages and newline-delimited fallbacks. - Exceptions raised while handling HTTP requests surface as
500responses with a JSON error payload so clients can log meaningful diagnostics. - To integrate with other Rack tooling (e.g., Puma), rely on
config.ruand the gems specified inGemfile(puma,rackup).