Loki MCP

by incu6us

Not rated
GitHub

About

Debug and investigate app issues using AI and Grafana Loki

Details

Author
incu6us
Categories
Developer Tools, Infrastructure, Other

Setup

Install Loki MCP in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/incu6us/loki-mcp-server

Follow the installation instructions in the repository README, then restart your MCP client.

Query Grafana Loki logs directly from AI agents using theModel Context Protocol(MCP).

Built in Go. Enables AI-powered log analysis using LogQL.

- Claude Desktop
- AI agent frameworks
- automation tools
- DevOps workflows

The officialgrafana/loki-mcpexposes a singleloki_querytool, 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 providing5 granular toolslabels,label_values, andserieslet the LLM discover what's available in Loki first, then construct precisequery_rangeorquerycalls. The result is more accurate log retrieval with fewer wasted round-trips.

Additionally, this server enforcesstrict input validation(limit caps, direction validation, label name format checks, mutually exclusive auth) to surface errors early instead of forwarding bad requests to Loki.

- query_range— Execute LogQL range queries to fetch logs over a time window
- query— Execute LogQL instant queries for point-in-time evaluation
- labels— List all available label names
- label_values— List values for a specific label
- series— Find active log stream series matching a selector

brew install incu6us/tap/loki-mcp-server
go install github.com/incu6us/loki-mcp-server/cmd/loki-mcp-server@latest
git clone https://github.com/incu6us/loki-mcp-server.git cd loki-mcp go build -o loki-mcp-server ./cmd/loki-mcp-server

The server is configured entirely via environment variables, injected by the MCP client.

Note:Basic auth (LOKI_USERNAME/LOKI_PASSWORD) and bearer token (LOKI_BEARER_TOKEN) are mutually exclusive.

Add to your Claude Code MCP configuration (~/.claude.json):

{ "mcpServers": { "loki-mcp-server": { "type": "stdio", "command": "/path/to/loki-mcp-server", "args": [], "env": { "LOKI_URL": "http://loki:3100", "LOKI_USERNAME": "admin", "LOKI_PASSWORD": "secret" } } } }

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.jsonon macOS):

{ "mcpServers": { "loki-mcp-server": { "type": "stdio", "command": "/path/to/loki-mcp-server", "args": [], "env": { "LOKI_URL": "http://loki:3100", "LOKI_USERNAME": "admin", "LOKI_PASSWORD": "secret" } } } }

Execute a LogQL range query against Loki to fetch logs over a time window.

Execute a LogQL instant query for point-in-time evaluation.

Find active log stream series matching a selector.

A Docker Compose setup is included underdeploy/to spin up a full Loki environment for testing:

- Loki— log storage athttp://localhost:3100
- Grafana— UI athttp://localhost:3000(anonymous admin, Loki pre-configured as datasource)
- Promtail— collects container logs and ships them to Loki
- Log generator— emits structured JSON logs with randomized apps (nginx,api,gateway,auth,payments), levels, and messages

# Start the stack docker compose -f deploy/docker-compose.yml up -d # Use loki-mcp-server against local Loki LOKI_URL=http://localhost:3100 loki-mcp-server # Stop the stack docker compose -f deploy/docker-compose.yml down
# Run tests go test ./... # Build go build -o loki-mcp-server ./cmd/loki-mcp-server # Vet go vet ./...

⭐ If this project is useful for you, please star the repository.

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

Seamlessly bring real-time production context—logs, metrics, and traces—into your local environment to auto-fix code faster.

A server for querying Loki logs from Grafana.

An MCP server for log analysis using the LogAI framework, with optional Grafana and GitHub integrations.

A Go-based server to query Grafana Loki logs using the Model Context Protocol (MCP).

An MCP server for querying Loki logs via logcli.

An MCP server for querying logs from Grafana Loki.

Search dashboards, investigate incidents and query datasources in your Grafana instance

Provides access to OpenTelemetry traces and metrics through Logfire.

Paid remote MCP for AI agent run monitoring, failure detection, tool-call incident replay, SLA receipts, and client status exports.

Access and manage Grafana resources, including dashboards, datasources, Prometheus, Loki, and alerting.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.