eln-mcp
# ELN MCP Server
建科 ELN 模板编辑平台 MCP Server — 覆盖编辑页 4 Tab 全功能(66 工具)。
## 快速开始
```bash
cd /Users/slouch/Desktop/eln-mcp
npm install
npx playwright install chromium
npm run build
```
## Cursor MCP 配置
**必填:** `ELN_USERNAME`、`ELN_PASSWORD`(仅写在 MCP 配置 env 中,源码无默认值)
```json
{
"mcpServers": {
"eln-form-design": {
"command": "node",
"args": ["/Users/slouch/Desktop/eln-mcp/dist/index.js"],
"env": {
"ELN_BASE_URL": "http://10.1.228.52:13002/api/v1",
"ELN_USERNAME": "your_username",
"ELN_PASSWORD": "your_password",
"ELN_HEADLESS": "true"
}
}
}
}
```
| 环境变量 | 必填 | 说明 |
|---------|------|------|
| `ELN_USERNAME` | 是 | 登录用户名 |
| `ELN_PASSWORD` | 是 | 登录密码 |
| `ELN_BASE_URL` | 否 | API 地址,默认 `http://10.1.228.52:13002/api/v1` |
| `ELN_HEADLESS` | 否 | 默认 `true`;设为 `false` 可显示浏览器 |
| `ELN_TOKEN_CACHE` | 否 | Token 缓存路径 |
换用户时只改 MCP 配置中的 `ELN_USERNAME` / `ELN_PASSWORD`,重启 MCP 即可。
## 程序级约束
- **禁止**(硬编码拦截):`activate_template`、`initiate_change`、检测记录提交类工具
- **不限制**分类范围:可在任意分类下 create/save/edit(由 ELN 账号权限决定)
## 组件增删改 MCP 工具
| 操作 | 工具 |
|------|------|
| 添加 | `add_component` |
| 删除 | `remove_component` |
| 修改属性 | `set_property` |
| 修改可选项 | `set_enum_options` |
| 修改校验 | `set_validator` / `remove_validator` |
| 修改响应器 | `set_reactions` / `remove_reactions` |
| 复制/移动/排序 | `copy_component` / `move_component` / `reorder_component` |
| 整体替换 | `set_full_schema` / `reset_schema` |
修改均在内存中生效,需 `save_template` 落库。
## 工具模块
| 模块 | 工具数 | 说明 |
|------|--------|------|
| auth | 2 | login, check_auth |
| query | 8 | 分类/模板/日志查询 |
| template | 8 | 模板生命周期 |
| form + form-ext | 21 | 表单 Tab |
| data + data-ext | 16 | 数据配置 Tab |
| table + table-ext | 9 | 表格 Tab |
| preview | 2 | 校验 + 预览会话 |
| session | 1 | get_session |
详见 [`docs/wiki/模板编辑.md`](docs/wiki/模板编辑.md)。
TDQS
Scored across 66 tools
Most tools have clear, distinct purposes (e.g., list_templates vs search_templates, get_schema vs list_components). However, there is overlap between add_formula/update_formula and add_output_item/update_output_item since the 'add' variants also support updating by ID, which could cause misselection.
The toolset largely follows a verb_noun snake_case pattern (list_, get_, set_, add_, remove_, etc.). Minor inconsistencies exist: mixing 'delete' and 'remove' for destruction (delete_template vs remove_component), and verbs like 'set' vs 'update' for the same action (set_full_schema vs update_*).
At 66 tools, the count is far above the 25+ threshold for 'too many'. While the domain is broad (template design, schema editing, table building, formulas, auth), the sheer number makes it heavy and potentially overwhelming for agents, despite each tool being reasonably scoped.
The toolset covers the full lifecycle of ELN template design: authentication, CRUD for templates, schema manipulation (components, properties, validators, reactions), table construction (rows, cells, bindings, styles), formulas/output items, detection date config, validation, and preview. No significant gaps are evident for the stated purpose.