Grafana-Loki MCP Server

by tumf

29 277 downloads Not rated yet MIT

About

A server for querying Loki logs from Grafana.

Details

License
MIT

Explore

- Query Loki logs through Grafana API
- Get Loki labels and label values
- Format query results in different formats (text, JSON, markdown)
- Support for both stdio and SSE transport protocols

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Grafana-Loki MCP Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

- Python 3.10+
- FastMCP
- Requests

1. Clone this repository
2. Install dependencies using uv:


pip install uv

uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate

uv pip install -e ".[dev]"

Set the following environment variables:

- GRAFANA_URL: URL of your Grafana instance
- GRAFANA_API_KEY: Grafana API key with appropriate permissions


export GRAFANA_URL=https://your-grafana-instance.com
export GRAFANA_API_KEY=your-api-key
grafana-loki-mcp

python

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "grafana-loki mcp server": {
            "grafana-loki-mcp": {
                "command": "uv",
                "args": [
                    "venv"
                ]
            }
        }
    }
}

McpServers

{
    "grafana-loki-mcp": {
        "command": "uv",
        "args": [
            "venv"
        ]
    }
}

Test
PyPI version
codecov
License: MIT

A FastMCP server that allows querying Loki logs from Grafana.

MCP Server Settings

{
  "mcpServers": {
    "loki": {
      "command": "uvx",
      "args": [
        "grafana-loki-mcp",
        "-u",
        "GRAFANA_URL",
        "-k",
        "GRAFANA_API_KEY"
      ]
    }
  }
}

- GRAFANA_URL: URL of your Grafana instance
- GRAFANA_API_KEY: Grafana API key with appropriate permissions

Features

- Query Loki logs through Grafana API
- Get Loki labels and label values
- Format query results in different formats (text, JSON, markdown)
- Support for both stdio and SSE transport protocols

Requirements

- Python 3.10+
- FastMCP
- Requests

Installation

Using pip

pip install grafana-loki-mcp

Development Setup

1. Clone this repository
2. Install dependencies using uv:

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.

Videos about Grafana-Loki MCP Server

Relevant YouTube tutorials, setups, and demos