MCP Kafka工具
About
MCP Kafka服务器 - 通过MCP协议连接Kafka,支持查询Topic信息、读写数据和回放历史数据
Details
- Author
- yufule
- Downloads
- 185
- Categories
- Other
Jump to
- 列出所有Kafka Topic
- 获取指定Topic的详细信息
- 向Topic发送消息
- 读取Topic最新消息
- 回放指定时间段的历史消息
- 支持STDIO和SSE运行模式
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
MCP Kafka工具Command (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
安装依赖后,以本地模式直接运行mcp_kafka_server.py,或以Web服务模式运行mcp_kafka_sse_server.py(启动在localhost:8000),然后在MCP客户端(如Claude、Cherry Studio)中连接对应节点即可使用。
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"mcp kafka\u5de5\u5177": {
"mcp-kafka-server": {
"command": "python",
"args": [
"mcp_kafka_server.py"
]
}
}
}
}
McpServers
{
"mcp-kafka-server": {
"command": "python",
"args": [
"mcp_kafka_server.py"
]
}
}
MCP Kafka工具
这是一个基于MCP(Model Context Protocol)协议的Kafka工具,可以通过大模型连接Kafka,提供以下功能:
1. 查询指定topic的信息
2. 往指定topic里面读写数据
3. 回放指定时间,指定topic的数据
安装依赖
pip install -r requirements.txt
使用方式
本地模式(STDIO)
直接运行mcp_kafka_server.py文件:
python mcp_kafka_server.py
然后在MCP客户端(如Claude、Cherry Studio等)中连接本地MCP服务器。
Web服务模式(SSE)
运行mcp_kafka_sse_server.py文件启动Web服务:
python mcp_kafka_sse_server.py
服务将启动在 http://localhost:8000,MCP端点为 http://localhost:8000/mcp
然后在MCP客户端中连接这个远程MCP服务器。
主要功能
1. 列出所有Topic
list_topics()
返回Kafka中所有可用的Topic列表。
2. 获取Topic信息
get_topic_info(topic_name)
获取指定Topic的详细信息,包括分区数量、每个分区的起始和结束偏移量以及消息数量。
3. 发送消息
send_message(topic_name, message, key)
向指定Topic发送消息,message可以是JSON字符串或普通字符串,key为可选参数。
4. 读取消息
read_messages(topic_name, max_messages, timeout_ms)
从指定Topic读取最新的消息,max_messages指定最大读取消息数(默认10条),timeout_ms指定超时时间(默认1000毫秒)。
5. 回放历史消息
replay_messages(topic_name, start_time, end_time, max_messages)
回放指定时间段内的消息,start_time和end_time为ISO格式的时间字符串(如'2023-01-01T00:00:00'),max_messages指定最大回放消息数(默认100条)。
配置Kafka连接
默认连接到localhost:9092,如需修改连接地址,请在KafkaManager类的初始化参数中修改bootstrap_servers。
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



