LDIMS MCP
Provides an MCP interface for the LDIMS document management system.
LDIMS MCP 脚本工具
本目录包含LDIMS MCP服务的实用脚本工具。
🚀 运行方式
方式一:MCP模式(推荐)
通过MCP客户端调用,Token配置在MCP客户端中:
# 编译
npm run build
# MCP客户端会自动调用 node dist/index.js
# Token通过MCP配置传递,不需要.env文件中的LDIMS_AUTH_TOKEN
方式二:HTTP模式(适合测试和集成)
启动独立的HTTP服务器,使用.env文件中的配置:
# 确保.env文件中配置了LDIMS_AUTH_TOKEN
npm run http
# 或直接运行
node dist/http-server.js
🔐 双Token模式说明:
- MCP模式:使用MCP客户端配置中的Token
- HTTP模式:使用
.env文件中的LDIMS_AUTH_TOKEN - 两种模式独立配置,互不干扰
🚀 快速开始
完整部署流程
-
生成长期Token
node scripts/get-long-term-token.js -
编译项目
npm run build -
测试API连接
node scripts/test-api-connection.js -
配置AI工具 - 参考下方"MCP服务注册配置"部分
-
重启AI工具 - 重启Cursor或Claude Desktop以加载新配置
📋 脚本说明
🔑 Token管理脚本
get-fresh-token.js
生成新的认证Token(24小时有效期)
node scripts/get-fresh-token.js
get-long-term-token.js
生成长期有效的认证Token(约7.5年有效期)
node scripts/get-long-term-token.js
update-env-token.js
更新环境文件中的Token配置
node scripts/update-env-token.js <new_token>
🧪 测试脚本
test-api-connection.js
全面测试LDIMS API连接和功能
node scripts/test-api-connection.js
测试内容:
- ✅ 健康检查
- ✅ 文档搜索功能
- ✅ 文档内容获取功能
- ✅ API响应时间和数据质量
🚀 使用场景
初次部署
- 运行
get-long-term-token.js生成长期Token - 运行
test-api-connection.js验证API连接 - 在AI工具中注册MCP服务(见下方配置说明)
Token过期处理
- 运行
get-fresh-token.js或get-long-term-token.js生成新Token - 运行
update-env-token.js更新配置文件 - 重启MCP服务
功能测试
- 运行
test-api-connection.js进行全面测试 - 检查测试结果确保所有功能正常
🔧 MCP服务注册配置
在Cursor中配置
在Cursor的MCP配置文件中添加以下配置:
配置文件位置:
- Windows:
%APPDATA%\Cursor\User\globalStorage\cursor.mcp\config.json - macOS:
~/Library/Application Support/Cursor/User/globalStorage/cursor.mcp/config.json - Linux:
~/.config/Cursor/User/globalStorage/cursor.mcp/config.json
{
"ldims": {
"command": "node",
"args": ["D:/DEV/LDIMS/backend_mcp/dist/index.js"],
"env": {
"LDIMS_API_BASE_URL": "http://localhost:3000",
"LDIMS_API_VERSION": "v1",
"LDIMS_AUTH_TOKEN": "your_long_term_token_here",
"NODE_ENV": "production"
}
}
}
在Claude Desktop中配置
配置文件位置:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
在Claude Desktop的配置文件中添加:
{
"mcpServers": {
"ldims": {
"command": "node",
"args": ["D:/DEV/LDIMS/backend_mcp/dist/index.js"],
"env": {
"LDIMS_API_BASE_URL": "http://localhost:3000",
"LDIMS_API_VERSION": "v1",
"LDIMS_AUTH_TOKEN": "your_long_term_token_here",
"NODE_ENV": "production"
}
}
}
}
配置说明
- command: 使用
node命令运行编译后的JavaScript文件 - args: 指向编译后的
dist/index.js文件的绝对路径 - LDIMS_API_BASE_URL: 使用HTTP地址,不是文件路径(如:
http://localhost:3000) - LDIMS_AUTH_TOKEN: 使用
get-long-term-token.js生成的长期Token - NODE_ENV: 设置为
production以获得最佳性能
⚠️ 重要提醒:
- 路径必须使用绝对路径,根据您的实际安装位置调整
- 确保先运行
npm run build编译项目 - 确保LDIMS后端服务在
http://localhost:3000运行
⚠️ 注意事项
- 确保LDIMS后端服务正在运行
- Token生成需要有效的数据库连接
- 测试脚本需要编译后的代码(先运行
npm run build) - 所有脚本都会读取项目根目录的
.env文件
📞 故障排除
如果脚本运行失败:
- 检查LDIMS后端服务状态
- 验证数据库连接
- 确认环境变量配置
- 查看控制台错误信息
🔧 开发说明
这些脚本是项目的核心工具,请不要随意修改。如需添加新功能,请:
- 遵循现有的代码风格
- 添加适当的错误处理
- 更新此README文档
Servidores relacionados
MCP Apple Notes
Perform semantic search and retrieval augmented generation over your Apple Notes.
Editor MCP
A server for file operations, allowing reading, editing, and managing text files through a standardized API.
Smart Photo Journal MCP Server
Create a memory journal from your local photos in the macOS Photos library.
Lumina Docs
An intelligent structured document management system designed for large language models.
Java MCP Filesystem Server
A secure Java-based MCP server that provides controlled filesystem access to AI assistants.
AgentMcp
A local server that allows AI to execute Windows CMD commands, read/write files, and manage directories within a specified path.
MCP File Edit
Perform file system operations such as reading, writing, patching, and managing directories.
Desktop Commander MCP Server
A Node.js MCP server for managing local files, processes, and terminal sessions.
peekaboo-mcp
A minimal MCP server providing read-only access to the file system.
MCP Filesystem Server
Provides secure access to the local filesystem via the Model Context Protocol (MCP).