Grafana MCP for AI Coding Agents: Live Observability Guide
> Learn how Grafana MCP, gcx, and Agent Observability help AI coding agents verify changes against live telemetry with safer setup, RBAC, and human review.
🎧 Listen — ~8 min
Ready · Grafana MCP for AI Coding Agents
The short answer
Grafana’s open-source MCP server and its hosted Grafana Cloud MCP server give AI coding agents access to live dashboards, metrics, logs, alerts, incidents, and other operational context. The practical value is not “letting an agent operate Grafana.” It is giving the agent an evidence loop: inspect the system, change code, generate realistic tests, and compare the result with observed behavior before a human approves the change.
For most teams, start read-only. Use a scoped service-account token for the self-managed server, keep write tools disabled, and expose only the datasources and tools needed for the repository. Grafana 9.0 or later is required for full open-source-server functionality.
What Grafana shipped for agentic development
Grafana Labs announced general availability for six AI capabilities during its July 27, 2026 AI Week: Grafana Assistant Investigations, Workspace, Automations, the Grafana Cloud MCP server, gcx, and Grafana Agent Observability. The MCP server is the protocol bridge; gcx is the more flexible agent-facing CLI for managing Grafana resources as code; Agent Observability instruments the agents themselves.
An independent InfoQ report published August 17 describes the development loop these tools enable: coding agents can query metrics, logs, traces, SLOs, and Synthetic Monitoring results while a feature is being built. In one example, an agent uses the existing service’s observed p95 latency to create a more realistic test for a new payment provider instead of inventing a number from model memory.
That distinction is important. A code-review agent can tell you that a diff looks plausible. Telemetry can tell you whether the running system behaves plausibly.
Architecture: telemetry becomes an agent feedback loop
The loop is deliberately asymmetric: the agent can gather evidence and propose or test changes, but a person still owns the merge decision. That is a safer default than giving a coding agent unrestricted write access to dashboards, alert policies, or production data.
Open-source server versus Grafana Cloud MCP
Grafana documents two options. The open-source server is self-managed and authenticates with a service-account token. The hosted Grafana Cloud MCP server uses OAuth 2.1 browser authorization scoped to the signed-in Grafana user, so it is the lower-friction choice when the team already operates in Grafana Cloud.
| Option | Best fit | Authentication | Operational trade-off |
|---|---|---|---|
| Open-source Grafana MCP server | Self-managed Grafana or teams wanting local control | Service-account token | You operate the server, transport, TLS, and permissions |
| Grafana Cloud MCP server | External agents connecting to Grafana Cloud | OAuth 2.1 | Less infrastructure, but cloud identity and scope must be governed |
| gcx CLI | GitOps, custom workflows, dashboards and alerts as code | Grafana credentials | More flexible, but teams must define workflow guardrails |
The open-source server exposes tools for dashboards, datasources such as Prometheus and Loki, alerting, incidents, OnCall, Sift, and Grafana deeplinks. Its tool surface is broader than a single “ask Grafana” prompt, which makes permission design and tool allowlists part of the implementation rather than an afterthought.
A safe setup for Claude Desktop, Cursor, or VS Code
Grafana’s official quick start uses uvx. A minimal client configuration looks like this:
1{
2 "mcpServers": {
3 "grafana": {
4 "command": "uvx",
5 "args": ["mcp-grafana"],
6 "env": {
7 "GRAFANA_URL": "https://grafana.example.com",
8 "GRAFANA_SERVICE_ACCOUNT_TOKEN": "${GRAFANA_SERVICE_ACCOUNT_TOKEN}"
9 }
10 }
11 }
12}Treat this as a configuration pattern, not a token-handling recommendation. The token should come from the client’s secret manager or process environment; do not commit it to a repository or paste it into an agent prompt.
A safer rollout sequence is:
- Create a dedicated Grafana service account for the agent, not a human administrator account.
- Grant the smallest read permissions needed for the repository’s dashboards and datasources.
- Start with read-only tools and a loopback or private network bind.
- Record MCP calls and correlate them with the agent session and repository commit.
- Add write tools only after testing approval boundaries, audit trails, and rollback.
The repository documentation also warns that datasource-related features may not work correctly with Grafana versions earlier than 9.0. Validate the version before debugging the client configuration.
What the agent can do with live telemetry
A useful workflow is not “build me a dashboard.” It is a chain of verifiable questions:
- What is the current error rate and p95 latency for the endpoint I am changing?
- Which labels, traces, and dashboard panels describe the existing behavior?
- What traffic shape should a local or CI test reproduce?
- Did the new code emit the expected telemetry under that traffic?
- Did the change alter an SLO, error budget, cost, or dependency pattern?
Grafana’s AI Week announcement describes gcx as an agentic CLI that manages dashboards, alert rules, datasources, and other resources as code, with GitOps support. InfoQ’s follow-up adds a practical pattern: production dashboard definitions can be pulled into a local Grafana stack, while observed traffic can inform k6 load-test scripts.
This is especially useful for AI-generated code because the agent often lacks the team’s undocumented operational context. A trace can reveal an unexpected downstream call. A log query can expose a retry storm. A latency histogram can invalidate an optimistic test fixture. Those are facts the model should retrieve, not facts it should guess.
Agent Observability closes the second blind spot
The MCP server helps an agent inspect the application. Grafana Agent Observability helps the team inspect the agent. Grafana says Agent Observability is generally available in Grafana Cloud and treats agent sessions as a fifth telemetry signal alongside metrics, logs, traces, and profiles.
Its documented capabilities include observing inputs, outputs, and execution flows; continuously evaluating response quality; guarding against hallucinations, drift, PII exposure, and dangerous tool calls; comparing agent versions; and tracking token cost by agent, model, and session.
That pairs naturally with an existing OpenTelemetry GenAI observability baseline. For MCP-heavy systems, also apply the authorization principles in the MCP security threat-modeling guide, and use structured outputs for reliable AI APIs when an agent’s result feeds an automated test or deployment gate.
Security boundaries that matter
The most important control is not the model’s system prompt. It is the authority represented by the credentials and tools exposed to the model.
Keep production writes outside the first iteration. Separate development and production Grafana instances where possible. Use datasource permissions and folder-level RBAC rather than a broad administrator role. If the MCP server is reachable over SSE or streamable HTTP, configure caller authentication; the project’s v1.1.0 release added an optional bearer-token gate and rejects unauthenticated requests with HTTP 401 when configured.
The release also marks tools with read-only, destructive, and open-world hints. Those hints improve client behavior, but they are not a substitute for server-side authorization. A malicious prompt, poisoned log line, or compromised repository can still try to steer an agent toward an unsafe action. Keep the authorization decision outside the model.
For a broader agent workflow, the harness engineering guide is a useful companion: define deterministic checks, bounded tools, artifacts, and human approval instead of treating an agent transcript as proof.
Performance, cost, and debugging
The main performance benefit is reduced context copying. An agent can query a narrow time range or panel instead of receiving an entire dashboard export in every prompt. The trade-off is query cost and tool-call latency. Prefer focused queries, cache stable dashboard definitions locally, and ask for a batch-friendly result where the tool supports it.
When a workflow fails, debug in this order:
- Confirm the Grafana URL and server version.
- Test the service-account token directly against a harmless read operation.
- Check whether the selected datasource is supported and visible to that account.
- Inspect MCP transport logs and tool arguments.
- Compare the agent’s requested time range, labels, and query with a known-good Grafana query.
- Verify that the resulting telemetry belongs to the current build, not an unrelated environment.
Do not treat a successful tool response as a successful engineering outcome. The final gate should compare behavior against a baseline and require human review for production-impacting changes.
FAQ
Is Grafana MCP a replacement for application monitoring?
No. It is an interface that lets an AI client use Grafana’s monitoring and observability data. You still need instrumentation, useful dashboards, appropriate alerts, access control, and operational ownership.
Should I let a coding agent change Grafana dashboards?
Start with read-only access. Add write tools only in a controlled development project or GitOps workflow where changes are reviewable, versioned, and reversible.
Is the hosted MCP server safer than the open-source server?
Neither is automatically safe. The hosted option reduces infrastructure work and uses OAuth 2.1 scopes. The self-managed option offers more control over deployment and network boundaries. In both cases, least privilege, auditability, and human approval matter more than the label.
What is the best first use case?
Use an agent to inspect a service’s baseline telemetry and generate a realistic test plan for a small change. That produces measurable value without granting the agent authority to modify production.
Conclusion
Grafana’s MCP server makes observability available where AI-generated code is being planned and tested. The strongest pattern is verification-first: retrieve live evidence, implement a bounded change, exercise it under realistic load, inspect the resulting telemetry, and keep a human in control of the merge.
The official documentation and repository are the source of truth for installation, tools, permissions, and release behavior. Start with a read-only pilot on one service, measure query latency and analyst time saved, and expand only when the audit and rollback story is as clear as the demo.
Sources and visual credits
- Grafana Labs: six agentic operations tools reach general availability — primary announcement.
- Grafana open-source MCP server documentation — setup, authentication, tools, and version requirements.
- grafana/mcp-grafana v1.1.0 release — bearer authentication and tool-safety metadata.
- InfoQ: Grafana MCP and gcx reach GA — independent coverage of agentic development workflows.
- Grafana Agent Observability announcement — primary product capabilities.
The architecture diagram is original Mermaid artwork by Essa Mamdani. The comparison table is original editorial synthesis. Product names and referenced interfaces are credited to Grafana Labs; no product screenshot is implied.
Keep reading
Related reading
⚡ Daily AI Model Drop — Get Kimi K3 benchmarks before Twitter
Join 2,400+ AI engineers. 1 email/day, no spam, unsubscribe anytime