Skip to main content

Add your description here

Project description

Kafka MCP Server

A Message Context Protocol (MCP) server that integrates with Apache Kafka to provide publish and consume functionalities for LLM and Agentic applications.

Overview

This project implements a server that allows AI models to interact with Kafka topics through a standardized interface. It supports:

  • Publishing messages to Kafka topics
  • Consuming messages from Kafka topics

Prerequisites

  • Python 3.8+
  • Apache Kafka instance
  • Python dependencies (see Installation section)

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd <repository-directory>
    
  2. Create a virtual environment and activate it:

    python -m venv venv
    source venv/bin/activate  # On Windows, use: venv\Scripts\activate
    
  3. Install the required dependencies:

    pip install -r requirements.txt
    

    If no requirements.txt exists, install the following packages:

    pip install aiokafka python-dotenv pydantic-settings mcp-server
    

Configuration

Create a .env file in the project root with the following variables:

# Kafka Configuration
KAFKA_BOOTSTRAP_SERVERS=localhost:9092
TOPIC_NAME=your-topic-name
IS_TOPIC_READ_FROM_BEGINNING=False
DEFAULT_GROUP_ID_FOR_CONSUMER=kafka-mcp-group

# Optional: Custom Tool Descriptions
# TOOL_PUBLISH_DESCRIPTION="Custom description for the publish tool"
# TOOL_CONSUME_DESCRIPTION="Custom description for the consume tool"

Usage

Running the Server

You can run the server using the provided main.py script:

python main.py --transport stdio

Available transport options:

  • stdio: Standard input/output (default)
  • sse: Server-Sent Events

Integrating with Claude Desktop

To use this Kafka MCP server with Claude Desktop, add the following configuration to your Claude Desktop configuration file:

{
    "mcpServers": {
        "kafka": {
            "command": "python",
            "args": [
                "<PATH TO PROJECTS>/main.py"
            ]
        }
    }
}

Replace <PATH TO PROJECTS> with the absolute path to your project directory.

Project Structure

  • main.py: Entry point for the application
  • kafka.py: Kafka connector implementation
  • server.py: MCP server implementation with tools for Kafka interaction
  • settings.py: Configuration management using Pydantic

Available Tools

kafka-publish

Publishes information to the configured Kafka topic.

kafka-consume

consume information from the configured Kafka topic.

  • Note: once a message is read from the topic it can not be read again using the same groupid

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kafka_mcp_server-0.1.1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kafka_mcp_server-0.1.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file kafka_mcp_server-0.1.1.tar.gz.

File metadata

  • Download URL: kafka_mcp_server-0.1.1.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.9

File hashes

Hashes for kafka_mcp_server-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7555f4374c4b1ec35b2306b221d413957df1d72d29e161f9f9b37f7902b898d1
MD5 a171d6351f184d42bd0efa5ddfef6343
BLAKE2b-256 6ecbd37fd944740bc701c669b9bf5a1f248613968687fe404ed73455b25fae58

See more details on using hashes here.

File details

Details for the file kafka_mcp_server-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for kafka_mcp_server-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bc7f3669b3a035a292175a9650f482959a39f591dc42035a4f92b6112922c116
MD5 8558e53d1272f964965c7ea670272fb8
BLAKE2b-256 9a7f3b4090f9487fc931a4be76f3fb4abfd3e083be4d4a25e87124525aa2408a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page