MCP Hub
Back to servers

Loki MCP Server

Enables AI models to query and analyze Kubernetes cluster logs through Grafana Loki, supporting semantic operations like error aggregation and pod restart detection. It provides tools for regex-based log searching and namespace discovery to facilitate natural language troubleshooting.

Updated
Feb 27, 2026

Loki MCP Server

An MCP (Model Context Protocol) server for semantic log querying via Loki. Designed to help AI models answer natural language questions about your cluster logs.

Features

  • Error Summary: Aggregate errors across your cluster with breakdowns by type
  • Pod Restart Detection: Find crashing/restarting pods
  • Log Search: Regex-based log search across your cluster
  • Namespace/Pod Discovery: List available namespaces and query specific pods
  • Semantic Tool Design: Tool names and parameters match natural language questions

Tools

get_error_summary

Get a summary of errors happening in your cluster.

  • namespace: Filter to specific namespace (empty = all)
  • hours: Look back this many hours (default: 1)

find_pod_restarts

Find pods that have restarted or crashed recently.

  • namespace: Filter to specific namespace (empty = all)
  • hours: Look back this many hours (default: 1)

search_logs

Search logs with a regex pattern.

  • query: Regex pattern to search for
  • namespace: Filter to specific namespace (empty = all)
  • hours: Look back this many hours (default: 1)
  • limit: Maximum log lines to return (default: 100)

list_namespaces

List all namespaces that have logs in Loki.

get_pod_logs

Get logs for a specific pod.

  • pod_name: Pod name (supports wildcards like ollama*)
  • namespace: Namespace of the pod (empty = search all)
  • hours: Look back this many hours (default: 1)
  • limit: Maximum log lines to return (default: 100)

Development

# Install dependencies
uv sync

# Run the server
uv run server.py

# For in-cluster, the server listens on stdio via MCP

Deployment (In-Cluster)

Add to your local-k8s-apps Helm values with:

  • Deployment with the MCP server
  • Exposed via HTTP on port 8000
  • Environment variable: LOKI_URL pointing to Loki service

The Ollama MCP bridge will load this server's tools and expose them to the model.

Reviews

No reviews yet

Sign in to write a review