Kafka MCP Server
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.
README
Kafka MCP Server
Overview
FastMCP-based MCP server that connects to Kafka and exposes MCP tools for common broker, topic, consumer, and retention operations.
Features
- List/create/delete topics and inspect topic configs.
- Tail recent messages or collect a short live stream.
- List consumer groups and compute group lag.
- Inspect cluster broker metadata.
- Store and manage named Kafka users locally.
Requirements
- Python 3.10+ (Makefile defaults to 3.13).
- uv (recommended) or any Python environment manager.
- A Kafka broker (local via Podman or your own cluster).
Quick start (uv)
- Create and activate a virtual environment:
- uv python install 3.13
- uv venv .venv --python 3.13
- source .venv/bin/activate
- Install dependencies:
- uv sync
- Run the server:
- uv run python -m app.main
Default MCP SSE endpoint: http://localhost:8000/mcp
Makefile shortcuts
- Start server: make start
- Start Kafka (Podman): make kafka-start
- Stop Kafka: make kafka-stop
- Kafka logs: make kafka-logs
- Run smoke test: make test-smoke
Configuration
Server settings come from FastMCP ServerSettings. The defaults are:
- Host: 0.0.0.0
- Port: 8000
FastMCP supports environment overrides such as:
- FASTMCP_SERVER_HOST
- FASTMCP_SERVER_PORT
Smoke tests and clients can use:
- MCP_URL (default http://localhost:8000/mcp)
- KAFKA_BOOTSTRAP_SERVERS (default localhost:9092)
- KAFKA_TEST_TOPIC (default mcp_smoke)
- KAFKA_TEST_GROUP (default mcp_smoke_group)
Kafka connection payload
Most tools require a Kafka connection object with the following fields:
- bootstrap_servers (required)
- security_protocol (default PLAINTEXT)
- sasl_mechanism, sasl_username, sasl_password (optional)
- ssl_cafile, ssl_certfile, ssl_keyfile (optional)
- oauth_token (required when sasl_mechanism is OAUTHBEARER)
MCP tool catalog
Each tool name below is the MCP command. Parameter shapes match the schemas in app/schemas.py.
health- Returns{"status":"ok"}.- Params: none
list_topics- Lists topics with partition and replication info.- Params:
connection
- Params:
create_topic- Creates a topic with optional configs.- Params:
connection,payload(name,num_partitions,replication_factor,configs)
- Params:
delete_topic- Deletes a topic by name.- Params:
connection,name
- Params:
topic_configs- Fetches topic configuration values.- Params:
connection,name
- Params:
topic_retention- Returnsretention.msfor a topic.- Params:
connection,name
- Params:
tail_messages- Reads the most recent messages for a topic.- Params:
connection,name,payload(limit)
- Params:
live_messages- Collects a short live stream of messages.- Params:
connection,name,payload(max_messages,duration_seconds,poll_interval_ms)
- Params:
list_consumer_groups- Lists consumer groups with state and member count.- Params:
connection
- Params:
consumer_group_lag- Computes lag per partition for a group.- Params:
connection,group_id
- Params:
cluster_info- Returns broker and controller metadata.- Params:
connection
- Params:
list_kafka_users- Lists locally stored user entries.- Params: none
upsert_kafka_user- Creates or updates a local user entry.- Params:
user(username,sasl_mechanism,note)
- Params:
delete_kafka_user- Deletes a local user entry.- Params:
username
- Params:
MCP command examples (Python)
from mcp import ClientSession
from mcp.client.sse import sse_client
MCP_URL = "http://localhost:8000/mcp"
connection = {
"bootstrap_servers": "localhost:9092",
"security_protocol": "PLAINTEXT",
"sasl_mechanism": None,
"sasl_username": None,
"sasl_password": None,
"ssl_cafile": None,
"ssl_certfile": None,
"ssl_keyfile": None,
"oauth_token": None,
}
async with sse_client(MCP_URL) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
await session.call_tool("list_topics", {"connection": connection})
await session.call_tool(
"create_topic",
{
"connection": connection,
"payload": {
"name": "example-topic",
"num_partitions": 1,
"replication_factor": 1,
"configs": {},
},
},
)
Local storage
Kafka user entries are stored at app/data/users.json.
Testing
Smoke test all MCP tools end-to-end:
- Start Kafka: make kafka-start
- Start the server: make start
- In a new terminal: make test-smoke
LocalAI (optional)
LocalAI is not required for Kafka MCP usage, but this repo includes helper targets for running models locally:
- Install LocalAI and a model: make localai-install && make localai-model
- Start LocalAI: make localai-start
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。