# Grafana (MCP Server)

> Search dashboards and query Prometheus, Loki and more in Grafana

- Type: MCP server
- Publisher: Grafana Labs (official)
- Categories: DevOps & Cloud, Data & Analytics
- Website: https://github.com/grafana/mcp-grafana
- Source: https://github.com/grafana/mcp-grafana
- Transport: stdio
- Launch command: uvx mcp-grafana
- Sign-in: api-key
- Environment variables: GRAFANA_URL, GRAFANA_SERVICE_ACCOUNT_TOKEN
- GitHub stars: 3500
- Listed: 2025-03-01

## About

Grafana's official MCP server provides access to a Grafana instance and its ecosystem: dashboards, datasources, Prometheus and Loki queries, SQL datasources, alerting, incidents and OnCall schedules. It runs via uvx, Docker or binary and authenticates with a Grafana service account token.

## Install

1. **Add the server to Codex**

   Codex CLI:

   ```bash
   codex mcp add grafana --env GRAFANA_URL=YOUR_GRAFANA_URL --env GRAFANA_SERVICE_ACCOUNT_TOKEN=YOUR_GRAFANA_SERVICE_ACCOUNT_TOKEN -- uvx mcp-grafana
   ```

   config.toml:

   ```toml
   [mcp_servers.grafana]
   command = "uvx"
   args = ["mcp-grafana"]
   
   [mcp_servers.grafana.env]
   GRAFANA_URL = "YOUR_GRAFANA_URL"
   GRAFANA_SERVICE_ACCOUNT_TOKEN = "YOUR_GRAFANA_SERVICE_ACCOUNT_TOKEN"
   ```

   Agents SDK:

   ```python
   from agents import Agent, Runner
   from agents.mcp import MCPServerStdio
   
   async with MCPServerStdio(
       name="Grafana",
       params={"command": "uvx", "args": ["mcp-grafana"]},
   ) as server:
       agent = Agent(name="Assistant", mcp_servers=[server])
       result = await Runner.run(agent, "Find the dashboard for the payments service")
       print(result.final_output)
   ```

## Tools

- `search_dashboards`
- `get_dashboard_by_uid`
- `list_datasources`
- `query_prometheus`
- `query_loki_logs`
- `query_sql`
- `alerting_rules_read`
- `list_incidents`
- `create_incident`
- `list_oncall_schedules`
- `get_panel_image`
- `generate_deeplink`

## Example prompts

- "Find the dashboard for the payments service"
- "Query Prometheus for HTTP 5xx rate over the last hour"
- "Search Loki logs for 'connection refused' in the api namespace"
- "Who is on call for the platform team right now?"

## Also available as

- app: [Grafana Cloud](https://chatgptplugins.directory/apps/grafana-cloud.md)

## Related

- [GitHub](https://chatgptplugins.directory/mcp/github.md): Manage repos, issues, pull requests and Actions from your AI agent
- [Supabase](https://chatgptplugins.directory/mcp/supabase.md): Manage Supabase databases, migrations, edge functions and logs
- [Sentry](https://chatgptplugins.directory/mcp/sentry.md): Search Sentry errors, issues and traces and debug them with Seer
- [Graphiti MCP](https://chatgptplugins.directory/mcp/graphiti.md): Temporal knowledge graph memory for agents, by Zep
- [Cloudflare API](https://chatgptplugins.directory/mcp/cloudflare-api.md): Access 2,500+ Cloudflare API endpoints through two Code Mode tools
- [Vercel](https://chatgptplugins.directory/mcp/vercel.md): Manage Vercel projects, deployments, logs and docs from AI tools

---
Source: https://chatgptplugins.directory/mcp/grafana · Index: https://chatgptplugins.directory/llms.txt · Independent and community-run. Not affiliated with or endorsed by OpenAI. ChatGPT is a trademark of OpenAI.
