npm package: @flinkhouse/server-kafkamanager
Description: MCP server for managing Kafka clusters
Author: flinkhouse
Latest version: 0.1.1

# Kafka Manager MCP Server

Model Context Protocol (MCP) server for managing Kafka clusters. This server provides tools for Kafka management operations including:

- Starting and stopping Kafka clusters
- Managing topics (list, create, delete, modify)
- Managing consumer groups (list, delete)
- Viewing topic data

## Prerequisites

- Node.js (v16+)
- Kafka installation (2.5.0+)

## Installation

```bash
npm install -g @modelcontextprotocol/server-kafkamanager
```

Or you can use it without installing:

```bash
npx @modelcontextprotocol/server-kafkamanager /path/to/kafka/home
```

## Usage

The server requires the path to your Kafka installation directory:

```bash
mcp-server-kafkamanager /path/to/kafka/home
```

For example:

```bash
mcp-server-kafkamanager /Users/jian.zhang04/Documents/kafka_2.12-2.5.0
```

## Available Tools

### Start Kafka Cluster

Starts a Kafka cluster by launching ZooKeeper and Kafka broker processes.

```
start_kafka_cluster [--dryRun]
```

Options:
- `dryRun`: Only display the command without running it (optional, default: false)

### Stop Kafka Cluster

Stops a running Kafka cluster by shutting down both the Kafka broker and ZooKeeper.

```
stop_kafka_cluster [--dryRun]
```

Options:
- `dryRun`: Only display the command without running it (optional, default: false)

### List Topics

Lists all topics in the Kafka cluster with their configurations.

```
list_topics [--bootstrap_server <server>]
```

Options:
- `bootstrap_server`: Kafka bootstrap server (optional, default: "localhost:9092")

### Create Topic

Creates a new Kafka topic with specified configuration.

```
create_topic --topic_name <name> [--partitions <num>] [--replication_factor <num>] [--bootstrap_server <server>]
```

Options:
- `topic_name`: Name of the topic to create
- `partitions`: Number of partitions (optional, default: 1)
- `replication_factor`: Replication factor (optional, default: 1)
- `bootstrap_server`: Kafka bootstrap server (optional, default: "localhost:9092")

### Delete Topic

Deletes a Kafka topic.

```
delete_topic --topic_name <name> [--bootstrap_server <server>]
```

Options:
- `topic_name`: Name of the topic to delete
- `bootstrap_server`: Kafka bootstrap server (optional, default: "localhost:9092")

### Modify Topic

Modifies an existing Kafka topic's configuration.

```
modify_topic --topic_name <name> --partitions <num> [--bootstrap_server <server>]
```

Options:
- `topic_name`: Name of the topic to modify
- `partitions`: New number of partitions
- `bootstrap_server`: Kafka bootstrap server (optional, default: "localhost:9092")

### List Consumer Groups

Lists all consumer groups in the Kafka cluster with their status and offsets.

```
list_consumer_groups [--bootstrap_server <server>]
```

Options:
- `bootstrap_server`: Kafka bootstrap server (optional, default: "localhost:9092")

### Delete Consumer Group

Deletes a consumer group from the Kafka cluster.

```
delete_consumer_group --group_id <id> [--bootstrap_server <server>]
```

Options:
- `group_id`: Consumer group ID to delete
- `bootstrap_server`: Kafka bootstrap server (optional, default: "localhost:9092")

### View Topic Data

Views data in a Kafka topic by consuming a specified number of messages.

```
view_topic_data --topic_name <name> [--max_messages <num>] [--bootstrap_server <server>]
```

Options:
- `topic_name`: Name of the topic to view
- `max_messages`: Maximum number of messages to consume (optional, default: 10)
- `bootstrap_server`: Kafka bootstrap server (optional, default: "localhost:9092")

## Docker Usage

You can also run this server using Docker:

```bash
docker build -t kafkamanager .
docker run -it --network host kafkamanager /path/to/kafka/home
```

## Example

```
# Start Kafka cluster
start_kafka_cluster

# Create a topic
create_topic --topic_name my-topic --partitions 3 --replication_factor 1

# List all topics
list_topics

# View messages in a topic
view_topic_data --topic_name my-topic --max_messages 5

# Stop Kafka cluster
stop_kafka_cluster
```

## Troubleshooting

- If you encounter connection issues, make sure Kafka and ZooKeeper are running properly
- Check Kafka logs in `/tmp/kafka.log` and ZooKeeper logs in `/tmp/zookeeper.log`
- Verify the bootstrap server address (default is localhost:9092)

## License

MIT