Loki MCP Server

Loki MCP Server

MCP server enabling AI assistants to query and analyze Grafana Loki logs.

2
Stars
0
Forks
0
Releases

Overview

A Model Context Protocol (MCP) server designed to connect AI assistants with Grafana Loki for querying and analyzing log data. The Loki MCP Server exposes MCP-compliant semantics for log analysis, enabling AI clients to issue operations such as LogQL-based queries, keyword searches, and label discovery against Loki. The architecture shows a direct interaction between an AI assistant and Loki via the Loki MCP Server, which handles authentication and protocol translation. Features include: Query Logs using LogQL with support for range and instant queries, Search Logs with advanced filtering and pattern matching, Label Discovery to retrieve available labels and values for streams, and full MCP protocol compatibility. The server emphasizes performance through built-in caching and optimized query execution, and security via multiple authentication methods (basic auth and bearer tokens). It exposes three main MCP tools: query_logs, search_logs, and get_labels; each with parameters like query, keywords, labels, and time ranges. Installation is via pip install -e ., supports environment variable configuration for LOKI_URL, and can be run as a CLI service. Development and testing workflows are provided.

Details

Owner
mo-silent
Language
Python
License
Updated
2025-12-07

Features

Query Logs

Execute LogQL queries against Loki with support for range and instant queries

Search Logs

Keyword-based log searching with advanced filtering and pattern matching

Label Discovery

Retrieve available log labels and label values for stream exploration

MCP Protocol

Fully compatible with Model Context Protocol for AI assistant integration

Performance

Built-in caching and optimized query execution

Security

Support for multiple authentication methods (basic auth, bearer tokens)

Rich Results

Structured output with timestamps, labels, and context information

Audience

AI assistantsIntegrate with Grafana Loki via MCP to query and analyze logs for AI-powered workflows.
DevelopersBuild MCP-enabled log analysis capabilities into AI-assisted applications.

Tags

LokiGrafana LokiMCPLogQLlogsAI integrationauthenticationcachinglog analysis