Add Grafana to a local diagnosis

Give your AI client a Grafana tool with a Viewer service account and the write tools off, and prove the token cannot write.

What you need
You need an active responder seat, and a Grafana admin to create a service account.

Before you start

  • Connect your client first. See Set up Diagnosis.
  • Install uv, which provides uvx.

Reference

Seeing when the problem started and which service shows it: error rate, latency, saturation and the matching log lines.

Prometheus and Loki queries, log patterns, the datasource list, dashboard search, panel queries and alert rules. Typical tools are query_prometheus, query_loki_logs, query_loki_patterns, list_datasources, search_dashboards and generate_deeplink.

For a disk question, ask for the node-exporter metric node_filesystem_avail_bytes. Its device and mountpoint labels say which filesystem is filling.

A Grafana service account with the Viewer role, and one token for it. Use Viewer because Grafana itself then refuses every write, whatever the tool server does. On Grafana Enterprise or Grafana Cloud, also limit the account with datasource permissions to the datasources that a diagnosis needs, for example datasources:query on their UIDs. The model can then read only those.

Replace the example address and token with yours.

Claude in the terminal

claude mcp add grafana --scope user \
  -e GRAFANA_URL=https://grafana.example.com \
  -e GRAFANA_SERVICE_ACCOUNT_TOKEN=glsa_your_token \
  -- uvx mcp-grafana --disable-write

Codex

codex mcp add grafana \
  --env GRAFANA_URL=https://grafana.example.com \
  --env GRAFANA_SERVICE_ACCOUNT_TOKEN=glsa_your_token \
  -- uvx mcp-grafana --disable-write

Cursor (~/.cursor/mcp.json) and the Claude desktop app

{
  "mcpServers": {
    "grafana": {
      "command": "uvx",
      "args": ["mcp-grafana", "--disable-write"],
      "env": {
        "GRAFANA_URL": "https://grafana.example.com",
        "GRAFANA_SERVICE_ACCOUNT_TOKEN": "glsa_your_token"
      }
    }
  }
}

The Claude desktop app does not read your shell path. If its log says spawn uvx ENOENT, set command to the full path that which uvx prints.

The Viewer role. Grafana refuses every write from this token. Rely on this layer.

--disable-write keeps the create and update tools and the raw SQL tools away from the model. It doesn't stop a write if the token allows one.

Send a write with the token. Grafana must answer 403.

Expect 403

curl -s -o /dev/null -w "%{http_code}\n" -X POST \
  -H "Authorization: Bearer glsa_your_token" -H "Content-Type: application/json" \
  -d '{"dashboard":{"title":"write-test"}}' \
  https://grafana.example.com/api/dashboards/db

The query text in each evidence reference, the figures your client builds, and the Explore links it sends. When it sends no link, Tellagen builds one from the Grafana address set up for your workspace in Tellagen, not from the address in your client. Never the token. Your model provider receives every query answer. See How a local diagnosis uses your tools.

You are done when

After your next diagnosis, Grafana has a tick under Your clients in Settings → AI diagnosis → Local, and the check above answered 403.

FAQs

  • The check answers 200 or 201. What now?

    The token can write. Change the role of the service account to Viewer, create a new token, and replace the old one in your client.

  • Grafana still shows Not found. What do I do?

    The tick comes with the next diagnosis your client picks up. To check sooner, an admin can select Recheck on the Grafana row in Tools a diagnosis can use, then Copy the prompt and paste it into the client. If it stays Not found, see Fix a tool that shows Not found.

Related guides

External setup references

Updated . Something out of date? Write to [email protected]. Open Markdown version