There is exactly one query tool here, which is the right shape for Loki: the interesting variation is in LogQL, not in the API surface. Setting the URL, tenant and credentials once in the environment means a question like "find error logs from the last hour" needs no connection details in the prompt, and the org parameter maps cleanly onto multi-tenant setups through the standard scope header.
A small Go MCP server for querying Grafana Loki. It runs over stdio for desktop clients, and can also start an HTTP server exposing an SSE endpoint for workflow tools such as n8n.
- A LogQL query with everything but the query string optional — `loki_query`
- Sensible defaults on the optional parameters: `start` an hour ago, `end` now, `limit` 100 results
- Multi-tenant support through an `org` parameter, sent as the `X-Scope-OrgID` header
- Connection details supplied per call or read from the environment, so a natural-language question does not have to repeat them
- Both authentication styles — basic auth via `LOKI_USERNAME` and `LOKI_PASSWORD`, or a bearer token via `LOKI_TOKEN`
- An SSE endpoint at `/sse` and an MCP endpoint at `/mcp` when run in HTTP mode, for tools that connect over the network rather than launching a process
Go 1.16 or higher to build (`go build -o loki-mcp-server ./cmd/server`), or the Docker image, which the README calls the most reliable option because it packages the Go module and build caches the client would otherwise have to find. `LOKI_URL` defaults to `http://localhost:3100`; `LOKI_ORG_ID`, `LOKI_USERNAME`, `LOKI_PASSWORD` and `LOKI_TOKEN` set the defaults for tenant and authentication. HTTP mode listens on port 8080 unless `SSE_PORT` says otherwise. The project's own security note asks you to prefer token authentication over username and password where you can. Licensed MIT.
Build from source — clone the repository and build it, then point your client at the binary
