L
Health: Not checked yetWe have not completed a health check for this listing yet.No health check has run yet.

Loki Mcp Server

incu6us
šŸ“Š Monitoring
0 Views
0 Installs

šŸŽļø šŸ  šŸŽ 🪟 🐧 - An MCP server for querying Grafana Loki directly with a discovery-first workflow — labels, values, series, and LogQL queries without requiring Grafana.

Quick Install

One-Click IDE Configuration
claude_desktop_config.json
{
  "mcpServers": {
    "incu6us-loki-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "incu6us-loki-mcp-server"
      ]
    }
  }
}
Or

Using an AI coding agent (Claude Code, Cursor, etc.)? Copy a ready-made prompt that tells it to fetch the setup instructions and install this server for you.

Documentation Overview

Loki MCP Server

CI Release codecov Go Report Card License: MIT Stars MCP

loki-mcp-server MCP server

Query Grafana Loki logs directly from AI agents using the Model Context Protocol (MCP).

Built in Go. Enables AI-powered log analysis using LogQL.

Supports integration with:

  • Claude Desktop
  • AI agent frameworks
  • automation tools
  • DevOps workflows

Motivation

The official grafana/loki-mcp exposes a single loki_query tool, which means the LLM must already know valid label names and values before it can build a query. This project takes a different approach by providing 5 granular tools — labels, label_values, and series let the LLM discover what's available in Loki first, then construct precise query_range or query calls. The result is more accurate log retrieval with fewer wasted round-trips.

Additionally, this server enforces strict input validation (limit caps, direction validation, label name format checks, mutually exclusive auth) to surface errors early instead of forwarding bad requests to Loki.

Features

  • query_range — Execute LogQL range queries to fetch logs over a time window
  • query — Execute LogQL instant queries for point-in-time evaluation
  • labels — List all available label names
  • label_values — List values for a specific label
  • series — Find active log stream series matching a selector

Installation

Homebrew

brew install incu6us/tap/loki-mcp-server

Go install

go install github.com/incu6us/loki-mcp-server/cmd/loki-mcp-server@latest

Or build from source:

git clone https://github.com/incu6us/loki-mcp-server.git
cd loki-mcp
go build -o loki-mcp-server ./cmd/loki-mcp-server

Configuration

The server is configured entirely via environment variables, injected by the MCP client.

VariableRequiredDefaultDescription
LOKI_URLyes—Base URL of the Loki instance
LOKI_USERNAMEno—Basic auth username
LOKI_PASSWORDno—Basic auth password
LOKI_BEARER_TOKENno—Bearer token authentication
LOKI_TLS_SKIP_VERIFYnofalseSkip TLS certificate verification
LOKI_TENANT_IDno—X-Scope-OrgID header for multi-tenant deployments
LOKI_HTTP_TIMEOUTno30sHTTP request timeout (Go duration, e.g. 10s, 1m)

Note: Basic auth (LOKI_USERNAME/LOKI_PASSWORD) and bearer token (LOKI_BEARER_TOKEN) are mutually exclusive.

Usage with Claude Code

Add to your Claude Code MCP configuration (~/.claude.json):

{
  "mcpServers": {
    "loki-mcp-server": {
      "type": "stdio",
      "command": "/path/to/loki-mcp-server",
      "args": [],
      "env": {
        "LOKI_URL": "http://loki:3100",
        "LOKI_USERNAME": "admin",
        "LOKI_PASSWORD": "secret"
      }
    }
  }
}

Usage with Claude Desktop

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "loki-mcp-server": {
      "type": "stdio",
      "command": "/path/to/loki-mcp-server",
      "args": [],
      "env": {
        "LOKI_URL": "http://loki:3100",
        "LOKI_USERNAME": "admin",
        "LOKI_PASSWORD": "secret"
      }
    }
  }
}

Tools

query_range

Execute a LogQL range query against Loki to fetch logs over a time window.

ParameterTypeRequiredDefaultDescription
querystringyes—LogQL query expression
startstringno1 hour agoStart of time range (RFC3339 or Unix nano)
endstringnonowEnd of time range
limitnumberno100Max entries (max 5000)
directionstringnobackwardforward or backward

query

Execute a LogQL instant query for point-in-time evaluation.

ParameterTypeRequiredDefaultDescription
querystringyes—LogQL query expression
limitnumberno100Max entries (max 5000)
timestringnonowEvaluation timestamp
directionstringnobackwardforward or backward

labels

List all available label names in Loki.

ParameterTypeRequiredDefaultDescription
startstringno6 hours agoStart of time range
endstringnonowEnd of time range

label_values

List values for a specific label.

ParameterTypeRequiredDefaultDescription
labelstringyes—Label name
startstringno6 hours agoStart of time range
endstringnonowEnd of time range

series

Find active log stream series matching a selector.

ParameterTypeRequiredDefaultDescription
matchstringyes—Stream selector (e.g. {app="nginx"})
startstringno6 hours agoStart of time range
endstringnonowEnd of time range

Local Development Stack

A Docker Compose setup is included under deploy/ to spin up a full Loki environment for testing:

  • Loki — log storage at http://localhost:3100
  • Grafana — UI at http://localhost:3000 (anonymous admin, Loki pre-configured as datasource)
  • Promtail — collects container logs and ships them to Loki
  • Log generator — emits structured JSON logs with randomized apps (nginx, api, gateway, auth, payments), levels, and messages
# Start the stack
docker compose -f deploy/docker-compose.yml up -d

# Use loki-mcp-server against local Loki
LOKI_URL=http://localhost:3100 loki-mcp-server

# Stop the stack
docker compose -f deploy/docker-compose.yml down

Development

# Run tests
go test ./...

# Build
go build -o loki-mcp-server ./cmd/loki-mcp-server

# Vet
go vet ./...

⭐ If this project is useful for you, please star the repository.

Related MCP Servers

M
Mcp Dotnet Diagnostics

šŸ  šŸŽ 🐧 - Live .NET runtime diagnostics for AI assistants. Ask Claude to diagnose memory leaks, GC pressure, LOH fragmentation, and thread starvation in any running .NET process — no code changes required. Install: dotnet tool install -g mcp-dotnet-diagnostics

šŸ“Š Monitoring0 views
C
Cirdan

šŸ šŸ  šŸŽ 🪟 🐧 - AI infrastructure cartographer & MCP server: fingerprints, graphs, and watches the live infrastructure an agent can reach (Docker, Kubernetes, cloud, IaC) and detects incidents.

šŸ“Š Monitoring0 views
A
Agentlens

šŸ“‡ šŸ  ā˜ļø šŸŽ 🪟 🐧 - Tamper-evident observability for AI agents: a SHA-256 hash-chained audit log with chain verification and signed export (EU AI Act Art. 12). Instrument any agent with zero code via npx -y @agentlensai/mcp; also ingests OpenTelemetry GenAI traces.

šŸ“Š Monitoring0 views
O
Openobserve Community Mcp

šŸ šŸ  šŸŽ 🪟 🐧 - Read-only MCP server for OpenObserve Community Edition via REST API. Search logs, traces, stream schemas, and dashboards without requiring the Enterprise license.

šŸ“Š Monitoring0 views
ā˜… Featured

Moxie Docs MCP

MCP & Agent Skills for Automated Documentation, and codebase conventions + context

View ServerFeature your own server →

Own this project?

This directory is pre-filled from public sources. Claim via GitHub README, site badge, or DNS TXT to get the verified badge and attach your website.

Claim this listing

Promote this listing

Optional paid placement. Free listings stay free forever.

Share & Embed

Add our SVG badge (dark/light directory styles) or embeddable widget to your site.