Labsco
MCP SERVER

Grafana Loki

by tumf

LogQL queries against Loki through the Grafana API, with the label metadata you need to write them and control over how results are formatted.

Observability, Monitoring & Incident Response
Summary
Ask the logs a question in the same window as the code.

The label calls matter more than they look. LogQL is unwriteable unless you know which labels exist and what values they take, and both are one call away here.

What it is

A FastMCP server that queries Loki logs through a Grafana instance. Alongside the query itself it exposes the label names and values a LogQL query depends on, and a formatter that decides how results come back.

What you get
  • Loki queried through the Grafana API
  • The available label names listed
  • The values a given label takes
  • Results formatted as text, JSON or markdown
  • A cap on characters per line so one enormous entry does not flood the response
  • Both stdio and SSE transports
Requirements

Python 3.10 or newer, a Grafana instance, and a Grafana API key with permission to query Loki — set as GRAFANA_URL and GRAFANA_API_KEY, or passed as -u and -k. Install with pip install grafana-loki-mcp.

Setup effort

One command plus a key — pip install grafana-loki-mcp, then supply credentials