Local Loki MCP server
Provides tools for searching logs in a Grafana Loki instance, filtering by service and text, listing service-label values, and checking Loki's health.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Local Loki MCP serverSearch logs for checkout service for connection refused in the last hour"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Local Loki MCP server
A small, read-only MCP server for a local Grafana Loki instance. It is built with FastAPI and the official MCP Python SDK.
What it exposes
search_logs(service, start, end, text=None)— searches a required service and optional literal text within a required RFC 3339 time range.list_services(start, end)— lists the available service-label values.loki_health()— checks whether Loki is ready.
The public tool has no limit parameter. The request also omits Loki's
limit query parameter, so Loki's own configured default/maximum applies.
Related MCP server: grafana-mcp
Run it
Install Python 3.11 or newer, then create and activate a virtual environment.
py -3.11 -m venv .venv .\.venv\Scripts\Activate.ps1 pip install -r requirements.txtSet environment variables in your shell if the defaults do not match your setup.
.env.examplelists the available settings. The defaults expect Loki athttp://127.0.0.1:3100and aservice_namelabel.Start the server.
uvicorn main:app --reload
The MCP Streamable HTTP endpoint is http://127.0.0.1:8000/mcp. The server's
own health endpoint is http://127.0.0.1:8000/health.
Example
Calling search_logs with:
{
"service": "checkout",
"text": "connection refused",
"start": "2026-08-26T08:00:00Z",
"end": "2026-08-26T09:00:00Z"
}generates this LogQL query:
{service_name="checkout"} |= "connection refused"If your labels use app instead, start the server with
$env:LOKI_SERVICE_LABEL = "app".
This server cannot be deployed
Maintenance
Related MCP Connectors
Read-only access to Auralogs production logs: search logs, inspect errors, review AI analyses.
Read-only access to a Lumin project's logs, metrics, uptime checks, alerts and infrastructure.
Ingest and search LogsLoom logs from coding agents.
Read-only routing for Zinvyl freight workflow audits and API failure diagnosis.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables 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.70 PyPI29MIT
- AlicenseNot gradedqualityDmaintenanceThis 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.22 npmMIT
- FlicenseAqualityDmaintenanceEnables 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-
- AlicenseNot gradedqualityCmaintenanceProvides 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.1MIT