# 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.

## Before you start

### Intended audience

Responders who run a Diagnosis from an AI client on their own computer.

### Required permissions

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


### Prerequisites

- Connect your client first. See [Set up Diagnosis](https://tellagen.com/help/set-up-diagnosis).
- Install `uv`, which provides `uvx`.

## Reference

<a id="step-used-for"></a>

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

<a id="step-reads"></a>

**Reads.** 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 id="step-credential"></a>

**Credential.** 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.

<a id="step-config"></a>

**Config.** Replace the example address and token with yours.

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.

Claude in the terminal:

```shell
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:

```shell
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:

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

<a id="step-read-only-by"></a>

**Read-only by.** 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.

<a id="step-check-it"></a>

**Check it.** Send a write with the token. Grafana must answer 403.

Expect 403:

```shell
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
```

<a id="step-reaches-tellagen"></a>

**Reaches Tellagen.** 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](https://tellagen.com/help/how-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

<a id="troubleshooting-the-check-answers-200-or-201-what-now"></a>

### 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.

<a id="troubleshooting-grafana-still-shows-not-found-what-do-i-do"></a>

### 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](https://tellagen.com/help/fix-a-tool-that-shows-not-found).

## Related articles

- **Recommended next task:** [How a local diagnosis uses your tools](https://tellagen.com/help/how-local-diagnosis-uses-your-tools)
- [Add an evidence tool to your client](https://tellagen.com/help/add-an-evidence-tool)

## External setup references

- [Grafana MCP server README](https://github.com/grafana/mcp-grafana) (verified 2026-11-16)


## Continue through the incident lifecycle

- **Previous task:** [How a local diagnosis uses your tools](https://tellagen.com/help/how-local-diagnosis-uses-your-tools)
- **Next task:** [Add Kubernetes to a local diagnosis](https://tellagen.com/help/add-kubernetes-to-a-local-diagnosis)
- [Back to Support Center](https://tellagen.com/help#help-search)

## Updated

2026-11-25
