OpenTelemetry MCP Server
Acts as a bridge to observability backends for querying Prometheus metrics and Loki logs, enabling alert investigation, troubleshooting, and correlation of metrics and logs for monitored services.
Provides tools for querying Prometheus metrics using PromQL, discovering metrics and labels, retrieving current and historical metric values, and investigating service health and performance issues.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@OpenTelemetry MCP Server show me the top 5 services by error rate in the last hour"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
otel-mcp
MCP server for querying Prometheus metrics and Loki logs with OIDC authentication.
Features
Query Prometheus metrics (PromQL)
Query Loki logs (LogQL)
HTTP API for K8s deployment
Service discovery (metrics, labels, log streams)
Related MCP server: Prometheus MCP Server
Quick Start
Local Development
# 1. Install
git clone <your-repo-url>
cd otel-mcp
uv sync
# 2. Configure .env
cp .env.example .env
# Edit .env with your Prometheus/Loki URLs
# 3. Run (stdio mode for local MCP)
uv run python -m src.serverProduction (Kubernetes + Authentik)
See K8S_DEPLOYMENT.md for full deployment guide.
# Build and deploy
docker build -t your-registry/otel-mcp:latest .
kubectl apply -f k8s/
# Access at https://otel-mcp.your-domain.comAvailable Tools
Prometheus (5 tools)
query_prometheus- Execute PromQL instant queriesquery_prometheus_range- Query metrics over time rangelist_metrics- List available metricslist_label_values- Get label values (discover services)list_labels- List all label names
Loki (4 tools)
query_loki- Execute LogQL queriessearch_logs- Simple log search with filterslist_log_labels- List log stream labelslist_log_label_values- Get log label values
Usage
Production: K8s with Authentik OAuth Proxy
Deploy HTTP server behind Authentik for authentication.
See K8S_DEPLOYMENT.md for complete setup.
# Build and deploy
docker build -t registry/otel-mcp:latest .
kubectl apply -f k8s/
# Use the API
curl -H "Authorization: Bearer YOUR_TOKEN" \
https://otel-mcp.your-domain.com/tools
curl -X POST https://otel-mcp.your-domain.com/call \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"tool": "query_prometheus", "arguments": {"query": "up"}}'Local: MCP stdio (Development)
For local MCP clients like Claude Desktop.
# Run stdio server
uv run python -m src.server
# Claude Desktop config
{
"mcpServers": {
"otel-mcp": {
"command": "uv",
"args": ["--directory", "/path/to/otel-mcp", "run", "python", "-m", "src.server"],
"env": {
"PROMETHEUS_URL": "http://localhost:9090",
"LOKI_URL": "http://localhost:3100"
}
}
}
}Configuration Options
Variable | Default | Description |
|
| Prometheus endpoint |
|
| Loki endpoint |
|
| Enable OIDC auth |
| - | OIDC provider URL |
| - | OAuth2 client ID |
| - | Token audience (optional) |
|
| Logging level |
|
| Query timeout (seconds) |
Backend Authentication
Prometheus/Loki support Basic Auth and Bearer tokens:
# Basic Auth
PROMETHEUS_AUTH_TYPE=basic
PROMETHEUS_USERNAME=admin
PROMETHEUS_PASSWORD=secret
# Bearer Token
LOKI_AUTH_TYPE=bearer
LOKI_BEARER_TOKEN=your-tokenExample Queries
# List services
{"tool": "list_label_values", "arguments": {"label": "job"}}
# Query CPU usage
{"tool": "query_prometheus", "arguments": {"query": "rate(cpu_usage[5m])"}}
# Search error logs
{"tool": "search_logs", "arguments": {"search_text": "error", "start": "1h"}}License
MIT
Available Tools
9 toolslist_labelsA
Get all label names available in Prometheus. Use this to discover what labels you can filter by.
Inputs: metric.
list_label_valuesB
Get all values for a specific label. Common labels: 'service', 'job', 'namespace', 'instance'. Use this to discover what services/namespaces are monitored.
Inputs: label (required), metric.
list_log_labelsB
List all log stream labels in Loki. Use this to discover what labels are available for filtering.
Inputs: start, end.
list_log_label_valuesA
Get all values for a specific log label. Common labels: 'namespace', 'job', 'app'. Use this to discover what namespaces/services have logs.
Inputs: label (required), start, end.
list_metricsB
List all available metrics in Prometheus. Useful for discovering what metrics are being collected.
Inputs: prefix.
query_lokiB
Execute raw LogQL query against Loki. Use this to search and filter logs.
Inputs: query (required), start, end, limit, +1 more.
query_prometheusA
Execute raw PromQL instant query against Prometheus. Returns metric values at a specific point in time.
Inputs: query (required), time.
query_prometheus_rangeB
Execute PromQL query over a time range. Returns time series data. Use this for getting metrics over time.
Inputs: query (required), start, end, step.
search_logsB
Search logs with simple filters. Easier than writing raw LogQL queries.
Inputs: service, namespace, search_text, level, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Most tools have distinct purposes, but there is some overlap between 'query_loki' and 'search_logs' as both handle log queries, which could cause confusion. The other tools are clearly differentiated by their target systems (Prometheus vs. Loki) and query types (instant vs. range).
All tool names follow a consistent verb_noun pattern with clear, descriptive naming. The verbs ('list', 'query', 'search') are used appropriately, and the nouns ('labels', 'metrics', 'logs') accurately reflect the target resources, making the set highly predictable.
With 9 tools, the server is well-scoped for its OpenTelemetry monitoring purpose. It covers essential operations for both Prometheus (metrics) and Loki (logs), including discovery, querying, and searching, without being overly complex or insufficient.
The tool set provides strong coverage for querying and discovering metrics and logs, but lacks write operations (e.g., creating or updating metrics/logs) which might be expected in a full OpenTelemetry workflow. However, for read-only monitoring tasks, it is largely complete.
Maintenance
Related MCP Connectors
Manage uptime monitors and incidents and search logs, metrics and traces from an AI assistant.
Open-source agent that observes and fixes your application. Query logs, traces, metrics, incidents.
AI SRE: investigate production incidents across your observability stack.
Query application logs, traces, and metrics from your AI coding assistant via Foam's MCP server.
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables AI assistants to interact with Grafana dashboards, datasources, alerts, incidents, and monitoring data through 43 comprehensive tools. Supports querying Prometheus metrics, Loki logs, managing incidents, and dashboard operations with full authentication support.43862 npm3MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to query Prometheus metrics, monitor alerts, and analyze system health through read-only access to your Prometheus server with built-in query safety and optional AI-powered metric analysis.MIT
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with direct access to Red Hat OpenShift AI observability data, enabling querying of Prometheus metrics, Alertmanager alerts, Loki logs, Grafana dashboards, and Kubernetes cluster state to troubleshoot vLLM inference workloads.5MIT
- AlicenseNot gradedqualityDmaintenanceProvides tools to search, query, and visualize Prometheus metrics, returning results in JSON format for AI analysis.309 npm3MIT