Skip to main content
Glama
piotr-szybicki

Local Loki MCP server

本地 Loki MCP 服务器

一个用于本地 Grafana Loki 实例的小型只读 MCP 服务器。它使用 FastAPI 和官方 MCP Python SDK 构建。

它提供的内容

  • search_logs(service, start, end, text=None) — 在必需的 RFC 3339 时间范围内搜索必需的服务和可选的文字文本。

  • list_services(start, end) — 列出可用的服务标签值。

  • loki_health() — 检查 Loki 是否就绪。

公共工具没有 limit 参数。请求也省略了 Loki 的 limit 查询参数,因此应用 Loki 自身配置的默认值/最大值。

Related MCP server: grafana-mcp

运行

  1. 安装 Python 3.11 或更高版本,然后创建并激活虚拟环境。

py -3.11 -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
  1. 如果默认值不符合你的设置,请在 shell 中设置环境变量。.env.example 列出了可用的设置。默认值期望 Loki 位于 http://127.0.0.1:3100,并使用 service_name 标签。

  2. 启动服务器。

uvicorn main:app --reload

MCP Streamable HTTP 端点是 http://127.0.0.1:8000/mcp。服务器自身的健康检查端点是 http://127.0.0.1:8000/health

示例

使用以下参数调用 search_logs

{
  "service": "checkout",
  "text": "connection refused",
  "start": "2026-08-26T08:00:00Z",
  "end": "2026-08-26T09:00:00Z"
}

会生成以下 LogQL 查询:

{service_name="checkout"} |= "connection refused"

如果你的标签改用 app,请使用 $env:LOKI_SERVICE_LABEL = "app" 启动服务器。

F
license - not found
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables querying and formatting Loki logs from Grafana via the Model Context Protocol. It supports LogQL queries, label retrieval, and provides results in text, JSON, or markdown formats.
    29
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    This MCP server enables natural-language querying of Grafana logs by automatically detecting log sources and service labels. It provides read-only access to log data with intelligent caching for efficient repeat queries.
    23
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Enables querying OpenTelemetry logs stored in OpenSearch across development and production environments. Provides tools for searching logs by various criteria including free-text Lucene queries, trace IDs, service names, error levels, and specific fields.
    8
  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides read-only access to Loki, Prometheus, and Tempo APIs, enabling natural language queries for logs, metrics, and traces. Supports multiple instances and authentication via bearer tokens.
    1
    MIT

View all related MCP servers

Related MCP Connectors

  • Read-only access to Auralogs production logs: search logs, inspect errors, review AI analyses.

  • MEOK ABCI Bridge MCP — read-only Tendermint / Cosmos blockchain query for agents. Built-in registry

  • Software component catalog: search your org's services, docs, APIs, dependencies, and ownership.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/piotr-szybicki/local-grafana-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server