Observability MCP Server
Based on the exposed schema, the server supports named-session observability queries across Prometheus, Loki, Tempo, and Grafana, plus Grafana annotation creation.
Connect, disconnect, and list configured observability sessions.
Run instant PromQL metric queries and compute HTTP 5xx error rates.
Run LogQL log queries.
Fetch Tempo traces by ID and search traces by tags.
List Grafana datasources and alert rules.
Create Grafana annotations; this is the only write tool in the provided schema.
The README additionally describes correlation, canary audit, slow-trace bottleneck, credential-cache, and silence tools, but those are not in the provided schema.
Provides tools for interacting with Grafana, including listing datasources and alert rules, and creating annotations.
Provides tools for querying Prometheus with instant PromQL queries and calculating HTTP 5xx error rates for a service label.
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., "@Observability MCP Server why did order-service fail? check logs and trace for request abc123"
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.
Observability MCP Server
A Python Model Context Protocol (MCP) server for Prometheus, Loki, Grafana Tempo, and Grafana — 15 SRE tools for PromQL metrics, LogQL logs, distributed traces, cross-signal incident correlation, slow-trace bottleneck detection, and post-deploy canary audits.
Overview
Observability MCP Server lets AI assistants investigate latency spikes, 5xx errors, and regressions across metrics, logs, and traces without switching between Grafana tabs.
Read-only queries by default: Metrics, logs, traces, datasources, and alert rules are read-only.
Cross-signal correlation:
obs_correlate_metrics_logs_and_trace,obs_post_deploy_canary_audit, andobs_get_slow_traces_and_bottlenecksunify Prometheus, Loki, and Tempo in single investigative calls.Explicit writes:
obs_manage_grafana_annotations_and_silencesis the only mutating tool (for annotations and silences).Named sessions:
ObsHubmanages multiple named environments (OBS_SESSION, defaultdefault) with optional credential caching under~/.observability-mcp-cache.
Related MCP server: LGTM MCP Server
Architecture & Investigation Flow
flowchart TB
subgraph L1["Layer 1 — AI Client"]
IDE["Cursor, Claude Desktop, Windsurf, VS Code"]
end
subgraph L2["Layer 2 — Observability MCP"]
SRV["observability-mcp (FastMCP — 15 tools)"]
HUB["ObsClient / Named Sessions"]
end
subgraph L3["Layer 3 — Signals"]
P["Prometheus :9090"]
L["Loki :3100"]
T["Tempo :3200"]
G["Grafana :3000"]
end
IDE -->|"PromQL / LogQL / Trace / Canary"| SRV
SRV --> HUB
HUB -->|"Instant PromQL"| P
HUB -->|"LogQL Range"| L
HUB -->|"Trace ID / TraceQL"| T
HUB -->|"Datasources / Alerts / Annotations"| Gflowchart LR
ERR["5xx Spike or Latency"] --> COR["obs_correlate_metrics_logs_and_trace"]
COR --> LOG["obs_query_logs"]
LOG --> TRACE["obs_search_traces / obs_get_trace"]
TRACE --> SLOW["obs_get_slow_traces_and_bottlenecks"]
SLOW --> NOTE["obs_manage_grafana_annotations_and_silences"]Project Layout
observability-mcp/
├── src/observability_mcp/
│ ├── __init__.py # Package metadata
│ ├── __main__.py # `python -m observability_mcp` entry point
│ ├── server.py # FastMCP server, 15 tools, /health, CLI transport
│ ├── obs_client.py # Prometheus, Loki, Tempo, and Grafana HTTP client
│ └── credential_store.py # Session credential persistence
├── tests/ # Unit & httpx.MockTransport regression tests
├── pyproject.toml # Hatchling config (`observability-mcp` CLI)
├── Dockerfile # Streamable HTTP container
└── mcpize.yaml # Hosted HTTP runtime configTools Reference (15)
Connection & Sessions (4)
Tool | Description |
| Connect to Prometheus, Loki, Tempo, and/or Grafana and create a named session. |
| Disconnect an observability session. |
| Show active sessions and configured backend URLs. |
| Persist backend URLs and tokens to local cache for a session. |
Metrics, Logs, Traces & Grafana (7)
Tool | Description |
| Run an instant PromQL query against Prometheus. |
| Compute HTTP 5xx error rate for a |
| Run a LogQL range query against Loki. |
| Fetch a single distributed trace from Tempo by |
| Search Tempo traces by tag |
| List Grafana datasources with types and connection details. |
| List Grafana-managed alert rules with current states ( |
SRE Correlation & Incident Governance (4)
Tool | Description |
| Cross-signal incident correlator linking metrics, logs, and traces. |
| Compare the 4 SRE Golden Signals before vs. after a deployment. |
| Find slow traces and identify the bottleneck service/span. |
| Create a Grafana annotation or Alertmanager silence. |
Installation & Configuration
Requires Python 3.10+ and uv.
git clone https://github.com/Pawangunjkar/observability-mcp.git
cd observability-mcp
uv sync
uv run observability-mcpEnvironment Variables
Variable | Default | Purpose |
| unset | Prometheus / Thanos / VictoriaMetrics base URL. |
| unset | Grafana Loki base URL. |
| unset | Grafana Tempo base URL. |
| unset | Grafana server base URL. |
| unset | Grafana API key or service account token. |
|
| Default session name. |
|
| HTTP timeout in seconds. |
|
| Credential cache directory. |
Cursor / Claude Desktop
{
"mcpServers": {
"observability": {
"command": "uv",
"args": ["run", "--directory", "/absolute/path/to/observability-mcp", "observability-mcp"],
"env": {
"PROMETHEUS_URL": "http://localhost:9090",
"LOKI_URL": "http://localhost:3100",
"TEMPO_URL": "http://localhost:3200",
"GRAFANA_URL": "http://localhost:3000",
"GRAFANA_TOKEN": ""
}
}
}
}Development & Tests
uv run python -m unittest discover -s tests -v
uv buildAuthor & License
Pawan Gunjkar — pawangunjkar@gmail.com · GitHub
MIT License — see LICENSE.
Available Tools
11 toolsobs_annotateB
Create a Grafana annotation. This is the write tool for observability.
Inputs: text (required), tags, session_name. Returns: result
obs_connectC
Save backend URLs and probe /ready or Grafana /api/health.
Inputs: loki_url, tempo_url, grafana_url, session_name, +2 more. Returns: result
obs_disconnectC
Drop an observability session.
Inputs: session_name. Returns: result
obs_error_rateC
HTTP 5xx rate for a service label over 5 minutes, if that metric exists.
Inputs: service (required), session_name. Returns: result
obs_get_traceB
Fetch one Tempo trace by id.
Inputs: trace_id (required), session_name. Returns: result
obs_grafana_alertsD
List Grafana alert rules.
Inputs: session_name. Returns: result
obs_grafana_datasourcesC
List Grafana datasources.
Inputs: session_name. Returns: result
obs_query_logsC
Run a LogQL query, for example {service="order-orchestrator"} |= "ERROR".
Inputs: query (required), limit, session_name. Returns: result
obs_query_metricsC
Run an instant PromQL query, for example sum(rate(http_requests_total[5m])).
Inputs: query (required), session_name. Returns: result
obs_search_tracesC
Search Tempo traces. tags example: service.name=order-orchestrator.
Inputs: tags (required), limit, session_name. Returns: result
obs_statusA
List configured observability sessions.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Each tool targets a distinct observability resource and action: connection, status, metrics queries, error-rate specialization, log queries, trace retrieval/search, Grafana datasource/alert listing, and annotation writing. While query_metrics and error_rate both touch metrics, error_rate is narrowly scoped to 5xx rates over a fixed window, and get_trace vs search_traces differ by lookup key vs tags, leaving no ambiguous boundaries.
All tools share the obs_ prefix, followed by a verb_noun or clear verb pattern (e.g., obs_query_metrics, obs_get_trace, obs_grafana_datasources, obs_annotate). The naming is predictable and uniform, with no mixed casing or inconsistent verb styles, making tool selection straightforward.
With 11 tools, the server covers a broad but well-scoped observability surface—metrics, logs, traces, and Grafana integration—without feeling bloated. Each tool serves a distinct purpose and earns its place, fitting within the ideal 3-15 tool range.
The tool set provides solid read coverage for metrics (instant queries, error rates), logs, traces (get/search), and Grafana metadata (datasources, alerts), plus one write operation (annotations). Minor gaps exist, such as missing range queries for Prometheus or alert management write operations, but the core observability workflows are well represented and agents can accomplish typical tasks without dead ends.
Maintenance
Related MCP Connectors
Lets AI agents analyze API metrics, request logs, and traces, and manage apps and alerts.
Read-only production context for AI agents: Docker/K8s health, deploys, logs, traffic, code graph
Open-source agent that observes and fixes your application. Query logs, traces, metrics, incidents.
Zero-signup OTLP, webhook HMAC, HTTP/SSE chaos, and causal /diff blackbox for coding agents.
Related MCP Servers
- FlicenseNot gradedqualityBmaintenanceEnables exploration of Kubernetes metrics, logs, traces, and service graph data via simple tools.2-
- AlicenseNot gradedqualityDmaintenanceProvides read-only access to Loki, Prometheus, and Tempo APIs, enabling natural language queries for logs, metrics, and traces. Supports multiple instances and authentication via bearer tokens.1MIT
- AlicenseBqualityDmaintenanceEnables querying Grafana Tempo traces and spans with flexible filtering, including TraceQL queries, tag-based filters, duration ranges, and aggregated statistics.6GPL 3.0
- AlicenseAqualityBmaintenanceEnables agents to explore dashboards and run their panel queries with template variables resolved, query Prometheus and Loki datasources, and read alerts, silences and annotations across Grafana's sources in a context-friendly, read-only-by-default form, with write tools available only when explicitly enabled.1436 npmMIT