Skip to main content

kafka-sentinel-mcp

CI PyPI Python License: MIT

Give AI agents safe, read-only eyes on your Kafka clusters.

An MCP (Model Context Protocol) server that exposes Kafka cluster health, consumer lag, partition state, and replay-readiness as structured tools — so LLM agents (Claude, or any MCP client) can diagnose streaming incidents without ever being able to break anything.

Built by an engineer who spent a decade running Kafka-based financial messaging at 99.999% availability, and got tired of every "AI + Kafka" demo assuming write access to production.

Why this exists

When a consumer group stalls at 3 a.m., the questions are always the same: Is it lag? A stuck partition? A rebalance storm? An offset reset gone wrong? These are pattern-matching questions — exactly what LLM agents are good at — but no operator will hand an agent admin rights on a production cluster.

kafka-sentinel-mcp draws a hard line: every tool is read-only by design, enforced at the client-config level (no admin operations are even imported). The agent can observe, correlate, and recommend; a human executes.

Tools

Tool What it returns
list_topics All non-internal topics with partition count and replication factor — start here if you don't know a topic name
list_consumer_groups All consumer group IDs with state — start here if you don't know a group name
cluster_health Broker count, controller status, under-replicated / offline partition counts
consumer_lag Per-group, per-topic, per-partition lag with committed vs end offsets
topic_audit Replication factor, min.insync.replicas, retention, and flags configs that violate durability best practice
partition_state Leaders, ISR shrinkage, skew across brokers
replay_readiness For a group + topic: earliest available offsets vs committed, i.e., "can we still replay what we missed?"
incident_snapshot One-call bundle of all the above, timestamped — designed for pasting into a postmortem

Quick start

pip install kafka-sentinel-mcp   # (or: uv tool install)

# Run against your cluster (read-only credentials!)
KAFKA_BOOTSTRAP=localhost:9092 kafka-sentinel-mcp

Add to Claude Desktop / any MCP client:

{
  "mcpServers": {
    "kafka-sentinel": {
      "command": "kafka-sentinel-mcp",
      "env": { "KAFKA_BOOTSTRAP": "broker1:9092,broker2:9092" }
    }
  }
}

Then ask your agent: "Why is the payments-consumer group falling behind, and can we still replay from where it stalled?"

Security posture

  • Read-only by construction: no produce, no topic/config mutation, no offset commits, no ACL ops. The mutation APIs are never imported, and a test in CI greps the server source on every run to keep it that way.

  • The observer consumer runs with enable.auto.commit=False and never commits — verified against a real broker, not just asserted.

  • Supports SASL/SSL; credentials are read from the environment only and never logged.

  • Every tool call is logged with its parameters for audit.

  • Least privilege: run with a principal that has only Describe on the cluster and topics, and Describe on consumer groups. When an ACL denies an operation the tool returns a structured result rather than a stack trace:

    {
      "error": "permission_denied",
      "operation": "list_consumer_groups",
      "detail": "...",
      "hint": "The Kafka principal in use lacks the ACL required for this operation. ..."
    }
    

    The agent can then tell the operator which ACL is missing instead of appearing broken. Non-authorization failures are deliberately not swallowed — they propagate, because silently degrading on an unrelated error would hide real problems.

Testing

pip install -e ".[dev]"

pytest -m "not integration"   # fast, fully mocked — no Docker needed
pytest -m integration         # starts a real Kafka via testcontainers (needs Docker)
pytest                        # both

The unit suite mocks librdkafka entirely and covers tool logic. The integration suite starts an actual broker, produces real records, and asserts the tools return correct lag, ISR state, durability flags, and replay-readiness — including that the observer leaves no committed offsets behind. Both run in CI.

Status

Early but tested. See ROADMAP.md. Issues and PRs welcome — especially war stories about what you wish an agent could have told you during an incident.

Citing this work

If you reference this project in academic work, see CITATION.cff, or use the "Cite this repository" button on GitHub.

License

MIT

Metadata

Release files for kafka-sentinel-mcp 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kafka-sentinel-mcp 0.1.5
File Size Uploaded Provenance
kafka_sentinel_mcp-0.1.5.tar.gz 109.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for kafka-sentinel-mcp 0.1.5
File Interpreter ABI Platform
kafka_sentinel_mcp-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 118.8 kB

Release files / kafka_sentinel_mcp-0.1.5.tar.gz

Download URL kafka_sentinel_mcp-0.1.5.tar.gz
Size 109.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5905e3c81ecc690fa24e8ef08755285498cb0aade84f342bb18f89ada03e7474
BLAKE2b-256 checksum
How to use checksums
c8f47eac210440ff73690e28547e38c09f429d4da74f5c75e0ce658e1b372f7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 31, 2026.

Transparency log

Release files / kafka_sentinel_mcp-0.1.5-py3-none-any.whl

Download URL kafka_sentinel_mcp-0.1.5-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b50ecf853c84f727c7f36af1bda8c536af739e2fa98db52ae39a75b9def1e3e
BLAKE2b-256 checksum
How to use checksums
6b101efb31264cc6fa3201a61bf6d5230aaf83f230f3be04b5b224fc63e33b08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 31, 2026.

Transparency log

Security for kafka-sentinel-mcp 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kafka_sentinel_mcp-0.1.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page