Show HN:MCP-Kafka——Kafka命令的自然语言接口
Show HN: MCP-Kafka – Natural Language Interface for Kafka Commands

原始链接: https://github.com/kanapuli/mcp-kafka

mcp-kafka是一个模型上下文协议(MCP)服务器,它连接AI助手与Apache Kafka,实现与Kafka集群的直接交互。它允许AI助手执行创建、管理和交互Kafka主题和消息的操作。主要功能包括创建/删除主题、列出主题、描述主题详情、生产带有键/头的消息以及使用超时时间消费消息。 该服务器使用Go (1.24+)构建,需要一个运行中的Kafka集群。配置参数会自动从自然语言请求中推导出来。支持的认证方式包括PLAINTEXT和SASL_PLAINTEXT,可以通过CLI标志配置bootstrap服务器、消费者组ID、用户名和密码。 安装包括构建应用程序,并通过在`claude_desktop_config.json`中添加一个包含可执行文件路径和相关参数的JSON条目将其配置为Claude桌面工具。 欢迎在MIT许可下贡献代码。

Hacker News 最新 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Show HN: MCP-Kafka – Kafka 命令的自然语言界面 (github.com/kanapuli) 6 分,由 akanapuli 1 小时前提交 | 隐藏 | 过去 | 收藏 | 讨论 我构建了一个模型上下文协议服务器,允许用户使用自然语言而不是复杂的 CLI 与 Kafka 交互。它使用大型语言模型 (LLM) 来解释用普通英语表达的命令,并执行相应的 Kafka 操作。这使得 Kafka 更易于非专家访问,同时保持其强大的功能。 加入我们 6 月 16-17 日在旧金山举办的 AI 初创公司学校! 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系我们 搜索:

原文

A Model Context Protocol (MCP) server for performing Kafka client operations from AI assistants.

mcp-kafka provides a bridge between AI assistants and Apache Kafka, allowing them to interact with Kafka clusters through the Model Context Protocol. This tool enables AI assistants to create, manage, and interact with Kafka topics and messages directly.

Here is a short video demo on youtube

mcp-kafka-demo

The mcp-kafka server provides the following Kafka operations:

  • Create Topic: Create a new Kafka topic with configurable partitions and replication factor
  • List Topics: Get a list of all available Kafka topics in the cluster
  • Delete Topic: Remove an existing Kafka topic
  • Describe Topic: Get detailed information about a specific topic, including partition details
  • Produce Message: Send messages to a Kafka topic with support for message keys and headers
  • Consume Messages: Read messages from a Kafka topic with configurable timeout
  • Go 1.24 or higher
  • A running Kafka cluster (default connection: localhost:9092)
  1. Clone the repository:

    git clone https://github.com/kanapuli/mcp-kafka.git
    cd mcp-kafka
  2. Build the application:

  3. Optionally, build for a specific platform:

    make build GOOS=darwin GOARCH=arm64

Installing as a Claude Desktop Tool

To use mcp-kafka with Claude Desktop:

  1. Build the application as mentioned above.

  2. Place the executable in a location included in your system PATH or in a dedicated tools directory.

  3. Please follow this Claude Desktop Tool Installation Guide to install the tool.

The JSON to be added to the claude_desktop_config.json file is as follows, Use the right username and password for SASL login. Leave them empty for PLAINTEXT authentication.

{
  "mcpServers": {
    "kafka": {
	    "command": "/Your-mcp-kafka-executable-path/mcp-kafka-darwin-arm64",
      "args": [
          "--bootstrap-servers=localhost:9092",
          "--consumer-group-id=mcp-kafka-consumer-group",
          "--username=",
          "--password="
        ],
      "env": {}
    }
  }
}

The mcp-kafka tool accepts the following configuration parameters:

Parameter Description Default
topic Topic to interact with (required)
num_partitions Number of partitions for topic creation (optional)
replication_factor Replication factor for topic creation (optional)
produce_message_key Key for produced messages (optional)
produce_message_value Value for produced messages (optional)
produce_message_headers Headers for produced messages (optional)
consumer_timeout Timeout in seconds for message consumption 10

These parameters will be automatically derived from your Natural language message to the LLM.

CLI flags for the mcp-kafka tool

The following flags should be used to configure the Kafka client:

--bootstrap-servers=localhost:9092
--consumer-group-id=mcp-kafka-consumer-group
--username='your_sasl_username'
--password='your_sasl_password'

NOTE: Currently, SASL_PLAINTEXT is supported along with PLAINTEXT authentication. SASL_SSL is not supported.

Contributions are welcome! Please feel free to submit a Pull Request.

MIT License

联系我们 contact @ memedata.com