Simple Loki MCP

Simple Loki MCP

A simple MCP server to query Loki logs using logcli.

5
Stars
7
Forks
0
Releases

Overview

Simple Loki MCP Server is an MCP interface that allows AI assistants to query Grafana Loki logs using the logcli CLI. It also automatically falls back to the Loki HTTP API when logcli is not available in the environment, ensuring operation across diverse deployments. It supports full LogQL querying with options such as from, to, limit, batch, and output, and can return formatted results in default, raw, or JSONL formats. The server can retrieve label values and the list of available labels, enabling dynamic query building. Configuration is flexible: authentication and Loki connection settings can be provided via environment variables (LOKI_ADDR, username/password, tokens, TLS options, tenant/org IDs, etc.) or via a logcli-config.yaml file. The path to the config file can be customized with LOKI_CONFIG_PATH. The server uses the same authentication for the HTTP API mode as for logcli, and applies a default limit of 1000 logs per query in both modes. Start it with npm start, or for development, npm run dev. It includes installation options via Smithery or direct npm usage.

Details

Owner
ghrud92
Language
TypeScript
License
MIT License
Updated
2025-12-07

Features

Query Loki logs with full LogQL support

Query Loki logs using LogQL with filtering options (from, to, limit, batch) and return results in multiple formats.

Get label values and metadata

Retrieve all label values and the set of available labels for dynamic query building.

Authentication and configuration via env vars or config files

Supports Loki connection and authentication settings through environment variables or a logcli-config.yaml file, with customizable config path.

Formatted results in multiple output formats

Provide output in default, raw, or JSON Lines formats, with options to suppress metadata as needed.

Automatic fallback to Loki HTTP API

Automatically uses the Loki HTTP API when logcli is unavailable, using the same authentication and formatting, with a default per-query limit.

Tags

LokiMCPlogcliGrafana LokiAuthenticationHTTP APITLSLogQLConfig