Skip to main content

Loki MCP Server

CI

A Go-based server implementation for the Model Context Protocol (MCP) with Grafana Loki integration.

Quick Start (Recommended)

Run the server directly with a single command using uvx or pipx. No manual build or Docker required (requires Go 1.24+).

# Using uvx
uvx elad12390-loki-mcp

# Using pipx
pipx run elad12390-loki-mcp

This will automatically download, compile, and run the server.

Configuration

The server is configured via environment variables. You can pass these when running the command:

  • LOKI_URL: Loki server URL (default: http://localhost:3100)
  • LOKI_ORG_ID: Default organization ID (X-Scope-OrgID)
  • LOKI_USERNAME: Basic auth username
  • LOKI_PASSWORD: Basic auth password
  • LOKI_TOKEN: Bearer token

Example with Claude Desktop config:

{
  "mcpServers": {
    "loki": {
      "command": "uvx",
      "args": ["elad12390-loki-mcp"],
      "env": {
        "LOKI_URL": "https://logs-prod-us-central1.grafana.net",
        "LOKI_USERNAME": "your-username",
        "LOKI_PASSWORD": "your-password"
      }
    }
  }
}

Features

The loki_query tool allows you to query Grafana Loki log data:

  • Query: LogQL query string (required)
  • Time Range: start and end times (default: last 1 hour)
  • Limit: Max entries (default: 100)
  • Org ID: Multi-tenant organization support

Example Queries:

  • "Find error logs from the last hour in Loki using query {job="varlogs"} |= "ERROR""
  • "Show me the most recent 50 logs from Loki with job=varlogs"
  • "Query Loki for logs with org 'tenant-123' using query {job="varlogs"}"

Development

If you want to contribute or build manually:

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

# Run
./loki-mcp-server

Docker

docker build -t loki-mcp-server .
docker run --rm -i loki-mcp-server

License

MIT License

Metadata

Release files for elad12390-loki-mcp 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for elad12390-loki-mcp 0.1.5
File Size Uploaded
elad12390_loki_mcp-0.1.5.tar.gz 5.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for elad12390-loki-mcp 0.1.5
File Interpreter ABI Platform
elad12390_loki_mcp-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 10.8 MB

Release files / elad12390_loki_mcp-0.1.5.tar.gz

Download URL elad12390_loki_mcp-0.1.5.tar.gz
Size 5.4 MB
Tags Source
SHA-256 checksum
How to use checksums
305152eea95ac68382c99d68267e1cc6a9f0ec9c2754b4df1ccc16648a01762c
BLAKE2b-256 checksum
How to use checksums
c1034038961a50861793d633fad8f61bf79a85a6c2081f7c5d82aa56f23cb5e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.8

Release files / elad12390_loki_mcp-0.1.5-py3-none-any.whl

Download URL elad12390_loki_mcp-0.1.5-py3-none-any.whl
Size 5.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
1b1ae68781b7aafaaa5eb453aaf95d60e1aba8d14aca9e26d7d63b8da3d88231
BLAKE2b-256 checksum
How to use checksums
2d926ea8566b79e25af4b5ba60041b36ba5349ce5295cca8b6759f20d170386f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.8

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page