Sponsored by Deepsite.site

Grafana MCP

Created By
izaitsevfb6 months ago
MCP server for grafana
Content

Grafana MCP

This project provides MCP server for Grafana, including MCP tools to interact with Grafana dashboards, data sources, alerts, and more.

The package includes a dashboard template resource that is properly bundled with the package for use when installed.

Usage

Installation

  1. Create a virtual environment (recommended)
python -m venv venv
source venv/bin/activate
  1. Install this package directly from GitHub using pip:
pip install -e git+https://github.com/izaitsevfb/grafana-mcp.git#egg=grafana_mcp

(Alternatively, you can install it locally with pip install -e .)

  1. Configure Grafana authentication

Create a .env file with your Grafana URL and API token:

cp .env.example .env

Then edit the .env file to add your actual Grafana URL and API token:

GRAFANA_URL=http://your-grafana-server:3000
GRAFANA_API_TOKEN=your-api-token-here

You can generate an API token in Grafana by navigating to: Configuration → API Keys → New API key.

  1. After installation, the MCP server can be run as:
python -m grafana_mcp
  1. Add this MCP server to Claude Code:
claude mcp add-json grafana '{ "type": "stdio", "command": "python", "args": [ "-m", "grafana_mcp" ], "env": {} }'

Note: By default, MCP config applies only to the current directory. If you want to use it globally, add --scope user to the command above:

claude mcp add-json --scope user grafana '{ "type": "stdio", "command": "python", "args": [ "-m", "grafana_mcp" ], "env": {} }'
  1. Run Claude Code as usual:
claude

Development

Development Installation

  1. Clone the repository
  2. Install in development mode:
    pip install -e .
    

The package uses Python's package resource management system to include the dashboard template. The dashboard.json file is stored in the src/grafana_mcp/ directory and is accessed using importlib.resources when the package is installed.

Testing

Run unit tests:

python -m unittest discover tests

For testing with token authentication, ensure you have created a .env file with your Grafana credentials as described above. The test suite includes mocked tests that don't require an actual Grafana instance.

Tools

The Grafana MCP provides the following tools:

Available Tools

Dashboard Management

  • get_grafana_info(): Get information about the connected Grafana instance including version and connection status
  • list_dashboards(): List all dashboards from the connected Grafana instance
  • get_dashboard(uid): Get details about a specific dashboard by UID

Organization Management

  • get_organization(): Get information about the current organization

Data Source Management

  • list_datasources(): List all available data sources

Requirements

  • grafana-client: Python client for Grafana API
  • python-dotenv: For loading environment variables from .env file
  • mcp: Model Context Protocol server implementation

Authentication

This package uses token authentication with the Grafana API. To configure authentication:

  1. In your Grafana instance, create an API key with appropriate permissions
  2. Create a .env file with the following variables:
    GRAFANA_URL=http://your-grafana-url:3000
    GRAFANA_API_TOKEN=your-api-token-here
    
  3. The MCP server will automatically load these credentials when started

More tools and features will be added in future versions.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
WindsurfThe new purpose-built IDE to harness magic
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Amap Maps高德地图官方 MCP Server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Tavily Mcp
Serper MCP ServerA Serper MCP Server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Playwright McpPlaywright MCP server
ChatWiseThe second fastest AI chatbot™
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
CursorThe AI Code Editor
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
DeepChatYour AI Partner on Desktop
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.