OpenTelemetry MCP Server

OpenTelemetry MCP Server

Enables 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.

Category
Visit Server

README

otel-mcp

MCP server for querying Prometheus metrics and Loki logs with OIDC authentication.

Features

  • Query Prometheus metrics (PromQL)
  • Query Loki logs (LogQL)
  • HTTP API for K8s deployment
  • Service discovery (metrics, labels, log streams)

Quick Start

Local Development

# 1. Install
git clone <your-repo-url>
cd otel-mcp
uv sync

# 2. Configure .env
cp .env.example .env
# Edit .env with your Prometheus/Loki URLs

# 3. Run (stdio mode for local MCP)
uv run python -m src.server

Production (Kubernetes + Authentik)

See K8S_DEPLOYMENT.md for full deployment guide.

# Build and deploy
docker build -t your-registry/otel-mcp:latest .
kubectl apply -f k8s/

# Access at https://otel-mcp.your-domain.com

Available Tools

Prometheus (5 tools)

  • query_prometheus - Execute PromQL instant queries
  • query_prometheus_range - Query metrics over time range
  • list_metrics - List available metrics
  • list_label_values - Get label values (discover services)
  • list_labels - List all label names

Loki (4 tools)

  • query_loki - Execute LogQL queries
  • search_logs - Simple log search with filters
  • list_log_labels - List log stream labels
  • list_log_label_values - Get log label values

Usage

Production: K8s with Authentik OAuth Proxy

Deploy HTTP server behind Authentik for authentication.

See K8S_DEPLOYMENT.md for complete setup.

# Build and deploy
docker build -t registry/otel-mcp:latest .
kubectl apply -f k8s/

# Use the API
curl -H "Authorization: Bearer YOUR_TOKEN" \
  https://otel-mcp.your-domain.com/tools

curl -X POST https://otel-mcp.your-domain.com/call \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"tool": "query_prometheus", "arguments": {"query": "up"}}'

Local: MCP stdio (Development)

For local MCP clients like Claude Desktop.

# Run stdio server
uv run python -m src.server

# Claude Desktop config
{
  "mcpServers": {
    "otel-mcp": {
      "command": "uv",
      "args": ["--directory", "/path/to/otel-mcp", "run", "python", "-m", "src.server"],
      "env": {
        "PROMETHEUS_URL": "http://localhost:9090",
        "LOKI_URL": "http://localhost:3100"
      }
    }
  }
}

Configuration Options

Variable Default Description
PROMETHEUS_URL http://localhost:9090 Prometheus endpoint
LOKI_URL http://localhost:3100 Loki endpoint
MCP_AUTH_ENABLED false Enable OIDC auth
MCP_OIDC_ISSUER - OIDC provider URL
MCP_OIDC_CLIENT_ID - OAuth2 client ID
MCP_OIDC_AUDIENCE - Token audience (optional)
LOG_LEVEL INFO Logging level
QUERY_TIMEOUT 30 Query timeout (seconds)

Backend Authentication

Prometheus/Loki support Basic Auth and Bearer tokens:

# Basic Auth
PROMETHEUS_AUTH_TYPE=basic
PROMETHEUS_USERNAME=admin
PROMETHEUS_PASSWORD=secret

# Bearer Token
LOKI_AUTH_TYPE=bearer
LOKI_BEARER_TOKEN=your-token

Example Queries

# List services
{"tool": "list_label_values", "arguments": {"label": "job"}}

# Query CPU usage
{"tool": "query_prometheus", "arguments": {"query": "rate(cpu_usage[5m])"}}

# Search error logs
{"tool": "search_logs", "arguments": {"search_text": "error", "start": "1h"}}

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured