LGTM MCP Server
Provides read-only access to Grafana Cloud or self-hosted Grafana LGTM stack (Loki, Prometheus, Tempo) for querying logs, metrics, and traces via LogQL, PromQL, and TraceQL.
Allows querying Prometheus metrics using PromQL, listing metric names, labels, and metadata, and retrieving series and label values.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@LGTM MCP Serverfetch error logs from the last hour"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
LGTM MCP Server
MCP server providing read-only access to Loki, Prometheus, and Tempo APIs.
Features
Multi-instance support: Configure multiple LGTM stacks and switch between them
Bearer token authentication: Works with Grafana Cloud and self-hosted deployments
Query tools: Execute LogQL, PromQL, and TraceQL queries
Metadata discovery: Expose labels, metrics, and tags as MCP resources
Syntax documentation: Built-in query language references
OpenTelemetry tracing: All HTTP client calls are traced and exported via OTLP/gRPC
Related MCP server: Prometheus MCP Server
Configuration
Create a config file at ~/.config/lgtm-mcp/config.yaml:
version: "1"
default_instance: "local"
instances:
local:
loki:
url: "http://localhost:3100"
prometheus:
url: "http://localhost:9090"
tempo:
url: "http://localhost:3200"
grafana-cloud:
loki:
url: "https://logs-prod-us-west-0.grafana.net"
username: "${GRAFANA_CLOUD_LOKI_USERNAME}"
token: "${GRAFANA_CLOUD_TOKEN}"
prometheus:
url: "https://prometheus-prod-01-us-west-0.grafana.net/api/prom"
username: "${GRAFANA_CLOUD_PROMETHEUS_USERNAME}"
token: "${GRAFANA_CLOUD_TOKEN}"
tempo:
url: "https://tempo-prod-us-west-0.grafana.net"
username: "${GRAFANA_CLOUD_TEMPO_USERNAME}"
token: "${GRAFANA_CLOUD_TOKEN}"Environment variables are expanded using ${VAR} syntax.
For Grafana Cloud, a token with read-only permissions is sufficient. See Creating access policies for details.
Usage
Claude Code
Add the MCP server using the Claude Code CLI:
claude mcp add lgtm -- uvx --from git+https://github.com/pokgak/lgtm-mcp lgtm-mcpOr manually add to your Claude Code MCP settings (~/.claude/settings.json):
{
"mcpServers": {
"lgtm": {
"command": "uvx",
"args": ["--from", "git+https://github.com/pokgak/lgtm-mcp", "lgtm-mcp"]
}
}
}Claude Desktop
Add to your Claude Desktop config file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"lgtm": {
"command": "uvx",
"args": ["--from", "git+https://github.com/pokgak/lgtm-mcp", "lgtm-mcp"]
}
}
}Local Development
If you've cloned the repository locally:
{
"mcpServers": {
"lgtm": {
"command": "uv",
"args": ["run", "lgtm-mcp"],
"cwd": "/path/to/lgtm-mcp"
}
}
}Available Tools
Loki (Logs)
loki_patterns- Start here! Detect log patterns and frequency (requirespattern_ingesterenabled)loki_stats- Get quick stats (stream count, bytes) without fetching logsloki_volume- Get log volume breakdown by labelsloki_query_logs- Retrieve log entries (use after patterns to get specific examples)loki_instant_query- Metric-type LogQL at single pointloki_get_labels- List label namesloki_get_label_values- Get values for a labelloki_get_series- Find matching log streams
Prometheus (Metrics)
prometheus_instant_query- Execute PromQL instant queryprometheus_range_query- Execute PromQL range query (broken)prometheus_range_query_chart- Range query with ASCII chart visualizationprometheus_get_metric_names- List metricsprometheus_get_label_names- List label namesprometheus_get_label_values- Get values for a labelprometheus_get_series- Find matching seriesprometheus_get_metadata- Get metric metadata
Tempo (Traces)
tempo_trace_summary- Start here! Get trace summary with stats (duration p50/p95/p99, error count, span tree)tempo_get_trace- Retrieve full trace data (use after summary for details)tempo_search_traces- Search with TraceQLtempo_get_tag_names- List tag namestempo_get_tag_values- Get values for a tagtempo_get_services- List service names
Utility
list_instances- List configured instancesset_default_instance- Change default instance
Available Resources
Resources expose metadata for query generation:
lgtm://{instance}/loki/labels- Loki label nameslgtm://{instance}/prometheus/labels- Prometheus label nameslgtm://{instance}/prometheus/metrics- Metric nameslgtm://{instance}/tempo/tags- Tempo tag nameslgtm://syntax/logql- LogQL syntax referencelgtm://syntax/promql- PromQL syntax referencelgtm://syntax/traceql- TraceQL syntax reference
Tracing
The server automatically instruments all HTTP client calls with OpenTelemetry. Traces are exported via OTLP/gRPC.
By default, traces are sent to http://localhost:4317. Override with:
export OTEL_EXPORTER_OTLP_ENDPOINT="http://your-collector:4317"Service name: lgtm-mcp
Development
# Install with dev dependencies
uv pip install -e ".[dev]"
# Run type checks
mypy src/
# Run linter
ruff check src/
# Run tests
pytestThis server cannot be deployed
Maintenance
Related MCP Connectors
- SuperlogOAuthsh.superlog
Open-source agent that observes and fixes your application. Query logs, traces, metrics, incidents.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Query OneLens cloud-cost data in natural language: breakdowns, trends, cost centers. Read-only.
- mcpOAuthcom.vibgrate
Query your team's drift, vulnerability, and upgrade data from any AI assistant. OAuth 2.1, 51 tools.
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables AI agents to query Prometheus metrics and Loki logs for intelligent alert investigation and troubleshooting. Provides service discovery, metric querying, log searching, and correlation tools to help identify root causes of issues.9-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to execute PromQL queries and discover metrics across multiple Prometheus tenants using the Model Context Protocol. It supports single and multi-tenant configurations with secure authentication for instant and range query analysis.MIT
- AlicenseNot gradedqualityDmaintenanceEnables natural language querying and analysis of OpenTelemetry traces, metrics, and logs stored in Elasticsearch/OpenSearch, allowing AI assistants to investigate performance issues, find root causes, and explore system behavior.12 npm14MIT
- AlicenseAqualityDmaintenanceEnables read-only querying of Grafana Loki logs through tools like label discovery, LogQL queries, and recent log retrieval, without requiring knowledge of the Loki API.4MIT