kafka-mcp-server

Expose Apache Kafka operations (topics, produce, consume, consumer groups) as MCP tools.

Kafka MCP Server

A Model Context Protocol (MCP) server that exposes Apache Kafka operations as tools. Built with TypeScript, stdio transport, and the Confluent Kafka client.

Prerequisites

  • Node.js 18.18+ or 20.9+
  • A running Kafka-compatible broker (Apache Kafka, Redpanda, etc.)

Setup

npm install
npm run build

Configuration

Set the KAFKA_BROKERS environment variable (required):

export KAFKA_BROKERS=localhost:9092

Multiple brokers can be comma-separated: broker1:9092,broker2:9092.

Running

npm start

The server communicates over stdio using the MCP protocol.

Claude Code

Add the MCP server using the CLI:

claude mcp add kafka-mcp-server -e KAFKA_BROKERS=localhost:9092 node /path/to/kafka-mcp-server/dist/index.js

Or add to .mcp.json in your project root:

{
  "mcpServers": {
    "kafka": {
      "command": "node",
      "args": ["/path/to/kafka-mcp-server/dist/index.js"],
      "env": {
        "KAFKA_BROKERS": "localhost:9092"
      }
    }
  }
}

Claude Desktop

Add to your Claude Desktop config (claude_desktop_config.json):

{
  "mcpServers": {
    "kafka": {
      "command": "node",
      "args": ["/path/to/kafka-mcp-server/dist/index.js"],
      "env": {
        "KAFKA_BROKERS": "localhost:9092"
      }
    }
  }
}

Tools

Topics

ToolDescriptionInputs
list-topicsList all topicsnone
describe-topicGet topic details (partitions, replicas)topic
create-topicCreate a new topictopic, numPartitions (default 1), replicationFactor (default 1)
delete-topicDelete a topictopic

Produce / Consume

ToolDescriptionInputs
produceSend a message to a topictopic, value, key (optional)
consumeRead messages from a topictopic, maxMessages (default 10), timeout (default 5000ms)

The consume tool creates an ephemeral consumer that reads from the earliest offset without committing. It disconnects after reaching maxMessages or the timeout.

Cluster

ToolDescriptionInputs
get-cluster-infoGet broker informationnone
list-consumer-groupsList all consumer groupsnone
describe-consumer-groupGet consumer group detailsgroupId

Development

npm run build          # Compile TypeScript
npm start              # Run the server
npm run lint           # Run ESLint
npm run lint:fix       # Run ESLint with auto-fix
npm run format         # Format code with Prettier
npm run format:check   # Check formatting

Server Terkait