Grafana-Loki MCP Server

by tumf

29 stars
277 downloads
Not rated
GitHub

About

A server for querying Loki logs from Grafana.

Details

Author
tumf
GitHub stars
29
Downloads
277
Categories
Developer Tools, Other, Infrastructure

- Query Loki logs through the Grafana API
- Retrieve Loki label names and label values
- Format query results as text, JSON, or markdown
- Supports stdio and SSE transport protocols
- Accepts Grafana-style relative time ranges (e.g., now-1h)
- Limits log line length per entry (configurable max per line)

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

Install via pip install grafana-loki-mcp or run with uvx grafana-loki-mcp. Configure it by setting the GRAFANA_URL and GRAFANA_API_KEY environment variables, or pass them as command-line arguments (-u and -k). The server supports both stdio and SSE transport protocols.

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"
        ]
    }
}

Grafana-Loki MCP Server

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.