Kafka MCP Server
Enables interaction with Kafka clusters via MCP, supporting topic management (list, create, delete, inspect), connection initialization, and more through natural language.
README
Kafka MCP Server
This project provides a Model Context Protocol (MCP) server that enables interaction with a Kafka cluster via standard tool-based interfaces. It exposes Kafka operations like producing messages, consuming, listing topics, and more ā all accessible through Claude Desktop or any MCP-compatible client.
š Features
- List Kafka topics
- Create and delete topics
- Produce messages
š Quick Start
1. Clone the repository
git clone https://github.com/joel-hanson/kafka-mcp-server.git
cd kafka-mcp-server
2. Setup Python environment (using conda)
conda create -n kafka-mcp python=3.10 -y
conda activate kafka-mcp
pip install -r requirements.txt
3. Start the MCP server (for local dev)
mcp dev
This starts the server and opens the MCP Inspector so you can test tool prompts and responses.
Usage
Running the Server
python server.py
Available Tools
- kafka_initialize_connection - Connect to Kafka using a properties file
- kafka_list_topics - List all topics in the cluster
- kafka_create_topic - Create a new topic
- kafka_delete_topic - Delete an existing topic
- kafka_get_topic_info - Get detailed information about a topic
Example Usage Flow
-
First, connect to Kafka:
Use kafka_initialize_connection with your properties file <path> OR Initialize connection with kafka using the properties file <path> -
List existing topics:
Use kafka_list_topics to see all topics OR List all the topics -
Create a new topic:
Use kafka_create_topic with name "my-topic", partitions 3, replication_factor 1 OR Create me a topic with name "my-topic" -
Get topic details:
Use kafka_get_topic_info for "my-topic"
Features
- Configuration Management: Loads Kafka connection details from standard properties files
- Topic Management: List, create, delete, and inspect topics
- Error Handling: Comprehensive error handling with informative messages
- Connection Management: Efficient connection pooling and cleanup
- Extensible: Easy to add more Kafka operations
Supported Kafka Operations
Current
- Topic listing
- Topic creation with custom partitions and replication factor
- Topic deletion
- Topic inspection (partitions, replicas, ISR)
Planned Features
- Message production
- Message consumption
- Consumer group management
- Offset management
- Cluster information
- Performance metrics
Troubleshooting
Common Issues
- Connection Failed: Verify your
bootstrap.serversin the properties file - Authentication Error: Check your SASL/SSL configuration
- Topic Already Exists: Use
kafka_get_topic_infoto check existing topics - Permission Denied: Ensure your Kafka user has the necessary permissions
Logging
The server logs to stdout. You can adjust the logging level by modifying the logging.basicConfig(level=logging.INFO) line in the code.
Security Notes
- Store sensitive credentials securely
- Use SSL/TLS for production environments
- Implement proper authentication and authorization
- Regularly rotate credentials
š§ Using with Claude Desktop
To integrate your Kafka MCP server with Claude Desktop:
Install it into Claude:
mcp install <file_spec> -f <optional env file>
Note: If you are seeing dependency-related issues, please configure the claud_desktop_config.json with the absolute path to the python and provide the file to run.
MCP Client Configuration
Add this to your MCP client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"kafka": {
"command": "python",
"args": ["/path/to/server.py"]
}
}
}
{
"mcpServers": {
"Kafka MCP Server": {
"command": "/opt/miniconda3/envs/kafka-mcp/bin/python",
"args": [
"/path/to/server.py"
]
}
}
}
Claude will now detect and interact with the tools you've defined via @mcp.prompt() in your Python server.
Configuration
Create a Kafka properties file (e.g., kafka.properties) with your Kafka connection details:
# Basic Kafka connection
bootstrap.servers=localhost:9092
client.id=kafka-mcp-client
# Security configuration (if needed)
# security.protocol=SASL_SSL
# sasl.mechanism=PLAIN
# sasl.username=your-username
# sasl.password=your-password
# SSL configuration (if needed)
# ssl.ca.location=/path/to/ca-cert
# ssl.certificate.location=/path/to/client-cert
# ssl.key.location=/path/to/client-key
š Project Structure
kafka_mcp_server/
āāā server.py # Main FastMCP server defining tools
āāā kafka_utils.py
āāā requirements.txt
āāā README.md
āāā ...
š§© Tool Debugging Tips
- Use
mcp devto inspect prompt behavior interactively - Add
print()orlogging.debug()in your tool functions - Use structured
@promptfunction signatures to ensure correct parsing
š¦ Requirements
Add this to your requirements.txt:
kafka-python
mcp[cli]
pydantic
uv
Testing
Please run docker compose up to bring up kafka cluster with a single broker you can interact with using the bootstrap.server localhost:9092.
š Resources
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.