MCP Kafka
Provides tools for managing Apache Kafka topics, messages, consumer groups, and cluster information with read/write access control and safety features.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Kafkalist all topics in the cluster"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Kafka
Category | Status |
Build & CI |
|
SonarCloud |
|
Security |
|
Technology |
|
A Model Context Protocol (MCP) server for Apache Kafka that provides AI assistants with safe, controlled access to Kafka clusters.
Features
12 Kafka tools for topic management, message operations, consumer groups, and cluster info
2-tier access control: READ (default) and READ/WRITE modes
Universal Kafka support: SASL (PLAIN, SCRAM, GSSAPI) and mTLS authentication
Safety controls: Protected internal topics, consumer group validation, message size limits
Built with FastMCP: Modern MCP server implementation
Installation
# Using uv (recommended)
uv add mcp-kafka
# Using pip
pip install mcp-kafkaQuick Start
1. Configure Environment
# Basic connection
export KAFKA_BOOTSTRAP_SERVERS=localhost:9092
# SASL authentication
export KAFKA_SECURITY_PROTOCOL=SASL_SSL
export KAFKA_SASL_MECHANISM=SCRAM-SHA-256
export KAFKA_SASL_USERNAME=your-username
export KAFKA_SASL_PASSWORD=your-password
# Enable write operations (disabled by default)
export SAFETY_ALLOW_WRITE_OPERATIONS=true2. Run the Server
# stdio transport (default, for MCP clients)
uv run mcp-kafka
# HTTP transport (for web integrations)
uv run mcp-kafka --transport http --host 127.0.0.1 --port 8000
# Using convenience scripts
./scripts/http-read.sh # Read-only HTTP server
./scripts/http-readwrite.sh # Read-write HTTP serverCLI Options
Option | Default | Description |
|
| Transport type: |
|
| Host to bind (HTTP only) |
|
| Port to bind (HTTP only) |
| - | Run health check and exit |
| - | Show version and exit |
3. Connect to MCP Client
Add to your MCP client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"kafka": {
"command": "uv",
"args": ["run", "mcp-kafka"],
"env": {
"KAFKA_BOOTSTRAP_SERVERS": "localhost:9092"
}
}
}
}Available Tools
Topic Management
Tool | Access | Description |
| READ | List all topics with partition counts |
| READ | Get detailed topic info and configuration |
| READ/WRITE | Create a new topic with partitions, replication factor, and config |
Message Operations
Tool | Access | Description |
| READ | Peek at messages (no offset commit) |
| READ/WRITE | Produce a message with optional key, headers, and partition |
Consumer Group Management
Tool | Access | Description |
| READ | List all consumer groups |
| READ | Get group details, members, and lag |
| READ | Get lag per partition |
| READ/WRITE | Reset consumer group offsets to earliest, latest, or specific offset |
Cluster Information
Tool | Access | Description |
| READ | Get cluster metadata |
| READ | List all brokers |
| READ | Get topic partition watermarks |
Configuration
For detailed configuration options and examples, see CONFIGURATION.md.
Environment Variables
Kafka Connection
Variable | Default | Description |
|
| Kafka broker addresses |
|
| Security protocol (PLAINTEXT, SSL, SASL_PLAINTEXT, SASL_SSL) |
|
| Client identifier |
|
| Operation timeout in seconds |
SASL Authentication
Variable | Default | Description |
| - | SASL mechanism (PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, GSSAPI) |
| - | SASL username |
| - | SASL password |
|
| Kerberos service name |
| - | Path to Kerberos keytab |
| - | Kerberos principal |
SSL/TLS
Variable | Default | Description |
| - | CA certificate path |
| - | Client certificate path |
| - | Client key path |
| - | Client key password |
Safety Controls
Variable | Default | Description |
|
| Enable READ/WRITE tools |
|
| Max message size in bytes (1MB) |
|
| Max messages per consume request |
| - | Comma-separated blocked topic patterns |
Security Controls
Variable | Default | Description |
|
| Enable rate limiting |
|
| Max requests per minute |
|
| Enable audit logging |
|
| Audit log file path |
|
| Enable OAuth/OIDC authentication |
| - | OAuth issuer URL (e.g., https://auth.example.com) |
| - | Expected JWT audience claim |
| - | JWKS endpoint URL (auto-derived from issuer if not set) |
Access Control
MCP Kafka uses a simple 2-tier access control system:
READ Access (Default)
List topics, consumer groups, and brokers
Describe topics and consumer groups
Consume messages (read-only peek)
Get cluster info and watermarks
READ/WRITE Access
Requires SAFETY_ALLOW_WRITE_OPERATIONS=true:
Create topics
Produce messages
Reset consumer group offsets
Protected Resources
The following resources are always protected:
Internal topics:
__consumer_offsets,__transaction_stateInternal consumer groups: Groups starting with
__Topics in blocklist: Configured via
SAFETY_TOPIC_BLOCKLIST
Development
Prerequisites
Python 3.11+
uv package manager
Setup
# Clone repository
git clone https://github.com/williajm/mcp_kafka.git
cd mcp_kafka
# Install dependencies
uv sync --all-extras
# Run tests
uv run pytest
# Run linting
uv run ruff check src/ tests/
uv run ruff format --check src/ tests/
# Run type checking
uv run mypy src/Local Kafka for Testing
A Docker Compose environment is provided for local development:
# Start Kafka
docker compose -f docker/docker-compose.yml up -d
# Create test topics
docker compose -f docker/docker-compose.yml exec kafka \
kafka-topics --create --topic test-topic --partitions 3 --replication-factor 1 \
--bootstrap-server localhost:9092
# Stop Kafka
docker compose -f docker/docker-compose.yml downLicense
MIT License - see LICENSE file for details.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
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/williajm/mcp_kafka'
If you have feedback or need assistance with the MCP directory API, please join our Discord server