Grafana Loki MCP Server
Project description
Loki MCP Server
A Go-based server implementation for the Model Context Protocol (MCP) with Grafana Loki integration.
Quick Start (Recommended)
Run the server directly with a single command using uvx or pipx. No manual build or Docker required (requires Go 1.24+).
# Using uvx
uvx elad12390-loki-mcp
# Using pipx
pipx run elad12390-loki-mcp
This will automatically download, compile, and run the server.
Configuration
The server is configured via environment variables. You can pass these when running the command:
LOKI_URL: Loki server URL (default:http://localhost:3100)LOKI_ORG_ID: Default organization ID (X-Scope-OrgID)LOKI_USERNAME: Basic auth usernameLOKI_PASSWORD: Basic auth passwordLOKI_TOKEN: Bearer token
Example with Claude Desktop config:
{
"mcpServers": {
"loki": {
"command": "uvx",
"args": ["elad12390-loki-mcp"],
"env": {
"LOKI_URL": "https://logs-prod-us-central1.grafana.net",
"LOKI_USERNAME": "your-username",
"LOKI_PASSWORD": "your-password"
}
}
}
}
Features
The loki_query tool allows you to query Grafana Loki log data:
- Query: LogQL query string (required)
- Time Range:
startandendtimes (default: last 1 hour) - Limit: Max entries (default: 100)
- Org ID: Multi-tenant organization support
Example Queries:
- "Find error logs from the last hour in Loki using query {job="varlogs"} |= "ERROR""
- "Show me the most recent 50 logs from Loki with job=varlogs"
- "Query Loki for logs with org 'tenant-123' using query {job="varlogs"}"
Development
If you want to contribute or build manually:
# Build
go build -o loki-mcp-server ./cmd/server
# Run
./loki-mcp-server
Docker
docker build -t loki-mcp-server .
docker run --rm -i loki-mcp-server
License
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file elad12390_loki_mcp-0.1.3.tar.gz.
File metadata
- Download URL: elad12390_loki_mcp-0.1.3.tar.gz
- Upload date:
- Size: 5.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0672d4a1ba26072f503abc6b067ee9f83f3014ffad2afa3b864bbfd9313bd6a
|
|
| MD5 |
0ff1fc8d4fb28aa5d06fcf09d32fa00f
|
|
| BLAKE2b-256 |
77fa77dac34c8926dd94a8038f2161cb75f2557e00bb2e325e476fe28390c84c
|
File details
Details for the file elad12390_loki_mcp-0.1.3-py3-none-any.whl.
File metadata
- Download URL: elad12390_loki_mcp-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f01f8e1267ab4f6311945b1dda5520058551bb145de3ee99621ddb3a3ba81484
|
|
| MD5 |
27decef69e514bafda4b18729c3c91b9
|
|
| BLAKE2b-256 |
f74fee7b42eb61323f9ffecc5385836e1cd9b7a180618e31958a5fb3acf8eb95
|