tumf/grafana-loki-mcp
If you are the rightful owner of grafana-loki-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A FastMCP server that allows querying Loki logs from Grafana.
Tools
Functions exposed to the LLM to take actions
query_loki
Query Loki logs through Grafana.
Args:
query: Loki query string (LogQL), Loki's domain-specific language for filtering and extracting logs.
Note: Separate multiple labels with commas. E.g.: {app="frontend", source="user"}
Examples:
- Simple log stream selection: {app="frontend"}
- Multiple labels: {app="frontend", source="user"}
- Filtering logs with pattern: {app="frontend"} |= "error"
- Multiple filters: {app="frontend"} |= "error" != "timeout"
- Regular expression: {app="frontend"} |~ "error.*timeout"
- Extracting fields: {app="frontend"} | json
- Extracting specific fields: {app="frontend"} | json message, level
- Filtering on extracted fields: {app="frontend"} | json | level="error"
- Counting logs: count_over_time({app="frontend"}[5m])
- Rate of logs: rate({app="frontend"}[5m])
start: Start time, accepts Grafana time format (e.g., 'now-1h'), ISO8601, Unix timestamp, or RFC3339. Default: 1 hour ago.
end: End time, accepts Grafana time format (e.g., 'now'), ISO8601, Unix timestamp, or RFC3339. Default: now.
limit: Maximum number of log lines to return.
direction: Query direction, either 'forward' or 'backward'.
max_per_line: Maximum characters per log line (0 for unlimited). Default: 100.
Returns: A dictionary containing the query results.
References: - Introduction to LogQL: https://grafana.com/docs/loki/latest/logql/ - LogQL filter expressions: https://grafana.com/docs/loki/latest/logql/filter-expr/
get_loki_labels
Get all label names from Loki.
Returns: Dict containing label names
get_loki_label_values
Get values for a specific label from Loki.
Args: label: Label name
Returns: Dict containing label values
get_datasources
Get all datasources from Grafana.
Returns: Dict containing all datasources
get_datasource_by_id
Get a specific datasource by ID from Grafana.
Args: datasource_id: ID of the datasource to retrieve
Returns: Dict containing the datasource details
get_datasource_by_name
Get a specific datasource by name from Grafana.
Args: name: Name of the datasource to retrieve
Returns: Dict containing the datasource details
Prompts
Interactive templates invoked by user choice
No prompts
Resources
Contextual data attached and managed by the client