Purpose
OpenTelemetry MCP Server is an MCP (Model Context Protocol) server used to query and analyze OpenTelemetry trace data across multiple backends, supporting backends such as Jaeger, Grafana Tempo, and Traceloop. It is designed for the observability of AI applications and, with the help of OpenLLMetry semantic conventions, enables AI agents to analyze distributed traces for automated debugging and observability. Users can query LLM traces through an AI assistant in the IDE, for example to find expensive API calls, debug errors, compare model performance, or track token usage.
Main Capabilities
- Multi-backend support: Can connect to Jaeger, Grafana Tempo, or Traceloop. Jaeger requires the service_name parameter when performing span searches.
- LLM-first design: Provides tools specifically for analyzing AI application traces.
- Advanced filtering: A general filtering system that supports powerful operators.
- Token analysis: Tracks and aggregates LLM token usage across models and services.
- Fast and type-safe: Built on asynchronous Python and Pydantic validation.
Tool Reference
- search_traces: Flexibly filter and search traces. Parameters include service_name, operation_name, start_time / end_time (ISO 8601 timestamps), min_duration_ms / max_duration_ms, gen_ai_system (LLM provider, such as openai, anthropic), gen_ai_model (model name, such as gpt-4, claude-3-opus), has_error, tags, limit (1-1000, default 100). Returns a list of trace summaries with token counts.
- get_trace: Retrieves full trace details, including all spans and OpenLLMetry attributes. Returns the complete trace tree, including all span attributes, parsed OpenLLMetry data for LLM spans, token usage for each span, and error information.
- get_llm_usage: Retrieves aggregated token usage metrics. Returns aggregated metrics, including total prompt / completion / total tokens, breakdown by model, and breakdown by service.
- list_services: Lists all available services and returns a list of service names.
In addition, the commonly used tool calls mentioned in the materials also include: find_errors (find error traces), get_llm_expensive_traces (find high-token-consumption requests), get_llm_slow_traces (find slow operations), get_llm_model_stats (model statistics), list_llm_models (list models in use).
Usage
No installation is required; configure the client to run the server directly from PyPI, or use uvx as an alternative. After configuration is complete, you can say to Claude: "Show me traces with errors from the last hour".
For End Users (Recommended)
- Always use the latest version
- No global installation required
- Automatically isolated environment
- Supports all platforms
Integration by Client
- Claude Desktop: Configure the MCP server in the configuration file. macOS path: ~/Library/Application Support/Claude/claude_desktop_config.json; Windows path: %APPDATA%\Claude\claude_desktop_config.json. You can use pipx (recommended) or uvx (alternative). There is a dedicated configuration for the Traceloop backend.
- Local Development (Clone the Repository): Option one: wrapper script (convenient for switching backends); option two: use UV directly (for multiple backends).
- Claude Code: Works with the MCP server in the Claude Desktop configuration. After configuration, it can be used in the Claude Code CLI.
- Cursor: Navigate to Settings → MCP → Add new MCP Configure the Server.
- Gemini CLI: Configure in the config file ~/.gemini/config.json, then use Gemini CLI to query traces.
Environment Requirements
- Python 3.11 or higher
- pipx or uv installed
- If you prefer to install the command line globally, there are corresponding methods as well
How to Run
- start_locally.sh (recommended): The simplest way to run. The script handles all configuration and starts the server in stdio mode (suitable for Claude Desktop integration). To switch backends, simply edit the script and uncomment the preferred backend.
- Manual run (advanced use cases or custom configuration):
- stdio transport: for local / Claude Desktop integration.
- HTTP/SSE transport: for remote access. The HTTP server is accessible by default via http://localhost:8000/sse access.
Configuration
- Option one: Environment variables (create a .env file, see .env.example).
- Option two: CLI arguments (override environment variables).
- Configuration priority: CLI arguments > environment variables > default values.
- Note: The API key contains project information. The backend uses the project slug "default", and Traceloop resolves the actual project / environment from the API key.
Use Cases
- Cost optimization: Identify expensive operations (get_llm_expensive_traces finds high-token requests), analyze by model (get_llm_usage shows which models cost the most), investigate specific traces (get_trace with trace_id shows the exact prompt / response).
- Performance debugging: Find slow operations (get_llm_slow_traces identifies latency issues), check errors (find_errors shows failure patterns), analyze finish reasons (get_llm_model_stats shows whether responses were truncated).
- Model adoption tracking: Discover which models are in use (list_llm_models), compare model statistics (get_llm_model_stats), identify shadow AI (look for unexpected models or services in list_llm_models results).
- Example queries: Find error traces, find expensive OpenAI operations ("Show me OpenAI traces from the last hour that took longer than 5 seconds"), analyze token usage by model, compare model performance (GPT-4 vs Claude).
Limitations
- Jaeger requires a service_name parameter when performing span searches.
- If token usage shows as zero, ensure the trace has OpenLLMetry instrumentation, check whether gen_ai.usage.* attributes exist in the span, and use get_trace to view the raw span attributes.
- If there are no trace results, check the time range, use list_services to verify the service name,confirm that the backend has trace data, and first try searching without filters.
- Future enhancements (cost calculation, model performance comparison tools, prompt pattern analysis, MCP resources, caching layer, additional backend support) are currently planned content and not yet available.
Development and License
Contributions are welcome. All tests are required to pass (pytest), code formatting (ruff format .), no linting errors (ruff check .), and type checking passes (mypy src/). Licensed under Apache 2.0. Related projects: OpenLLMetry, Model Context Protocol, Claude Desktop.