@chenyingxian/zentao-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +6 -0
- package/CONFIG.md +77 -0
- package/CONFIG.zh-CN.md +77 -0
- package/MCP_TOOLS.md +154 -0
- package/MCP_TOOLS.zh-CN.md +154 -0
- package/README.md +213 -0
- package/README.zh-CN.md +79 -0
- package/package.json +40 -0
- package/scripts/get-token.sh +86 -0
- package/src/index.js +271 -0
- package/src/zentao-client.js +1123 -0
package/.env.example
ADDED
package/CONFIG.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
This MCP server is configured with environment variables. It does not read a required config file by default, which makes it suitable for local MCP clients and `npx` usage.
|
|
4
|
+
|
|
5
|
+
## Required Variables
|
|
6
|
+
|
|
7
|
+
Use account/password login:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ZENTAO_BASE_URL=https://zentao.example.com
|
|
11
|
+
ZENTAO_ACCOUNT=your-account
|
|
12
|
+
ZENTAO_PASSWORD=your-password
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Or use a pre-issued RESTful API v1 token:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
ZENTAO_BASE_URL=https://zentao.example.com
|
|
19
|
+
ZENTAO_TOKEN=your-token
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Optional Variables
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
ZENTAO_TIMEOUT_MS=15000
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`ZENTAO_TIMEOUT_MS` controls the HTTP request timeout in milliseconds.
|
|
29
|
+
|
|
30
|
+
## MCP Client Example
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"mcpServers": {
|
|
35
|
+
"zentao": {
|
|
36
|
+
"command": "npx",
|
|
37
|
+
"args": ["zentao-mcp"],
|
|
38
|
+
"env": {
|
|
39
|
+
"ZENTAO_BASE_URL": "https://zentao.example.com",
|
|
40
|
+
"ZENTAO_ACCOUNT": "your-account",
|
|
41
|
+
"ZENTAO_PASSWORD": "your-password",
|
|
42
|
+
"ZENTAO_TIMEOUT_MS": "15000"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Token Helper
|
|
50
|
+
|
|
51
|
+
After global installation:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
zentao-mcp-get-token --base-url "https://zentao.example.com" --account "your-account" --password "your-password"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
From a source checkout:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
./scripts/get-token.sh --base-url "https://zentao.example.com" --account "your-account" --password "your-password"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The helper prints only the token when login succeeds.
|
|
64
|
+
|
|
65
|
+
## Compatibility Notes
|
|
66
|
+
|
|
67
|
+
- ZenTao installations can differ by edition, version, and customization.
|
|
68
|
+
- RESTful API v1 is used for standard resources such as tasks, stories, builds, and test tasks.
|
|
69
|
+
- Some "My" pages and build linking flows use legacy JSON or form routes because older ZenTao versions do not expose every operation through RESTful API v1.
|
|
70
|
+
- If your ZenTao instance uses a path prefix, include it in `ZENTAO_BASE_URL`, for example `https://zentao.example.com/zentao`.
|
|
71
|
+
|
|
72
|
+
## Security Notes
|
|
73
|
+
|
|
74
|
+
- Do not commit real `.env` files.
|
|
75
|
+
- Do not publish accounts, passwords, tokens, internal URLs, task IDs, story IDs, build IDs, or business data in public examples.
|
|
76
|
+
- Prefer MCP client environment variables or a local secret manager for credentials.
|
|
77
|
+
|
package/CONFIG.zh-CN.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# 配置说明
|
|
2
|
+
|
|
3
|
+
本 MCP Server 通过环境变量配置,默认不强制读取配置文件,方便在本地 MCP 客户端或 `npx` 中使用。
|
|
4
|
+
|
|
5
|
+
## 必填变量
|
|
6
|
+
|
|
7
|
+
使用账号密码登录:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ZENTAO_BASE_URL=https://zentao.example.com
|
|
11
|
+
ZENTAO_ACCOUNT=your-account
|
|
12
|
+
ZENTAO_PASSWORD=your-password
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
或者直接使用已签发的 RESTful API v1 token:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
ZENTAO_BASE_URL=https://zentao.example.com
|
|
19
|
+
ZENTAO_TOKEN=your-token
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 可选变量
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
ZENTAO_TIMEOUT_MS=15000
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`ZENTAO_TIMEOUT_MS` 用于控制 HTTP 请求超时时间,单位为毫秒。
|
|
29
|
+
|
|
30
|
+
## MCP 客户端示例
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"mcpServers": {
|
|
35
|
+
"zentao": {
|
|
36
|
+
"command": "npx",
|
|
37
|
+
"args": ["zentao-mcp"],
|
|
38
|
+
"env": {
|
|
39
|
+
"ZENTAO_BASE_URL": "https://zentao.example.com",
|
|
40
|
+
"ZENTAO_ACCOUNT": "your-account",
|
|
41
|
+
"ZENTAO_PASSWORD": "your-password",
|
|
42
|
+
"ZENTAO_TIMEOUT_MS": "15000"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Token 辅助脚本
|
|
50
|
+
|
|
51
|
+
全局安装后:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
zentao-mcp-get-token --base-url "https://zentao.example.com" --account "your-account" --password "your-password"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
源码目录中:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
./scripts/get-token.sh --base-url "https://zentao.example.com" --account "your-account" --password "your-password"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
登录成功时,脚本只输出 token。
|
|
64
|
+
|
|
65
|
+
## 兼容性说明
|
|
66
|
+
|
|
67
|
+
- 禅道不同版本、版本类型和二开环境的路由可能不同。
|
|
68
|
+
- 标准资源优先使用 RESTful API v1,例如任务、需求、构建、测试单。
|
|
69
|
+
- 部分“我的”页面和构建关联需求流程使用旧版 JSON / 表单路由,因为旧版本禅道不一定为所有操作提供 RESTful API v1。
|
|
70
|
+
- 如果禅道部署在子路径下,请把路径写入 `ZENTAO_BASE_URL`,例如 `https://zentao.example.com/zentao`。
|
|
71
|
+
|
|
72
|
+
## 安全说明
|
|
73
|
+
|
|
74
|
+
- 不要提交真实 `.env` 文件。
|
|
75
|
+
- 不要在公开示例中暴露账号、密码、token、内部地址、任务 ID、需求 ID、构建 ID 或业务数据。
|
|
76
|
+
- 建议通过 MCP 客户端环境变量或本地密钥管理方式提供凭据。
|
|
77
|
+
|
package/MCP_TOOLS.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# MCP Tools
|
|
2
|
+
|
|
3
|
+
All tools return JSON text so the caller can inspect the original ZenTao fields and pass IDs into later tools.
|
|
4
|
+
|
|
5
|
+
## `zentao_get_my_tasks`
|
|
6
|
+
|
|
7
|
+
Reads pending tasks assigned to the current user.
|
|
8
|
+
|
|
9
|
+
Parameters:
|
|
10
|
+
|
|
11
|
+
- `order_by`: Sort field. Default: `id_desc`.
|
|
12
|
+
- `rec_per_page`: Page size. Default: `100`, max: `1000`.
|
|
13
|
+
- `page_id`: Page number. Default: `1`.
|
|
14
|
+
|
|
15
|
+
Typical use:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"order_by": "id_desc",
|
|
20
|
+
"rec_per_page": 100,
|
|
21
|
+
"page_id": 1
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## `zentao_get_finished_tasks`
|
|
26
|
+
|
|
27
|
+
Reads tasks finished by the current user.
|
|
28
|
+
|
|
29
|
+
Parameters:
|
|
30
|
+
|
|
31
|
+
- `rec_per_page`: Return count. Default: `20`, max: `20`.
|
|
32
|
+
- `page_id`: Local page number. Default: `1`.
|
|
33
|
+
|
|
34
|
+
This tool follows the legacy "My contributed tasks" route and keeps the response compact.
|
|
35
|
+
|
|
36
|
+
## `zentao_get_task`
|
|
37
|
+
|
|
38
|
+
Reads one task by ID.
|
|
39
|
+
|
|
40
|
+
Parameters:
|
|
41
|
+
|
|
42
|
+
- `task_id`: ZenTao task ID.
|
|
43
|
+
|
|
44
|
+
The response keeps the original `desc` HTML and adds `descText` plain text.
|
|
45
|
+
|
|
46
|
+
## `zentao_create_build`
|
|
47
|
+
|
|
48
|
+
Creates a build from a development task and links the related story after build creation.
|
|
49
|
+
|
|
50
|
+
Parameters:
|
|
51
|
+
|
|
52
|
+
- `task_id`: Development task ID.
|
|
53
|
+
- `dry_run`: Preview only. Default: `true`. Pass `false` to create the build.
|
|
54
|
+
|
|
55
|
+
The tool resolves:
|
|
56
|
+
|
|
57
|
+
- development task
|
|
58
|
+
- story
|
|
59
|
+
- product
|
|
60
|
+
- project
|
|
61
|
+
- execution
|
|
62
|
+
- matching test task and assignee when available
|
|
63
|
+
|
|
64
|
+
When created successfully, the response includes the new build ID and related product information.
|
|
65
|
+
|
|
66
|
+
## `zentao_create_testtask`
|
|
67
|
+
|
|
68
|
+
Creates a test task from a development task and build.
|
|
69
|
+
|
|
70
|
+
Parameters:
|
|
71
|
+
|
|
72
|
+
- `task_id`: Development task ID.
|
|
73
|
+
- `build_id`: Build ID.
|
|
74
|
+
- `dry_run`: Preview only. Default: `true`. Pass `false` to create the test task.
|
|
75
|
+
- `owner`: Optional owner account. If omitted, the matched test task assignee is used.
|
|
76
|
+
- `begin`: Start date in `yyyy-mm-dd`. Defaults to today.
|
|
77
|
+
- `end`: End date in `yyyy-mm-dd`. Defaults to four days after `begin`.
|
|
78
|
+
- `attachment_paths`: Optional local file paths to upload, such as `.jmx` and `.md` files.
|
|
79
|
+
|
|
80
|
+
The tool uses the task priority as the test task priority.
|
|
81
|
+
|
|
82
|
+
## `zentao_create_release_task`
|
|
83
|
+
|
|
84
|
+
Generates release task data from a list of development tasks.
|
|
85
|
+
|
|
86
|
+
Parameters:
|
|
87
|
+
|
|
88
|
+
- `task_ids`: Development task IDs included in the release.
|
|
89
|
+
- `system`: System or module name.
|
|
90
|
+
- `story_id`: Optional main story ID. If omitted, the first related story is used.
|
|
91
|
+
- `release_scope`: Release scope. Default: `生产环境`.
|
|
92
|
+
- `gray_tag`: Optional gray/canary tag for production release notes.
|
|
93
|
+
- `branch`: Git branch. If omitted, the tool tries to parse it from task descriptions.
|
|
94
|
+
- `release_content`: Release content lines. If omitted, related story titles are used.
|
|
95
|
+
- `database`: Database changes. Empty means `无`.
|
|
96
|
+
- `env`: Environment variable changes. Empty means `无`.
|
|
97
|
+
- `cron`: Scheduled job changes. Empty means `无`.
|
|
98
|
+
- `dependencies`: Dependency package changes. Empty means `无`.
|
|
99
|
+
- `other`: Other notes. Empty means `无`.
|
|
100
|
+
- `risk`: Risks. Empty means `无`.
|
|
101
|
+
- `dry_run`: Preview only. Current implementation supports preview mode only.
|
|
102
|
+
|
|
103
|
+
Generated task name:
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
发布-{system} xxxxxx {release_scope}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The generated description contains these sections:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
一.更新范围
|
|
113
|
+
二.代码
|
|
114
|
+
三.数据库
|
|
115
|
+
四.环境变量
|
|
116
|
+
五.计划任务
|
|
117
|
+
六.依赖包
|
|
118
|
+
七.其它
|
|
119
|
+
八.对外说明发布的内容
|
|
120
|
+
九.风险
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
For people in the release content section, the tool resolves main development and test tasks, includes child tasks, removes task creators from contributor candidates, and sorts development contributors before test contributors.
|
|
124
|
+
|
|
125
|
+
## `zentao_get_effort_logs`
|
|
126
|
+
|
|
127
|
+
Reads effort logs from `effort-calendar` and "My Effort" routes.
|
|
128
|
+
|
|
129
|
+
Parameters:
|
|
130
|
+
|
|
131
|
+
- `type`: Effort type. Default: `all`.
|
|
132
|
+
- `order_by`: Sort field. Default: `date_desc`.
|
|
133
|
+
- `rec_per_page`: Page size. Default: `100`, max: `1000`.
|
|
134
|
+
- `page_id`: Page number. Default: `1`.
|
|
135
|
+
|
|
136
|
+
## `zentao_generate_weekly_summary`
|
|
137
|
+
|
|
138
|
+
Generates a weekly summary from effort logs.
|
|
139
|
+
|
|
140
|
+
Parameters:
|
|
141
|
+
|
|
142
|
+
- `start_date`: Start date in `yyyy-mm-dd`. Defaults to Monday of the current week.
|
|
143
|
+
- `end_date`: End date in `yyyy-mm-dd`. Defaults to Sunday of the current week.
|
|
144
|
+
- `rec_per_page`: Page size. Default: `100`, max: `1000`.
|
|
145
|
+
- `max_pages`: Max pages to read. Default: `10`, max: `50`.
|
|
146
|
+
|
|
147
|
+
Output style:
|
|
148
|
+
|
|
149
|
+
```text
|
|
150
|
+
1、Item A。2、Item B。共计X小时。
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
The summary removes duplicate work items and excludes existing weekly-summary-like effort entries.
|
|
154
|
+
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# MCP 工具说明
|
|
2
|
+
|
|
3
|
+
所有工具都返回 JSON 文本,调用方可以查看禅道原始字段,也可以把返回的 ID 继续传给后续工具。
|
|
4
|
+
|
|
5
|
+
## `zentao_get_my_tasks`
|
|
6
|
+
|
|
7
|
+
查询待处理下指派给当前用户的任务。
|
|
8
|
+
|
|
9
|
+
参数:
|
|
10
|
+
|
|
11
|
+
- `order_by`:排序字段,默认 `id_desc`。
|
|
12
|
+
- `rec_per_page`:每页数量,默认 `100`,最大 `1000`。
|
|
13
|
+
- `page_id`:页码,默认 `1`。
|
|
14
|
+
|
|
15
|
+
示例:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"order_by": "id_desc",
|
|
20
|
+
"rec_per_page": 100,
|
|
21
|
+
"page_id": 1
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## `zentao_get_finished_tasks`
|
|
26
|
+
|
|
27
|
+
查询由当前用户完成的任务。
|
|
28
|
+
|
|
29
|
+
参数:
|
|
30
|
+
|
|
31
|
+
- `rec_per_page`:返回数量,默认 `20`,最大 `20`。
|
|
32
|
+
- `page_id`:本地分页页码,默认 `1`。
|
|
33
|
+
|
|
34
|
+
该工具使用“我的贡献任务”旧版路由,并尽量保持返回结果简洁。
|
|
35
|
+
|
|
36
|
+
## `zentao_get_task`
|
|
37
|
+
|
|
38
|
+
按任务 ID 查询任务详情。
|
|
39
|
+
|
|
40
|
+
参数:
|
|
41
|
+
|
|
42
|
+
- `task_id`:禅道任务 ID。
|
|
43
|
+
|
|
44
|
+
返回结果会保留原始 `desc` HTML,并额外提供纯文本 `descText`。
|
|
45
|
+
|
|
46
|
+
## `zentao_create_build`
|
|
47
|
+
|
|
48
|
+
按开发任务创建构建,并在创建后自动关联该任务对应的需求。
|
|
49
|
+
|
|
50
|
+
参数:
|
|
51
|
+
|
|
52
|
+
- `task_id`:开发任务 ID。
|
|
53
|
+
- `dry_run`:是否只预览,默认 `true`。传 `false` 才会真实创建。
|
|
54
|
+
|
|
55
|
+
工具会解析:
|
|
56
|
+
|
|
57
|
+
- 开发任务
|
|
58
|
+
- 需求
|
|
59
|
+
- 产品
|
|
60
|
+
- 项目
|
|
61
|
+
- 执行
|
|
62
|
+
- 可匹配的测试任务和测试负责人
|
|
63
|
+
|
|
64
|
+
创建成功后,返回结果会包含新构建 ID 和关联产品信息。
|
|
65
|
+
|
|
66
|
+
## `zentao_create_testtask`
|
|
67
|
+
|
|
68
|
+
按开发任务和构建创建测试单。
|
|
69
|
+
|
|
70
|
+
参数:
|
|
71
|
+
|
|
72
|
+
- `task_id`:开发任务 ID。
|
|
73
|
+
- `build_id`:构建 ID。
|
|
74
|
+
- `dry_run`:是否只预览,默认 `true`。传 `false` 才会真实创建。
|
|
75
|
+
- `owner`:测试单负责人账号。不传时使用匹配到的测试任务指派人。
|
|
76
|
+
- `begin`:开始日期,格式 `yyyy-mm-dd`,默认今天。
|
|
77
|
+
- `end`:结束日期,格式 `yyyy-mm-dd`,默认开始日期后第 4 天。
|
|
78
|
+
- `attachment_paths`:可选附件本地路径,例如 `.jmx` 和 `.md` 文件。
|
|
79
|
+
|
|
80
|
+
测试单优先级会按开发任务优先级填写。
|
|
81
|
+
|
|
82
|
+
## `zentao_create_release_task`
|
|
83
|
+
|
|
84
|
+
根据开发任务列表生成发版任务信息。
|
|
85
|
+
|
|
86
|
+
参数:
|
|
87
|
+
|
|
88
|
+
- `task_ids`:本次发版包含的开发任务 ID 列表。
|
|
89
|
+
- `system`:系统或模块名。
|
|
90
|
+
- `story_id`:可选主需求 ID。不传时使用第一个关联需求。
|
|
91
|
+
- `release_scope`:发布范围,默认 `生产环境`。
|
|
92
|
+
- `gray_tag`:生产发布时可填写对应灰度 tag。
|
|
93
|
+
- `branch`:Git 分支。不传时尝试从任务描述中解析。
|
|
94
|
+
- `release_content`:发布内容。不传时使用关联需求标题。
|
|
95
|
+
- `database`:数据库变更,空值按 `无`。
|
|
96
|
+
- `env`:环境变量变更,空值按 `无`。
|
|
97
|
+
- `cron`:计划任务变更,空值按 `无`。
|
|
98
|
+
- `dependencies`:依赖包变更,空值按 `无`。
|
|
99
|
+
- `other`:其它事项,空值按 `无`。
|
|
100
|
+
- `risk`:风险,空值按 `无`。
|
|
101
|
+
- `dry_run`:是否只预览。当前实现仅支持预览。
|
|
102
|
+
|
|
103
|
+
生成的任务名称:
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
发布-{system} xxxxxx {release_scope}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
生成的描述包含以下大项:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
一.更新范围
|
|
113
|
+
二.代码
|
|
114
|
+
三.数据库
|
|
115
|
+
四.环境变量
|
|
116
|
+
五.计划任务
|
|
117
|
+
六.依赖包
|
|
118
|
+
七.其它
|
|
119
|
+
八.对外说明发布的内容
|
|
120
|
+
九.风险
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
对外说明中的人员信息会查找主开发任务和主测试任务,并包含对应子任务;候选人员会剔除任务创建者,避免完成后回指给创建人时被误加入;排序按开发人员字典序 + 测试人员字典序。
|
|
124
|
+
|
|
125
|
+
## `zentao_get_effort_logs`
|
|
126
|
+
|
|
127
|
+
读取 `effort-calendar` 和“我的日志”工时记录。
|
|
128
|
+
|
|
129
|
+
参数:
|
|
130
|
+
|
|
131
|
+
- `type`:日志类型,默认 `all`。
|
|
132
|
+
- `order_by`:排序字段,默认 `date_desc`。
|
|
133
|
+
- `rec_per_page`:每页数量,默认 `100`,最大 `1000`。
|
|
134
|
+
- `page_id`:页码,默认 `1`。
|
|
135
|
+
|
|
136
|
+
## `zentao_generate_weekly_summary`
|
|
137
|
+
|
|
138
|
+
根据工时日志生成周总结文本。
|
|
139
|
+
|
|
140
|
+
参数:
|
|
141
|
+
|
|
142
|
+
- `start_date`:开始日期,格式 `yyyy-mm-dd`,默认本周一。
|
|
143
|
+
- `end_date`:结束日期,格式 `yyyy-mm-dd`,默认本周日。
|
|
144
|
+
- `rec_per_page`:每页读取数量,默认 `100`,最大 `1000`。
|
|
145
|
+
- `max_pages`:最多读取页数,默认 `10`,最大 `50`。
|
|
146
|
+
|
|
147
|
+
输出格式:
|
|
148
|
+
|
|
149
|
+
```text
|
|
150
|
+
1、事项 A。2、事项 B。共计X小时。
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
生成时会去除重复事项,并排除已有周总结风格的日志。
|
|
154
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# zentao-mcp
|
|
2
|
+
|
|
3
|
+
ZenTao MCP server for RESTful API v1 and legacy JSON routes.
|
|
4
|
+
|
|
5
|
+
This package is intended for self-hosted ZenTao installations where the v1 API is available and some "My" pages still need ZenTao legacy JSON routes.
|
|
6
|
+
|
|
7
|
+
## Documentation
|
|
8
|
+
|
|
9
|
+
- [Configuration](./CONFIG.md)
|
|
10
|
+
- [MCP Tools](./MCP_TOOLS.md)
|
|
11
|
+
- [中文文档](./README.zh-CN.md)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g zentao-mcp
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
You can also run it without a global install:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx zentao-mcp
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Configuration
|
|
26
|
+
|
|
27
|
+
Set the following environment variables in your MCP client:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
ZENTAO_BASE_URL=https://zentao.example.com
|
|
31
|
+
ZENTAO_ACCOUNT=your-account
|
|
32
|
+
ZENTAO_PASSWORD=your-password
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Alternatively, provide a pre-issued v1 token:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
ZENTAO_BASE_URL=https://zentao.example.com
|
|
39
|
+
ZENTAO_TOKEN=your-token
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Optional:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
ZENTAO_TIMEOUT_MS=15000
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## MCP Client Example
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"mcpServers": {
|
|
53
|
+
"zentao": {
|
|
54
|
+
"command": "npx",
|
|
55
|
+
"args": ["zentao-mcp"],
|
|
56
|
+
"env": {
|
|
57
|
+
"ZENTAO_BASE_URL": "https://zentao.example.com",
|
|
58
|
+
"ZENTAO_ACCOUNT": "your-account",
|
|
59
|
+
"ZENTAO_PASSWORD": "your-password"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Get a Token
|
|
67
|
+
|
|
68
|
+
The package includes a helper script:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
zentao-mcp-get-token --base-url "https://zentao.example.com" --account "your-account" --password "your-password"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
If you run from a source checkout:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
./scripts/get-token.sh --base-url "https://zentao.example.com" --account "your-account" --password "your-password"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Tools
|
|
81
|
+
|
|
82
|
+
### `zentao_get_my_tasks`
|
|
83
|
+
|
|
84
|
+
Read pending tasks assigned to the current user.
|
|
85
|
+
|
|
86
|
+
Parameters:
|
|
87
|
+
|
|
88
|
+
- `order_by`: Sort field, default `id_desc`.
|
|
89
|
+
- `rec_per_page`: Page size, default `100`, max `1000`.
|
|
90
|
+
- `page_id`: Page number, default `1`.
|
|
91
|
+
|
|
92
|
+
Uses:
|
|
93
|
+
|
|
94
|
+
- `POST /api.php/v1/tokens`
|
|
95
|
+
- `GET /my-work-task-assignedTo-id_desc-0-1-100.json`
|
|
96
|
+
|
|
97
|
+
### `zentao_get_finished_tasks`
|
|
98
|
+
|
|
99
|
+
Read tasks finished by the current user.
|
|
100
|
+
|
|
101
|
+
Parameters:
|
|
102
|
+
|
|
103
|
+
- `rec_per_page`: Return count, default `20`, max `20`.
|
|
104
|
+
- `page_id`: Local page number, default `1`.
|
|
105
|
+
|
|
106
|
+
Uses:
|
|
107
|
+
|
|
108
|
+
- `GET /my-contribute-task-finishedBy.json`
|
|
109
|
+
|
|
110
|
+
### `zentao_get_task`
|
|
111
|
+
|
|
112
|
+
Read one task by ID.
|
|
113
|
+
|
|
114
|
+
Parameters:
|
|
115
|
+
|
|
116
|
+
- `task_id`: ZenTao task ID.
|
|
117
|
+
|
|
118
|
+
Uses:
|
|
119
|
+
|
|
120
|
+
- `GET /api.php/v1/tasks/:taskID`
|
|
121
|
+
|
|
122
|
+
The response keeps the original ZenTao `desc` HTML and adds `descText` plain text.
|
|
123
|
+
|
|
124
|
+
### `zentao_create_build`
|
|
125
|
+
|
|
126
|
+
Create a build from a development task. The tool reads the related story, product, project, and execution, creates a build, and links the story after creation.
|
|
127
|
+
|
|
128
|
+
Parameters:
|
|
129
|
+
|
|
130
|
+
- `task_id`: Development task ID.
|
|
131
|
+
- `dry_run`: Preview only by default. Pass `false` to create the build and link the story.
|
|
132
|
+
|
|
133
|
+
Uses:
|
|
134
|
+
|
|
135
|
+
- `GET /api.php/v1/tasks/{taskID}`
|
|
136
|
+
- `GET /api.php/v1/executions/{executionID}/builds?limit=20&page=1`
|
|
137
|
+
- `POST /build-create-{executionID}.html?t=json`
|
|
138
|
+
- `POST /build-linkStory-{buildID}--0.html?t=json`
|
|
139
|
+
|
|
140
|
+
### `zentao_create_testtask`
|
|
141
|
+
|
|
142
|
+
Create a test task from a development task and build.
|
|
143
|
+
|
|
144
|
+
Parameters:
|
|
145
|
+
|
|
146
|
+
- `task_id`: Development task ID.
|
|
147
|
+
- `build_id`: Build ID.
|
|
148
|
+
- `dry_run`: Preview only by default. Pass `false` to create the test task.
|
|
149
|
+
- `owner`: Optional owner account. If omitted, the first matched test task assignee is used.
|
|
150
|
+
- `begin`: Start date in `yyyy-mm-dd`. Defaults to today.
|
|
151
|
+
- `end`: End date in `yyyy-mm-dd`. Defaults to four days after `begin`.
|
|
152
|
+
- `attachment_paths`: Optional local files to upload, such as `.jmx` and `.md` files.
|
|
153
|
+
|
|
154
|
+
Uses:
|
|
155
|
+
|
|
156
|
+
- `GET /api.php/v1/tasks/{taskID}`
|
|
157
|
+
- `GET /api.php/v1/stories/{storyID}`
|
|
158
|
+
- `GET /api.php/v1/builds/{buildID}`
|
|
159
|
+
- `GET /api.php/v1/executions/{executionID}/tasks?limit=1000&page=1`
|
|
160
|
+
- `POST /api.php/v1/projects/{projectID}/testtasks`
|
|
161
|
+
|
|
162
|
+
### `zentao_create_release_task`
|
|
163
|
+
|
|
164
|
+
Generate release task data from a list of development tasks. This tool currently previews only and does not create the task.
|
|
165
|
+
|
|
166
|
+
Parameters:
|
|
167
|
+
|
|
168
|
+
- `task_ids`: Development task IDs included in the release.
|
|
169
|
+
- `system`: System or module name, for example `WebApp`.
|
|
170
|
+
- `story_id`: Optional main story ID. If omitted, the first task story is used.
|
|
171
|
+
- `release_scope`: Release scope, default `生产环境`.
|
|
172
|
+
- `gray_tag`: Optional gray/canary tag for production releases.
|
|
173
|
+
- `branch`: Git branch. If omitted, the tool tries to parse `git分支:` from task descriptions.
|
|
174
|
+
- `release_content`: Release notes. If omitted, related story titles are used.
|
|
175
|
+
- `database` / `env` / `cron` / `dependencies` / `other` / `risk`: Release description sections. Empty values become `无`.
|
|
176
|
+
|
|
177
|
+
The generated task name is:
|
|
178
|
+
|
|
179
|
+
```text
|
|
180
|
+
发布-{system} xxxxxx {release_scope}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### `zentao_get_effort_logs`
|
|
184
|
+
|
|
185
|
+
Read effort logs from `effort-calendar` and "My Effort".
|
|
186
|
+
|
|
187
|
+
Parameters:
|
|
188
|
+
|
|
189
|
+
- `type`: Effort type, default `all`.
|
|
190
|
+
- `order_by`: Sort field, default `date_desc`.
|
|
191
|
+
- `rec_per_page`: Page size, default `100`, max `1000`.
|
|
192
|
+
- `page_id`: Page number, default `1`.
|
|
193
|
+
|
|
194
|
+
### `zentao_generate_weekly_summary`
|
|
195
|
+
|
|
196
|
+
Generate a weekly summary from effort logs:
|
|
197
|
+
|
|
198
|
+
```text
|
|
199
|
+
1、Item A。2、Item B。共计X小时。
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Parameters:
|
|
203
|
+
|
|
204
|
+
- `start_date`: Start date in `yyyy-mm-dd`. Defaults to Monday of the current week.
|
|
205
|
+
- `end_date`: End date in `yyyy-mm-dd`. Defaults to Sunday of the current week.
|
|
206
|
+
- `rec_per_page`: Page size, default `100`, max `1000`.
|
|
207
|
+
- `max_pages`: Max pages to read, default `10`, max `50`.
|
|
208
|
+
|
|
209
|
+
## Notes
|
|
210
|
+
|
|
211
|
+
- Mutating tools use `dry_run=true` by default where supported.
|
|
212
|
+
- Some ZenTao installations expose different legacy routes depending on version and customization.
|
|
213
|
+
- Do not publish real `.env` files or tokens.
|