# Grafana MCP — Dashboards, Alerts & OnCall Tools > Grafana MCP server connects your MCP client to Grafana so agents can search dashboards, query panels, and automate ops tasks with a service account token. ## Install Merge the JSON below into your `.mcp.json`: ## Quick Use 1. Install `uv` and add to your MCP config: ```json { "mcpServers": { "grafana": { "command": "uvx", "args": ["mcp-grafana"], "env": { "GRAFANA_URL": "http://localhost:3000", "GRAFANA_SERVICE_ACCOUNT_TOKEN": "" } } } } ``` 2. Restart your MCP client. 3. Ask the agent to “search dashboards” and fetch a dashboard summary. ## Intro Grafana MCP server connects your MCP client to Grafana so agents can search dashboards, query panels, and automate ops tasks with a service account token. - **Best for:** SRE/ops teams who want agents to navigate Grafana dashboards and automate common read/write tasks safely - **Works with:** Grafana 9.0+, service account token, MCP clients via uvx or Docker/Helm installs - **Setup time:** 12 minutes ## Practical Notes - Requires Grafana 9.0+ for full functionality (README requirement) - Some tool categories are disabled/limited by flags; plan least-privilege RBAC scopes (README RBAC section) ## A Least-Privilege MCP Pattern for Observability Treat your Grafana token like production credentials. Suggested steps: 1. Create a dedicated Grafana service account for MCP. 2. Start with **read-only** operations (dashboard search, summaries). 3. Only then enable write tools (dashboard patch/update) when you’re comfortable with the audit trail. To keep agent context small: - Prefer summary tools over full dashboard JSON. - Use JSONPath-style property extraction to pull only what you need. This makes Grafana automation scalable: the agent can answer “what changed?” and “what’s broken?” without flooding the context window. ### FAQ **Q: Do I need a Grafana token?** A: Yes. The README uses `GRAFANA_SERVICE_ACCOUNT_TOKEN` for authentication. **Q: Can I run it without Docker?** A: Yes. The README shows a uvx-based quick start and also Docker/Helm options. **Q: Why does context size matter?** A: Dashboard JSON can be huge; use summaries and property extraction to avoid token blowups. ## Source & Thanks > Source: https://github.com/grafana/mcp-grafana > License: Apache-2.0 > GitHub stars: 2,989 · forks: 353 --- ## 快速使用 1. 安装 `uv` 并加入 MCP 配置: ```json { "mcpServers": { "grafana": { "command": "uvx", "args": ["mcp-grafana"], "env": { "GRAFANA_URL": "http://localhost:3000", "GRAFANA_SERVICE_ACCOUNT_TOKEN": "" } } } } ``` 2. 重启 MCP 客户端。 3. 让 Agent 先“搜索仪表盘”,再拉一个 dashboard summary 验证可用。 ## 简介 Grafana MCP server 让 MCP 客户端直连你的 Grafana:用 service account token 搜索仪表盘、读取/更新内容、运行查询并辅助运维自动化,适合把排障步骤变成可重复的“工具链”。 - **适合谁:** 希望让 Agent 更高效地导航 Grafana 仪表盘,并安全自动化常见运维读写任务的团队 - **可搭配:** Grafana 9.0+、service account token、通过 uvx 或 Docker/Helm 接入 MCP 客户端 - **准备时间:** 12 分钟 ## 实战建议 - README 要求 Grafana 9.0+ 才能完整工作 - 工具类别可用 flags 开关;按 README 的 RBAC 建议规划最小权限 scopes ## 面向可观测性的最小权限模式 把 Grafana token 当成生产凭据对待。 建议步骤: 1. 为 MCP 单独创建 service account。 2. 先只开只读能力(搜索仪表盘、获取摘要)。 3. 等审计链路与误操作风险可控后,再逐步开放写入类工具(patch/update)。 为了控制上下文体积: - 优先用 summary,而不是拉全量 dashboard JSON。 - 用 property/JSONPath 式的提取只取必要字段。 这样 Agent 才能在不爆上下文的前提下回答“发生了什么 / 哪里坏了”。 ### FAQ **必须有 Grafana token 吗?** 答:需要,README 使用 `GRAFANA_SERVICE_ACCOUNT_TOKEN` 作为认证方式。 **不装 Docker 也能跑吗?** 答:可以,README 提供 uvx 快速启动,也有 Docker/Helm 选项。 **为什么要管上下文大小?** 答:dashboard JSON 很大;用 summary 与字段提取避免 token 爆炸。 ## 来源与感谢 > Source: https://github.com/grafana/mcp-grafana > License: Apache-2.0 > GitHub stars: 2,989 · forks: 353 --- Source: https://tokrepo.com/en/workflows/grafana-mcp-dashboards-alerts-oncall-tools Author: MCP Hub