observability-mcp
MCP server that enables AI assistants to query Grafana/Loki logs and Thanos/Prometheus metrics directly from MCP-compatible clients like Cursor or Claude Desktop.
README
observability-mcp
MCP (Model Context Protocol) servers that let AI assistants query your observability stack — Grafana/Loki for logs and Thanos/Prometheus for metrics — directly from Cursor, Claude Desktop, or any MCP-compatible client.
Packages
| Package | Entry-point | What it does |
|---|---|---|
grafana_mcp |
grafana-mcp |
Query Loki logs via Grafana datasource proxy |
thanos_mcp |
thanos-mcp |
Query Prometheus/Thanos metrics (PromQL) |
observability_mcp |
observability-mcp |
Combined server — all tools in one connection |
Requirements
- Python 3.10+
- Access to a running Grafana instance (for
grafana_mcp) - Access to a Thanos or Prometheus instance (for
thanos_mcp)
Installation
From GitHub (recommended)
Install directly from the repo without cloning:
pip install "observability-mcp @ git+https://github.com/ThainaJardim/observability-mcp.git"
# With browser-cookie support for Grafana SSO:
pip install "observability-mcp[browser-cookie] @ git+https://github.com/ThainaJardim/observability-mcp.git"
After installation, the grafana-mcp, thanos-mcp, and observability-mcp commands are available.
From source (local clone)
git clone https://github.com/ThainaJardim/observability-mcp.git
cd observability-mcp
pip install .
# For automatic Grafana SSO login via browser cookies (macOS/Linux):
pip install ".[browser-cookie]"
Quick start
Grafana / Loki
export GRAFANA_URL=https://grafana.example.com
export LOKI_DATASOURCE_ID=1 # numeric datasource ID in Grafana
export OIDC_ISSUER=https://keycloak.example.com/auth/realms/myrealm
grafana-mcp
Thanos / Prometheus
export THANOS_URL=https://thanos.example.com
export OIDC_ISSUER=https://keycloak.example.com/auth/realms/myrealm
thanos-mcp
Combined (both in one server)
# Set all env vars from above, then:
observability-mcp
Authentication
Grafana MCP
Auth mode is auto-detected from environment variables (or forced with
GRAFANA_AUTH_MODE):
| Mode | How it works | Variables needed |
|---|---|---|
browser-cookie (default) |
Reads Keycloak SSO cookies from Chrome, follows the Grafana OAuth flow automatically, caches grafana_session locally |
OIDC_ISSUER, GRAFANA_URL |
token |
Grafana service-account token | GRAFANA_BEARER_TOKEN |
cookie |
Static grafana_session cookie |
GRAFANA_SESSION_COOKIE |
kubeconfig |
OIDC id-token from kubectl kubeconfig | OIDC_ISSUER |
browser-cookie mode requires
browser-cookie3(pip install ".[browser-cookie]"). On first use it reads Chrome's cookie store — you may be prompted to allow macOS Keychain access. You must be logged into Grafana in Chrome at least once.
Thanos MCP
Auth mode is auto-detected (or forced with THANOS_AUTH_MODE):
| Mode | How it works | Variables needed |
|---|---|---|
kubeconfig (default) |
OIDC id-token from kubectl kubeconfig, auto-refreshed | OIDC_ISSUER, kubectl on PATH |
token |
Static Bearer token | THANOS_ACCESS_TOKEN |
cookie |
oauth2-proxy session cookie | THANOS_SESSION_COOKIE |
Cursor MCP configuration
Create or edit .cursor/mcp.json in your project:
{
"mcpServers": {
"grafana": {
"command": "python",
"args": ["-m", "grafana_mcp.server"],
"env": {
"GRAFANA_URL": "https://grafana.example.com",
"LOKI_DATASOURCE_ID": "1",
"OIDC_ISSUER": "https://keycloak.example.com/auth/realms/myrealm",
"PATH": "/usr/local/bin:/usr/bin:/bin"
}
},
"thanos": {
"command": "python",
"args": ["-m", "thanos_mcp.server"],
"env": {
"THANOS_URL": "https://thanos.example.com",
"OIDC_ISSUER": "https://keycloak.example.com/auth/realms/myrealm",
"PATH": "/usr/local/bin:/usr/bin:/bin"
}
}
}
}
Tip: Use an absolute Python interpreter path (e.g.
/usr/local/bin/python3) if Cursor cannot findpythonin its PATH.
Combined server (one entry)
{
"mcpServers": {
"observability": {
"command": "python",
"args": ["-m", "observability_mcp.server"],
"env": {
"GRAFANA_URL": "https://grafana.example.com",
"LOKI_DATASOURCE_ID": "1",
"THANOS_URL": "https://thanos.example.com",
"OIDC_ISSUER": "https://keycloak.example.com/auth/realms/myrealm",
"PATH": "/usr/local/bin:/usr/bin:/bin"
}
}
}
}
Available MCP tools
Grafana/Loki tools (grafana_mcp)
| Tool | Description |
|---|---|
query_loki_logs |
Run a LogQL range query and return matching log streams |
query_loki_instant |
Run a LogQL instant query |
list_loki_labels |
List all available Loki label names |
list_loki_label_values |
List values for a specific Loki label |
Thanos/Prometheus tools (thanos_mcp)
| Tool | Description |
|---|---|
query_metrics |
Run an instant PromQL query |
query_metrics_range |
Run a PromQL range query |
list_labels |
List all metric label names |
list_series |
List time-series matching a selector |
Development
# Install in editable mode with dev extras
pip install -e ".[dev,browser-cookie]"
# Run tests
pytest
# Run a specific server locally
python -m grafana_mcp.server
python -m thanos_mcp.server
python -m observability_mcp.server
Environment variable reference
| Variable | Default | Description |
|---|---|---|
GRAFANA_URL |
(required) | Grafana base URL |
LOKI_DATASOURCE_ID |
(required) | Numeric Loki datasource ID in Grafana |
GRAFANA_AUTH_MODE |
auto | Force Grafana auth mode |
GRAFANA_BEARER_TOKEN |
— | Grafana service-account token |
GRAFANA_SESSION_COOKIE |
— | grafana_session cookie value |
GRAFANA_SESSION_CACHE |
~/.cache/grafana-mcp/session.json |
Path to session cache file |
THANOS_URL |
(required) | Thanos/Prometheus base URL |
THANOS_AUTH_MODE |
auto | Force Thanos auth mode |
THANOS_ACCESS_TOKEN |
— | Static Bearer token |
THANOS_SESSION_COOKIE |
— | oauth2-proxy cookie value |
OIDC_ISSUER |
— | OIDC issuer URL (Keycloak realm URL) |
REQUEST_TIMEOUT_SECONDS |
30 |
HTTP timeout for all requests |
LOG_LEVEL |
INFO |
Logging level |
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.