Kafka Sentinel

io.github.sanjay-amu由 GitHub 账号 sanjay-amu 发布v0.1.2更新于 Oct 27, 2026

Read-only Kafka observability MCP server: cluster health, consumer lag, and replay-readiness.

概览

AI 生成的概览

只读的 Kafka 可观测性 MCP 服务器,让助手查看集群健康、消费延迟、分区状态与重放可行性。

可以做什么
  • 列出主题与消费组,获取名称和状态
  • 报告集群健康:broker 数量、控制器状态、副本不足与离线分区数
  • 按组、主题、分区展示消费延迟及已提交与末端偏移量
  • 审计主题持久性配置,查看分区 leader、ISR 收缩与分布倾斜
  • 检查指定组与主题的重放可行性,并一次性生成带时间戳的故障快照
适用场景
适合排查流式数据故障,例如消费组停滞、延迟飙升、重平衡风暴或偏移量重置,也适合让助手在没有任何写入或管理权限的情况下观察并关联 Kafka 状态。
运行要求
以 Python 包形式通过 pip 或 uv 本地安装,经 stdio 启动。需要 KAFKA_BOOTSTRAP;可选 SASL/SSL 配置通过 KAFKA_SECURITY_PROTOCOL、KAFKA_SASL_MECHANISM、KAFKA_SASL_USERNAME、KAFKA_SASL_PASSWORD 与 KAFKA_SSL_CA_LOCATION 提供。需要能访问 broker 的网络。
安装前请注意
需要 Kafka 凭据,包括机密项 KAFKA_SASL_PASSWORD,均从环境变量读取。应使用仅有 Describe 权限的最小权限账号。每次工具调用都会连同参数记录用于审计。项目自述为早期但已测试。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Kafka Sentinel,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

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

ToolWhat it returns
list_topicsAll non-internal topics with partition count and replication factor — start here if you don't know a topic name
list_consumer_groupsAll consumer group IDs with state — start here if you don't know a group name
cluster_healthBroker count, controller status, under-replicated / offline partition counts
consumer_lagPer-group, per-topic, per-partition lag with committed vs end offsets
topic_auditReplication factor, min.insync.replicas, retention, and flags configs that violate durability best practice
partition_stateLeaders, ISR shrinkage, skew across brokers
replay_readinessFor a group + topic: earliest available offsets vs committed, i.e., "can we still replay what we missed?"
incident_snapshotOne-call bundle of all the above, timestamped — designed for pasting into a postmortem

Quick start

bash
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:

json
{  "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:

    json
    {  "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

bash
pip install -e ".[dev]"
pytest -m "not integration"   # fast, fully mocked — no Docker neededpytest -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

来源:README.md,提交 719153d

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.2最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分