Mcp Kafka

io.github.dockndevai由 GitHub 账号 dockndevai 发布v0.3.3更新于 Oct 28, 2026

Apache Kafka monitoring & management for AI agents (with consumer lag) — governed.

已验证STDIO仅桌面数据库安全与监控

概览

AI 生成的概览

面向 Apache Kafka 的本地 MCP 服务器,让助手查看集群、主题、偏移量与消费延迟,并可选执行受管控的写入和管理操作。

可以做什么
  • 查看集群信息:broker、controller、集群 ID,以及按允许列表过滤的主题名称
  • 检查主题:分区、副本、同步副本、非默认配置,以及各分区的最早与最新偏移量
  • 查看消费组:列出消费组及协议类型,描述其状态,并计算各分区与总体的消费延迟
  • 在读写模式下管理主题:创建主题、增加分区、修改主题配置、重置消费组偏移量
  • 在管理模式删除主题或消费组,且需显式开启删除开关
适用场景
适合让助手回答 Kafka 集群的运维问题,例如哪些消费组延迟最高、某个主题如何分区,或在聊天客户端中做范围受限的主题变更。仅做监控时以只读模式启动即可。
运行要求
通过 npx 从 npm 包以 stdio 在本地运行,需要 Node.js。必须提供 KAFKA_BROKERS(逗号分隔的 host:port 列表),可选 KAFKA_MODE(read-only、read-write 或 admin,默认只读)。需要能访问 broker 的网络;支持明文、TLS 以及 SASL PLAIN/SCRAM 认证。
安装前请注意
读写和管理模式可创建主题、增加分区、修改配置、重置消费组偏移量,以及删除主题或消费组(删除还需开启删除开关)。除非确实需要变更,否则保持只读,并配合主题允许列表、受保护主题、试运行和审计日志。broker 凭据与 TLS/SASL 设置通过环境变量提供。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

mcp-kafka

[CI] [License: MIT] [npm]

A Model Context Protocol server for Apache Kafka. It lets an MCP-capable client (Claude Desktop, Claude Code, etc.) monitor and manage Kafka clusters — topics, partitions, configs, and consumer groups (including lag) — with behaviour controlled entirely by flags.

Safe by default: it starts read-only, can be scoped to an allowlist of topics, protects internal/critical topics from mutation, and gates destructive operations behind an explicit opt-in.

Features

  • Monitoring — cluster/broker info, topic metadata and offsets, consumer groups, and per-partition + total consumer lag.
  • Management — create topics, add partitions, alter topic configs, reset group offsets; delete topics/groups (admin).
  • Access modes — read-only → read-write → admin, layered so a mode never exposes tools above its level.
  • Security flags — topic allowlist, protected/internal topics, delete gating, dry-run, and JSON audit logging (see below).
  • Auth — plaintext, TLS, and SASL (PLAIN / SCRAM-SHA-256 / SCRAM-SHA-512).

Security model

ConcernFlagDefaultEffect
What can the server do?KAFKA_MODEread-onlyread-only exposes only monitoring; read-write adds management; admin adds deletes. Tools above the mode are never registered.
Which topics are in scope?KAFKA_TOPIC_ALLOWLIST(all)When set, operations on other topics are refused.
Protect internal topicsKAFKA_PROTECT_INTERNAL_TOPICStrueTopics starting with _ can be read but never mutated.
Protect specific topicsKAFKA_PROTECTED_TOPICS(none)Additional read-only-forever topics.
Can it delete?KAFKA_ALLOW_DELETEfalsedelete_topic / delete_consumer_group need this and admin mode.
Preview without touching the clusterKAFKA_DRY_RUNfalseWrite/admin tools validate + log intent, then return.
Audit trailKAFKA_AUDIT_LOGtrueEmits a JSON line to stderr per guarded operation.
Interactive confirmation(automatic)—Destructive & high-impact actions prompt the human to approve via MCP elicitation before running; clients without elicitation fall back to the *_ALLOW_* gate.

Tools

Read (read-only+): cluster_info, list_topics, describe_topic, topic_offsets, list_consumer_groups, describe_consumer_group (with lag)

Write (read-write+): create_topic, create_partitions, alter_topic_config, reset_consumer_group_offsets

Admin (admin): delete_topic, delete_consumer_group (both need KAFKA_ALLOW_DELETE)

Quickstart — add to your agent

Published on npm as @dockndevai/mcp-kafka. No clone or build needed — your MCP client runs it on demand with npx. Start in read-only mode; see .env.example for every variable and docs/CLIENTS.md for the full per-client guide.

Claude Code (CLI)

bash
claude mcp add kafka -e KAFKA_BROKERS="localhost:9092" -e KAFKA_MODE="read-only" -- npx -y @dockndevai/mcp-kafka

Claude Desktop · Cursor · Windsurf — same block in claude_desktop_config.json, .cursor/mcp.json, or ~/.codeium/windsurf/mcp_config.json:

json
{  "mcpServers": {    "kafka": {      "command": "npx",      "args": [        "-y",        "@dockndevai/mcp-kafka"      ],      "env": {        "KAFKA_BROKERS": "localhost:9092",        "KAFKA_MODE": "read-only"      }    }  }}

OpenAI Codex CLI — in ~/.codex/config.toml:

toml
[mcp_servers.kafka]command = "npx"args = ["-y", "@dockndevai/mcp-kafka"]env = { KAFKA_BROKERS = "localhost:9092", KAFKA_MODE = "read-only" }

VS Code (GitHub Copilot, Agent mode) — in .vscode/mcp.json:

json
{  "servers": {    "kafka": {      "type": "stdio",      "command": "npx",      "args": [        "-y",        "@dockndevai/mcp-kafka"      ],      "env": {        "KAFKA_BROKERS": "localhost:9092",        "KAFKA_MODE": "read-only"      }    }  }}

Example prompts

  • "Which consumer groups have the most lag right now?"
  • "Describe the orders topic and show its offsets."
  • "Create a topic events with 6 partitions and 7-day retention." (needs read-write)

Run from source (development)

Prefer the published package above. To run from a clone:

bash
npm installnpm run buildnode dist/index.js   # with the environment variables set

Develop

bash
npm run devnpm testnpm run typecheck

Publishing

This server ships a server.json for the official MCP registry and an mcpName for npm ownership validation. See PUBLISHING.md for publishing to npm and listing on the MCP registry, Smithery, Glama, Cursor, and PulseMCP.

License

MIT

来源:README.md,提交 4996b18

工具

6

cluster_info

Cluster info

Describe the Kafka cluster: brokers, controller, and cluster id.

无需输入参数。

list_topics

List topics

List topic names. Topics outside the allowlist are filtered out.

输入参数includeInternal

describe_topic

Describe topic

Partitions, replicas, in-sync replicas, and non-default configs for a topic.

输入参数topic必填

topic_offsets

Topic offsets

Earliest and latest offsets per partition for a topic (message backlog view).

输入参数topic必填

list_consumer_groups

List consumer groups

List consumer groups and their protocol types.

无需输入参数。

describe_consumer_group

Describe consumer group (with lag)

Describe a consumer group's state and compute per-partition and total lag across its topics.

输入参数groupId必填

版本历史

3
  1. v0.3.3最新Oct 26, 2026
  2. v0.3.0Sep 29, 2026
  3. v0.2.2Sep 16, 2026

评分

已满足适用检查项的 90%

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

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

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

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分