kafka-mcp
MCP server for Apache Kafka that allows LLM agents to inspect topics, consumer groups, and safely manage offsets (reset, rewind).
README
Kafka MCP Server
An MCP server implementation for Kafka, allowing LLMs to interact with and manage Kafka clusters.
Features
- Cluster Management: View broker details
describe_cluster,describe_brokers. - Topic Management: List
list_topics, createcreate_topic, deletedelete_topic, describedescribe_topic, and increase partitionscreate_partitions. - Configuration Management: View
describe_configsand modifyalter_configsdynamic configs for topics, brokers, and groups. - Consumer Groups: List
list_consumer_groups, describedescribe_consumer_group, and securely manage offsets withreset_consumer_group_offsetandrewind_consumer_group_offset_by_timestamp. Advanced tools include state validation, dry runs, and execution audit logging. - Messaging: Consume messages
consume_messages(from beginning, latest, or specific offsets) and produce messagesproduce_message.
Prerequisites
- Python 3.10+
uvpackage manager (recommended)- A running Kafka cluster (e.g., local Docker, Confluent Cloud, etc.)
Installation
- Clone the repository.
- Install dependencies:
uv sync
Configuration
The server requires the KAFKA_BOOTSTRAP_SERVERS environment variable.
KAFKA_BOOTSTRAP_SERVERS: Comma-separated list of broker urls (e.g.,localhost:9092).KAFKA_CLIENT_ID: (Optional) Client ID for connection (default:kafka-mcp).
Usage
Running the Server
You can run the server directly using uv or python, or use Docker.
Using uv (Recommended)
export KAFKA_BOOTSTRAP_SERVERS=localhost:9092
uv run kafka-mcp
Using Docker
-
Build the Docker image:
docker build -t kafka-mcp . -
Run the container:
docker run -i --rm -e KAFKA_BOOTSTRAP_SERVERS=host.docker.internal:9092 kafka-mcp(Note: Use
host.docker.internalinstead oflocalhostif your Kafka cluster is running on the host machine.)
Claude Desktop Configuration
Add the following to your Claude Desktop configuration file (claude_desktop_config.json):
{
"mcpServers": {
"kafka": {
"command": "<uv PATH>",
"args": [
"--directory",
"<kafka-mcp PATH>",
"run",
"kafka-mcp"
],
"env": {
"KAFKA_BOOTSTRAP_SERVERS": "localhost:9092"
}
}
}
}
Debugging / Development
To verify that the server can start and connect to your Kafka cluster (ensure your Kafka is running first):
# Set your bootstrap server
export KAFKA_BOOTSTRAP_SERVERS=localhost:9092
# Run a quick check
uv run python -c "from src.kafka_mcp import main; print('Imports successful')"
Available Tools
| Category | Tool Name | Description |
|---|---|---|
| Cluster | describe_cluster |
Get cluster metadata (controller, brokers). |
describe_brokers |
List all brokers. | |
| Topics | list_topics |
List all available topics. |
describe_topic |
Get detailed info (partitions, replicas) for a topic. | |
create_topic |
Create a new topic with partitions/replication factor. | |
delete_topic |
Delete a topic. | |
create_partitions |
Increase partitions for a topic. | |
| Configs | describe_configs |
View dynamic configs for topic/broker/group. |
alter_configs |
Update dynamic configs. | |
| Consumers | list_consumer_groups |
List all active consumer groups. |
describe_consumer_group |
Get members and state of a group. | |
get_consumer_group_offsets |
Get committed offset, high/low watermarks, and calculate total lag for a topic. | |
reset_consumer_group_offset |
Safely change consumer group offsets to earliest, latest, or a specific offset. | |
rewind_consumer_group_offset_by_timestamp |
Rewind/advance consumer group offsets securely based on a timestamp. | |
| Messages | consume_messages |
Consume messages from a topic (supports offsets, limits). |
produce_message |
Send a message to a topic. |
Project Structure
src/kafka_mcp/
├── configs/ # Configuration handling
├── connections/ # Kafka client factories (singleton)
├── tools/ # Tool implementations
│ ├── admin.py # Topic & Config management
│ ├── cluster.py # Cluster metadata
│ ├── consumer.py # Consumer group & message consumption
│ └── producer.py # Message production
└── main.py # Entry point & MCP tool registration
Troubleshooting
- Connection Refused: Ensure
KAFKA_BOOTSTRAP_SERVERSis correct and reachable.
TODO
- SASL
- JMX
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。