Simple Loki MCP Server

by ghrud92

Not rated
GitHub

About

Query Grafana Loki logs using logcli with an automatic fallback to the HTTP API.

Details

Author
ghrud92
Categories
Database, Other, Infrastructure

Setup

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

Repository: https://github.com/ghrud92/simple-loki-mcp

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

Query Grafana Loki logs using logcli with an automatic fallback to the HTTP API.

Loki MCP Server is aModel Context Protocol (MCP)interface for querying Grafana Loki logs usinglogcli. 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 whenlogcliis not available in the environment

- Node.js v16 or higher
- TypeScript
- (Optional)
Grafana Loki logcliinstalled and accessible in your PATH. Iflogcliis 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 viaSmithery:

npx -y @smithery/cli install @ghrud92/simple-loki-mcp --client claude
{ "mcpServers": { "simple-loki": { "command": "npx", "args": ["-y", "simple-loki-mcp"], "env": { "LOKI_ADDR": "https://loki.sup.band" } } } }
git clone https://github.com/ghrud92/loki-mcp.git cd loki-mcp

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.g. "2023-01-01T13:00:00Z")
- limit: Maximum number of logs to return
- batch: Batch size for query results
- output: Output format ("default", "raw", or "jsonl")
- quiet: Suppress query metadata
- forward: Display results in chronological order

Retrieve all values for a specific label.

- label(required): Label name to get values for

- LOKI_ADDR: Loki server address (URL)
- LOKI_USERNAME: Username for basic auth
- LOKI_PASSWORD: Password for basic auth
- LOKI_TENANT_ID: Tenant ID for multi-tenant Loki
- LOKI_BEARER_TOKEN: Bearer token for authentication
- LOKI_BEARER_TOKEN_FILE: File containing bearer token
- LOKI_CA_FILE: Custom CA file for TLS
- LOKI_CERT_FILE: Client certificate file for TLS
- LOKI_KEY_FILE: Client key file for TLS
- LOKI_ORG_ID: Organization ID for multi-org setups
- LOKI_TLS_SKIP_VERIFY: Skip TLS verification ("true" or "false")
- LOKI_CONFIG_PATH: Custom path to config file
- DEBUG: Enable debug logging

Note: When the client is using the HTTP API mode (whenlogcliis not available), the same configuration parameters are used to authenticate and connect to the Loki server.

Alternatively, create alogcli-config.yamlfile in one of these locations:

- Custom path specified byLOKI_CONFIG_PATH
- Current working directory
- Your home directory (~/.logcli-config.yaml)

addr: https://loki.example.com username: user password: pass tenant_id: mytenant

The server will automatically check iflogcliis installed and available in the environment:
- Iflogcliis available, it will be used for all queries, providing the full functionality of the CLI tool
- Iflogcliis not available, the server will automatically fall back to using the Loki HTTP API:

- No additional configuration is needed
- The same authentication parameters are used for the HTTP API
- Response formatting is consistent with the CLI output
- Default limit of 1000 logs per query is applied in both modes

This automatic detection ensures that the server works seamlessly in different environments without manual configuration.

# Run linter npm run lint # Fix linting issues npm run lint:fix # Run tests npm run test

This project is licensed under the MIT License - see theLICENSE.mdfile for details.

An MCP server for querying logs from Grafana Loki.

Retrieve and analyze time-series data from Prometheus databases using PromQL queries.

A Prometheus MCP server with full API support for comprehensive management and deep interaction with Prometheus beyond basic query support. Written in go, it is a single binary install that is capable of STDIO, SSE, and HTTP transports for complex deployments.

Access VictoriaMetrics APIs for monitoring, observability, and debugging.

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

Access Grafana resources like dashboards, datasources, Prometheus, Loki, and alerts.

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

MCP server for Grafana — manage dashboards, datasources, alerts, folders, and annotations over stdio

A server for querying Loki logs from Grafana.

Transparent MCP proxy with OpenTelemetry tracing. Wrap any MCP server, persist traces to any OTel backend · SQLite · Postgres · MySQL. No code changes needed.

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.