模型上下文协议 (MCP) 是一种用于处理大型语言模型 (LLMs) 与外部系统之间交互的协议。本仓库借助 Couchbase Node.js SDK 实现了一个 Couchbase MCP 服务器,让 MCP 客户端(如 Claude Desktop)能够对 Couchbase Capella 集群执行自然语言查询。
模型上下文协议 (MCP) 可处理大型语言模型 (LLMs) 与外部系统的交互。本项目使用 Couchbase Node.js SDK 实现了 Couchbase MCP 服务器,借助该服务器,您可以使用自然语言对 Couchbase Capella 集群执行查询,例如:
Show me the results of SELECT * FROM my_bucket LIMIT 10
Execute this query: SELECT name, age FROM users WHERE active = true
Get me the latest 5 documents from my_bucket
Summarize the latest 5 orders from the orders bucket for me
query-couchbase
git clone git@github.com:hummusonrails/couchbase-mcp-server.git
cd couchbase-mcp-server
npm install
.env
文件,并添加您的 Couchbase 连接字符串、用户名和密码:COUCHBASE_CONNECTION_STRING=couchbases://your-cluster.cloud.couchbase.com
COUCHBASE_USERNAME=your_username
COUCHBASE_PASSWORD=your_password
请参考 .env.sample
文件以获取所需的环境变量。
3. 构建项目:
npm run build
npx couchbase-mcp-server
⚠️ 重要提示
MCP 服务器使用 StdioServerTransport,因此它通过标准输入/输出进行通信。请确保您的 MCP 客户端(例如 Claude Desktop)配置为连接到本地 MCP 服务器。请按照 Claude Desktop 文档 配置您的 MCP 客户端以连接到本地服务器。
下图展示了 MCP 服务器在与 Claude Desktop 客户端交互时的工作情况。用户以纯英语形式提出一般性请求,MCP 服务器将其转换为 SQL++ 查询,并在 Couchbase Capella 集群上执行。结果以可读格式返回给用户。
要在本地工作:
npm install
npm run build
stderr
,以确保 stdout
仅包含 MCP 协议 JSON。检查日志以获取详细连接和错误消息。欢迎贡献!请随意提交拉取请求或打开问题提出您的建议。对于任何更改,请遵循项目的代码风格。
此项目根据 MIT 许可证发布。有关详细信息,请参阅 LICENSE 文件。