Skip to main content

Grafana Loki MCP Server

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elad12390_loki_mcp-0.1.4.tar.gz (5.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elad12390_loki_mcp-0.1.4-py3-none-any.whl (5.4 MB view details)

Uploaded Python 3

File details

Details for the file elad12390_loki_mcp-0.1.4.tar.gz.

File metadata

  • Download URL: elad12390_loki_mcp-0.1.4.tar.gz
  • Upload date:
  • Size: 5.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for elad12390_loki_mcp-0.1.4.tar.gz
Algorithm Hash digest
SHA256 c458e03df906cc9ccd8131333d877cb7876bf2bbeda0be328a94b002f898dd0b
MD5 5229edee5d0ad29f4bf2fe263d1d28ee
BLAKE2b-256 1f448378c2730d47d9f4155de3eab725709b2d4e9b8903cf5375e734fc027b46

See more details on using hashes here.

File details

Details for the file elad12390_loki_mcp-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for elad12390_loki_mcp-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1df58bdb6f74900bda186f3e8f391de158d8769c31fd666384064a197bfde32e
MD5 d09e8b6558309389983768a4b1408444
BLAKE2b-256 d5d2383c20fa478b44c7a9df37bf5579e3295d3fa4b9b2c7797fdbf0add95c44

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page