Skip to main content
Glama
Karma MCP Server
by driosalido

🚨 Karma MCP Server

License: MIT Python 3.11+ MCP Protocol Docker Support Just

Bring AI-powered intelligence to your Kubernetes alerts. Karma MCP Server enables Claude to directly interact with your Karma Alert Dashboard, providing natural language queries, analysis, and management of Prometheus/Alertmanager alerts.

🌟 What is This?

Karma MCP Server is a bridge that connects Claude Desktop (or any MCP-compatible client) to your Karma Alert Dashboard. This allows you to:

  • πŸ—£οΈ Ask questions in natural language about your alerts: "How many critical alerts are there in production?"

  • πŸ” Search and filter across multiple Kubernetes clusters simultaneously

  • πŸ“Š Get instant insights about alert patterns and trends

  • πŸš€ Accelerate incident response with AI-powered alert analysis

  • πŸ”„ Automate routine checks without leaving your conversation

Example Interactions with Claude

You: "Show me all critical alerts in the production cluster"
Claude: [Lists and analyzes critical alerts with context]

You: "Which pods are crash looping?"
Claude: [Shows KubePodCrashLooping alerts with namespace, pod details, and suggestions]

You: "Search for OOM killed containers across all clusters"
Claude: [Performs multi-cluster search and provides memory optimization tips]

Related MCP server: OpenTelemetry MCP Server

🎯 Key Features

Core Alert Management

  • βœ… Real-time alert listing with severity, state, and cluster information

  • βœ… Multi-cluster support - search across all your Kubernetes clusters at once

  • βœ… Smart filtering by cluster, namespace, severity, and alert state

  • βœ… Detailed alert inspection with annotations, labels, and runbook links

  • βœ… Statistical summaries showing alert distribution and trends

Advanced Capabilities

  • πŸ” Alert name search - Search specific alerts by pattern matching

  • πŸ” State filtering - Filter by active, suppressed, or all states

  • πŸ” Cross-cluster analysis - Compare alert patterns between environments

Integration Features

  • πŸ”„ MCP Protocol support for AI assistants

  • 🐳 Docker support with multi-architecture images

  • ☸️ Kubernetes-ready deployment

πŸ“¦ Installation

Quick Start with Claude Desktop

  1. Install via UV (recommended)

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Clone and install
git clone https://github.com/driosalido/karma-mcp.git
cd karma-mcp
uv sync --all-extras

# Optional: Install Just task runner for easier development
brew install just        # macOS
# See: https://github.com/casey/just#installation for other platforms
  1. Configure Claude Desktop, Claude Code, or Cursor

Local Installation (Stdio Mode)

Add to your MCP client configuration:

Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "karma": {
      "command": "uv",
      "args": ["run", "python", "-m", "karma_mcp.server"],
      "cwd": "/path/to/karma-mcp",
      "env": {
        "KARMA_URL": "http://your-karma-instance:8080"
      }
    }
  }
}

Claude Code (add to project's claude_desktop_config.json or global config):

{
  "mcpServers": {
    "karma": {
      "command": "uv",
      "args": ["run", "python", "-m", "karma_mcp.server"],
      "cwd": "/path/to/karma-mcp",
      "env": {
        "KARMA_URL": "http://your-karma-instance:8080"
      }
    }
  }
}

Cursor (via MCP extension or custom configuration):

{
  "mcpServers": {
    "karma": {
      "command": "uv", 
      "args": ["run", "python", "-m", "karma_mcp.server"],
      "cwd": "/path/to/karma-mcp",
      "env": {
        "KARMA_URL": "http://your-karma-instance:8080"
      }
    }
  }
}

Remote HTTP Server (Alternative)

If you have deployed the HTTP server version, use SSE transport:

{
  "mcpServers": {
    "karma": {
      "transport": {
        "type": "sse",
        "url": "https://your-karma-mcp-server.com/mcp/sse"
      }
    }
  }
}
  1. Connect to your Karma instance

# If Karma is in Kubernetes
kubectl port-forward svc/karma 8080:80 -n monitoring

# Or set your Karma URL directly
export KARMA_URL=http://your-karma-instance:8080
  1. Restart Claude Desktop and start asking about your alerts!

Docker Installation

# Using pre-built image
docker run -d \
  -e KARMA_URL=http://your-karma:8080 \
  -p 8000:8000 \
  driosalido/karma-mcp:latest

# Or build locally
docker build -f docker/Dockerfile -t karma-mcp .
docker run -d -e KARMA_URL=http://karma:8080 karma-mcp

Kubernetes Deployment

# Deploy using Docker image
kubectl create deployment karma-mcp \
  --image=driosalido/karma-mcp:latest

kubectl set env deployment/karma-mcp \
  KARMA_URL=http://karma.monitoring:80

πŸ› οΈ Available MCP Tools

The following tools are available for Claude to use:

Tool

Description

Example Query

check_karma

Verify Karma connectivity

"Is Karma accessible?"

list_alerts

List all active alerts

"Show me all alerts"

get_alerts_summary

Statistical summary by severity/state

"Give me an alert summary"

get_alert_details

Detailed info about specific alert

"Details about KubePodCrashLooping"

list_clusters

List all K8s clusters with counts

"Which clusters have alerts?"

list_alerts_by_cluster

Filter by cluster

"Show teddy-prod alerts"

list_active_alerts

Show only active alerts

"What's currently firing?"

list_suppressed_alerts

Show silenced/inhibited

"What alerts are suppressed?"

get_alerts_by_state

Filter by state (active/suppressed/all)

"Show all suppressed alerts"

search_alerts

Search alerts by name pattern

"Find all OOM alerts"

silence_alert

Create alert silence

"Silence KubePodCrashLooping for 2h"

🧠 AI-Enhanced Analysis

The Karma MCP Server includes specialized prompts that help Claude provide more valuable alert analysis:

πŸ“š Available Prompt Resources

Resource

Purpose

Description

prompts://alert-analysis

Alert Analysis

Comprehensive guidelines for troubleshooting common K8s alerts

prompts://incident-response

Incident Response

Escalation procedures and communication templates

prompts://kubernetes-context

K8s Context

Deep Kubernetes knowledge for alert interpretation

prompts://business-impact

Business Impact

Prioritization framework based on service criticality

🎯 Enhanced Capabilities

With these prompts, Claude can:

  • πŸ” Correlate related alerts across clusters and namespaces

  • 🚨 Prioritize by business impact (prod > staging > dev)

  • πŸ”§ Suggest specific actions for common alert types

  • πŸ“Š Provide context about Kubernetes resource relationships

  • πŸš€ Guide incident response with escalation procedures

πŸ”Œ API Integration

The server runs as an MCP server using stdio protocol for communication with Claude Desktop. For programmatic access, you can call the MCP tools directly from your Python code:

from karma_mcp.server import list_alerts, get_alerts_summary

# Example usage
alerts = await list_alerts()
summary = await get_alerts_summary()

πŸ§ͺ Testing

# Run unit tests
uv run pytest tests/unit/

# Run with coverage
uv run pytest --cov=karma_mcp tests/

# Run integration tests (requires Karma instance)
KARMA_URL=http://localhost:8080 uv run pytest tests/integration/

# Manual testing with real Karma server
KARMA_URL=http://localhost:8080 uv run python -c "
import asyncio
from karma_mcp.server import list_alerts, get_alerts_summary
asyncio.run(list_alerts())
"

πŸ”§ Development

Setting up the development environment

# Clone the repository
git clone https://github.com/driosalido/karma-mcp.git
cd karma-mcp

# Install dependencies (includes dev dependencies)
uv sync --all-extras

# Install Just task runner (modern alternative to Make)
# macOS
brew install just

# Other platforms: https://github.com/casey/just#installation

# Set up development environment
just dev-setup

Task Runner: Just vs Make

This project uses Just as the modern task runner (alternative to Make). Key benefits:

  • βœ… No tab/space issues (common Make problem)

  • βœ… Better variable handling and environment integration

  • βœ… Cleaner syntax and cross-platform compatibility

  • βœ… Built-in command listing with just

  • βœ… Modern features like default values and string interpolation

# See all available commands
just

# Common development tasks
just test-unit              # Run unit tests (78 tests)
just lint                   # Code linting  
just format                 # Code formatting
just check                  # All quality checks
just test-with-karma        # Test with real Karma server
just docker-build-local     # Build Docker image
just version               # Show version info

Manual Development Commands

If you prefer direct commands or don't have Just installed:

# Run tests
uv run pytest tests/unit/ -v

# Code quality
uv run ruff check src/ tests/
uv run ruff format src/ tests/

# Install pre-commit hooks  
uv run pre-commit install

Project Structure

karma-mcp/
β”œβ”€β”€ src/karma_mcp/
β”‚   └── server.py         # Main MCP server with all tools
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ unit/             # Unit tests
β”‚   β”œβ”€β”€ integration/      # Integration tests
β”‚   └── fixtures/         # Test data
β”œβ”€β”€ docker/
β”‚   └── Dockerfile        # Docker configuration
β”œβ”€β”€ scripts/
β”‚   └── test_karma.py     # Integration testing utilities
β”œβ”€β”€ justfile              # Modern task runner (preferred)
β”œβ”€β”€ Makefile              # Traditional Make tasks (legacy)
β”œβ”€β”€ pyproject.toml        # Project dependencies and config
└── .github/workflows/    # CI/CD pipelines

πŸ“Š Real-World Use Cases

Daily Operations

  • Morning standup: "Show me all critical alerts from the last 24 hours"

  • Shift handover: "Summarize current active alerts by cluster"

  • Quick checks: "Are there any database-related alerts?"

Incident Response

  • Investigation: "Find all alerts related to the payment service"

  • Pattern detection: "Show me crash loops in the API namespace"

  • Impact analysis: "Which clusters are affected by high CPU throttling?"

Capacity Planning

  • Resource issues: "List all OOM killed containers this week"

  • Scaling decisions: "Show pods with high memory pressure"

  • Performance: "Find all high latency alerts"

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Areas we'd love help with:

  • πŸ“ˆ Historical trending and analytics

  • πŸ” Authentication support for secured Karma instances

  • 🌍 Additional language support for alert descriptions

  • πŸ“± Slack/Teams notification integrations

  • πŸ€– AI-powered alert correlation and root cause analysis

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Karma Alert Dashboard - The excellent alert dashboard that makes this possible

  • Model Context Protocol - Anthropic's protocol for AI tool integration

  • FastMCP - Simplified MCP server development

  • The Kubernetes and Prometheus communities for their amazing monitoring ecosystem

πŸ“š Documentation

  • Configuration: Set KARMA_URL environment variable to your Karma instance

  • Troubleshooting: Check the GitHub Issues for common problems

  • Examples: See the "Real-World Use Cases" section above for query examples

πŸš€ Roadmap

Completed βœ…

  • Core alert querying and filtering

  • Multi-cluster support

  • State-based filtering (active/suppressed)

  • Docker containerization

  • CI/CD with GitHub Actions

  • Alert search by pattern

  • Alert silencing capability

In Progress πŸ”¨

  • Alert acknowledgment

  • Silence management (list/delete)

Future Plans πŸ’­

  • Historical data and trending

  • Alert correlation analysis

  • Grafana integration

  • Authentication for secured Karma instances


Need help? Open an issue or reach out on GitHub Discussions

Like this project? Give it a ⭐ on GitHub!

Available Tools

14 tools
check_karmaA

Check connection to Karma server

Inputs: no named parameters. Returns: result

create_silenceA

Create a new silence for specific alerts

Args: cluster: Target cluster name (e.g., 'teddy-prod') alertname: Name of the alert to silence duration: Duration of silence (e.g., '2h', '30m', '1d') comment: Comment explaining why the alert is being silenced matchers: Additional matchers in format 'key=value,key2=value2' (optional)

Returns: Silence creation result with silence ID

Inputs: cluster (required), alertname (required), duration, comment, +1 more. Returns: result

delete_silenceA

Delete (expire) an existing silence

Args: silence_id: ID of the silence to delete cluster: Cluster where the silence exists

Returns: Deletion result

Inputs: silence_id (required), cluster (required). Returns: result

get_alert_detailsC

Get detailed information about a specific alert

Args: alert_name: Name of the alert to get details for

Inputs: alert_name (required). Returns: result

get_alert_details_multi_clusterA

Get detailed information about a specific alert across multiple clusters

Args: alert_name: Name of the alert to search for (e.g., 'KubePodCrashLooping') cluster_filter: Optional cluster name filter. If empty, searches all clusters.

Inputs: alert_name (required), cluster_filter. Returns: result

get_alerts_by_stateC

Get alerts filtered by state (active, suppressed, or all)

Inputs: state (required). Returns: result

get_alerts_summaryA

Get a summary of alerts grouped by severity and state

Inputs: no named parameters. Returns: result

list_active_alertsA

List only active (non-suppressed) alerts

Inputs: no named parameters. Returns: result

list_alertsB

List all active alerts in Karma

Inputs: no named parameters. Returns: result

list_alerts_by_clusterA

List alerts filtered by specific cluster

Args: cluster_name: Name of the cluster to filter by (e.g., 'teddy-prod', 'edge-prod')

Inputs: cluster_name (required). Returns: result

list_clustersA

List all available Kubernetes clusters in Karma

Inputs: no named parameters. Returns: result

list_silencesA

List all active silences across clusters or for a specific cluster

Args: cluster: Optional cluster name to filter silences (e.g., 'teddy-prod')

Returns: Formatted list of active silences with details

Inputs: cluster. Returns: result

list_suppressed_alertsC

List only suppressed alerts

Inputs: no named parameters. Returns: result

search_alerts_by_containerA

Search for alerts by container name across multiple clusters

Args: container_name: Name of the container to search for cluster_filter: Optional cluster name filter (e.g., 'teddy-prod', 'edge-prod'). If empty, searches all clusters.

Inputs: container_name (required), cluster_filter. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 14 tools

    Disambiguation5/5

    Each tool has a distinct purpose: health check, silence management, alert listing/filtering by various criteria, cluster listing, and container search. No overlapping ambiguity.

    Naming Consistency5/5

    All tools use consistent lowercase underscore-separated verb_noun naming (e.g., create_silence, list_alerts, get_alert_details). No mixed conventions.

    Tool Count5/5

    14 tools cover all necessary operations for a Karma alert management server: connection check, silence CRUD, alert listing with various filters, and cluster info. Well-scoped.

    Completeness5/5

    The tool set covers the full range of Karma operations: checking server health, managing silences (create/delete), listing and filtering alerts by state, cluster, container, and getting details. No obvious gaps.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      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.
      9
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to interact with and manage Kubernetes clusters, supporting operations on pods, deployments, services, configmaps, secrets, namespaces, metrics, and events with built-in safety features for destructive actions.
      9
      7 npm
      1
      MIT
    • A
      license
      C
      quality
      D
      maintenance
      Enables Claude AI to interact with Prometheus Alertmanager for alert retrieval, silence management, and alert grouping through natural language.
      6
      42 npm
      10
      MIT