by ghrud92
A Model Context Protocol (MCP) interface for querying Grafana Loki logs using `logcli`, enabling AI assistants to access and analyze log data from Loki directly.
Simple Loki MCP Server is a Model Context Protocol (MCP) interface designed to allow AI assistants to query and analyze logs stored in Grafana Loki. It acts as a bridge between AI models and Loki, enabling seamless access to log data for various analytical tasks.
Installation:
npx -y @smithery/cli install @ghrud92/simple-loki-mcp --client claude
mcpServers
with the provided JSON snippet.npm install
), and build the project (npm run build
).Starting the Server:
npm start
(for production)npm run dev
(for development)Configuration:
LOKI_ADDR
, LOKI_USERNAME
, LOKI_PASSWORD
, etc., for Loki access.logcli-config.yaml
in specified locations with Loki connection details.Available MCP Tools:
query-loki
: Query logs using LogQL with various filtering options.get-label-values
: Retrieve all values for a specific label.get-labels
: Retrieve all available labels.logcli
is not available.Q: What are the prerequisites for running Simple Loki MCP Server?
A: Node.js v16 or higher, TypeScript, and optionally Grafana Loki logcli
installed and accessible in your PATH. Access to a Loki server instance is also required.
Q: What happens if logcli
is not installed?
A: The server will automatically fall back to using the Loki HTTP API. No additional configuration is needed, and the same authentication parameters are used.
Q: How can I configure Loki access?
A: You can configure Loki access using environment variables (e.g., LOKI_ADDR
, LOKI_USERNAME
) or by creating a logcli-config.yaml
file.
Q: What output formats are supported for queries? A: You can get results in "default", "raw", or "jsonl" (JSON lines) formats.
Q: Can I use this with Claude Desktop? A: Yes, you can install it for Claude Desktop automatically via Smithery.
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
logcli
is 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.
Discover more MCP servers with similar functionality and use cases
by netdata
Real-time, per‑second infrastructure monitoring platform that provides instant insights, auto‑discovery, edge‑based machine‑learning anomaly detection, and lightweight visualizations without requiring complex configuration.
by Arize-ai
Arize Phoenix is an open-source AI and LLM observability tool for inspecting traces, managing prompts, curating datasets, and running experiments.
by msgbyte
Provides website analytics, uptime monitoring, and server status in a single self‑hosted application.
by grafana
Provides programmatic access to Grafana dashboards, datasources, alerts, incidents, and related operational data through a Model Context Protocol server, enabling AI assistants and automation tools to query and manipulate Grafana resources.
by dynatrace-oss
Provides a local server that enables real‑time interaction with the Dynatrace observability platform, exposing tools for problem retrieval, DQL execution, Slack notifications, workflow automation, and AI‑assisted troubleshooting.
by pydantic
Provides tools to retrieve, query, and visualize OpenTelemetry traces and metrics from Pydantic Logfire via a Model Context Protocol server.
by VictoriaMetrics-Community
Access VictoriaMetrics instances through Model Context Protocol, enabling AI assistants and tools to query metrics, explore labels, debug configurations, and retrieve documentation without leaving the conversational interface.
by axiomhq
Axiom MCP Server implements the Model Context Protocol (MCP) for Axiom, enabling AI agents to query logs, traces, and other event data using the Axiom Processing Language (APL). It allows AI agents to perform monitoring, observability, and natural language analysis of data for debugging and incident response.
by GeLi2001
Datadog MCP Server is a Model Context Protocol (MCP) server that interacts with the official Datadog API. It enables users to access and manage various Datadog functionalities, including monitoring, dashboards, metrics, events, logs, and incidents.