Assistant Mcp

作者 grafana1ccacf29049fApache-2.0279 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Connect AI coding agents (Claude Code, Cursor, VS Code, OpenAI Codex) to Grafana Cloud via the `mcp-grafana` Model Context Protocol server. Installs the server with `go install`, generates a Grafana service-account token, wires `~/.claude/settings.json` or `~/.cursor/mcp.json` with the `command` + `env` block, runs `--disable-write` for safer read-only sessions, switches to SSE transport for team-shared / VS Code setups, and verifies with `/mcp` + a `list_datasources` round-trip. Use when connecting Claude Code to Grafana, setting up MCP for Grafana, configuring the Grafana MCP server, using Grafana tools in Cursor/VS Code, querying Grafana from an AI agent, sharing the MCP server across a team — even when the user says "give my agent Grafana access", "let Claude see my metrics", or "Cursor + Grafana" without saying "MCP".

AI 產生的概覽

設定 Grafana MCP 伺服器,讓 AI 程式開發代理能查詢 Grafana Cloud 的指標、儀表板和告警。

功能
這個技能說明如何用 go install 安裝 mcp-grafana 模型情境協定伺服器、建立 Grafana 服務帳戶權杖,並把伺服器寫入 Claude Code、Cursor 或 VS Code 的設定檔。內容涵蓋以 --disable-write 唯讀方式執行、為團隊共用情境切換到 SSE 傳輸,以及透過 /mcp 和 list_datasources 往返呼叫驗證連線。另外也提供權杖權限範圍與輪換的安全建議,並指向工具、SSE 傳輸與 A2A 的參考文件。
適用情境
適用於把 Claude Code、Cursor 或 VS Code 等 AI 程式開發代理連接到 Grafana Cloud、設定 Grafana MCP 伺服器,或在團隊中共用同一個 MCP 伺服器。也適用於使用者只說讓代理存取 Grafana 或查看指標、並未提到 MCP 的需求。
執行需求
需要 Go 工具鏈來安裝 mcp-grafana,需要具備服務帳戶權杖和 URL 的 Grafana Cloud 執行個體,以及連線到 Grafana 的網路。代理所在環境需支援 MCP 設定檔,例如 ~/.claude/settings.json 或 ~/.cursor/mcp.json。不含指令碼,僅為說明文件加三份參考檔案。

Grafana Cloud MCP Server Setup

The Grafana MCP server exposes Grafana Cloud capabilities as tools that AI agents can call via the Model Context Protocol. Agents can then query metrics, search dashboards, manage alerts, investigate incidents, and interact with Fleet Management without leaving the coding environment.

Transports: stdio (agent spawns the server as a subprocess, simplest), or SSE (server runs independently, agents connect via HTTP — see references/sse-transport.md [blocked]).

Common Workflows

Connecting Claude Code to Grafana (stdio)

bash
# 1. Install the servergo install github.com/grafana/mcp-grafana/cmd/mcp-grafana@latest
# 2. Verify the binarymcp-grafana --version# If "command not found": ensure $GOPATH/bin (or $HOME/go/bin) is on PATH.
  1. Get a service-account token: Grafana Cloud → Administration → Service Accounts → create with Viewer role (add Editor only if you need writes) → generate token. Note the Grafana URL (e.g. https://myorg.grafana.net).

  2. Wire ~/.claude/settings.json (or project-local .claude/settings.json):

    json
    {  "mcpServers": {    "grafana": {      "command": "mcp-grafana",      "args": ["--disable-write"],      "env": {        "GRAFANA_URL": "https://myorg.grafana.net",        "GRAFANA_API_KEY": "glsa_xxxx"      }    }  }}

    --disable-write is the safer default — drop it once you've verified the read path works.

  3. Restart Claude Code, then verify:

    /mcp

    The grafana server should appear with its tool list. Then ask:

    What data sources are configured in my Grafana instance?

    A clean response = working. If the tool call fails:

    • Check GRAFANA_URL has no trailing slash
    • Confirm the API key hasn't expired
    • Re-run with mcp-grafana --debug to see raw request/response

Connecting Cursor

Same Grafana token. Settings → Features → MCP Servers (or edit ~/.cursor/mcp.json):

json
{  "mcpServers": {    "grafana": {      "command": "mcp-grafana",      "args": ["--disable-write"],      "env": {        "GRAFANA_URL": "https://myorg.grafana.net",        "GRAFANA_API_KEY": "glsa_xxxx"      }    }  }}

Verify the same way — Cursor surfaces MCP servers in its agent panel; run a query like "list dashboards tagged kubernetes".

Sharing the server across a team (SSE)

Switch from stdio to SSE so the server runs once and many agents connect to it. Full setup with VS Code config in references/sse-transport.md [blocked].

Security considerations

  • API keys belong in env vars or a secrets manager — never in committed files.
  • Use --disable-write for shared environments and CI; only lift it on the specific machine where the agent should be allowed to mutate Grafana.
  • Scope service-account permissions to the minimum: Viewer is enough for queries and dashboard reads. Only grant Editor when the agent needs to create dashboards or annotations.
  • Rotate tokens periodically via Administration → Service Accounts.

References

  • references/tools.md [blocked] — full list of MCP tools exposed (query / dashboard / alerting / Fleet Management / annotations) and how to discover the live set
  • references/sse-transport.md [blocked] — SSE setup for team sharing and VS Code, with stdio-vs-SSE decision matrix + common failure modes
  • references/a2a.md [blocked] — Agent-to-Agent (A2A) protocol for delegating reasoning to the Grafana Assistant (vs direct tool calls via MCP)

External resources

來源與署名

來源:grafana/skills位於skills/grafana-cloud/assistant-mcp提交1ccacf2

授權條款: Apache-2.0

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架

更多來自 grafana/skills 的技能

React 19 Plugin Migration

grafana

指導將 Grafana 外掛遷移至 React 19 相容,依序完成建置、相依性與原始碼修改步驟。

Software Development279今天更新

Plugin Bundle Size

grafana

指導使用 React.lazy、Suspense 與 webpack 程式碼分割來最佳化 Grafana 應用程式外掛的打包體積。

Software Development279今天更新

Grafana Scenes

grafana

使用 @grafana/scenes 框架建置 Grafana 外掛頁面,涵蓋場景、面板、變數與下鑽導覽。

Software Development279今天更新

Check Npm

grafana

對 JS/TS 儲存庫的 npm、yarn 或 pnpm 設定進行唯讀供應鏈強化稽核。

Security279今天更新

Mimir

grafana

指導架設與維運 Grafana Mimir,用於可擴充、多租戶、長期的 Prometheus 與 OTLP 指標儲存。

DevOps & Cloud279今天更新

K6 Trend Analysis

grafana

Analyze Grafana Cloud k6 test run trends over time. Detects slow metric drift (e.g., P95 latency creeping up while still passing thresholds), computes headroom to thresholds, flags anomalies, and recommends threshold tightening. Use when the user asks about test performance trends, wants to know if metrics are degrading, asks whether thresholds should be tightened, or wants a health check across recent runs for a specific test. Trigger on phrases like "how is my test trending", "is P95 getting worse", "check for performance regression", "should I tighten thresholds", "are my tests degrading", "show me trends for test X", "analyze my k6 test runs", or "is my test getting slower". Also trigger when a user asks to check all tests in a project -- run this skill once per test and synthesize.

待分類279今天更新