MCP Server for Grafana Loki log exploration, LogQL queries, and schema discovery
517
Let your AI assistant explore and analyze logs in Grafana Loki: discover labels and structured metadata, write bounded LogQL queries, summarize service errors, compare log patterns across releases, correlate trace IDs, and spot high-volume log streams.
latest, 0.2.1linux/amd64, linux/arm64talkops-loki-mcp-serverloki:// for structured context discovery/app/skills (browse on GitHub)linux/amd64, linux/arm64) with built-in query byte and time-window guardrails.MCP_ALLOW_WRITE=true.stdio)Use this configuration in Claude Desktop, Cursor, Windsurf, or VS Code (mcp.json / claude_desktop_config.json):
{
"mcpServers": {
"loki": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"MCP_TRANSPORT=stdio",
"-e",
"LOKI_URL",
"talkopsai/loki-mcp-server:latest"
],
"env": {
"LOKI_URL": "http://host.docker.internal:3100"
}
}
}
}
Using Claude Code? Register it in one command:
claude mcp add loki -e LOKI_URL=http://host.docker.internal:3100 -- docker run -i --rm -e MCP_TRANSPORT=stdio -e LOKI_URL talkopsai/loki-mcp-server:latest
Restart your MCP client and try asking:
checkout service logging in the last 30 minutes?"4bf92f3577b34da6a3ce929d0e0e4736."By default (MCP_TRANSPORT=http), the container starts an MCP Streamable HTTP server on port 8770 so multiple clients can share a single instance:
docker run --rm -p 8770:8770 \
-e LOKI_URL=http://host.docker.internal:3100 \
talkopsai/loki-mcp-server:latest
Point your MCP client at http://localhost:8770/mcp:
{
"mcpServers": {
"loki": {
"url": "http://localhost:8770/mcp"
}
}
}
Out of the box, the container runs in read-only mode (MCP_ALLOW_WRITE=false). To allow mutations (updating Ruler rule groups, submitting log deletion requests, and applying Loki Operator CRDs), pass -e MCP_ALLOW_WRITE=true to docker run. Even with writes enabled, changes support dry-run previews and destructive operations require explicit confirmation.
| Variable | Container Default | Description |
|---|---|---|
LOKI_URL | http://localhost:3100 | Loki base URL (use http://host.docker.internal:3100 for a host instance) |
LOKI_ORG_ID | none | Tenant ID (X-Scope-OrgID) for multi-tenant Loki |
LOKI_AUTH_TOKEN | none | Bearer token for Loki authentication |
MCP_ALLOW_WRITE | false | Set to true to enable rule mutations, log deletion, and Operator writes |
MCP_TOOLSETS | all | Filter tools: discovery, query, analysis, diagnostics, rules, governance, operator, readonly |
K8S_ENABLED | false | Set to true (with mounted /app/.kube/config) for Loki Operator tools |
MCP_TRANSPORT | http | http (standalone server) or stdio (MCP client subprocess) |
MCP_PORT | 8770 | HTTP listen port inside the container |
| Tool | Access | Description |
|---|---|---|
loki_analyze_volume | Read | Attribute ingested log bytes and stream counts by label for FinOps optimization. |
loki_apply_operator_cr | Write | Validate, preview (dry_run=True), or Server-Side Apply a Loki Operator CR. |
loki_compare_periods | Read | Compare log volume, error counts, and error signatures across two windows or versions. |
loki_correlate_trace_logs | Read | Find and chronologically order all logs matching a trace_id or request_id. |
loki_delete_rule_group | Write (destructive) | Preview (dry_run=True) or delete a Loki Ruler rule group after confirmation. |
loki_get_detected_fields | Read | Discover structured metadata, JSON keys, and logfmt fields with types and cardinalities in Loki 3.x streams. |
loki_get_diagnostics | Read | Diagnose Loki backend readiness, build version, and discarded log sample reasons. |
loki_get_label_values | Read | Retrieve values for a specific indexed label in Grafana Loki, optionally scoped by stream selector. |
loki_get_labels | Read | List all indexed label names in Grafana Loki over an optional time window. |
loki_get_log_patterns | Read | Retrieve recurring structural <_> log patterns and line counts from Loki's pattern ingester. |
loki_get_query_stats | Read | Estimate streams, chunks, entries, and uncompressed bytes touched by a LogQL selector before execution. |
loki_get_series | Read | Return active Loki log stream label sets and per-label cardinality for a stream selector. |
loki_manage_delete_requests | Write (destructive) | List, preview (dry_run=True), create, or cancel a Loki Compactor log deletion request. |
loki_query_a2ui | Read | Execute a LogQL range query and flatten results into an interactive A2UI log table payload. |
loki_query_instant | Read | Evaluate a LogQL metric or stream query at a single point in time. |
loki_query_range | Read | Execute a LogQL range query returning log streams or metric time-series matrices with cost guardrails. |
loki_summarize_service_logs | Read | Compute a high-signal service log health & error summary in one call. |
loki_upsert_rule_group | Write | Validate, preview (dry_run=True), or upsert a Loki Ruler alerting/recording rule group. |
This image also ships step-by-step operational playbooks (SKILL.md) under /app/skills:
authoring-logql-and-analyzing-logsauthoring-loki-alerting-and-recording-rulesdiscovering-loki-schema-and-log-structureoperating-loki-deployments-and-ingestionoptimizing-loki-cardinality-and-finopstriaging-loki-incidents-and-errorsTo copy the skills onto your workstation for Claude Code or Cursor:
docker run --rm --entrypoint tar talkopsai/loki-mcp-server:latest -C /app/skills -cf - . | tar -xf - -C ~/.claude/skills/
Content type
Image
Digest
sha256:01850c31d…
Size
72 MB
Last updated
3 days ago
docker pull talkopsai/loki-mcp-server