by ghrud92
Provides an MCP interface for querying Grafana Loki logs via `logcli` or the Loki HTTP API, enabling AI assistants to retrieve and analyze log data directly from Loki.
Simple Loki MCP Server offers an MCP endpoint that lets AI assistants execute LogQL queries, fetch label information, and receive results in various formats. It automatically chooses between the logcli CLI and the Loki HTTP API, so it works in environments where the CLI may not be installed.
npx -y @smithery/cli install @ghrud92/simple-loki-mcp --client claude
Via npm:
git clone https://github.com/ghrud92/loki-mcp.git
cd loki-mcp
npm install
npm run build
npm start # production
npm run dev # development with hot‑reload
{
"mcpServers": {
"simple-loki": {
"command": "npx",
"args": ["-y", "simple-loki-mcp"],
"env": { "LOKI_ADDR": "https://your-loki-instance" }
}
}
}
Required environment variables (or a logcli-config.yaml file) include LOKI_ADDR, optional auth variables such as LOKI_USERNAME, LOKI_PASSWORD, LOKI_BEARER_TOKEN, etc.logcli when available.logcli is missing.logcli-config.yaml file.LOKI_TENANT_ID.Q: Do I need to install logcli?
A: No. The server detects its presence; if absent, it seamlessly switches to the HTTP API.
Q: Which environment variables are mandatory?
A: At minimum LOKI_ADDR (the Loki endpoint). Authentication variables depend on your Loki setup.
Q: Can I customize the query limit?
A: Yes, using the limit parameter in the query-loki tool or by setting LOKI_DEFAULT_LIMIT in a config file.
Q: How are results formatted?
A: Choose default (table), raw (plain text), or jsonl (JSON lines) via the output parameter.
Q: Is the server compatible with other MCP clients?
A: Absolutely – any client that follows the Model Context Protocol can invoke the defined tools (query-loki, get-label-values, get-labels).
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.
logcli is not available in the environmentlogcli is not available, the server will automatically use the Loki HTTP API insteadTo install Simple Loki MCP Server for Claude Desktop automatically via Smithery:
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
npm install
npm run build
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 returnbatch: Batch size for query resultsoutput: Output format ("default", "raw", or "jsonl")quiet: Suppress query metadataforward: Display results in chronological orderRetrieve all values for a specific label.
Parameters:
label (required): Label name to get values forRetrieve all available labels.
No parameters required.
You can configure Loki access using:
LOKI_ADDR: Loki server address (URL)LOKI_USERNAME: Username for basic authLOKI_PASSWORD: Password for basic authLOKI_TENANT_ID: Tenant ID for multi-tenant LokiLOKI_BEARER_TOKEN: Bearer token for authenticationLOKI_BEARER_TOKEN_FILE: File containing bearer tokenLOKI_CA_FILE: Custom CA file for TLSLOKI_CERT_FILE: Client certificate file for TLSLOKI_KEY_FILE: Client key file for TLSLOKI_ORG_ID: Organization ID for multi-org setupsLOKI_TLS_SKIP_VERIFY: Skip TLS verification ("true" or "false")LOKI_CONFIG_PATH: Custom path to config fileDEBUG: Enable debug loggingNote: When the client is using the HTTP API mode (when
logcliis not available), the same configuration parameters are used to authenticate and connect to the Loki server.
Alternatively, create a logcli-config.yaml file in one of these locations:
LOKI_CONFIG_PATH~/.logcli-config.yaml)Example config file:
addr: https://loki.example.com
username: user
password: pass
tenant_id: mytenant
Start the server:
npm start
For development:
npm run dev
The server will automatically check if logcli is installed and available in the environment:
logcli is available, it will be used for all queries, providing the full functionality of the CLI toollogcli is not available, the server will automatically fall back to using the Loki HTTP API:
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 the LICENSE.md file for details.
Please log in to share your review and rating for this MCP.
{
"mcpServers": {
"simple-loki": {
"command": "npx",
"args": [
"-y",
"simple-loki-mcp"
],
"env": {
"LOKI_ADDR": "<YOUR_LOKI_ADDRESS>"
}
}
}
}claude mcp add simple-loki npx -y simple-loki-mcpExplore related MCPs that share similar capabilities and solve comparable challenges
by netdata
Delivers real‑time, per‑second infrastructure monitoring with zero‑configuration agents, on‑edge machine‑learning anomaly detection, and built‑in dashboards.
by Arize-ai
Open-source AI observability platform enabling tracing, evaluation, dataset versioning, experiment tracking, prompt management, and interactive playground for LLM applications.
by msgbyte
Provides integrated website traffic analysis, uptime checking, and server health monitoring in a single self‑hosted platform.
by grafana
Provides programmatic access to a Grafana instance and its surrounding ecosystem through the Model Context Protocol, enabling AI assistants and other clients to query and manipulate dashboards, datasources, alerts, incidents, on‑call schedules, and more.
by dynatrace-oss
Provides a local server that enables real‑time interaction with the Dynatrace observability platform, exposing tools for querying data, retrieving problems, sending Slack notifications, and integrating AI assistance.
by pydantic
Provides tools to retrieve and query OpenTelemetry trace and metric data from Pydantic Logfire, allowing LLMs to analyze distributed traces and run arbitrary SQL queries against telemetry records.
by VictoriaMetrics-Community
Provides a Model Context Protocol server exposing read‑only VictoriaMetrics APIs, enabling seamless monitoring, observability, and automation through AI‑driven assistants.
by GeLi2001
Enables interaction with the Datadog API through a Model Context Protocol server, providing access to monitors, dashboards, metrics, logs, events, and incident data.
by last9
Provides AI agents with real‑time production context—including logs, metrics, traces, and alerts—through a Model Context Protocol server, enabling automatic code fixing and faster debugging.