wklee610/kafka-mcp

๐Ÿ—„๏ธ Databases
0 Views
0 Installs

๐Ÿ ๐Ÿ  โ˜๏ธ - MCP server for Apache Kafka that allows LLM agents to inspect topics, consumer groups, and safely manage offsets (reset, rewind).

Quick Install

One-Click IDE Configuration
claude_desktop_config.json
{
  "mcpServers": {
    "wklee610-kafka-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "wklee610-kafka-mcp"
      ]
    }
  }
}
Or

Using an AI coding agent (Claude Code, Cursor, etc.)? Copy a ready-made prompt that tells it to fetch the setup instructions and install this server for you.

Documentation Overview

Kafka MCP Server

Python License Kafka MCP


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, create create_topic, delete delete_topic, describe describe_topic, and increase partitions create_partitions.
  • Configuration Management: View describe_configs and modify alter_configs dynamic configs for topics, brokers, and groups.
  • Consumer Groups: List list_consumer_groups, describe describe_consumer_group, and securely manage offsets with reset_consumer_group_offset and rewind_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 messages produce_message.

Prerequisites

  • Python 3.10+
  • uv package manager (recommended)
  • A running Kafka cluster (e.g., local Docker, Confluent Cloud, etc.)

Installation

  1. Clone the repository.
  2. 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-mcp

Using Docker

  1. Build the Docker image:

    docker build -t kafka-mcp .
    
  2. Run the container:

    docker run -i --rm -e KAFKA_BOOTSTRAP_SERVERS=host.docker.internal:9092 kafka-mcp
    

    (Note: Use host.docker.internal instead of localhost if 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

CategoryTool NameDescription
Clusterdescribe_clusterGet cluster metadata (controller, brokers).
describe_brokersList all brokers.
Topicslist_topicsList all available topics.
describe_topicGet detailed info (partitions, replicas) for a topic.
create_topicCreate a new topic with partitions/replication factor.
delete_topicDelete a topic.
create_partitionsIncrease partitions for a topic.
Configsdescribe_configsView dynamic configs for topic/broker/group.
alter_configsUpdate dynamic configs.
Consumerslist_consumer_groupsList all active consumer groups.
describe_consumer_groupGet members and state of a group.
get_consumer_group_offsetsGet committed offset, high/low watermarks, and calculate total lag for a topic.
reset_consumer_group_offsetSafely change consumer group offsets to earliest, latest, or a specific offset.
rewind_consumer_group_offset_by_timestampRewind/advance consumer group offsets securely based on a timestamp.
Messagesconsume_messagesConsume messages from a topic (supports offsets, limits).
produce_messageSend 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 registration

Troubleshooting

  • Connection Refused: Ensure KAFKA_BOOTSTRAP_SERVERS is correct and reachable.

TODO

  • SASL
  • JMX

Related MCP Servers

modelcontextprotocol/server-postgresVerified

๐Ÿ“‡ ๐Ÿ  - PostgreSQL database integration with schema inspection and query capabilities

๐Ÿ—„๏ธ Databases1 views
Aiven-Open/mcp-aiven

๐Ÿ โ˜๏ธ ๐ŸŽ–๏ธ - Navigate your Aiven projects and interact with the PostgreSQLยฎ, Apache Kafkaยฎ, ClickHouseยฎ and OpenSearchยฎ services

๐Ÿ—„๏ธ Databases0 views
alexanderzuev/supabase-mcp-server

Supabase MCP Server with support for SQL query execution and database exploration tools

๐Ÿ—„๏ธ Databases0 views
aliyun/alibabacloud-tablestore-mcp-server

โ˜• ๐Ÿ โ˜๏ธ - MCP service for Tablestore, features include adding documents, semantic search for documents based on vectors and scalars, RAG-friendly, and serverless.

๐Ÿ—„๏ธ Databases0 views

Engagement

Views
0
Installs
0
Upvotes
0

Views and upvotes are unique per visitor network (hashed IP). Installs count copy actions.

Status

Health: Not checked yet

We have not completed a health check for this listing yet.

No check timestamp yet.

Unclaimed listing (imported or pending owner verification). Claim it โ†’
โ˜… Spotlight Slot

Feature Your MCP Server

Get maximum visibility for your server across our directory, search results, and detail pages.

Spotlight Your Server

Own this project?

This directory is pre-filled from public sources. Claim via GitHub README, site badge, or DNS TXT to get the verified badge and attach your website.

Claim this listing

Promote this listing

Optional paid placement. Free listings stay free forever.

Share & Embed

Add our SVG badge (dark/light directory styles) or embeddable widget to your site.