Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

kafka_mcp_server

MCP.Pizza Chef: pavanjava

Kafka MCP Server is a Python-based MCP server that integrates Apache Kafka with AI models, enabling them to publish and consume messages via Kafka topics. It standardizes Kafka interactions for LLMs and agentic applications, facilitating real-time data exchange and event-driven workflows. Requires Python 3.8+ and a Kafka instance for deployment.

Use This MCP server To

Publish messages to Kafka topics from AI models Consume Kafka topic messages for real-time AI processing Integrate Kafka messaging into LLM-driven workflows Enable event-driven AI agents using Kafka streams Facilitate asynchronous communication between AI components via Kafka

README

MseeP.ai Security Assessment Badge

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

kafka_mcp_server FAQ

How do I install the Kafka MCP Server?
Clone the repository, create a Python 3.8+ virtual environment, activate it, and install dependencies as per the README instructions.
What are the prerequisites for running Kafka MCP Server?
You need Python 3.8 or higher and a running Apache Kafka instance.
Can Kafka MCP Server handle both publishing and consuming messages?
Yes, it supports both publishing messages to and consuming messages from Kafka topics.
Is Kafka MCP Server compatible with multiple LLM providers?
Yes, it is designed to work with various LLMs including OpenAI, Anthropic Claude, and Google Gemini by standardizing Kafka interactions.
How does Kafka MCP Server improve AI workflows?
It enables seamless, real-time message exchange between AI models and Kafka, supporting event-driven and asynchronous AI applications.
What programming language is Kafka MCP Server implemented in?
It is implemented in Python, requiring version 3.8 or above.
Can I use Kafka MCP Server in distributed AI systems?
Yes, it facilitates distributed communication by leveraging Kafka's scalable messaging infrastructure.