mcp-kafka
mcp-kafka
一个面向 Apache Kafka 的 Model Context Protocol 服务器。它让支持 MCP 的客户端(Claude Desktop、Claude Code 等)能够监控和管理 Kafka 集群——主题、分区、配置和消费者组(含 consumer lag)——行为完全由标志(flag)控制。
默认安全:服务以只读模式启动,可通过主题 allowlist 限定范围,可让内部/关键主题不被修改,并且破坏性操作被放在显式 opt-in 之后。
功能
监控 — 集群/broker 信息、主题元数据和偏移量、消费者组,以及每个分区 + 总体统计的 consumer lag(消费滞后)。
管理 — 创建主题、增加分区、更改主题配置、重置消费组偏移量;删除主题/消费者组(admin 模式)。
访问模式 —-
read-only→read-write→admin,分层设计,任何模式都不会暴露其层级以上的工具。安全标志 — 主题 allowlist、保护内部/关键主题、删除开关、dry-run,以及 JSON 审计日志(见下文)。
认证 — 明文、TLS 和 SASL(PLAIN / SCRAM-SHA-256 / SCRAM-SHA-512)。
Related MCP server: Kafka MCP Server
安全模型
关注项 | 标志 | 默认值 | 作用 |
服务器能做什么? |
|
|
|
哪些主题在范围内? |
| (全部) | 设置后,对范围外其他主题的操作会被拒绝。 |
保护内部主题线程 |
|
| 以 |
保护指定主题 |
| (无) | 追加的永久只读主题。 |
是否可以删除? |
|
|
|
不真正触碰集群地预览 |
|
| 写/管理工具先校验并记录意图,然后返回。 |
审计追踪 |
|
| 每次受控操作都会向 stderr 输出一行 JSON。 |
工具
读取(read-only+):cluster_info、list_topics、describe_topic、topic_offsets、list_consumer_groups、describe_consumer_group(含 lag)
写入(read-write+):create_topic、create_partitions、alter_topic_config、reset_consumer_group_offsets
管理(admin):delete_topic、delete_consumer_group(二者均需 KAFKA_ALLOW_DELETE)
与你的 MCP 客户端配合使用
可配合 Claude Code、Claude Desktop、Cursor、OpenAI Codex CLI、Windsurf、VS Code(Copilot)以及任何其他 MCP 客户端使用——各客户端配置步骤请见 docs/CLIENTS.md。
安装
npm install
npm run build使用 Claude Desktop / Claude Code 运行
{
"mcpServers": {
"kafka": {
"command": "node",
"args": ["/absolute/path/to/mcp-kafka/dist/index.js"],
"env": {
"KAFKA_BROKERS": "broker1:9092,broker2:9092",
"KAFKA_MODE": "read-only",
"KAFKA_SSL": "true",
"KAFKA_SASL_MECHANISM": "scram-sha-512",
"KAFKA_SASL_USERNAME": "mcp",
"KAFKA_SASL_PASSWORD": "…"
}
}
}
}示例提示词
"当前哪些消费者组的 lag 最严重?"
"描述
orders主题并展示其偏移量。""创建一个 6 个分区、保留 7 天的
events主题。"(需要read-write)
开发
npm run dev
npm test
npm run typecheck发布
本服务器提供了官方 MCP 注册表所需的 server.json,以及用于 npm 所有权验证的 mcpName。发布到 npm 并在 MCP 注册表、Smithery、Glama、Cursor 和 PulseMCP 上列出,请参阅 PUBLISHING.md。
许可证
MIT
Available Tools
6 toolscluster_infoCluster infoARead-onlyIdempotent
Describe the Kafka cluster: brokers, controller, and cluster id.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
describe_consumer_groupDescribe consumer group (with lag)BRead-onlyIdempotent
Describe a consumer group's state and compute per-partition and total lag across its topics.
| Name | Required | Description | Default |
|---|---|---|---|
| groupId | Yes | Consumer group id |
describe_topicDescribe topicCRead-onlyIdempotent
Partitions, replicas, in-sync replicas, and non-default configs for a topic.
| Name | Required | Description | Default |
|---|---|---|---|
| topic | Yes | Topic name |
list_consumer_groupsList consumer groupsARead-onlyIdempotent
List consumer groups and their protocol types.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
list_topicsList topicsBRead-onlyIdempotent
List topic names. Topics outside the allowlist are filtered out.
| Name | Required | Description | Default |
|---|---|---|---|
| includeInternal | No | Include internal topics (starting with _) |
topic_offsetsTopic offsetsARead-onlyIdempotent
Earliest and latest offsets per partition for a topic (message backlog view).
| Name | Required | Description | Default |
|---|---|---|---|
| topic | Yes | Topic name |
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
v0.2.2- Changed
describe_consumer_group1 field changed- removed
Input schema / additionalPropertiesRemoved value: -false
- Changed
describe_topic1 field changed- removed
Input schema / additionalPropertiesRemoved value: -false
- Changed
list_topics1 field changed- removed
Input schema / additionalPropertiesRemoved value: -false
- Changed
topic_offsets1 field changed- removed
Input schema / additionalPropertiesRemoved value: -false
6 tool updates
v0.1.0- First observed
cluster_info - First observed
describe_consumer_group - First observed
describe_topic - First observed
list_consumer_groups - First observed
list_topics - First observed
topic_offsets
TDQS
Scored across 6 tools
Each tool targets a distinct resource+action: topic listing vs. topic detail vs. offset backlog, consumer group listing vs. group detail/lag, and cluster summary. The list_* vs describe_* split is crisp, and topic_offsets is clearly separated from describe_topic. No two tools could be reasonably confused.
Most tools follow a verb_noun pattern (list_topics, describe_topic, describe_consumer_group, list_consumer_groups), but topic_offsets and cluster_info use noun-phrase forms. The deviation is minor and still readable, and the overall style is snake_case and predictable.
Six tools is well-scoped for a read-only Kafka inspection server, covering the three core surfaces (topics, consumer groups, cluster) without redundancy. Each tool earns its place with no filler.
The read-only inspection surface is coherent and covers topic metadata, offset backlog, consumer group lag, and cluster state with no dead ends within its scope. Gaps exist for write/admin operations (create/delete topics, config changes) and message preview, but these appear intentionally out of scope.
Maintenance
Related MCP Connectors
Managed MCP gateway with OAuth, per-agent permissions, shared accounts and activity logs.
Governed MCP gateway: one endpoint for your tools, with credential custody and audit log.
One MCP URL for all your connectors — scoped writes, enforced constraints, and a full audit trail.
Managed Keycloak from any MCP client: clusters, realms, apps, SSO, users, domains, audit events.
Related MCP Servers
AlicenseBqualityAmaintenanceAn MCP server implementation built to interact with Confluent Kafka and Confluent Cloud REST APIs.241,927 npm169MIT- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables interaction with Kafka clusters to manage topics, monitor consumer groups, and stream messages. It provides a comprehensive suite of tools for broker metadata inspection and local Kafka user management.MIT
- AlicenseBqualityBmaintenanceMCP server for Apache Kafka that allows LLM agents to inspect topics, consumer groups, and safely manage offsets (reset, rewind).1913Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables interaction with Kafka clusters via MCP, supporting topic management (list, create, delete, inspect), connection initialization, and more through natural language.1Apache 2.0