The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Loki MCP
An MCP ( Model Context Protocol ) Server for Grafana Loki
Install
docker run --rm -i loki-mcp-serverclaude mcp add loki-mcp -- docker run --rm -i loki-mcp-server{
"mcpServers": {
"loki-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"loki-mcp-server"
]
}
}
}Install command taken from the project's README or registry entry. Always review code before running it.
README excerpt
Read full README on GitHub →Loki MCP Server
A Go-based server implementation for the Model Context Protocol (MCP) with Grafana Loki integration.
Getting Started
Prerequisites
- Go 1.16 or higher
Building and Running
Build and run the server:
# Build the server
go build -o loki-mcp-server ./cmd/server
# Run the server
./loki-mcp-server
Or run directly with Go:
go run ./cmd/server
The server communicates using stdin/stdout and SSE following the Model Context Protocol (MCP). This makes it suitable for use with Claude Desktop and other MCP-compatible clients.
Project Structure
.
├── cmd/
│ ├── server/ # MCP server implementation
│ └── client/ # Client for testing the MCP server
├── internal/
│ ├── handlers/ # Tool handlers
│ └── models/ # Data models
├── pkg/
│ └── utils/ # Utility functions and shared code
└── go.mod # Go module definition
MCP Server
The Loki MCP Server implements the Model Context Protocol (MCP) and provides the following tools:
Loki Query Tool
The loki_query tool allows you to query Grafana Loki log data:
Required parameters:
query: LogQL query string
Optional parameters:
url: The Loki server URL (default: from LOKI_URL environment variable or http://localhost:3100)start: Start time for the query (default: 1h ago)end: End time for the query (default: now)limit: Maximum number of entries to return (default: 100)org: Organization ID for the query (sent as X-Scope-OrgID header)
Environment Variables
The Loki query tool supports the following environment variables:
LOKI_URL: Default Loki server URL to use if not specified in the requestLOKI_ORG_ID: Default organization ID to use if not specified in the requestLOKI_USERNAME: Default username for basic authentication if not specified in the requestLOKI_PASSWORD: Default password for basic authentication if not specified in the requestLOKI_TOKEN: Default bearer token for authentication if not specified in the request
Security Note: When using authentication environment variables, be careful not to expose sensitive credentials in logs or configuration files. Consider using token-based authentication over username/password when possible.
Testing the MCP Server
You can test the MCP server using the provided client:
# Build the client
go build -o loki-mcp-client ./cmd/client
# Loki query examples:
./loki-mcp-client loki_query "{job=\"varlogs\"}"
./loki-mcp-client loki_query "{job=\"varlogs\"}" "-1h" "now" 100
# Using environment variables:
export LOKI_URL="http://localhost:3100"
./loki-mcp-client loki_query "{job=\"varlogs\"}"
# Using environment variables for both URL and org:
export LOKI_URL="http://localhost:3100"
export LOKI_ORG_ID="tenant-123"
./loki-mcp-client loki_query "{job=\"varlogs\"}"
# Using environment variables for authentication:
export LOKI_URL="http://localhost:3100"
export LOKI_USERNAME="admin"
export LOKI_PASSWORD="password"
./loki-mcp-client loki_query "{job=\"varlogs\"}"
# Using environment variables with bearer token:
export LOKI_URL="http://localhost:3100"
export LOKI_TOKEN="your-bearer-token"
./loki-mcp-client loki_query "{job=\"varlogs\"}"
Similar plugs
Reverse engineer anything with agents, from app behavior down to native binaries.
Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.
Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype…
User-friendly AI Interface (Supports Ollama, OpenAI API, ...)