Go-based MCP server for discovering and querying Grafana Loki logs with LogQL, without requiring Grafana.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
One-click editor setup isnβt available for this listing yet β we donβt have a confirmed install command, and weβd rather show nothing than point your editor at the wrong package or host. Follow the projectβs own setup instructions, linked above.
Inspect callable tools, capabilities, and parameters exposed to AI agents by Loki MCP Server.
Query Grafana Loki logs directly from AI agents using the Model Context Protocol (MCP).
Built in Go. Enables AI-powered log analysis using LogQL.
Supports integration with:
The official grafana/loki-mcp exposes a single loki_query tool, which means the LLM must already know valid label names and values before it can build a query. This project takes a different approach by providing 5 granular tools β labels, label_values, and series let the LLM discover what's available in Loki first, then construct precise query_range or query calls. The result is more accurate log retrieval with fewer wasted round-trips.
Additionally, this server enforces strict input validation (limit caps, direction validation, label name format checks, mutually exclusive auth) to surface errors early instead of forwarding bad requests to Loki.
Or build from source:
The server is configured entirely via environment variables, injected by the MCP client.
| Variable | Required | Default | Description |
|---|---|---|---|
LOKI_URL | yes | β | Base URL of the Loki instance |
LOKI_USERNAME | no | β | Basic auth username |
LOKI_PASSWORD | no | β | Basic auth password |
LOKI_BEARER_TOKEN | no | β | Bearer token authentication |
LOKI_TLS_SKIP_VERIFY | no | false | Skip TLS certificate verification |
LOKI_TENANT_ID | no | β | X-Scope-OrgID header for multi-tenant deployments |
LOKI_HTTP_TIMEOUT | no | 30s | HTTP request timeout (Go duration, e.g. 10s, 1m) |
MCP_HTTP_ADDR | no | β | Listen address for the streamable HTTP transport, e.g. :8080. Unset means stdio |
Note: Basic auth (
LOKI_USERNAME/LOKI_PASSWORD) and bearer token (LOKI_BEARER_TOKEN) are mutually exclusive.
By default the server speaks MCP over stdio, which is what Claude Code, Claude Desktop and most local clients expect.
Set MCP_HTTP_ADDR to serve the streamable HTTP transport instead, for running the
server as a remote endpoint behind a proxy or gateway:
The HTTP mode is stateless, so it can run behind a load balancer with several replicas.
It carries no authentication of its own β put it behind TLS and an authenticating proxy
before exposing it, and remember that whoever reaches the endpoint can read every log
line the configured LOKI_URL credentials can see.
Add to your Claude Code MCP configuration (~/.claude.json):
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
Execute a LogQL range query against Loki to fetch logs over a time window.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
query | string | yes | β | LogQL query expression |
start | string | no | 1 hour ago | Start of time range (RFC3339 or Unix nano) |
end | string | no | now | End of time range |
limit | number | no | 100 | Max entries (max 5000) |
direction | string | no | backward | forward or backward |
Execute a LogQL instant query for point-in-time evaluation.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
query | string | yes | β | LogQL query expression |
limit | number | no | 100 | Max entries (max 5000) |
time | string | no | now | Evaluation timestamp |
direction | string | no | backward | forward or backward |
List all available label names in Loki.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
start | string | no | 6 hours ago | Start of time range |
end | string | no | now | End of time range |
List values for a specific label.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
label | string | yes | β | Label name |
start | string | no | 6 hours ago | Start of time range |
end | string | no | now | End of time range |
Find active log stream series matching a selector.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
match | string | yes | β | Stream selector (e.g. {app="nginx"}) |
start | string | no | 6 hours ago | Start of time range |
end | string | no | now | End of time range |
A Docker Compose setup is included under deploy/ to spin up a full Loki environment for testing:
http://localhost:3100http://localhost:3000 (anonymous admin, Loki pre-configured as datasource)nginx, api, gateway, auth, payments), levels, and messagesβ If this project is useful for you, please star the repository.
Factual signals from GitHub, npm, and our automated checks β not a rating.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/incu6us-loki-mcp-server)<a href="https://allmcps.com/mcp/incu6us-loki-mcp-server"><img src="https://allmcps.com/api/badge/incu6us-loki-mcp-server?style=directory" alt="Loki MCP Server on AllMCPs" /></a>