Morphik 多模态数据库的 Model Context Protocol (MCP) 服务器实现。
此 MCP 服务器允许 Claude 和其他兼容 MCP 的 AI 助手与 Morphik 数据库系统进行交互,支持以下功能:
服务器支持两种传输模式:
你需要访问以下之一:
# 连接到本地 Morphik 服务器
npx morphik-mcp
# 连接到 Morphik 云平台(替换为你的实际 URI)
npx morphik-mcp --uri=https://api.morphik.ai
# 指定文件操作允许的目录(逗号分隔)
npx morphik-mcp --allowed-dir=~/Documents,~/Downloads
npm install -g morphik-mcp
# 连接到本地 Morphik 服务器
morphik-mcp
# 连接到 Morphik 云平台
morphik-mcp --uri=https://api.morphik.ai
# 指定文件操作允许的目录
morphik-mcp --allowed-dir=~/Documents,~/Downloads
# 克隆仓库
git clone https://github.com/morphik-org/morphik-npm-mcp.git
cd morphik-npm-mcp
# 安装依赖
npm install
# 构建项目
npm run build
# 启动服务器(本地 Morphik)
npm start
# 启动服务器并启用文件操作
node build/index.js --allowed-dir=~/Documents,~/Downloads
服务器默认通过标准输入输出流运行,并且可以与像 Claude 这样的 MCP 客户端一起使用。
对于 HTTP/HTTPS 模式(可流式传输),请参阅 streamable_https.md 文档。
在你的 Claude Desktop 配置文件中添加以下内容:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"morphik-local": {
"command": "npx",
"args": ["-y", "morphik-mcp"]
},
"morphik-cloud": {
"command": "npx",
"args": ["-y", "morphik-mcp", "--uri=https://api.morphik.ai"]
},
"morphik-with-files": {
"command": "npx",
"args": ["-y", "morphik-mcp", "--allowed-dir=~/Documents,~/Downloads"]
}
}
}
请参阅 MCP_TOOLS.md 获取详细的参数文档和响应格式。
服务器目前提供以下工具,并有更多功能即将推出:
ingest-text: 将文本文档摄入到 Morphik 中
ingest-file-from-path: 从服务器文件系统摄入文件到 Morphik
ingest-file-from-base64: 通过提供文件名和 base64 编码的内容上传文件(适用于无法访问磁盘的 HTTP 传输)
ingest-files-from-paths: 批量摄入多个文件
retrieve-chunks: 根据查询检索最相关的“页面”(文本或图像片段),与 @morphik-app 中的 find_relevant_pages 工具相同
retrieve-docs: 根据查询从 Morphik 检索相关文档
search-documents: 通过全文搜索按文件名或标题搜索文档
get-pages-in-range: 获取文档中的一个包含范围内的页面(最多 10 页),与 @morphik-app 中的 get_all_pages_within_range_from_document 相同
get-document: 根据 ID 获取 Morphik 中的具体文档
delete-document: 根据 ID 删除 Morphik 中的文档
一参数:documentId, apiKey
check-ingestion-status: 检查已摄入文档的处理状态
morphik-filters: 查看、设置或清除应用于检索/列表操作的类型化元数据过滤器(支持 eq, regex, number_range, date_range)
list-documents: 更新工具,使用 /documents/list_docs,包括 include_total_count, return_documents, fields,以及文件夹/终端用户范围
list-allowed-directories: 列出服务器被允许访问的目录
list-directory: 列出特定目录下的文件和子目录
search-files: 在目录及其子目录中搜索匹配模式的文件
get-file-info: 获取文件或目录的详细信息
出于安全考虑,文件操作仅限于启动服务器时通过 --allowed-dir 参数明确指定的目录。如果没有指定目录,则只有用户的主目录是可访问的。
服务器会验证所有文件路径以确保它们位于允许的目录内,防止访问敏感的系统文件。还会检查符号链接,确保它们不会指向允许目录之外的位置。
构建项目:
npm run build
运行测试:
npm test
运行手动测试:
npm run test:manual
ISC