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
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows, use: venv\Scripts\activate
-
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 applicationkafka.py: Kafka connector implementationserver.py: MCP server implementation with tools for Kafka interactionsettings.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
Metadata
Release files for kafka-mcp-server 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| kafka_mcp_server-0.1.1.tar.gz | 9.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kafka_mcp_server-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.7 kB
Release files / kafka_mcp_server-0.1.1.tar.gz
| Download URL | kafka_mcp_server-0.1.1.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7555f4374c4b1ec35b2306b221d413957df1d72d29e161f9f9b37f7902b898d1
|
|
BLAKE2b-256 checksum How to use checksums |
6ecbd37fd944740bc701c669b9bf5a1f248613968687fe404ed73455b25fae58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.9
|
Release files / kafka_mcp_server-0.1.1-py3-none-any.whl
| Download URL | kafka_mcp_server-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc7f3669b3a035a292175a9650f482959a39f591dc42035a4f92b6112922c116
|
|
BLAKE2b-256 checksum How to use checksums |
9a7f3b4090f9487fc931a4be76f3fb4abfd3e083be4d4a25e87124525aa2408a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.9
|