MCP 文档服务器是一个简单的服务器,它实现了模型上下文协议(MCP),可用于文档搜索和检索。借助该服务器,用户能够高效地存储和查找文档,同时具备语义搜索等实用功能。
npm install
npm run build
npm run stdio
npm install
npm run build
npm run stdio
此服务器设计用于与 Cursor 配合使用。您可以通过 search
工具使用关键字参数搜索文档。
search({
keyword: "data"
})
您可以直接从 Cursor 创建新文档:
create_document({
title: "New Confluence Page",
content: "This is a page created in Confluence",
serviceId: "confluence"
})
架构基于可插拔式文档服务。每个服务实现通用接口以进行搜索和检索文档。
本地存储服务将文档保存到本地文件系统:
data/documents/
目录(按需自动创建)data/documents.json
(按需自动创建)Confluence 服务使用 Confluence REST API 和 CQL(Confluence 查询语言)搜索工作区文档。要启用此功能,请设置以下环境变量:
# Confluence 配置
export CONFLUENCE_BASE_URL="https://your-domain.atlassian.net/wiki"
export CONFLUENCE_USERNAME="your-email@example.com"
export CONFLUENCE_API_TOKEN="your-api-token"
export CONFLUENCE_SPACE="your-space-key"
您可以在启动服务器之前设置这些变量:
CONFLUENCE_BASE_URL="https://your-domain.atlassian.net/wiki" \
CONFLUENCE_USERNAME="your-email@example.com" \
CONFLUENCE_API_TOKEN="your-api-token" \
CONFLUENCE_SPACE="your-space-key" \
npm run stdio
服务使用基本认证,使用您的电子邮件和 API 令牌。凭据以 Base64 编码字符串形式发送在授权头中:
Authorization: Basic
本地存储服务自动创建 data/documents
目录和 data/documents.json
文件(按需生成)。这些文件不在仓库中,并按需自动生成。
MCP 服务器设计为可扩展。您可以通过实现 DocumentService
接口轻松添加新文档服务:
interface DocumentService {
id: string;
getByKeywords: (keywords: string[]) => Promise<Document[]>;
createDocument?: (title: string, content: string) => Promise<Document>;
}
要添加新服务:
src/services/
目录下为您的服务创建新目录DocumentService
接口src/services/index.ts
注册您的服务一些可能的文档服务实现方向: