kafka-mcp is an MCP server that enables LLMs to fully manage and interact with Apache Kafka clusters across the following areas:
Cluster Management
describe_cluster: Retrieve cluster metadata including brokers and controller infodescribe_brokers: List all brokers with their details
Topic Management
list_topics,describe_topic,create_topic,delete_topic,create_partitions(increase only)
Configuration Management
describe_configs/alter_configs: View and update dynamic configs for topics, brokers, or consumer groups
Consumer Group Management
list_consumer_groups,describe_consumer_group: List and inspect group state and membersget_consumer_group_offsets: Retrieve committed offsets, watermarks, and lag per partitionreset_consumer_group_offset: Reset offsets to earliest, latest, or a specific offset — with dry-run and force optionsrewind_consumer_group_offset_by_timestamp: Rewind/advance offsets by timestamp — with dry-run and force options
Messaging
consume_messages: Read messages from a topic with configurable offset, partition, limit, and timeoutproduce_message: Publish a message to a topic with optional key and headers
Provides tools for managing and interacting with Apache Kafka clusters, enabling users to perform cluster metadata lookups, manage topics and partitions, modify configurations, monitor consumer groups, and produce or consume messages.
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-mcpUsing 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
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 |
| Get cluster metadata (controller, brokers). |
| List all brokers. | |
Topics |
| List all available topics. |
| Get detailed info (partitions, replicas) for a topic. | |
| Create a new topic with partitions/replication factor. | |
| Delete a topic. | |
| Increase partitions for a topic. | |
Configs |
| View dynamic configs for topic/broker/group. |
| Update dynamic configs. | |
Consumers |
| List all active consumer groups. |
| Get members and state of a group. | |
| Get committed offset, high/low watermarks, and calculate total lag for a topic. | |
| Safely change consumer group offsets to earliest, latest, or a specific offset. | |
| Rewind/advance consumer group offsets securely based on a timestamp. | |
Messages |
| Consume messages from a topic (supports offsets, limits). |
| 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 registrationTroubleshooting
Connection Refused: Ensure
KAFKA_BOOTSTRAP_SERVERSis correct and reachable.
TODO
SASL
JMX