Loki MCP Server

Give MCP clients a direct way to query Grafana Loki with LogQL.

Source repo
grafana/loki-mcp
Stars
★ 170
Last updated
8d ago
Primary language
Go

At a glance

Works with
Universal · cross-platformClaude.ai
You'll need
Go 1.16 or higherGrafana LokiDocker for container-based deploymentShell / CLINetwork accessMCP Server
Typical use
An operations engineer uses Claude Desktop to turn a request for recent service errors into a LogQL query against Loki.
Main limitation
The documented product scope centers on one loki_query tool; there is no evidenced label discovery, rule administration, alert management, or production log-ingestion interface.

What does this agent do, and when should you use it?

Loki MCP Server is a Go implementation of the Model Context Protocol for Grafana Loki. Its `loki_query` tool accepts LogQL, a time range, a result limit, and an optional organization ID, then returns results obtained from Loki. The server can run as a standard input/output MCP process or expose HTTP endpoints at `/sse` and `/mcp`. The repository also includes a test client, tool handlers, data models, and a Docker Compose environment containing Loki, Grafana, sample-log generation, and the MCP server. It fits teams that want Claude Desktop, Cursor, n8n, or another MCP-compatible client to reach a self-hosted Loki deployment, but it is not a general-purpose log backend and does not supply Loki itself.

An MCP client calls loki_query with the required query LogQL string and may also provide url, start, end, limit, and org. The handler queries the selected Grafana Loki server, sends org as the X-Scope-OrgID header, and returns the resulting log entries to the client. When values are omitted, it can read connection, tenant, and authentication settings from LOKI_URL, LOKI_ORG_ID, LOKI_USERNAME, LOKI_PASSWORD, and LOKI_TOKEN; documented defaults are http://localhost:3100, one hour ago through now, and 100 entries. The process supports stdin/stdout MCP as well as HTTP mode with /sse and /mcp on port 8080 by default. The cmd/client program exercises the tool directly, while the Docker Compose setup can generate sample logs and make them available for inspection in Grafana.

  1. An operations engineer uses Claude Desktop to turn a request for recent service errors into a LogQL query against Loki.
  2. A platform team operating multi-tenant Loki selects a tenant with the org parameter and sends the corresponding X-Scope-OrgID header.
  3. An n8n maintainer connects an MCP Client Tools node to /sse so an AI Agent can retrieve logs during a workflow.
  4. A developer starts Loki, Grafana, a log generator, and the MCP server with Docker Compose to test queries and client configuration locally.
  5. A Cursor user runs the server in Docker and queries application logs from the editor while investigating a defect.

How do you install or deploy this agent?

Install Go 1.16 or newer and ensure a Grafana Loki server is reachable. Build and start the server with:

go build -o loki-mcp-server ./cmd/server
./loki-mcp-server

Alternatively, run it directly:

go run ./cmd/server

For a container deployment:

docker build -t loki-mcp-server .
docker run --rm -i loki-mcp-server

Expose the default HTTP/SSE port when needed:

docker run -p 8080:8080 --rm -i loki-mcp-server

Set LOKI_URL for the Loki endpoint. Multi-tenant deployments may set LOKI_ORG_ID; authentication uses either LOKI_USERNAME plus LOKI_PASSWORD, or LOKI_TOKEN. The HTTP port can be changed with SSE_PORT.

How do you use this agent?

Configure Loki and make a first test query:

export LOKI_URL="http://localhost:3100"
go build -o loki-mcp-client ./cmd/client
./loki-mcp-client loki_query "{job=\"varlogs\"}"

To supply a time range and result limit, run:

./loki-mcp-client loki_query "{job=\"varlogs\"}" "-1h" "now" 100

For the complete local test environment, run docker-compose up -d, followed by ./test-loki-query.sh '{job="varlogs"} |= "ERROR"'. For Claude Desktop, register the built binary as an MCP server, provide the required LOKI_URL and authentication environment variables, and restart the client before invoking loki_query. HTTP integrations can connect to http://your-server-address:8080/sse; MCP protocol messages use http://your-server-address:8080/mcp.

What are this agent's strengths and limitations?

Pros
  • Supports both stdin/stdout and HTTP/SSE delivery, covering desktop MCP clients and network-based workflows such as n8n.
  • loki_query exposes time bounds, result limits, and an organization ID, with explicit X-Scope-OrgID support for multi-tenant Loki.
  • Supports both basic authentication and bearer tokens, with connection and credential defaults configurable through environment variables.
  • Includes a test client, query and log-insertion scripts, plus a Docker Compose environment with Loki, Grafana, and generated sample logs.
Limitations
  • The documented product scope centers on one loki_query tool; there is no evidenced label discovery, rule administration, alert management, or production log-ingestion interface.
  • Adoption requires an existing or separately deployed Grafana Loki service, plus network and port configuration for HTTP/SSE use.
  • Usernames, passwords, and tokens may be supplied through environment variables, so operators must prevent credentials from leaking into logs or configuration.
  • Repository metadata lists the license as unknown while the README claims MIT; adopters should verify the actual LICENSE file.
  • Using go run from Claude Desktop may require additional HOME, GOPATH, GOMODCACHE, and GOCACHE configuration, which is why the documentation characterizes Docker as the more reliable route.

How does this agent compare with similar options?

Key facts side by side with the most closely related agents.

Agent Source review Stars Updated Language Full support on
Loki MCP Server This agent 56 · Major gaps ★ 170 8d ago Go Claude.ai
Agency Orchestrator: One Sentence to Orchestrate an AI Expert Team 61 · Some gaps ★ 2.3k 1d ago TypeScript Codex · Claude Code · OpenAI API · Claude API
Dokploy MCP Server 65 · Some gaps ★ 383 5d ago TypeScript Claude Code · Claude.ai
Stakpak 57 · Major gaps ★ 1.8k 2mo ago Rust OpenAI API · Claude API

How does FollowAgents rate this agent?

FollowAgents source review · FARS-2.1
Major gaps
56/ 100 5-point scale 2.8 / 5
Trust 13/29
Reliability 6/14
Adaptability 14/18
Convention 10/18
Effectiveness 9/13
Verifiability 4/8
Why each dimension lost points
Trust13 / 29 · 2.2/5

The product exposes a single, primarily read-only Loki query tool and documents query parameters, destination URL, tenant header, authentication environment variables, and the stdio/SSE paths, providing reasonable evidence for limited scope, data-flow visibility, and bounded external effects. Deductions apply because callers may supply the URL, server-side access control for HTTP/SSE is not specified, and the example auto-approves loki_query rather than requesting per-call confirmation. Credential guidance is only a general warning, with no demonstrated secret storage, log redaction, or transport-security policy. Dependencies are versioned and CI runs go mod verify and govulncheck, but the scanner is installed from latest and Actions are not commit-pinned. Queries normally create no persistent state needing rollback, yet recovery behavior is not explicitly documented. Attribution is weak because the module identifies scottlepp/loki-mcp while the assessed object is named grafana/loki-mcp, with no explanation of ownership or affiliation.

Reliability6 / 14 · 2.1/5

The README, go.mod, and CI provide partially consistent build and test instructions, while Go module versions are fixed and downloaded and verified in CI. Major deductions follow from the README requiring Go 1.16 while go.mod and CI require Go 1.24.4; the workflow documentation describes a real-Loki integration job that is entirely commented out in ci.yml; and claims of comprehensive tests cannot be checked without the test sources. The supplied material gives almost no evidence of runtime error classification, actionable user-facing failure messages, retries, or timeout handling.

Adaptability14 / 18 · 3.9/5

Documentation thoroughly addresses Claude Desktop, Cursor, n8n, Docker, local Loki, and multi-tenant use, with varied natural-language and command examples, earning full credit for audiences and scenarios. Tool parameters and broad boundaries are described, but no handler code confirms validation, accepted time syntax, limit bounds, or claimed natural-language mapping. Environment variables and platform configurations are useful, though the Go-version conflict, unclear SSE startup selection, and cursory HTTP authentication guidance reduce environment-fit confidence.

Convention10 / 18 · 2.8/5

The README is well organized and covers architecture, installation routes, environment variables, Docker, and extensive examples. Naming is mostly stable, although lokiserver, loki-mcp-server, and the repository/module identities differ. Known limitations are not collected or meaningfully discussed. The README asserts MIT licensing, but neither the LICENSE text nor confirming license metadata is supplied, so that claim is only partial evidence. No releases, semantic-version policy, or changelog are shown. CI establishes an update path, but responsible maintainers, support channels, and repository affiliation remain unclear.

Effectiveness9 / 13 · 3.5/5

Mapping LogQL queries, time ranges, limits, tenant selection, and authentication into MCP offers clear additional value to users who already operate Loki; client, container, and prompt examples improve practical usability. Deductions apply because no actual response example or output schema is supplied, and large-result handling, pagination, truncation, performance, and resource costs are not documented. Deployment also requires a Loki endpoint, credentials, and either Go or Docker, supporting adequate rather than exceptional cost-benefit.

Verifiability4 / 8 · 2.5/5

Some claims are traceable across go.mod and ci.yml, including the Go version, pinned module dependencies, and build, test, verification, and vulnerability-scan commands; the README also identifies intended implementation locations. Deductions apply because handlers, models, tests, and the LICENSE text are absent, preventing verification of parameter behavior, authentication precedence, output formatting, error handling, and coverage. The workflow guide presents a commented-out integration job as active, while the README states comprehensive testing and automatic natural-language understanding without separating those assertions from directly demonstrated facts.

Risks and how to mitigate them
  • Not found in source: confirmation before actingTurn on (or add) a confirmation step before it acts, and try it in a sandbox or test environment before real data.
  • The README's Go 1.16 prerequisite conflicts with Go 1.24.4 in go.mod and CI; confirm the actual toolchain before deployment.
  • Server-side authentication, bind-address behavior, and TLS policy for the HTTP/SSE endpoints are undocumented; do not expose them to untrusted networks without additional controls.
  • Because callers can provide the Loki URL, deployments should restrict allowed destinations to reduce internal-service access and unintended log-query disclosure risks.
  • The example enables autoApprove, while Loki logs may contain sensitive data; production use should retain human authorization or enforce strict tool and tenant policies.
  • No storage, redaction, or rotation mechanism is demonstrated for LOKI_PASSWORD or LOKI_TOKEN; do not commit real credentials to configuration or logs.
  • The real-Loki integration job in ci.yml is commented out, so the workflow documentation's integration-test claim is not evidence of a currently executed check.
  • MIT licensing is asserted only in the README, with no LICENSE text supplied; verify the license file and repository ownership before adoption or redistribution.
Evidence confidence: Low Reviewed Sep 21, 2026 Reviewed revision c8148563dd26
See the full review method →

FAQ

Does it host Loki or collect logs?
No. It queries an existing Grafana Loki service. The local Docker Compose example separately starts Loki, Grafana, and a log generator for testing.
Does it support multi-tenant Loki?
Yes. Supply org per request or set LOKI_ORG_ID; the value is sent to Loki in the X-Scope-OrgID header.
How can it authenticate to Loki?
It supports basic authentication through LOKI_USERNAME and LOKI_PASSWORD, or bearer authentication through LOKI_TOKEN. The documentation recommends token-based authentication when possible and warns against exposing credentials.
Is Docker mandatory?
No. The server can be compiled or run directly with Go 1.16 or newer. Docker and Docker Compose are additional deployment and local-testing options.
What should I check when a query fails?
Check that LOKI_URL is reachable, the LogQL expression is valid, the selected time range contains data, and the tenant and authentication values match the target Loki configuration.
View on GitHub ↗ Install ↓

Compare agents like this one

The same FARS review applied across the shortlist this agent qualifies for.

Related agents