LM

lexfrei/mcp-loki

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

5 stars 3 forks 品質 71 トレンド 33BSD-3-Clause

MCP server for querying Grafana Loki logs

概要

MCP server for querying Grafana Loki logs. Enables LLMs to search and analyze logs via the Model Context Protocol. - — Execute range queries with flexible time ranges - — List labels and their values for query building - — Find log streams matching label selectors - — Get cardinality and size metrics - — Ready-made LogQL patterns for common log analysis tasks - — Basic auth, Bearer token, multi-tenant (X-Scope-OrgID) - — linux/amd64 and linux/arm64 - — Verified with cosign keyless signing All configuration is done via environment variables: Get label names or values for a specific label. Find log streams matching label selectors. Check if Loki is ready to accept requests. No parameters required. Get Loki server configuration in YAML format. No parameters required. Find error logs for a specific application.

README

以下は原文 README の抜粋です。原文を見る。

MCP Loki

MCP server for querying Grafana Loki logs. Enables LLMs to search and analyze logs via the Model Context Protocol.

Features

  • LogQL Queries — Execute range queries with flexible time ranges
  • Label Discovery — List labels and their values for query building
  • Series Exploration — Find log streams matching label selectors
  • Index Statistics — Get cardinality and size metrics
  • Prompt Templates — Ready-made LogQL patterns for common log analysis tasks
  • Multiple Auth Methods — Basic auth, Bearer token, multi-tenant (X-Scope-OrgID)
  • Multi-arch Images — linux/amd64 and linux/arm64
  • Signed Images — Verified with cosign keyless signing

Quick Start

Container (Podman/Docker)

Add to your MCP client configuration:

{
  "mcpServers": {
    "loki": {
      "command": "podman",
      "args": [
        "run", "--rm", "-i",
        "-e", "LOKI_URL=http://loki:3100",
        "ghcr.io/lexfrei/mcp-loki:latest"
      ]
    }
  }
}

Go Install

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

MCP client configuration:

{
  "mcpServers": {
    "loki": {
      "command": "mcp-loki",
      "env": {
        "LOKI_URL": "http://loki:3100"
      }
    }
  }
}

Configuration

All configuration is done via environment variables:

Variable Required Default Description
LOKI_URL No http://localhost:3100 Loki server URL
LOKI_USERNAME No — Basic auth username
LOKI_PASSWORD No — Basic auth password
LOKI_TOKEN No — Bearer token (alternative to basic auth)
LOKI_ORG_ID No — X-Scope-OrgID header for multi-tenant Loki
MCP_HTTP_PORT No — Enable HTTP SSE transport on this port

Authentication Examples

No authentication (local Loki):

{
  "command": "podman",
  "args": [
    "run", "--rm", "-i",
    "-e", "LOKI_URL=http://loki:3100",
    "ghcr.io/lexfrei/mcp-loki:latest"
  ]
}

Basic authentication:

{
  "command": "podman",
  "args": [
    "run", "--rm", "-i",
    "-e", "LOKI_URL=https://loki.example.com",
    "-e", "LOKI_USERNAME=admin",
    "-e", "LOKI_PASSWORD=secret",
    "ghcr.io/lexfrei/mcp-loki:latest"
  ]
}

Bearer token (Grafana Cloud):

{
  "command": "podman",
  "args": [
    "run", "--rm", "-i",
    "-e", "LOKI_URL=https://logs-prod-us-central1.grafana.net",
    "-e", "LOKI_TOKEN=glc_xxx",
    "-e", "LOKI_ORG_ID=123456",
GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

{ "mcpServers": { "loki": { "command": "podman", "args": [ "run", "--rm", "-i", "-e", "LOKI_URL=http://loki:3100", "ghcr.io/lexfrei/mcp-loki:latest" ] } } }