grafana-cursor-mcp
Enables querying Elasticsearch logs via Lucene queries, integrated as a log datasource within Grafana.
Allows querying Grafana logs, metrics, dashboards, and alerts, including listing datasources, running LogQL/PromQL queries, and generating Explore URLs.
Allows running Prometheus/PromQL queries for metrics, retrieving time series data from Prometheus-compatible datasources.
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., "@grafana-cursor-mcpfind logs with call_id 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.
Grafana MCP for Cursor
Query Grafana logs, metrics, and dashboards from Cursor. This MCP server lets the AI in Cursor call your Grafana instance via tools—no need to leave the editor to check logs or run a PromQL query.
Logs – Loki, Elasticsearch. Filter by label (e.g.
call_id,session_id,request_id) or custom LogQL/Lucene. Results saved to a temp file so Cursor can analyze them.Metrics – Run Prometheus/PromQL (or compatible) queries.
Dashboards – List and inspect dashboards by UID.
Alerts – List provisioned alert rules.
Explore – Build “Open in Grafana” URLs for any query.
Works with any Grafana instance and any log/metric datasource you already use. No custom log store—Grafana stays the single source of truth.
Package: grafana-cursor-mcp on npm
Quick start
You only need the MCP config and your Grafana URL + API key. No clone or build required if you use the npm package.
1. Get a Grafana API token
In Grafana: Administration → Service accounts (or API Keys) → create one with Viewer (or least privilege). Copy the token.
2. Add the MCP server to Cursor
Open Cursor Settings → MCP (or edit ~/.cursor/mcp.json). Add this (or merge the grafana-logs entry into your existing mcpServers):
{
"mcpServers": {
"grafana-logs": {
"command": "npx",
"args": ["-y", "grafana-cursor-mcp"],
"env": {
"GRAFANA_URL": "https://your-grafana.example.com",
"GRAFANA_API_KEY": "your-service-account-token"
}
}
}
}Replace only:
GRAFANA_URL→ your Grafana base URL (no trailing slash).GRAFANA_API_KEY→ the token from step 1.
Optional: add "GRAFANA_DEFAULT_DATASOURCE_UID": "your-loki-uid" to env if you have one default log datasource.
3. Restart Cursor
The AI can now use the Grafana tools. No clone or build—grafana-cursor-mcp runs via npx.
Alternative: run from source
If you prefer to clone and build locally:
git clone https://github.com/hacktivist1512/grafana-cursor-mcp.git
cd grafana-cursor-mcp
npm install
npm run build:mcpIn your MCP config, use "command": "node" and "args": ["/absolute/path/to/grafana-cursor-mcp/packages/mcp-server/dist/index.js"] instead of npx. See mcp.json.example in the repo.
Related MCP server: SonarQube MCP Server
Config (env)
Variable | Required | Description |
| Yes | Grafana base URL (e.g. |
| Yes | Service account or API key token. ( |
| No | Default log datasource UID so log tools don’t need |
Security: Keep the API key only in env or MCP config—never in code or docs. Use a Viewer (or minimal) role.
Tools the AI can use
Logs
Tool | Description |
list_log_datasources | List log datasources (Loki, Elasticsearch) with name and UID. Use when the user hasn’t specified which datasource to query. |
get_logs | Run a custom log query (LogQL for Loki, Lucene for ES). Optional |
get_logs_for_call | Get logs by label (e.g. |
Metrics
Tool | Description |
query_metrics | Run a Prometheus/PromQL (or compatible) query. Params: |
Grafana context
Tool | Description |
grafana_info | Get org name and all datasources (name, UID, type). Use to check connection and pick the right datasource. |
get_explore_url | Build a Grafana Explore URL for a given datasource, query, and time range (“Open in Grafana”). |
Dashboards
Tool | Description |
list_dashboards | Search dashboards ( |
get_dashboard | Get a dashboard by UID. With |
Alerting
Tool | Description |
list_alert_rules | List provisioned alert rules ( |
Repo structure
packages/mcp-server– MCP server (Node/TypeScript). All tools above; stdio transport for Cursor.packages/grafana-app– Optional Grafana app plugin (e.g. “Cursor logs” page and MCP snippet).
Publishing (maintainers)
The package is published as grafana-cursor-mcp. To publish a new version: cd packages/mcp-server, bump version in package.json, then npm publish. See docs/GITHUB_AND_NPM.md for details.
License
Apache-2.0. See LICENSE.
This server cannot be deployed
Maintenance
Related MCP Connectors
Query application logs, traces, and metrics from your AI coding assistant via Foam's MCP server.
- SuperlogOAuthsh.superlog
Open-source agent that observes and fixes your application. Query logs, traces, metrics, incidents.
Shared memory for AI coding agents. Save once, reuse from Cursor, Claude Code, Codex.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Related MCP Servers
- AlicenseBqualityBmaintenanceEnables 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.431,485 npm3MIT
- AlicenseAqualityDmaintenanceEnables Cursor AI to query SonarQube for pull request metrics, issues, file issues, and duplication reports directly, without manual data export.436 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to query Grafana dashboards, alerts, and datasources for observability insights and incident investigation.MIT
- AlicenseAqualityDmaintenanceMCP server that enables AI assistants to query Grafana/Loki logs and Thanos/Prometheus metrics directly from MCP-compatible clients like Cursor or Claude Desktop.8MIT