Skip to main content
Glama

mcp-kafka

CI License: MIT

一个面向 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

安全模型

关注项

标志

默认值

作用

服务器能做什么?

KAFKA_MODE

read-only

read-only 只暴露监控;read-write 增加管理;admin 增加删除。高于当前模式的工具永远不会注册。

哪些主题在范围内?

KAFKA_TOPIC_ALLOWLIST

(全部)

设置后,对范围外其他主题的操作会被拒绝。

保护内部主题线程

KAFKA_PROTECT_INTERNAL_TOPICS

true

以 _ 开头的主题可以读,但绝不能改。

保护指定主题

KAFKA_PROTECTED_TOPICS

(无)

追加的永久只读主题。

是否可以删除?

KAFKA_ALLOW_DELETE

false

delete_topic / delete_consumer_group 需要此开关 和 admin 模式。

不真正触碰集群地预览

KAFKA_DRY_RUN

false

写/管理工具先校验并记录意图,然后返回。

审计追踪

KAFKA_AUDIT_LOG

true

每次受控操作都会向 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 tools
cluster_infoCluster infoA
Read-onlyIdempotent

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

NameRequiredDescriptionDefault

No parameters

describe_consumer_groupDescribe consumer group (with lag)B
Read-onlyIdempotent

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

NameRequiredDescriptionDefault
groupIdYesConsumer group id
describe_topicDescribe topicC
Read-onlyIdempotent

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

NameRequiredDescriptionDefault
topicYesTopic name
list_consumer_groupsList consumer groupsA
Read-onlyIdempotent

List consumer groups and their protocol types.

NameRequiredDescriptionDefault

No parameters

list_topicsList topicsB
Read-onlyIdempotent

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

NameRequiredDescriptionDefault
includeInternalNoInclude internal topics (starting with _)
topic_offsetsTopic offsetsA
Read-onlyIdempotent

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

NameRequiredDescriptionDefault
topicYesTopic name

Tool Schema Changelog

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

  1. 4 tool updatesv0.2.2
    • Changeddescribe_consumer_group1 field changed
      • removedInput schema / additionalProperties
        Removed value: -false
    • Changeddescribe_topic1 field changed
      • removedInput schema / additionalProperties
        Removed value: -false
    • Changedlist_topics1 field changed
      • removedInput schema / additionalProperties
        Removed value: -false
    • Changedtopic_offsets1 field changed
      • removedInput schema / additionalProperties
        Removed value: -false
  2. 6 tool updatesv0.1.0
    • First observedcluster_info
    • First observeddescribe_consumer_group
    • First observeddescribe_topic
    • First observedlist_consumer_groups
    • First observedlist_topics
    • First observedtopic_offsets

TDQS

A3.6/5.0

Scored across 6 tools

Disambiguation5/5

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.

Naming Consistency4/5

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.

Tool Count5/5

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.

Completeness4/5

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

ActivityActive
ResponsivenessNo recent community issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    An 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
  • A
    license
    B
    quality
    B
    maintenance
    MCP server for Apache Kafka that allows LLM agents to inspect topics, consumer groups, and safely manage offsets (reset, rewind).
    19
    13
    Apache 2.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables interaction with Kafka clusters via MCP, supporting topic management (list, create, delete, inspect), connection initialization, and more through natural language.
    1
    Apache 2.0