- Home
- MCP servers
- Grafana-Loki
Grafana-Loki
- python
18
GitHub Stars
python
Language
5 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"tumf-grafana-loki-mcp": {
"command": "uvx",
"args": [
"grafana-loki-mcp",
"-u",
"GRAFANA_URL",
"-k",
"GRAFANA_API_KEY"
],
"env": {
"GRAFANA_URL": "https://grafana.example.com",
"GRAFANA_API_KEY": "YOUR_API_KEY"
}
}
}
}You run the Grafana-Loki MCP Server to query Loki logs through Grafana's API and return results in flexible formats. This MCP lets you fetch logs, inspect Loki labels, and format output for easy analysis from your preferred MCP client.
How to use
You interact with the server through an MCP client that can call tools exposed by this server. The main capability is querying Loki logs via Grafana, retrieving Loki labels and label values, and formatting results for readability. You can choose the output format (text, JSON, or markdown) and control the amount of data returned with limits.
How to install
Prerequisites you need before installing this MCP server:
-
Python 3.10 or newer
-
FastMCP
-
Requests
Configuration and usage details
Configure the MCP server to connect to your Grafana instance by providing the Grafana URL and a Grafana API key with the necessary permissions. The server runs as a local process and communicates with Grafana using the specified transport.
{
"mcpServers": {
"loki": {
"command": "uvx",
"args": [
"grafana-loki-mcp",
"-u",
"GRAFANA_URL",
"-k",
"GRAFANA_API_KEY"
]
}
}
}
Example usage scenarios
Query Loki logs with a limit and format the results as markdown for easy reading in a chat or document.
# Example client usage:
# 1) Call query_loki to fetch logs
# 2) Call format_loki_results to format as markdown
# This block is illustrative for how you might structure client calls in your MCP client.
Available tools
query_loki
Query Loki logs through Grafana. Parameters include query, start, end, limit, direction, and max_per_line to control results.
get_loki_labels
Retrieve all Loki label names for dynamic querying and filtering.
get_loki_label_values
Fetch possible values for a specific Loki label to aid in constructing queries.
format_loki_results
Format Loki query results into text, json, or markdown for readability.