eln-mcp-server
by shjk0817
README.md
# ELN MCP Server
ELN 数据管理平台表单设计 MCP Server。
## 快速开始
### 1. 安装依赖
```bash
cd d:\github\trae\formily\eln-mcp-server
npm install
npx playwright install chromium
```
### 2. 编译
```bash
npm run build
```
### 3. 配置到 AI 客户端
将以下配置添加到你的 AI 客户端的 MCP 配置文件中:
```json
{
"mcpServers": {
"eln-form-design": {
"command": "node",
"args": ["d:\\github\\trae\\formily\\eln-mcp-server\\dist\\index.js"],
"env": {
"ELN_BASE_URL": "http://10.1.228.52:13002/api/v1",
"ELN_USERNAME": "admin",
"ELN_PASSWORD": "qwert123",
"ELN_HEADLESS": "true"
}
}
}
}
```
### 4. 各客户端配置文件位置
| AI 客户端 | 配置文件路径 | 格式 |
|-----------|-------------|------|
| TRAE | `~/.trae-cn/mcp_config.json` | 同上方 JSON |
| Claude Desktop | `%APPDATA%\Claude\claude_desktop_config.json` | 同上方 JSON |
| Cursor | `~/.cursor/mcp_config.json` | 同上方 JSON |
| VS Code (Copilot) | `.vscode/mcp.json` | 同上方 JSON |
### 5. 环境变量说明
| 变量 | 默认值 | 说明 |
|------|--------|------|
| ELN_BASE_URL | http://10.1.228.52:13002/api/v1 | ELN 服务器 API 地址 |
| ELN_USERNAME | admin | 登录用户名 |
| ELN_PASSWORD | qwert123 | 登录密码 |
| ELN_HEADLESS | true | Playwright 无头模式(false=显示浏览器窗口) |
| ELN_TOKEN_CACHE | (系统临时目录) | Token 缓存文件路径 |
### 6. Skill 文件部署
Skill 文件位于 `d:\github\trae\formily\eln-skills\` 目录。将此目录路径告知 AI 客户端:
- **TRAE**: 在项目 `.trae` 配置中添加 skills 路径
- **Claude Desktop**: 放入 `~/.claude/skills/` 目录
- **Cursor**: 在项目 `AGENTS.md` 中引用路径
## 使用流程
```
1. 对 AI 说: "帮我登录 ELN 系统"
→ AI 调用 login 工具
2. 对 AI 说: "创建一个矿渣粉重量分析模板"
→ AI 调用 list_categories → create_template → add_component → add_formula → save_template
3. 对 AI 说: "查看系统里有哪些模板"
→ AI 调用 list_templates
4. 对 AI 说: "修改模板 258 的公式"
→ AI 调用 select_template → list_formulas → add_formula → save_template
```
## 工具列表(26 个)
### 认证(2)
- `login` - 浏览器自动化登录
- `check_auth` - 检查 token 有效性
### 模板管理(5)
- `create_template` - 创建新模板
- `select_template` - 选择已有模板
- `copy_template` - 复制模板
- `delete_template` - 删除模板信息
- `save_template` - 保存到服务器
### 表单设计(7)
- `add_component` - 添加组件(29 种)
- `set_property` - 修改组件属性
- `get_schema` - 获取当前 Schema
- `set_full_schema` - 直接设置完整 Schema
- `remove_component` - 删除组件
- `list_components` - 列出所有组件
- `reset_schema` - 重置 Schema
### 数据配置(5)
- `add_formula` - 添加公式(22 个函数)
- `list_formulas` - 列出公式
- `add_output_item` - 添加输出值
- `set_detection_date` - 设置检测日期
- `get_data_config` - 获取数据配置
### 表格搭建(3)
- `set_table_template` - 设置表格模板
- `get_table_template` - 获取表格模板
- `bind_cell_data` - 绑定单元格
### 查询(4)
- `list_templates` - 查询模板列表
- `get_template_detail` - 获取模板详情
- `list_categories` - 查询分类
- `list_submission_logs` - 查询提交日志
## Skill 文件
| 文件 | 内容 |
|------|------|
| component-catalog.md | 29 种组件的属性和用法 |
| formily-schema-guide.md | Formily JSON Schema 编写规范 |
| expression-engine.md | 22 个内置函数和公式编写示例 |
| table-building.md | x-spreadsheet 表格搭建指南 |
| form-design-workflow.md | 完整工作流和常见请求处理 |
## 技术栈
- 运行时: Node.js 18+
- 语言: TypeScript 5.3+
- MCP SDK: @modelcontextprotocol/sdk
- 浏览器自动化: Playwright
- 参数校验: Zod
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessSyncing