kafka-mcp
š¦ kafka-mcp
An MCP server that gives your AI agents eyes into Apache Kafka.
kafka-mcp exposes Kafka administration operations as Model Context Protocol tools, so assistants like
Claude Desktop, Claude Code, or any MCP-compatible client can inspect and operate your cluster in plain language ā
"list all my topics with their replication factor" ā instead of you reaching for the CLI.
It ships with a batteries-included docker-compose.yml that spins up a complete local Kafka lab
(KRaft broker + Schema Registry + Web UI) so you can try it end-to-end in minutes.
⨠Features
š Drop-in MCP server ā runs over
stdio, so any MCP client can launch it as a subprocess.š Topic management ā list & describe topics, create / delete, add partitions, and read or alter configs.
š„ Consumer group insight ā list & describe groups, inspect members & assignments, and compute per-partition lag.
šØ Produce & peek ā send a message to a topic, or read recent records back without committing offsets.
𩺠Cluster & offset views ā describe brokers / controller and fetch earliest / latest watermarks per partition.
ā” Async-friendly ā blocking Kafka admin calls are offloaded to worker threads so the event loop stays snappy.
š³ Self-contained local lab ā one
docker compose upgives you Kafka (KRaft, no ZooKeeper), Schema Registry, and a Web UI.š ļø Tiny & hackable ā a single module (
src/zaksway_kafka_mcp/__init__.py) you can read in one sitting and extend with new tools.
š§ How it works
āāāāāāāāāāāāāāāāāāāā MCP over stdio āāāāāāāāāāāāāāāāāāāā Kafka Admin API āāāāāāāāāāāāāāāāāāāā
ā AI Agent ā āāāāāāāāāāāāāāāāā¶ ā kafka-mcp ā āāāāāāāāāāāāāāāāāā¶ ā Kafka broker ā
ā (Claude, etc.) ā tool calls ā (FastMCP server)ā confluent-kafka ā (localhost:9092)ā
āāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāāThe agent never talks to Kafka directly ā it calls a tool, kafka-mcp translates that into a
confluent-kafka admin or client request, and returns structured JSON the model can reason about.
š¦ Prerequisites
Python 3.12+
uv for dependency management (recommended)
Docker + Docker Compose (only if you want the local Kafka lab)
š Quick start
1. Clone & install
git clone <your-repo-url> kafka-mcp
cd kafka-mcp
uv sync2. Start a local Kafka (optional, but handy)
docker compose up -dThis brings up three services:
Service | URL / Port | What it's for |
Kafka broker |
| The broker your MCP server connects to |
Schema Registry |
| Avro/Protobuf/JSON schema management |
Kafka UI |
| Browse topics, messages, and consumer groups |
š” Auto-create topics is enabled, so you can produce to a new topic and watch it appear via the MCP
list_topicstool.
3. Run the MCP server
uv run kafka-zakswayYou should see:
Kafka MCP for you agents!The server is now listening on stdio, ready for an MCP client to connect.
š¤ Connecting an MCP client
Most clients (Claude Desktop, Claude Code, ā¦) launch MCP servers from a JSON config. Once it's installed from PyPI, point them at the published package ā no clone required:
{
"mcpServers": {
"kafka-zaksway": {
"command": "uvx",
"args": ["zaksway-kafka-mcp"],
"env": {
"BOOTSTRAP_SERVER": "localhost:9092"
}
}
}
}Claude Desktop ā add the block to
claude_desktop_config.json.Claude Code ā
claude mcp add kafka-zaksway -- uvx zaksway-kafka-mcp
š” Hacking on a local clone instead? Swap to
"command": "uv"with"args": ["--directory", "/absolute/path/to/zaksway-kafka-mcp", "run", "kafka-zaksway"].
Restart the client, and kafka-zaksway will appear among your available tools.
š§° Available tools
kafka-mcp exposes 14 tools spanning topic management, consumer groups, the cluster, and the data plane.
Tools marked ā ļø are destructive (they delete data) ā agents should confirm before calling them.
Category | Tool | Parameters | Description |
Topics |
|
| List topics with partition count & replication factor. |
Topics |
|
| Per-partition leader / replicas / ISR + non-default config overrides. |
Topics |
|
| Create a new topic. |
Topics |
|
| Permanently delete a topic and all of its data. |
Topics |
|
| Increase a topic's partition count (cannot shrink). |
Topics |
|
| Set / update topic configuration entries. |
Topics |
|
| Earliest & latest offsets (watermarks) per partition. |
Cluster |
| ā | Cluster id, controller broker, and broker list. |
Groups |
| ā | All consumer groups with their state. |
Groups |
|
| State, coordinator, members & their partition assignments. |
Groups |
|
| Committed offset, end offset, and lag per partition. |
Groups |
|
| Permanently delete a consumer group. |
Data |
|
| Produce a single message and await delivery. |
Data |
|
| Peek recent messages without committing offsets. |
š” The registered MCP tool names are full descriptive sentences (e.g.
Show committed offsets and lag for a Kafka consumer group); the short identifiers above mirror the Python functions insrc/zaksway_kafka_mcp/__init__.pyand are used here for brevity.
Example ā list_topics response:
[
{ "name": "orders", "partitions": 6, "replication-factor": 1 },
{ "name": "payments", "partitions": 3, "replication-factor": 1 }
]āļø Configuration
The server is configured entirely through environment variables.
Variable | Default | Description |
|
| Kafka bootstrap server(s) to connect to. |
š¦ Releasing to PyPI
The package is published to PyPI as zaksway-kafka-mcp by a GitHub Actions workflow (.github/workflows/publish.yml) that triggers on v* version tags and authenticates via Trusted Publishing (OIDC) ā no API tokens stored anywhere.
One-time setup ā register a Trusted Publisher on PyPI:
Field | Value |
Owner |
|
Repository |
|
Workflow filename |
|
Environment |
|
To cut a release:
# 1. Bump `version` in pyproject.toml (e.g. 0.1.0 -> 0.2.0), then:
git commit -am "release: v0.2.0"
git tag v0.2.0
git push origin master --tagsThe workflow verifies the tag matches pyproject.toml, builds the wheel + sdist, smoke-tests both, and publishes. Once published, anyone can run it with zero install:
uvx zaksway-kafka-mcp # run the server directly
# or
pip install zaksway-kafka-mcp # then run: kafka-zakswayšļø Project structure
kafka-mcp/
āāā src/zaksway_kafka_mcp/
ā āāā __init__.py # The MCP server + all 14 tool definitions
ā āāā __main__.py # `python -m zaksway_kafka_mcp` entry point
āāā tests/
ā āāā smoke_test.py # Import/packaging check run in CI before publish
āāā .github/workflows/
ā āāā publish.yml # Build + publish to PyPI on `v*` tags (Trusted Publishing)
āāā docker-compose.yml # Local Kafka lab (broker + schema registry + UI)
āāā pyproject.toml # Project metadata, dependencies & build backend
āāā uv.lock # Pinned dependency lockfile
āāā README.md # You are hereš£ļø Roadmap
Recently shipped ā
create_topic/delete_topicadd_partitions&alter_topic_configDescribe consumer groups & their lag
Peek at the latest messages on a topic
Ideas for what's next:
Reset / set consumer group offsets
ACL management (list / create / delete)
Broker config inspection
Schema Registry integration (list subjects & schemas)
š§āš» Author
Zakaria BOUAZZA : https://zakaria.lu
š License
No license has been specified yet. Add one (e.g. MIT) before sharing publicly.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/zakariahere/zaksway-kafka-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server