
ghrud92/simple-loki-mcp
Developer toolsЭта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал
Loki MCP Server is a Model Context Protocol (MCP) interface for querying Grafana Loki logs using logcli. The server enables AI assistants to access and analyze log data from Loki directly.
Обзор
Loki MCP Server is a Model Context Protocol (MCP) interface for querying Grafana Loki logs using logcli. The server enables AI assistants to access and analyze log data from Loki directly. - Query Loki logs with full LogQL support - Get label values and metadata - Authentication and configuration support via environment variables or config files - Provides formatted results in different output formats (default, raw, JSON lines) - Automatic fallback to HTTP API when logcli is not available in the environment - Node.js v16 or higher - TypeScript - (Optional) Grafana Loki logcli installed and accessible in your PATH. If logcli is not available, the server will automatically use the Loki HTTP API instead - Access to a Loki server instance To install Simple Loki MCP Server for Claude Desktop automatically via Smithery: Query logs from Loki with filtering options. - query (required): Loki query string (LogQL) - from: Start timestamp (e.g. "2023-01-01T12:00:00Z") - to: End timestamp (e.
README
Показан фрагмент оригинального README. Открыть оригинал.
Simple Loki MCP Server
Loki MCP Server is a Model Context Protocol (MCP) interface for querying Grafana Loki logs using logcli. The server enables AI assistants to access and analyze log data from Loki directly.
Features
- Query Loki logs with full LogQL support
- Get label values and metadata
- Authentication and configuration support via environment variables or config files
- Provides formatted results in different output formats (default, raw, JSON lines)
- Automatic fallback to HTTP API when
logcliis not available in the environment
Prerequisites
- Node.js v16 or higher
- TypeScript
- (Optional) Grafana Loki logcli installed and accessible in your PATH. If
logcliis not available, the server will automatically use the Loki HTTP API instead - Access to a Loki server instance
Installation
Installing via Smithery
To install Simple Loki MCP Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @ghrud92/simple-loki-mcp --client claude
for MCP
{
"mcpServers": {
"simple-loki": {
"command": "npx",
"args": ["-y", "simple-loki-mcp"],
"env": {
"LOKI_ADDR": "https://loki.sup.band"
}
}
}
}
npm
- Clone the repository:
git clone https://github.com/ghrud92/loki-mcp.git
cd loki-mcp
- Install dependencies:
npm install
- Build the project:
npm run build
Available MCP Tools
query-loki
Query logs from Loki with filtering options.
Parameters:
query(required): Loki query string (LogQL)from: Start timestamp (e.g. “2023-01-01T12:00:00Z”)to: End timestamp (e.g. “2023-01-01T13:00:00Z”)limit: Maximum number of logs to returnbatch: Batch size for query resultsoutput: Output format (“default”, “raw”, or “jsonl”)quiet: Suppress query metadataforward: Display results in chronological order
get-label-values
Retrieve all values for a specific label.
Parameters:
label(required): Label name to get values for
get-labels
Retrieve all available labels.
No parameters required.
Configuration
You can configure Loki access using:
Environment Variables
LOKI_ADDR: Loki server address (URL)LOKI_USERNAME: Username for basic authLOKI_PASSWORD: Password for basic authLOKI_TENANT_ID: Tenant ID for multi-tenant LokiLOKI_BEARER_TOKEN: Bearer token for authenticationLOKI_BEARER_TOKEN_FILE: File containing bearer token
Установка
npx -y simple-loki-mcpКонфигурация
{
"mcpServers": {
"simple-loki": {
"command": "npx",
"args": ["-y", "simple-loki-mcp"],
"env": {
"LOKI_ADDR": "https://loki.sup.band"
}
}
}
}