MCP Confluent Kafka云服务器
一种用于与 Confluent Kafka 和 Confluent Cloud REST API 交互的 MCP 服务器实现。
服务介绍
mcp-confluent
一个MCP服务器实现,使AI助手能够与Confluent Kafka和Confluent Cloud REST APIs交互。该服务器允许像Claude Desktop和Goose CLI这样的AI工具通过自然语言交互来管理Kafka主题、连接器和Flink SQL语句。
演示
Goose CLI

Claude Desktop

目录
用户指南
开始使用
-
创建一个
.env文件: 将示例的.env文件结构(如下所示)复制到你的项目根目录下的一个名为.env的新文件中。 -
填充
.env文件: 根据您的Confluent Cloud环境填写必要的值。有关每个变量的详细信息,请参见配置部分。 -
安装Node.js(如果尚未安装)
- 我们建议使用NVM(Node版本管理器)来管理Node.js版本
- 安装并使用Node.js:
nvm install 22 nvm use 22
配置
在项目的根目录下创建一个包含以下配置的.env文件:
# .env file
BOOTSTRAP_SERVERS="pkc-v12gj.us-east4.gcp.confluent.cloud:9092"
KAFKA_API_KEY="..."
KAFKA_API_SECRET="..."
KAFKA_REST_ENDPOINT="https://pkc-v12gj.us-east4.gcp.confluent.cloud:443"
KAFKA_CLUSTER_ID=""
KAFKA_ENV_ID="env-..."
FLINK_ENV_ID="env-..."
FLINK_ORG_ID=""
FLINK_REST_ENDPOINT="https://flink.us-east4.gcp.confluent.cloud"
FLINK_ENV_NAME=""
FLINK_DATABASE_NAME=""
FLINK_API_KEY=""
FLINK_API_SECRET=""
FLINK_COMPUTE_POOL_ID="lfcp-..."
CONFLUENT_CLOUD_API_KEY=""
CONFLUENT_CLOUD_API_SECRET=""
CONFLUENT_CLOUD_REST_ENDPOINT="https://api.confluent.cloud"
SCHEMA_REGISTRY_API_KEY="..."
SCHEMA_REGISTRY_API_SECRET="..."
SCHEMA_REGISTRY_ENDPOINT="https://psrc-zv01y.northamerica-northeast2.gcp.confluent.cloud"
环境变量参考
| Variable | Description | Default Value | Required |
|---|---|---|---|
| BOOTSTRAP_SERVERS | List of Kafka broker addresses in the format host1:port1,host2:port2 used to establish initial connection to the Kafka cluster (string) | Yes | |
| CONFIG_PATH | File system path to store and retrieve conversation-based configurations for session persistence (Future Implementation) (string) | Yes | |
| CONFLUENT_CLOUD_API_KEY | Master API key for Confluent Cloud platform administration, enabling management of resources across your organization (string (min: 1)) | Yes | |
| CONFLUENT_CLOUD_API_SECRET | Master API secret paired with CONFLUENT_CLOUD_API_KEY for comprehensive Confluent Cloud platform administration (string (min: 1)) | Yes | |
| FLINK_API_KEY | Authentication key for accessing Confluent Cloud's Flink services, including compute pools and SQL statement management (string (min: 1)) | Yes | |
| FLINK_API_SECRET | Secret token paired with FLINK_API_KEY for authenticated access to Confluent Cloud's Flink services (string (min: 1)) | Yes | |
| KAFKA_API_KEY | Authentication credential (username) required to establish secure connection with the Kafka cluster (string (min: 1)) | Yes | |
| KAFKA_API_SECRET | Authentication credential (password) paired with KAFKA_API_KEY for secure Kafka cluster access (string (min: 1)) | Yes | |
| SCHEMA_REGISTRY_API_KEY | Authentication key for accessing Schema Registry services to manage and validate data schemas (string (min: 1)) | Yes | |
| SCHEMA_REGISTRY_API_SECRET | Authentication secret paired with SCHEMA_REGISTRY_API_KEY for secure Schema Registry access (string (min: 1)) | Yes | |
| CONFLUENT_CLOUD_REST_ENDPOINT | Base URL for Confluent Cloud's REST API services (default) | No | |
| FLINK_COMPUTE_POOL_ID | Unique identifier for the Flink compute pool, must start with 'lfcp-' prefix (string) | No | |
| FLINK_DATABASE_NAME | Name of the associated Kafka cluster used as a database reference in Flink SQL operations (string (min: 1)) | No | |
| FLINK_ENV_ID | Unique identifier for the Flink environment, must start with 'env-' prefix (string) | No | |
| FLINK_ENV_NAME | Human-readable name for the Flink environment used for identification and display purposes (string (min: 1)) | No | |
| FLINK_ORG_ID | Organization identifier within Confluent Cloud for Flink resource management (string (min: 1)) | No | |
| FLINK_REST_ENDPOINT | Base URL for Confluent Cloud's Flink REST API endpoints used for SQL statement and compute pool management (string) | No | |
| KAFKA_CLUSTER_ID | Unique identifier for the Kafka cluster within Confluent Cloud ecosystem (string (min: 1)) | No | |
| KAFKA_ENV_ID | Environment identifier for Kafka cluster, must start with 'env-' prefix (string) | No | |
| KAFKA_REST_ENDPOINT | REST API endpoint for Kafka cluster management and administration (string) | No | |
| SCHEMA_REGISTRY_ENDPOINT | URL endpoint for accessing Schema Registry services to manage data schemas (string) | No |
使用说明
此MCP服务器设计用于与各种MCP客户端(如Claude桌面版或Goose CLI/桌面版)配合使用。具体的配置和交互将取决于您使用的客户端。但一般步骤如下:
-
构建: 按照开发者指南中的说明从源代码构建并运行服务器。这通常包括:
- 安装依赖项 (
npm install) - 构建项目 (
npm run build或npm run dev)
- 安装依赖项 (
-
配置您的MCP客户端: 每个客户端都有自己的方式来指定MCP服务器的地址及任何所需的凭证。您需要配置您的客户端(例如,Claude, Goose),使其连接到该服务器正在运行的地址(很可能是带有特定端口的
localhost)。服务器运行的端口可能通过环境变量配置。 -
启动MCP客户端: 一旦您的客户端配置为连接到MCP服务器,您可以启动您的MCP客户端,在启动时它将在本地启动一个此MCP服务器的实例。该实例将负责管理数据模式,并代表您与Confluent Cloud进行交互。
-
通过客户端与Confluent互动: 一旦客户端连接成功,您可以使用客户端界面与Confluent Cloud资源进行交互。客户端会向此MCP服务器发送请求,然后该服务器将代表您与Confluent Cloud进行通信。
配置Claude桌面版
有关安装Claude桌面版和MCP服务器的更多详细信息,请参阅这里。
要配置Claude桌面版以使用此MCP服务器:
-
打开Claude桌面版配置
- 在Mac上:
~/Library/Application Support/Claude/claude_desktop_config.json - 在Windows上:
%APPDATA%\Claude\claude_desktop_config.json
- 在Mac上:
-
编辑配置文件
- 使用您喜欢的文本编辑器打开配置文件
- 使用以下方法之一添加或修改配置:
{ "mcpServers": { "confluent": { "command": "node", "args": [ "/path/to/confluent-mcp-server/dist/index.js", "--env-file", "/path/to/confluent-mcp-server/.env", ] } } }{ "mcpServers": { "confluent": { "command": "npx", "args": [ "-y" "@confluentinc/mcp-confluent", "-e", "/path/to/confluent-mcp-server/.env" ] } } }将
/path/to/confluent-mcp-server/替换为您实际安装此MCP服务器的路径。 -
重启Claude桌面版
- 关闭并重新打开Claude桌面版使更改生效
- MCP服务器将在Claude桌面版启动时自动开始运行
现在将配置 Claude Desktop 以使用您的本地 MCP 服务器进行 Confluent 交互。

配置 Goose CLI
有关如何安装 Goose CLI 的详细说明,请参见这里。
安装完成后,请按照以下步骤操作:
-
运行配置命令:
goose configure -
按照交互提示操作:
- 选择
Add extension - 选择
Command-line Extension - 输入
mcp-confluent作为扩展名 - 选择以下配置方法之一:
node /path/to/confluent-mcp-server/dist/index.js --env-file /path/to/confluent-mcp-server/.envnpx -y @confluentinc/mcp-confluent -e /path/to/confluent-mcp-server/.env - 选择
请将 /path/to/confluent-mcp-server/ 替换为您实际安装此 MCP 服务器的路径。

开发者指南
项目结构
/
├── src/ # Source code
│ ├── confluent/ # Code related to Confluent integration (API clients, etc.)
│ ├── tools/ # Tool implementations (each tool in a separate file)
│ ├── index.ts # Main entry point for the server
│ └── ... # Other server logic, utilities, etc.
├── dist/ # Compiled output (TypeScript -> JavaScript)
├── openapi.json # OpenAPI specification for Confluent Cloud
├── .env # Environment variables (example - should be copied and filled)
├── README.md # This file
└── package.json # Node.js project metadata and dependencies
构建和运行
-
安装依赖项:
npm install -
开发模式(监听更改):
npm run dev此命令会将 TypeScript 代码编译为 JavaScript,并在检测到
src/目录中的更改时自动重新构建。 -
生产环境构建(一次性编译):
npm run build -
启动服务器:
npm run start
测试
MCP Inspector
对于测试 MCP 服务器,您可以使用 MCP Inspector,这是一个用于测试和调试 MCP 服务器的交互式开发者工具。
# make sure you've already built the project either in dev mode or by running npm run build
npx @modelcontextprotocol/inspector node $PATH_TO_PROJECT/dist/index.js --env-file $PATH_TO_PROJECT/.env
添加新工具
- 在枚举类
ToolName中添加一个新的枚举。 - 在
ToolFactory类的处理程序映射中添加您的新工具。 - 创建一个新文件,导出继承自
BaseToolHandler的类。- 实现基类的
handle方法。 - 实现基类的
getToolConfig方法。
- 实现基类的
- 完成后,在
index.ts中将其添加到enabledTools集合中。
生成类型
# as of v7.5.2 there is a bug when using allOf w/ required https://github.com/openapi-ts/openapi-typescript/issues/1474. need --empty-objects-unknown flag to avoid it
npx openapi-typescript ./openapi.json -o ./src/confluent/openapi-schema.d.ts --empty-objects-unknown
贡献
我们非常欢迎以 Github Issues 的形式提交错误报告和反馈。有关贡献指南,请参阅 CONTRIBUTING.md