mcp-server-kafka
Enables AI agents to interact with Apache Kafka message clusters through the MCP protocol, allowing safe and efficient Kafka messaging operations.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-server-kafkalist all topics in my Kafka cluster"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-server-kafka
📖 项目简介
mcp-server-kafka 是一个遵循 Model Context Protocol (MCP) 规范的 Apache Kafka 服务端集成。通过标准化的 MCP 协议,让大型语言模型(LLM)与 AI Agent 能够安全、高效地与 Apache Kafka 消息集群交互。
本项目工程底座参考 oss-template 规范构建,提供开箱即用的现代化 CI/CD 流水线与自动化发版机制。
Related MCP server: Kafka MCP Server
✨ 核心特性
🎯 现代 Python 技术栈:基于 Python 3.10+ 与
uv构建,遵循 PEP 621 标准规范;⚡ 纯异步高性能架构:底层基于
aiokafka纯异步事件驱动,天然契合 MCP 协议;🚀 自动化发版流水线:打 Tag(如
v0.1.0)自动触发发版、自动提取 PR/Commit 生成精美更新日志、自动挂载打包物附件;🛡️ 规范化工作流:支持 Conventional Commits 提交规范、预置结构化 Issue 反馈与标准 PR 审查模版。
🛠️ 快速开始
1. 环境准备
本项目推荐使用现代极速包管理器 uv:
# 克隆仓库
git clone https://github.com/atengk/mcp-server-kafka.git
cd mcp-server-kafka
# 创建虚拟环境并同步依赖
uv sync --all-extras2. 运行测试与代码检查
# 执行单元测试
uv run pytest
# 执行代码风格与语法检查
uv run ruff check .3. MCP 客户端配置示例
以 Claude Desktop (claude_desktop_config.json) 为例:
{
"mcpServers": {
"kafka": {
"command": "uv",
"args": [
"--directory",
"/path/to/mcp-server-kafka",
"run",
"mcp-server-kafka"
],
"env": {
"MCP_KAFKA_BOOTSTRAP_SERVERS": "localhost:9092"
}
}
}
}4. Docker 与 Docker Compose 运行 (常驻 SSE 网关模式)
本项目已集成多架构 Docker 镜像,并自动发布至 GitHub Container Registry (GHCR):
# 使用 Docker Compose 一键启动常驻服务
docker compose up -d
# 或使用 docker run 直接启动
docker run -d \
--name mcp-server-kafka \
-p 8000:8000 \
-e MCP_KAFKA_BOOTSTRAP_SERVERS=host.docker.internal:9092 \
ghcr.io/atengk/mcp-server-kafka:latest🚀 版本发版指南
当准备发布新版本时,推送一个语义化版本号的 Git Tag 即可触发自动化发版:
# 1. 确保本地 main 分支代码最新且 CI 绿灯通过
git checkout main
git pull origin main
# 2. 打标签并推送到 GitHub (支持 v0.1.0, v1.0.0 等)
git tag v0.1.0
git push origin v0.1.0GitHub Actions 将会自动执行 .github/workflows/release.yml:
提取自上一版本以来的全部合并 PR 与提交记录;
自动生成 GitHub Release 详情并归类贡献者;
将打包产物与 SHA-256 校验和自动挂载至 Release 页面附件;
自动构建多架构 Docker 镜像并推送至 GHCR (
ghcr.io/atengk/mcp-server-kafka)。
📂 仓库目录结构
.
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ └── feature_request.md
│ ├── workflows/
│ │ ├── ci.yml
│ │ └── release.yml
│ └── PULL_REQUEST_TEMPLATE.md
├── src/
│ └── mcp_server_kafka/
│ ├── __init__.py
│ └── server.py
├── tests/
│ ├── __init__.py
│ └── test_basic.py
├── .cliff.toml
├── .dockerignore
├── .editorconfig
├── .gitattributes
├── .gitignore
├── CONTRIBUTING.md
├── docker-compose.yml
├── Dockerfile
├── LICENSE
├── README.md
└── pyproject.toml📄 开源许可证
本项目基于 Apache License 2.0 协议开源。
Available Tools
6 toolskafka_cluster_infoA
获取 Kafka 集群整体元数据与 Broker 节点列表(包含 Cluster ID、控制器与节点地址)
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It discloses the informational read nature and the returned fields, which is helpful, but says nothing about permissions, whether it hits a live broker, latency, or failure behavior. For a zero-param read tool this is acceptable but leaves gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence with the verb, resource and scope, and no filler. Every element earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so return-value explanation is not required, and the tool has no parameters and no annotations to reconcile. The description is complete for such a simple read-only introspection tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool takes zero parameters, so there is nothing to document; baseline 4 applies. The parenthetical content describes returned fields rather than inputs, which does not confuse the parameter story.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb (获取) and a precise resource (Kafka 集群整体元数据与 Broker 节点列表), enumerating the returned contents (Cluster ID、控制器、节点地址). It is clearly distinguishable from the topic/message siblings, which all operate on topics or messages rather than cluster-level metadata.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Usage is implied by the resource — an agent can infer this is the cluster-introspection tool — but the description never says when to choose it versus the topic-level siblings, and states no prerequisites or exclusions. Adequate but not explicit guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
kafka_create_topicB
在 Kafka 集群中创建新主题(支持指定分区数与副本因子;只读模式下不可用)
| Name | Required | Description | Default |
|---|---|---|---|
| partitions | No | ||
| topic_name | Yes | ||
| replication_factor | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full behavioral burden. It does disclose one important trait not in any structured field: the tool is unavailable in read-only mode. But it omits other relevant behavior for a mutation tool, such as what happens if the topic already exists, permission requirements, or failure modes.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence states the purpose first, then parenthetical details for tunables and the mode restriction. Nothing is wasted, though the parenthetical packs several distinct ideas together.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so return values need not be explained. Still, for a mutation tool with zero annotations and 0% parameter description coverage, the description is thin: it does not cover error/conflict behavior or parameter constraints an agent needs to call it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0% (properties have only titles), so the description must compensate. It does name the two tunable parameters (partition count and replication factor), but adds no semantics such as valid ranges, defaults, or the replication-factor-vs-broker constraint. It partially compensates but leaves real gaps.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb+resource ('create a new topic in the Kafka cluster'), which clearly distinguishes it from the list/describe/delete/produce siblings. It does not explicitly name alternatives, but the action is unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It provides one meaningful exclusion condition ('unavailable in read-only mode'), which is real usage guidance. However, it offers no when-to-use context relative to siblings and no guidance on prerequisites such as broker availability or existing topic conflicts.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
kafka_delete_topicA
从 Kafka 集群中删除主题(高危破坏操作,必须传入 confirm=True 显式确认)
| Name | Required | Description | Default |
|---|---|---|---|
| confirm | No | ||
| topic_name | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden and does disclose the critical trait: this is a destructive, high-risk operation that requires explicit confirm=True. It stops short of stating irreversibility, required permissions, or the effect on active consumers/producers.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence carrying the action, the risk level, and the confirmation requirement with zero filler. Nothing to trim.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so return values need no explanation. The description covers the destructive nature and the confirm gate, but omits permissions/auth requirements and irreversibility, which matter for a destructive operation with no annotations.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, so the description must compensate. It fully explains the non-obvious `confirm` parameter (must be explicitly True), which is the semantically important one; `topic_name` is self-evident from its name. It adds real meaning beyond the bare boolean/default in the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb and resource ('delete topic from Kafka cluster'), which is unambiguous and inherently distinct from all siblings (list/describe/create/produce). An agent immediately knows what this tool does without opening the schema.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description flags the operation as high-risk and states the confirm=True prerequisite, which is useful gating guidance. However, it never says when to use this versus alternatives (e.g. kafka_describe_topic to verify before deleting) or when not to use it, so usage routing is only implied.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
kafka_describe_topicB
查询指定 Kafka 主题的详细拓扑(分区分布、Leader 节点、ISR 同步副本与配置)
| Name | Required | Description | Default |
|---|---|---|---|
| topic_name | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full behavioral burden. It does disclose what information is retrieved (partitions, leaders, ISR, config), which implies a read-only, non-mutating inspection, but it never explicitly states there are no side effects, nor does it mention error behavior for a non-existent topic or any permission requirements.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single sentence with zero filler, front-loading the verb and resource before the parenthetical list of returned details. Every clause earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple, one-parameter read tool with an output schema available, the description covers purpose and returned content adequately. The minor gaps are usage routing and explicit read-only/error behavior, which are not strictly required given the output schema carries return-value semantics.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Only one parameter exists and the schema description coverage is 0% (just a 'Topic Name' title). The phrase '指定 Kafka 主题' implies the parameter identifies the topic to inspect, adding a little context, but it largely restates what the parameter name already conveys and gives no format or naming-convention guidance.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description gives a specific verb (查询/describe) and resource (指定 Kafka 主题, a single named topic) and enumerates what it returns: partition distribution, Leader nodes, ISR replicas, and configuration. This implicitly separates it from kafka_list_topics (which enumerates topics) and kafka_cluster_info (which is cluster-scoped), though no sibling is named explicitly.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no statement of when to use this tool versus kafka_list_topics, kafka_cluster_info, or the create/delete siblings, and no preconditions (e.g., topic must already exist) or exclusions are given. The agent must infer usage entirely from the purpose clause.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
kafka_list_topicsB
列出 Kafka 集群中的主题清单(支持按名称模式过滤并默认排除内部系统主题)
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | No | ||
| include_internal | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden, and it does disclose one meaningful behavioral trait: internal system topics are excluded by default. However, it omits other behavioral context such as auth/permission requirements, result limits, or ordering. It adds some value but leaves notable gaps for a zero-annotation tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence with no wasted words, efficiently combining the core action with the two key behaviors. It is appropriately sized for a simple two-parameter list tool.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so return values need not be explained, and both simple parameters are touched on. For a low-complexity list tool this is nearly complete, with only pattern syntax and usage alternatives left implicit.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It does map to both parameters, indicating that 'pattern' filters by name and that internal topics are excluded by default (matching include_internal's default), but it gives no pattern syntax (glob vs regex vs substring), leaving format semantics unclear.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb (列出/list) and resource (Kafka 主题/topics) with scope ('Kafka 集群中的'), making the operation unambiguous. It does not explicitly differentiate itself from siblings like kafka_describe_topic or kafka_cluster_info, but the list operation is naturally distinct.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no guidance on when to use this versus alternatives such as kafka_describe_topic for details or kafka_cluster_info for cluster metadata. Usage is only implied by the verb 'list', and no exclusions or prerequisites are given.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
kafka_produce_messageB
向指定 Kafka 主题发送消息(支持 Key、JSON/文本载荷与 Headers;只读模式下不可用)
| Name | Required | Description | Default |
|---|---|---|---|
| key | No | ||
| topic | Yes | ||
| value | Yes | ||
| headers | No | ||
| partition | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It discloses the read-only-mode restriction and supported payload formats, which adds real context, but omits key behavioral traits for a write operation: required permissions, delivery guarantees, error behavior, and whether the write is idempotent/reversible.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence that leads with the core action and then appends the mode restriction and format notes. No wasted words, though the parenthetical bundles several facts tightly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so return values need not be explained, and the read-only caveat is helpful. Still, for a 5-parameter mutation tool with zero schema description coverage, the missing partition semantics and lack of operational context leave it only adequate.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It mentions key, value/payload (clarifying JSON or text), and headers, adding format meaning beyond the bare schema. But it never addresses the partition parameter or what the key does with respect to partitioning, leaving a coverage gap.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb and resource (send a message to a Kafka topic), which is clearly distinct from the sibling tools that only manage topic metadata (list/create/delete/describe). However, it does not explicitly name an alternative to route away from, so sibling differentiation is implicit rather than stated.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Includes one useful condition — unavailable in read-only mode — which is a genuine 'when not to use' signal. It does not mention any alternative tools or when to prefer other approaches, and lacks prerequisites (e.g. topic must exist, broker connectivity).
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
6 tool updates
v0.1.0- First observed
kafka_cluster_info - First observed
kafka_create_topic - First observed
kafka_delete_topic - First observed
kafka_describe_topic - First observed
kafka_list_topics - First observed
kafka_produce_message
TDQS
Scored across 6 tools
Each tool targets a distinct Kafka resource and action: cluster metadata, topic listing, topic description, topic creation, topic deletion, and message production. There is no functional overlap or ambiguity between any pair.
All tools share the kafka_ prefix and five use a consistent verb_noun pattern (list_topics, describe_topic, create_topic, delete_topic, produce_message). The lone outlier is kafka_cluster_info, which uses a noun phrase rather than a verb, but this is a minor deviation.
Six tools is well-scoped for Kafka administration and message production, with each tool earning its place and no redundant operations. The count is neither bloated nor too thin for the apparent domain.
The set covers cluster info, topic lifecycle (create/delete/list/describe), and producing messages, but lacks any consume/read-message tool, which is a fundamental Kafka operation. Consumer group and offset management are also absent, creating a significant gap that would cause agent failures for read-oriented tasks.
Maintenance
Related MCP Connectors
Enable secure connectivity between Sentry issues and debugging data, and LLM clients, using a Model Context Protocol (MCP) server.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
A Model Context Protocol server for Wix AI tools
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI models to publish and consume messages from Apache Kafka topics through a standardized interface, making it easy to integrate Kafka messaging with LLM and agent applications.17Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with Apache Kafka through natural language, supporting operations like producing/consuming messages, managing topics, and querying brokers, partitions, and consumer group offsets.1MIT
- AlicenseBqualityBmaintenanceMCP server for Apache Kafka that allows LLM agents to inspect topics, consumer groups, and safely manage offsets (reset, rewind).1913Apache 2.0
- FlicenseCqualityDmaintenanceExposes Kafka administration operations as MCP tools, enabling AI agents to inspect Kafka clusters using natural language.1-