kafka-mcp
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.Secure Connections: Connect with TLS/mTLS and SASL PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, GSSAPI, or OAUTHBEARER.
JMX Monitoring: Read broker and topic metrics from one or more Prometheus JMX Exporter endpoints and summarize cluster health.
Related MCP server: Kafka MCP Server
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
Only KAFKA_BOOTSTRAP_SERVERS is required. Existing PLAINTEXT configurations remain unchanged.
Variable | Required | Description |
| Yes | Comma-separated broker addresses, such as |
| No | Kafka client ID. Defaults to |
| No |
|
| No | JSON object of additional scalar confluent-kafka/librdkafka client properties. Explicit variables and connection safety settings take precedence. |
SASL
Set KAFKA_SASL_MECHANISM to PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, GSSAPI, or OAUTHBEARER whenever a SASL security protocol is used.
PLAIN and SCRAM use:
export KAFKA_SECURITY_PROTOCOL=SASL_SSL
export KAFKA_SASL_MECHANISM=SCRAM-SHA-512
export KAFKA_SASL_USERNAME="$KAFKA_USERNAME"
export KAFKA_SASL_PASSWORD="$KAFKA_PASSWORD"GSSAPI/Kerberos supports these optional variables:
Variable | librdkafka property |
|
|
|
|
|
|
|
|
|
|
The prebuilt confluent-kafka wheels do not include GSSAPI. Kerberos deployments outside Docker must install confluent-kafka against a librdkafka build compiled with SASL GSSAPI support; the provided Docker image builds that variant from source and includes the Kerberos runtime tools.
OAUTHBEARER supports librdkafka's built-in OIDC flow:
export KAFKA_SECURITY_PROTOCOL=SASL_SSL
export KAFKA_SASL_MECHANISM=OAUTHBEARER
export KAFKA_SASL_OAUTHBEARER_METHOD=oidc
export KAFKA_SASL_OAUTHBEARER_CLIENT_ID="$OAUTH_CLIENT_ID"
export KAFKA_SASL_OAUTHBEARER_CLIENT_SECRET="$OAUTH_CLIENT_SECRET"
export KAFKA_SASL_OAUTHBEARER_TOKEN_ENDPOINT_URL=https://idp.example.com/oauth/token
export KAFKA_SASL_OAUTHBEARER_SCOPE=kafkaKAFKA_SASL_OAUTHBEARER_EXTENSIONS is optional. librdkafka's default unsecured-token handler is for development and testing only; it requires both KAFKA_SASL_OAUTHBEARER_CONFIG and KAFKA_ENABLE_SASL_OAUTHBEARER_UNSECURE_JWT=true instead of the OIDC variables.
Metadata and client-assertion flows are also supported. Set KAFKA_SASL_OAUTHBEARER_METADATA_AUTHENTICATION_TYPE=azure_imds for Azure IMDS. AWS IAM uses aws_iam with KAFKA_SASL_OAUTHBEARER_CONFIG; it additionally requires confluent-kafka[oauthbearer-aws] 2.15 or newer. JWT assertion properties such as sasl.oauthbearer.grant.type and sasl.oauthbearer.assertion.private.key.file can be passed through KAFKA_CLIENT_CONFIG_JSON, so the base 2.13 client remains compatible.
TLS and mTLS
The following variables map directly to librdkafka TLS settings:
Variable | Description |
| CA certificate path. The system CA store is used when omitted. |
| Client certificate path for mTLS. |
| Client private key path for mTLS. |
| Optional private key password. |
| Hostname verification algorithm, usually |
| Certificate revocation list path. |
The client certificate and key must be configured together. Less common librdkafka properties, including PKCS#12 keystores and cipher controls, can be supplied through KAFKA_CLIENT_CONFIG_JSON:
export KAFKA_SECURITY_PROTOCOL=SSL
export KAFKA_CLIENT_CONFIG_JSON='{"ssl.keystore.location":"/run/secrets/client.p12","ssl.keystore.password":"secret"}'JMX Exporter
JMX monitoring is optional and does not affect the Kafka tools. Run Prometheus JMX Exporter as a Java agent on each broker, then provide its HTTP /metrics endpoints. Keeping Java RMI disabled avoids exposing Kafka's unauthenticated remote JMX port.
export KAFKA_JMX_EXPORTER_ENDPOINTS='{
"broker-1": "http://broker-1:7071/metrics",
"broker-2": "http://broker-2:7071/metrics",
"broker-3": "http://broker-3:7071/metrics"
}'The value may also be a JSON array, a comma-separated URL list, or a comma-separated name=url list. For HTTPS or an authenticated reverse proxy, use:
Variable | Description |
| Per-request timeout. Defaults to |
| Verify HTTPS certificates. Defaults to |
| Custom CA certificate path. |
| HTTPS client certificate path. |
| HTTPS client key path. |
| Optional HTTPS client key password. |
| HTTP Basic authentication. |
| HTTP Bearer authentication. |
| Additional HTTP headers as a JSON object of strings. |
Basic and Bearer authentication are mutually exclusive. JMX tools return a structured not_configured response when no exporter endpoints are set.
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
The image supports TLS, PLAIN, SCRAM, OAUTHBEARER/OIDC, and GSSAPI. Its multi-stage build compiles the Python client against a checksum-verified librdkafka release with Kerberos support.
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
host.docker.internalinstead oflocalhostif your Kafka cluster is running on the host machine.)
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. | |
Metrics |
| Summarize replication, ISR, controller, log-directory, and broker reachability signals. |
| Read curated broker metrics or filtered raw exporter samples. | |
| Read metrics carrying the requested topic label. | |
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)
├── metrics/ # Prometheus JMX Exporter client and parser
├── tools/ # Tool implementations
│ ├── admin.py # Topic & Config management
│ ├── cluster.py # Cluster metadata
│ ├── consumer.py # Consumer group & message consumption
│ ├── metrics.py # Broker, topic, and cluster health metrics
│ └── producer.py # Message production
└── main.py # Entry point & MCP tool registrationTroubleshooting
Connection Refused: Ensure
KAFKA_BOOTSTRAP_SERVERSis correct and reachable.SASL Authentication Failed: Verify the security protocol, mechanism, credentials, and CA trust path together.
JMX Status Is Unknown: Ensure the exporter rules include Kafka broker/controller MBeans. Raw samples remain available through
get_broker_metrics(include_raw=true).
Available Tools
19 toolsalter_configsB
Update dynamic configs for a resource. resource_type: "topic", "broker", or "group" configs: Dictionary of config key-value pairs
Inputs: configs (required), resource_name (required), resource_type (required). Returns: result
consume_messagesB
Consumes messages from a topic. offset_spec: 'earliest', 'latest', or specific integer offset. timeout: seconds to wait for messages.
Inputs: topic_name (required), limit, timeout, partition, +1 more. Returns: result
create_partitionsB
Increases the number of partitions for a topic. Note: Partition count can only be increased, not decreased.
Inputs: topic_name (required), new_total_count (required). Returns: result
create_topicC
Creates a new topic.
Inputs: topic_name (required), config, num_partitions, replication_factor. Returns: result
delete_topicC
Deletes a topic.
Inputs: topic_name (required). Returns: result
describe_brokersB
Returns a list of brokers with their details.
Inputs: no named parameters. Returns: result
describe_clusterA
Returns information about the Kafka cluster (brokers, controller).
Inputs: no named parameters. Returns: object
describe_cluster_healthB
Summarizes Kafka health signals exposed by Prometheus JMX Exporter.
Inputs: no named parameters. Returns: object
describe_configsB
Get dynamic configs for a resource. resource_type: "topic", "broker", or "group" (case insensitive)
Inputs: resource_name (required), resource_type (required). Returns: object
describe_consumer_groupC
Describes a specific consumer group.
Inputs: group_id (required). Returns: object
describe_topicB
Returns detailed information about a specific topic.
Inputs: topic_name (required). Returns: object
get_broker_metricsB
Returns curated or filtered raw JMX Exporter metrics for one or all brokers.
Inputs: limit, broker_id, include_raw, metric_name, +1 more. Returns: object
get_consumer_group_offsetsA
Get the committed offsets and lag for a specific consumer group and topic. Returns the committed offset, high/low watermarks, and calculated lag for each partition.
Inputs: group_id (required), topic_name (required). Returns: object
get_topic_metricsB
Returns JMX Exporter metrics labeled for a Kafka topic.
Inputs: topic_name (required), limit, broker_id, include_raw. Returns: object
list_consumer_groupsB
Lists all consumer groups.
Inputs: no named parameters. Returns: result
list_topicsB
Returns a list of all topic names in the cluster.
Inputs: no named parameters. Returns: result
produce_messageC
Produces a message to a topic.
Inputs: value (required), topic_name (required), key, headers. Returns: result
reset_consumer_group_offsetA
Resets the offset of a consumer group using AdminClient. offset_spec: 'earliest', 'latest', or a specific integer offset string. dry_run: If True, only calculates and returns the proposed offset changes without applying them. force: If True, forces the modification even if the group is active or STABLE.
Inputs: group_id (required), topic_name (required), force, dry_run, +2 more. Returns: object
rewind_consumer_group_offset_by_timestampB
Rewinds consumer group offsets manually based on a specific timestamp. Finds offsets matching the timestamp using Consumer, then sets using AdminClient. dry_run: If True, only calculates and returns the proposed offset changes without applying them. force: If True, forces the modification even if the group is active or STABLE.
Inputs: group_id (required), topic_name (required), timestamp_ms (required), force, +2 more. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 19 tools
Most tools have distinct purposes, but there is minor overlap between describe_brokers and describe_cluster (which also includes broker info), and between describe_cluster_health and get_broker_metrics (health summary vs raw metrics). Overall, an agent can reliably differentiate them.
All 19 tools follow a consistent verb_noun pattern (e.g., list_topics, create_topic, reset_consumer_group_offset). Verbs like describe, list, create, delete, get, reset, produce are used uniformly, making the naming predictable.
With 19 tools, the server is comprehensive but slightly on the heavier side. However, given Kafka's complexity (topics, partitions, configs, consumer groups, metrics), each tool serves a clear need and the count is justifiable.
The tool surface covers the core Kafka lifecycle: topic management (create/delete/describe), partition scaling, configs (describe/alter), message production and consumption, consumer group management (list/describe/offsets/reset/rewind), and cluster monitoring (brokers, health, metrics). No obvious gaps for standard operations.
Maintenance
Related MCP Connectors
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
MCP server for building and testing AI agents with multi-model experimentation and insights.
An MCP server that provides agents access to the KeldynAI platform
Related MCP Servers
AlicenseBqualityAmaintenanceAn MCP server implementation built to interact with Confluent Kafka and Confluent Cloud REST APIs.241,927 npm171MIT- AlicenseNot gradedqualityDmaintenanceAn 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.MIT
- AlicenseNot gradedqualityAmaintenanceAn MCP server that enables AI assistants to safely interact with Apache Kafka clusters, providing tools for topic management, message operations, consumer groups, and cluster information.3MIT
- FlicenseCqualityDmaintenanceExposes Kafka administration operations as MCP tools, enabling AI agents to inspect Kafka clusters using natural language.1-