Skip to main content
Glama

Grafana

Official
by grafana
Apache 2.0
1,633
  • Linux
  • Apple

Grafana MCP server

A (MCP) server for Grafana.

This provides access to your Grafana instance and the surrounding ecosystem.

Features

  • Search for dashboards

  • Dashboards

    • Get dashboard by UID

    • Update or create a dashboard (DISCLAIMER: Be careful with context windows. See https://github.com/grafana/mcp-grafana/issues/101 for details)

    • Get the title, query string, and datasource information (including UID and type, if available) from every panel in a dashboard

  • List and fetch datasource information

  • Query datasources

    • Prometheus

    • Loki

      • Log queries

      • Metric queries

    • Tempo

    • Pyroscope

  • Query Prometheus metadata

    • Metric metadata

    • Metric names

    • Label names

    • Label values

  • Query Loki metadata

    • Label names

    • Label values

    • Stats

  • Search, create, update and close incidents

  • Start Sift investigations and view the results

    • Create Investigations

    • List Investigations with a limit parameter

    • Get Investigation

    • Get Analyses

    • Find error patterns in logs using Sift

    • Find slow requests using Sift

    • Add tools on the other Sift Checks

  • Alerting

    • List and fetch alert rule information

    • Get alert rule statuses (firing/normal/error/etc.)

    • Create and change alert rules

    • List contact points

    • Create and change contact points

  • Access Grafana OnCall functionality

    • List and manage schedules

    • Get shift details

    • Get current on-call users

    • List teams and users

    • List alert groups

  • Admin functionality

    • List users

    • List teams

    • List roles

    • List assignments of roles

    • Debug role assignments

The list of tools is configurable, so you can choose which tools you want to make available to the MCP client. This is useful if you don't use certain functionality or if you don't want to take up too much of the context window. To disable a category of tools, use the --disable-<category> flag when starting the server. For example, to disable the OnCall tools, use --disable-oncall.

Tools

Tool

Category

Description

list_teams

Admin

List all teams

search_dashboards

Search

Search for dashboards

get_dashboard_by_uid

Dashboard

Get a dashboard by uid

update_dashboard

Dashboard

Update or create a new dashboard

get_dashboard_panel_queries

Dashboard

Get panel title, queries, datasource UID and type from a dashboard

list_datasources

Datasources

List datasources

get_datasource_by_uid

Datasources

Get a datasource by uid

get_datasource_by_name

Datasources

Get a datasource by name

query_prometheus

Prometheus

Execute a query against a Prometheus datasource

list_prometheus_metric_metadata

Prometheus

List metric metadata

list_prometheus_metric_names

Prometheus

List available metric names

list_prometheus_label_names

Prometheus

List label names matching a selector

list_prometheus_label_values

Prometheus

List values for a specific label

list_incidents

Incident

List incidents in Grafana Incident

create_incident

Incident

Create an incident in Grafana Incident

add_activity_to_incident

Incident

Add an activity item to an incident in Grafana Incident

resolve_incident

Incident

Resolve an incident in Grafana Incident

query_loki_logs

Loki

Query and retrieve logs using LogQL (either log or metric queries)

list_loki_label_names

Loki

List all available label names in logs

list_loki_label_values

Loki

List values for a specific log label

query_loki_stats

Loki

Get statistics about log streams

list_alert_rules

Alerting

List alert rules

get_alert_rule_by_uid

Alerting

Get alert rule by UID

list_oncall_schedules

OnCall

List schedules from Grafana OnCall

get_oncall_shift

OnCall

Get details for a specific OnCall shift

get_current_oncall_users

OnCall

Get users currently on-call for a specific schedule

list_oncall_teams

OnCall

List teams from Grafana OnCall

list_oncall_users

OnCall

List users from Grafana OnCall

get_investigation

Sift

Retrieve an existing Sift investigation by its UUID

get_analysis

Sift

Retrieve a specific analysis from a Sift investigation

list_investigations

Sift

Retrieve a list of Sift investigations with an optional limit

find_error_pattern_logs

Sift

Finds elevated error patterns in Loki logs.

find_slow_requests

Sift

Finds slow requests from the relevant tempo datasources.

Usage

  1. Create a service account in Grafana with enough permissions to use the tools you want to use, generate a service account token, and copy it to the clipboard for use in the configuration file. Follow the for details.

  2. You have several options to install mcp-grafana:

    • Docker image: Use the pre-built Docker image from Docker Hub:

      docker pull mcp/grafana docker run -p 8000:8000 -e GRAFANA_URL=http://localhost:3000 -e GRAFANA_API_KEY=<your service account token> mcp/grafana
    • Download binary: Download the latest release of mcp-grafana from the releases page and place it in your $PATH.

    • Build from source: If you have a Go toolchain installed you can also build and install it from source, using the GOBIN environment variable to specify the directory where the binary should be installed. This should also be in your PATH.

      GOBIN="$HOME/go/bin" go install github.com/grafana/mcp-grafana/cmd/mcp-grafana@latest
  3. Add the server configuration to your client configuration file. For example, for Claude Desktop:

    If using the binary:

    { "mcpServers": { "grafana": { "command": "mcp-grafana", "args": [], "env": { "GRAFANA_URL": "http://localhost:3000", "GRAFANA_API_KEY": "<your service account token>" } } } }

    If using Docker:

    { "mcpServers": { "grafana": { "command": "docker", "args": [ "run", "--rm", "-p", "8000:8000", "-e", "GRAFANA_URL", "-e", "GRAFANA_API_KEY", "mcp/grafana" ], "env": { "GRAFANA_URL": "http://localhost:3000", "GRAFANA_API_KEY": "<your service account token>" } } } }

Note: if you see Error: spawn mcp-grafana ENOENT in Claude Desktop, you need to specify the full path to mcp-grafana.

Using VSCode with remote MCP server

Make sure your .vscode/settings.json includes:

"mcp": { "servers": { "grafana": { "type": "sse", "url": "http://localhost:8000/sse" } } }

Debug Mode

You can enable debug mode for the Grafana transport by adding the -debug flag to the command. This will provide detailed logging of HTTP requests and responses between the MCP server and the Grafana API, which can be helpful for troubleshooting.

To use debug mode with the Claude Desktop configuration, update your config as follows:

If using the binary:

{ "mcpServers": { "grafana": { "command": "mcp-grafana", "args": ["-debug"], "env": { "GRAFANA_URL": "http://localhost:3000", "GRAFANA_API_KEY": "<your service account token>" } } } }

If using Docker:

{ "mcpServers": { "grafana": { "command": "docker", "args": [ "run", "--rm", "-p", "8000:8000", "-e", "GRAFANA_URL", "-e", "GRAFANA_API_KEY", "mcp/grafana", "-debug" ], "env": { "GRAFANA_URL": "http://localhost:3000", "GRAFANA_API_KEY": "<your service account token>" } } } }

Development

Contributions are welcome! Please open an issue or submit a pull request if you have any suggestions or improvements.

This project is written in Go. Install Go following the instructions for your platform.

To run the server, use:

make run

You can also run the server using the SSE transport inside a custom built Docker image. To build the image, use

make build-image

And to run the image, use:

docker run -it --rm -p 8000:8000 mcp-grafana:latest

Testing

There are three types of tests available:

  1. Unit Tests (no external dependencies required):

make test-unit

You can also run unit tests with:

make test
  1. Integration Tests (requires docker containers to be up and running):

make test-integration
  1. Cloud Tests (requires cloud Grafana instance and credentials):

make test-cloud

Note: Cloud tests are automatically configured in CI. For local development, you'll need to set up your own Grafana Cloud instance and credentials.

More comprehensive integration tests will require a Grafana instance to be running locally on port 3000; you can start one with Docker Compose:

docker-compose up -d

The integration tests can be run with:

make test-all

If you're adding more tools, please add integration tests for them. The existing tests should be a good starting point.

Linting

To lint the code, run:

make lint

This includes a custom linter that checks for unescaped commas in jsonschema struct tags. The commas in description fields must be escaped with \\, to prevent silent truncation. You can run just this linter with:

make lint-jsonschema

See the JSONSchema Linter documentation for more details.

License

This project is licensed under the Apache License, Version 2.0.

-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

A Model Context Protocol (MCP) server for Grafana.

This provides access to your Grafana instance and the surrounding ecosystem.

  1. Features
    1. Tools
  2. Usage
    1. Debug Mode
  3. Development
    1. Testing
    2. Linting
  4. License

    Related MCP Servers

    • A
      security
      A
      license
      A
      quality
      A beginner-friendly Model Context Protocol (MCP) server that helps users understand MCP concepts, provides interactive examples, and lists available MCP servers. This server is designed to be a helpful companion for developers working with MCP. Also comes with a huge list of servers you can install.
      Last updated -
      3
      16
      63
      Apache 2.0
    • -
      security
      A
      license
      -
      quality
      MCP Server simplifies the implementation of the Model Context Protocol by providing a user-friendly API to create custom tools and manage server workflows efficiently.
      Last updated -
      3
      4
      MIT License
    • -
      security
      A
      license
      -
      quality
      MCP Server provides a simpler API to interact with the Model Context Protocol by allowing users to define custom tools and services to streamline workflows and processes.
      Last updated -
      6
      3
      MIT License
    • A
      security
      A
      license
      A
      quality
      A Model Context Protocol (MCP) server designed to easily dump your codebase context into Large Language Models (LLMs).
      Last updated -
      1
      24
      2
      Apache 2.0

    View all related MCP servers

    MCP directory API

    We provide all the information about MCP servers via our MCP API.

    curl -X GET 'https://glama.ai/api/mcp/v1/servers/grafana/mcp-grafana'

    If you have feedback or need assistance with the MCP directory API, please join our Discord server