An AI-powered Kafka monitoring and management system using the Model Context Protocol (MCP). This project enables natural language interactions with Apache Kafka clusters through AI assistants like Claude Desktop.
Transform complex Kafka operations into simple conversations:
- "How is my orders topic doing?" โ Get comprehensive health analysis
- "Are there any consumer lag issues?" โ Receive intelligent lag analysis with recommendations
- "Show me recent payment failures" โ Inspect and analyze message patterns
- "Should I scale my Kafka cluster?" โ Get performance insights and scaling advice
โโโโโโโโโโโโโโโโโโโ MCP Protocol โโโโโโโโโโโโโโโโโโโ Kafka APIs โโโโโโโโโโโโโโโโโโโ
โ AI Assistant โโโโโโโโโโโโโโโโโโโโบโ Kafka MCP โโโโโโโโโโโโโโโโโโโบโ Kafka Cluster โ
โ โ (stdio/HTTP) โ Server โ (Admin/Client) โ โ
โ - Claude โ โ โ โ - Brokers โ
โ - Cursor โ โ - Tool Handlers โ โ - Topics โ
โ - Custom Apps โ โ - Kafka Clients โ โ - Partitions โ
โโโโโโโโโโโโโโโโโโโ โ - Data Analysis โ โ - Consumer Grps โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
kafka-mcp-integration/
โโโ docker/ # Docker configurations
โ โโโ docker-compose.yml # Kafka cluster setup
โ โโโ kafka-setup.sh # Kafka initialization
โโโ mcp-server/ # MCP server implementation
โ โโโ src/
โ โ โโโ index.ts # Server entry point
โ โ โโโ server.ts # MCP server logic
โ โ โโโ tools/ # Kafka analysis tools
โ โ โโโ kafka/ # Kafka client wrappers
โ โ โโโ types/ # TypeScript definitions
โ โโโ package.json
โ โโโ tsconfig.json
โโโ mcp-client/ # MCP client for testing
โ โโโ src/
โ โ โโโ index.ts # Client entry point
โ โ โโโ client.ts # MCP client implementation
โ โ โโโ demo.ts # Demo scenarios
โ โโโ package.json
โ โโโ tsconfig.json
โโโ config/ # Configuration files
โ โโโ kafka.json # Kafka settings
โ โโโ mcp-server.json # MCP server config
โโโ scripts/ # Automation scripts
โ โโโ setup.ps1 # Complete setup
โ โโโ start-kafka.ps1 # Start Kafka cluster
โ โโโ start-mcp-server.ps1 # Start MCP server
โ โโโ demo.ps1 # Run demo scenarios
โโโ README.md
- Docker Desktop (running)
- Node.js (v16 or higher)
- Claude Desktop (for AI integration)
# Clone and navigate to project
git clone <repository-url>
cd kafka-mcp-integration
# Clean build everything
cd mcp-server
Remove-Item -Recurse -Force dist, node_modules -ErrorAction SilentlyContinue
npm install && npm run build
cd ../mcp-client
Remove-Item -Recurse -Force dist, node_modules -ErrorAction SilentlyContinue
npm install && npm run build
cd ..
# Run setup script
./scripts/setup.ps1
# Start Kafka cluster
./scripts/start-kafka.ps1
# Wait for Kafka to be ready
Start-Sleep -Seconds 45
# Create sample topics
docker exec kafka kafka-topics --create --topic orders --bootstrap-server localhost:29092 --partitions 3 --replication-factor 1
docker exec kafka kafka-topics --create --topic payments --bootstrap-server localhost:29092 --partitions 2 --replication-factor 1
# Produce sample messages
docker exec kafka bash -c 'echo "{\"order_id\":\"order_001\",\"amount\":99.99,\"status\":\"completed\"}" | kafka-console-producer --topic orders --bootstrap-server localhost:29092'
# Start MCP server
./scripts/start-mcp-server.ps1
# In new terminal, test client
cd mcp-client
node dist/index.js
# Try commands:
# check_topic_health {"topic": "orders"}
# analyze_consumer_lag {"topic": "orders"}
# inspect_messages {"topic": "orders", "limit": 5}
# analyze_broker_performance {}
Create %APPDATA%\Claude\claude_desktop_config.json
:
{
"mcpServers": {
"kafka-mcp": {
"command": "node",
"args": [
"C:\\path\\to\\kafka-mcp-integration\\mcp-server\\dist\\index.js"
],
"env": {
"KAFKA_BROKERS": "localhost:29092",
"NODE_ENV": "production"
}
}
}
}
Restart Claude Desktop and start chatting with your Kafka cluster!
Analyzes consumer group lag across topics and partitions.
Usage: {"topic": "orders"}
Returns: Detailed lag analysis with recommendations
Comprehensive health check for Kafka topics.
Usage: {"topic": "orders"}
Returns: Partition health, replication status, and issues
Samples and analyzes recent messages from topics.
Usage: {"topic": "orders", "limit": 10}
Returns: Recent messages with metadata and patterns
Monitors broker metrics and cluster performance.
Usage: {}
Returns: Broker status, metrics, and performance insights
You: "How is my Kafka cluster doing?"
Claude: "Let me check your cluster health..."
[Runs multiple tools and provides comprehensive analysis]
You: "My order processing seems slow, what's wrong?"
Claude: "I'll analyze your consumer lag..."
[Identifies bottlenecks and suggests optimizations]
You: "Are there any suspicious payment patterns?"
Claude: "Let me examine recent payment messages..."
[Analyzes messages and identifies anomalies]
Edit config/kafka.json
:
{
"brokers": ["localhost:29092"],
"clientId": "kafka-mcp-server",
"connectionTimeout": 3000
}
Edit config/mcp-server.json
:
{
"transport": "stdio",
"tools": {
"enabled": ["analyze_consumer_lag", "check_topic_health", "inspect_messages", "analyze_broker_performance"]
}
}
# Check compilation
cd mcp-server
npx tsc --noEmit
# Verify Kafka connection
docker exec kafka kafka-topics --list --bootstrap-server localhost:29092
# Check port usage
netstat -an | findstr ":29092"
netstat -an | findstr ":9092"
- Verify config file location:
%APPDATA%\Claude\claude_desktop_config.json
- Check file paths are absolute and correct
- Restart Claude Desktop after config changes
- Look for MCP connection indicator in Claude Desktop
# Stop all services
taskkill /F /IM node.exe
# Clean Docker
cd docker
docker-compose down --volumes --remove-orphans
docker system prune -f
# Clean builds
Remove-Item -Recurse -Force mcp-server\dist, mcp-client\dist -ErrorAction SilentlyContinue
MIT License - see LICENSE file for details
Transform your Kafka operations with the power of AI! ๐