Loki MCP Server

Loki MCP Server

An MCP interface that allows AI assistants to query and analyze Grafana Loki logs using LogQL, with support for authentication and various output formats.

Category
Visit Server

README

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)

Prerequisites

  • Node.js v16 or higher
  • TypeScript
  • Grafana Loki logcli installed and accessible in your PATH
  • Access to a Loki server instance

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/loki-mcp.git
cd loki-mcp
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

Configuration

You can configure Loki access using:

Environment Variables

  • 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

Config Files

Alternatively, create a logcli-config.yaml file in one of these locations:

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

Example config file:

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

Usage

Start the server:

npm start

For development:

npm run dev

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 return
  • batch: Batch size for query results
  • output: Output format ("default", "raw", or "jsonl")
  • quiet: Suppress query metadata
  • forward: 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.

Development

# Run linter
npm run lint

# Fix linting issues
npm run lint:fix

# Run tests
npm run test

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured