@zzp123/mcp-zentao 1.15.0 → 1.17.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/CHANGELOG.md +55 -0
- package/README.md +81 -10
- package/dist/api/zentaoApi.d.ts +28 -2
- package/dist/api/zentaoApi.js +74 -50
- package/dist/index-dev.d.ts +10 -0
- package/dist/index-dev.js +940 -0
- package/dist/index-pm.d.ts +10 -0
- package/dist/index-pm.js +1131 -0
- package/dist/index-qa.d.ts +10 -0
- package/dist/index-qa.js +916 -0
- package/dist/index.js +118 -25
- package/dist/roleConfig.d.ts +48 -0
- package/dist/roleConfig.js +205 -0
- package/dist/types/zentao.d.ts +22 -5
- package/json-args.js +0 -0
- package/package.json +3 -3
- package/scripts/generate-role-versions.cjs +214 -0
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ if (configIndex !== -1 && configIndex + 1 < args.length) {
|
|
|
29
29
|
// Create an MCP server
|
|
30
30
|
const server = new McpServer({
|
|
31
31
|
name: "Zentao API",
|
|
32
|
-
version: "1.
|
|
32
|
+
version: "1.16.0"
|
|
33
33
|
});
|
|
34
34
|
// Initialize ZentaoAPI instance
|
|
35
35
|
let zentaoApi = null;
|
|
@@ -1504,7 +1504,51 @@ server.tool("downloadFile", {
|
|
|
1504
1504
|
fs.writeFileSync(savePath, fileBuffer);
|
|
1505
1505
|
return { content: [{ type: "text", text: `文件已下载到: ${savePath}` }] };
|
|
1506
1506
|
});
|
|
1507
|
-
// Comment tools (评论工具)
|
|
1507
|
+
// Comment tools (评论工具) - 使用 REST API v1
|
|
1508
|
+
server.tool("getComments", "获取评论列表 - 获取指定对象的所有评论", {
|
|
1509
|
+
objectType: z.enum([
|
|
1510
|
+
'story', // 软件需求
|
|
1511
|
+
'requirement', // 用户需求
|
|
1512
|
+
'task', // 任务
|
|
1513
|
+
'bug', // Bug
|
|
1514
|
+
'testcase', // 测试用例
|
|
1515
|
+
'testtask', // 测试单
|
|
1516
|
+
'todo', // 待办
|
|
1517
|
+
'doc', // 文档
|
|
1518
|
+
'execution', // 执行/迭代
|
|
1519
|
+
'project', // 项目
|
|
1520
|
+
'doctemplate' // 文档模板
|
|
1521
|
+
]).describe("对象类型"),
|
|
1522
|
+
objectID: z.number().describe("对象ID")
|
|
1523
|
+
}, async ({ objectType, objectID }) => {
|
|
1524
|
+
if (!zentaoApi)
|
|
1525
|
+
throw new Error("Please initialize Zentao API first");
|
|
1526
|
+
const comments = await zentaoApi.getComments(objectType, objectID);
|
|
1527
|
+
return {
|
|
1528
|
+
content: [{
|
|
1529
|
+
type: "text",
|
|
1530
|
+
text: JSON.stringify({
|
|
1531
|
+
total: comments.length,
|
|
1532
|
+
objectType,
|
|
1533
|
+
objectID,
|
|
1534
|
+
comments
|
|
1535
|
+
}, null, 2)
|
|
1536
|
+
}]
|
|
1537
|
+
};
|
|
1538
|
+
});
|
|
1539
|
+
server.tool("getCommentDetail", "获取单条评论详情", {
|
|
1540
|
+
commentId: z.number().describe("评论ID")
|
|
1541
|
+
}, async ({ commentId }) => {
|
|
1542
|
+
if (!zentaoApi)
|
|
1543
|
+
throw new Error("Please initialize Zentao API first");
|
|
1544
|
+
const comment = await zentaoApi.getCommentDetail(commentId);
|
|
1545
|
+
return {
|
|
1546
|
+
content: [{
|
|
1547
|
+
type: "text",
|
|
1548
|
+
text: JSON.stringify(comment, null, 2)
|
|
1549
|
+
}]
|
|
1550
|
+
};
|
|
1551
|
+
});
|
|
1508
1552
|
server.tool("addComment", "添加评论 - 为需求、任务、Bug等对象添加评论", {
|
|
1509
1553
|
objectType: z.enum([
|
|
1510
1554
|
'story', // 软件需求
|
|
@@ -1515,42 +1559,87 @@ server.tool("addComment", "添加评论 - 为需求、任务、Bug等对象添
|
|
|
1515
1559
|
'testtask', // 测试单
|
|
1516
1560
|
'todo', // 待办
|
|
1517
1561
|
'doc', // 文档
|
|
1562
|
+
'execution', // 执行/迭代
|
|
1563
|
+
'project', // 项目
|
|
1518
1564
|
'doctemplate' // 文档模板
|
|
1519
1565
|
]).describe("对象类型"),
|
|
1520
1566
|
objectID: z.number().describe("对象ID"),
|
|
1521
|
-
comment: z.string().describe("评论内容,支持HTML格式")
|
|
1522
|
-
|
|
1567
|
+
comment: z.string().describe("评论内容,支持HTML格式"),
|
|
1568
|
+
uid: z.string().optional().describe("唯一标识符(可选)")
|
|
1569
|
+
}, async ({ objectType, objectID, comment, uid }) => {
|
|
1523
1570
|
if (!zentaoApi)
|
|
1524
1571
|
throw new Error("Please initialize Zentao API first");
|
|
1525
|
-
const result = await zentaoApi.addComment(
|
|
1572
|
+
const result = await zentaoApi.addComment({
|
|
1573
|
+
objectType,
|
|
1574
|
+
objectID,
|
|
1575
|
+
comment,
|
|
1576
|
+
uid
|
|
1577
|
+
});
|
|
1526
1578
|
return {
|
|
1527
1579
|
content: [{
|
|
1528
1580
|
type: "text",
|
|
1529
1581
|
text: JSON.stringify({
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
actionID: result.actionID,
|
|
1533
|
-
details: `已为 ${objectType} #${objectID} 添加评论`
|
|
1582
|
+
message: '评论添加成功',
|
|
1583
|
+
comment: result
|
|
1534
1584
|
}, null, 2)
|
|
1535
1585
|
}]
|
|
1536
1586
|
};
|
|
1537
1587
|
});
|
|
1588
|
+
server.tool("updateComment", "更新评论 - 只能更新自己的评论", {
|
|
1589
|
+
commentId: z.number().describe("评论ID"),
|
|
1590
|
+
comment: z.string().describe("更新后的评论内容,支持HTML格式"),
|
|
1591
|
+
uid: z.string().optional().describe("唯一标识符(可选)")
|
|
1592
|
+
}, async ({ commentId, comment, uid }) => {
|
|
1593
|
+
if (!zentaoApi)
|
|
1594
|
+
throw new Error("Please initialize Zentao API first");
|
|
1595
|
+
const result = await zentaoApi.updateComment(commentId, {
|
|
1596
|
+
comment,
|
|
1597
|
+
uid
|
|
1598
|
+
});
|
|
1599
|
+
return {
|
|
1600
|
+
content: [{
|
|
1601
|
+
type: "text",
|
|
1602
|
+
text: JSON.stringify({
|
|
1603
|
+
message: '评论更新成功',
|
|
1604
|
+
comment: result
|
|
1605
|
+
}, null, 2)
|
|
1606
|
+
}]
|
|
1607
|
+
};
|
|
1608
|
+
});
|
|
1609
|
+
server.tool("deleteComment", "删除评论 - 只能删除自己的评论,管理员可以删除所有评论", {
|
|
1610
|
+
commentId: z.number().describe("评论ID")
|
|
1611
|
+
}, async ({ commentId }) => {
|
|
1612
|
+
if (!zentaoApi)
|
|
1613
|
+
throw new Error("Please initialize Zentao API first");
|
|
1614
|
+
const result = await zentaoApi.deleteComment(commentId);
|
|
1615
|
+
return {
|
|
1616
|
+
content: [{
|
|
1617
|
+
type: "text",
|
|
1618
|
+
text: JSON.stringify({
|
|
1619
|
+
status: 'success',
|
|
1620
|
+
message: result.message || '评论删除成功'
|
|
1621
|
+
}, null, 2)
|
|
1622
|
+
}]
|
|
1623
|
+
};
|
|
1624
|
+
});
|
|
1625
|
+
// 便捷工具 - 为特定类型对象添加评论
|
|
1538
1626
|
server.tool("addStoryComment", "为需求添加评论 - 专用工具,支持软件需求(story)和用户需求(requirement)", {
|
|
1539
1627
|
storyId: z.number().describe("需求ID"),
|
|
1540
1628
|
comment: z.string().describe("评论内容,支持HTML格式")
|
|
1541
1629
|
}, async ({ storyId, comment }) => {
|
|
1542
1630
|
if (!zentaoApi)
|
|
1543
1631
|
throw new Error("Please initialize Zentao API first");
|
|
1544
|
-
|
|
1545
|
-
|
|
1632
|
+
const result = await zentaoApi.addComment({
|
|
1633
|
+
objectType: 'story',
|
|
1634
|
+
objectID: storyId,
|
|
1635
|
+
comment
|
|
1636
|
+
});
|
|
1546
1637
|
return {
|
|
1547
1638
|
content: [{
|
|
1548
1639
|
type: "text",
|
|
1549
1640
|
text: JSON.stringify({
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
actionID: result.actionID,
|
|
1553
|
-
details: `已为需求 #${storyId} 添加评论`
|
|
1641
|
+
message: `已为需求 #${storyId} 添加评论`,
|
|
1642
|
+
comment: result
|
|
1554
1643
|
}, null, 2)
|
|
1555
1644
|
}]
|
|
1556
1645
|
};
|
|
@@ -1561,15 +1650,17 @@ server.tool("addTaskComment", "为任务添加评论", {
|
|
|
1561
1650
|
}, async ({ taskId, comment }) => {
|
|
1562
1651
|
if (!zentaoApi)
|
|
1563
1652
|
throw new Error("Please initialize Zentao API first");
|
|
1564
|
-
const result = await zentaoApi.addComment(
|
|
1653
|
+
const result = await zentaoApi.addComment({
|
|
1654
|
+
objectType: 'task',
|
|
1655
|
+
objectID: taskId,
|
|
1656
|
+
comment
|
|
1657
|
+
});
|
|
1565
1658
|
return {
|
|
1566
1659
|
content: [{
|
|
1567
1660
|
type: "text",
|
|
1568
1661
|
text: JSON.stringify({
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
actionID: result.actionID,
|
|
1572
|
-
details: `已为任务 #${taskId} 添加评论`
|
|
1662
|
+
message: `已为任务 #${taskId} 添加评论`,
|
|
1663
|
+
comment: result
|
|
1573
1664
|
}, null, 2)
|
|
1574
1665
|
}]
|
|
1575
1666
|
};
|
|
@@ -1580,15 +1671,17 @@ server.tool("addBugComment", "为Bug添加评论", {
|
|
|
1580
1671
|
}, async ({ bugId, comment }) => {
|
|
1581
1672
|
if (!zentaoApi)
|
|
1582
1673
|
throw new Error("Please initialize Zentao API first");
|
|
1583
|
-
const result = await zentaoApi.addComment(
|
|
1674
|
+
const result = await zentaoApi.addComment({
|
|
1675
|
+
objectType: 'bug',
|
|
1676
|
+
objectID: bugId,
|
|
1677
|
+
comment
|
|
1678
|
+
});
|
|
1584
1679
|
return {
|
|
1585
1680
|
content: [{
|
|
1586
1681
|
type: "text",
|
|
1587
1682
|
text: JSON.stringify({
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
actionID: result.actionID,
|
|
1591
|
-
details: `已为Bug #${bugId} 添加评论`
|
|
1683
|
+
message: `已为Bug #${bugId} 添加评论`,
|
|
1684
|
+
comment: result
|
|
1592
1685
|
}, null, 2)
|
|
1593
1686
|
}]
|
|
1594
1687
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type Role = 'pm' | 'qa' | 'dev' | 'admin' | 'all';
|
|
2
|
+
export declare const TOOL_CATEGORIES: {
|
|
3
|
+
init: string[];
|
|
4
|
+
story: string[];
|
|
5
|
+
storyReadonly: string[];
|
|
6
|
+
product: string[];
|
|
7
|
+
plan: string[];
|
|
8
|
+
program: string[];
|
|
9
|
+
feedback: string[];
|
|
10
|
+
bug: string[];
|
|
11
|
+
bugResolve: string[];
|
|
12
|
+
bugReadonly: string[];
|
|
13
|
+
testcase: string[];
|
|
14
|
+
task: string[];
|
|
15
|
+
taskReadonly: string[];
|
|
16
|
+
project: string[];
|
|
17
|
+
execution: string[];
|
|
18
|
+
build: string[];
|
|
19
|
+
ticket: string[];
|
|
20
|
+
comment: string[];
|
|
21
|
+
utility: string[];
|
|
22
|
+
user: string[];
|
|
23
|
+
};
|
|
24
|
+
export declare const ROLE_PERMISSIONS: Record<Role, string[]>;
|
|
25
|
+
/**
|
|
26
|
+
* 检查当前角色是否有权限使用指定工具
|
|
27
|
+
* @param toolName 工具名称
|
|
28
|
+
* @param role 当前角色
|
|
29
|
+
* @returns true 如果有权限,false 否则
|
|
30
|
+
*/
|
|
31
|
+
export declare function hasPermission(toolName: string, role?: Role): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* 获取当前运行环境的角色
|
|
34
|
+
* @returns 角色类型
|
|
35
|
+
*/
|
|
36
|
+
export declare function getCurrentRole(): Role;
|
|
37
|
+
/**
|
|
38
|
+
* 获取当前角色的工具列表
|
|
39
|
+
* @param role 角色类型
|
|
40
|
+
* @returns 工具名称数组
|
|
41
|
+
*/
|
|
42
|
+
export declare function getToolsForRole(role: Role): string[];
|
|
43
|
+
/**
|
|
44
|
+
* 获取角色的显示名称
|
|
45
|
+
* @param role 角色类型
|
|
46
|
+
* @returns 角色的中文显示名称
|
|
47
|
+
*/
|
|
48
|
+
export declare function getRoleName(role: Role): string;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// 角色配置 - 定义每个角色可以使用的工具
|
|
2
|
+
// 工具分类
|
|
3
|
+
export const TOOL_CATEGORIES = {
|
|
4
|
+
// 初始化工具(所有角色都需要)
|
|
5
|
+
init: ['initZentao'],
|
|
6
|
+
// 需求管理(产品经理完整权限,其他只读)
|
|
7
|
+
story: [
|
|
8
|
+
'createStory', 'createRequirement', 'getStoryDetail',
|
|
9
|
+
'changeStory', 'changeRequirement', 'deleteStory', 'deleteRequirement',
|
|
10
|
+
'getRequirementDetail', 'getProductStories', 'addStoryComment'
|
|
11
|
+
],
|
|
12
|
+
storyReadonly: ['getStoryDetail', 'getRequirementDetail', 'getProductStories'],
|
|
13
|
+
// 产品管理(仅产品经理)
|
|
14
|
+
product: [
|
|
15
|
+
'getProducts', 'getProductDetail', 'createProduct',
|
|
16
|
+
'updateProduct', 'deleteProduct'
|
|
17
|
+
],
|
|
18
|
+
// 计划管理(仅产品经理)
|
|
19
|
+
plan: [
|
|
20
|
+
'getProductPlans', 'getPlanDetail', 'createPlan',
|
|
21
|
+
'updatePlan', 'deletePlan', 'linkStoriesToPlan',
|
|
22
|
+
'unlinkStoriesFromPlan', 'linkBugsToPlan', 'unlinkBugsFromPlan'
|
|
23
|
+
],
|
|
24
|
+
// 项目集管理(仅产品经理)
|
|
25
|
+
program: [
|
|
26
|
+
'getPrograms', 'getProgramDetail', 'createProgram',
|
|
27
|
+
'updateProgram', 'deleteProgram'
|
|
28
|
+
],
|
|
29
|
+
// 反馈管理(仅产品经理)
|
|
30
|
+
feedback: [
|
|
31
|
+
'getFeedbacks', 'getFeedbackDetail', 'createFeedback',
|
|
32
|
+
'updateFeedback', 'deleteFeedback', 'assignFeedback', 'closeFeedback'
|
|
33
|
+
],
|
|
34
|
+
// Bug管理(测试完整权限,开发可以解决,产品只读)
|
|
35
|
+
bug: [
|
|
36
|
+
'getMyBugs', 'getProductBugs', 'getBugDetail', 'createBug',
|
|
37
|
+
'updateBug', 'deleteBug', 'resolveBug', 'addBugComment'
|
|
38
|
+
],
|
|
39
|
+
bugResolve: ['getMyBugs', 'getBugDetail', 'resolveBug', 'addBugComment'],
|
|
40
|
+
bugReadonly: ['getMyBugs', 'getProductBugs', 'getBugDetail'],
|
|
41
|
+
// 测试用例(仅测试)
|
|
42
|
+
testcase: [
|
|
43
|
+
'getProductTestCases', 'getTestCaseDetail', 'createTestCase',
|
|
44
|
+
'updateTestCase', 'deleteTestCase'
|
|
45
|
+
],
|
|
46
|
+
// 任务管理(开发完整权限,其他只读)
|
|
47
|
+
task: [
|
|
48
|
+
'getMyTasks', 'getTaskDetail', 'createTask',
|
|
49
|
+
'updateTask', 'finishTask', 'deleteTask', 'addTaskComment'
|
|
50
|
+
],
|
|
51
|
+
taskReadonly: ['getMyTasks', 'getTaskDetail'],
|
|
52
|
+
// 项目管理(仅开发)
|
|
53
|
+
project: [
|
|
54
|
+
'getProjects', 'getProjectDetail', 'createProject',
|
|
55
|
+
'updateProject', 'deleteProject', 'getProjectReleases',
|
|
56
|
+
'getProjectExecutions', 'getProjectBuilds'
|
|
57
|
+
],
|
|
58
|
+
// 迭代管理(仅开发)
|
|
59
|
+
execution: [
|
|
60
|
+
'getExecutionDetail', 'createExecution', 'updateExecution',
|
|
61
|
+
'deleteExecution', 'getExecutionBuilds'
|
|
62
|
+
],
|
|
63
|
+
// 版本构建(测试和开发)
|
|
64
|
+
build: [
|
|
65
|
+
'getBuildDetail', 'createBuild', 'updateBuild', 'deleteBuild'
|
|
66
|
+
],
|
|
67
|
+
// 工单管理(所有角色)
|
|
68
|
+
ticket: [
|
|
69
|
+
'getTickets', 'getTicketDetail', 'createTicket',
|
|
70
|
+
'updateTicket', 'deleteTicket'
|
|
71
|
+
],
|
|
72
|
+
// 评论功能(所有角色)
|
|
73
|
+
comment: [
|
|
74
|
+
'getComments', 'getCommentDetail', 'addComment',
|
|
75
|
+
'updateComment', 'deleteComment', 'addTaskComment', 'addBugComment'
|
|
76
|
+
],
|
|
77
|
+
// 模块和文件(所有角色)
|
|
78
|
+
utility: [
|
|
79
|
+
'getModules', 'uploadFile', 'uploadImageFromClipboard', 'downloadFile'
|
|
80
|
+
],
|
|
81
|
+
// 用户管理(仅管理员)
|
|
82
|
+
user: [
|
|
83
|
+
'getUsers', 'getUserDetail', 'getMyProfile', 'createUser',
|
|
84
|
+
'updateUser', 'deleteUser'
|
|
85
|
+
]
|
|
86
|
+
};
|
|
87
|
+
// 角色权限配置
|
|
88
|
+
export const ROLE_PERMISSIONS = {
|
|
89
|
+
// 产品经理:需求、产品、计划、项目集、反馈、评论
|
|
90
|
+
pm: [
|
|
91
|
+
...TOOL_CATEGORIES.init,
|
|
92
|
+
...TOOL_CATEGORIES.story,
|
|
93
|
+
...TOOL_CATEGORIES.product,
|
|
94
|
+
...TOOL_CATEGORIES.plan,
|
|
95
|
+
...TOOL_CATEGORIES.program,
|
|
96
|
+
...TOOL_CATEGORIES.feedback,
|
|
97
|
+
...TOOL_CATEGORIES.bugReadonly,
|
|
98
|
+
...TOOL_CATEGORIES.taskReadonly,
|
|
99
|
+
...TOOL_CATEGORIES.comment,
|
|
100
|
+
...TOOL_CATEGORIES.ticket,
|
|
101
|
+
...TOOL_CATEGORIES.utility
|
|
102
|
+
],
|
|
103
|
+
// 测试工程师:Bug、测试用例、版本构建、评论
|
|
104
|
+
qa: [
|
|
105
|
+
...TOOL_CATEGORIES.init,
|
|
106
|
+
...TOOL_CATEGORIES.bug,
|
|
107
|
+
...TOOL_CATEGORIES.testcase,
|
|
108
|
+
...TOOL_CATEGORIES.build,
|
|
109
|
+
...TOOL_CATEGORIES.storyReadonly,
|
|
110
|
+
...TOOL_CATEGORIES.taskReadonly,
|
|
111
|
+
...TOOL_CATEGORIES.comment,
|
|
112
|
+
...TOOL_CATEGORIES.ticket,
|
|
113
|
+
...TOOL_CATEGORIES.utility
|
|
114
|
+
],
|
|
115
|
+
// 开发工程师:任务、Bug解决、项目、迭代、版本构建、评论
|
|
116
|
+
dev: [
|
|
117
|
+
...TOOL_CATEGORIES.init,
|
|
118
|
+
...TOOL_CATEGORIES.task,
|
|
119
|
+
...TOOL_CATEGORIES.bugResolve,
|
|
120
|
+
...TOOL_CATEGORIES.project,
|
|
121
|
+
...TOOL_CATEGORIES.execution,
|
|
122
|
+
...TOOL_CATEGORIES.build,
|
|
123
|
+
...TOOL_CATEGORIES.storyReadonly,
|
|
124
|
+
...TOOL_CATEGORIES.comment,
|
|
125
|
+
...TOOL_CATEGORIES.ticket,
|
|
126
|
+
...TOOL_CATEGORIES.utility
|
|
127
|
+
],
|
|
128
|
+
// 管理员:所有工具
|
|
129
|
+
admin: [
|
|
130
|
+
...TOOL_CATEGORIES.init,
|
|
131
|
+
...TOOL_CATEGORIES.story,
|
|
132
|
+
...TOOL_CATEGORIES.product,
|
|
133
|
+
...TOOL_CATEGORIES.plan,
|
|
134
|
+
...TOOL_CATEGORIES.program,
|
|
135
|
+
...TOOL_CATEGORIES.feedback,
|
|
136
|
+
...TOOL_CATEGORIES.bug,
|
|
137
|
+
...TOOL_CATEGORIES.testcase,
|
|
138
|
+
...TOOL_CATEGORIES.task,
|
|
139
|
+
...TOOL_CATEGORIES.project,
|
|
140
|
+
...TOOL_CATEGORIES.execution,
|
|
141
|
+
...TOOL_CATEGORIES.build,
|
|
142
|
+
...TOOL_CATEGORIES.comment,
|
|
143
|
+
...TOOL_CATEGORIES.ticket,
|
|
144
|
+
...TOOL_CATEGORIES.utility,
|
|
145
|
+
...TOOL_CATEGORIES.user
|
|
146
|
+
],
|
|
147
|
+
// 完整权限(默认)
|
|
148
|
+
all: [] // 空数组表示所有工具都可用
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* 检查当前角色是否有权限使用指定工具
|
|
152
|
+
* @param toolName 工具名称
|
|
153
|
+
* @param role 当前角色
|
|
154
|
+
* @returns true 如果有权限,false 否则
|
|
155
|
+
*/
|
|
156
|
+
export function hasPermission(toolName, role = 'all') {
|
|
157
|
+
// 'all' 角色有所有权限
|
|
158
|
+
if (role === 'all')
|
|
159
|
+
return true;
|
|
160
|
+
// 检查该角色的权限列表
|
|
161
|
+
const permissions = ROLE_PERMISSIONS[role];
|
|
162
|
+
if (!permissions)
|
|
163
|
+
return false;
|
|
164
|
+
return permissions.includes(toolName);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* 获取当前运行环境的角色
|
|
168
|
+
* @returns 角色类型
|
|
169
|
+
*/
|
|
170
|
+
export function getCurrentRole() {
|
|
171
|
+
const role = process.env.ZENTAO_ROLE?.toLowerCase();
|
|
172
|
+
// 验证是否是有效的角色
|
|
173
|
+
if (role && ['pm', 'qa', 'dev', 'admin', 'all'].includes(role)) {
|
|
174
|
+
return role;
|
|
175
|
+
}
|
|
176
|
+
// 默认返回 'all'(所有权限)
|
|
177
|
+
return 'all';
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* 获取当前角色的工具列表
|
|
181
|
+
* @param role 角色类型
|
|
182
|
+
* @returns 工具名称数组
|
|
183
|
+
*/
|
|
184
|
+
export function getToolsForRole(role) {
|
|
185
|
+
if (role === 'all') {
|
|
186
|
+
// 返回所有工具
|
|
187
|
+
return Object.values(TOOL_CATEGORIES).flat();
|
|
188
|
+
}
|
|
189
|
+
return ROLE_PERMISSIONS[role] || [];
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* 获取角色的显示名称
|
|
193
|
+
* @param role 角色类型
|
|
194
|
+
* @returns 角色的中文显示名称
|
|
195
|
+
*/
|
|
196
|
+
export function getRoleName(role) {
|
|
197
|
+
const names = {
|
|
198
|
+
pm: '产品经理',
|
|
199
|
+
qa: '测试工程师',
|
|
200
|
+
dev: '开发工程师',
|
|
201
|
+
admin: '管理员',
|
|
202
|
+
all: '完整权限'
|
|
203
|
+
};
|
|
204
|
+
return names[role] || '未知角色';
|
|
205
|
+
}
|
package/dist/types/zentao.d.ts
CHANGED
|
@@ -717,14 +717,31 @@ export interface UploadFileRequest {
|
|
|
717
717
|
filename: string;
|
|
718
718
|
uid?: string;
|
|
719
719
|
}
|
|
720
|
-
export type CommentObjectType = 'story' | 'requirement' | 'task' | 'bug' | 'testcase' | 'testtask' | 'todo' | 'doc' | 'doctemplate';
|
|
720
|
+
export type CommentObjectType = 'story' | 'requirement' | 'task' | 'bug' | 'testcase' | 'testtask' | 'todo' | 'doc' | 'execution' | 'project' | 'doctemplate';
|
|
721
|
+
export interface Comment {
|
|
722
|
+
id: number;
|
|
723
|
+
objectType: string;
|
|
724
|
+
objectID: number;
|
|
725
|
+
action: string;
|
|
726
|
+
actor: string;
|
|
727
|
+
actorName?: string;
|
|
728
|
+
date: string;
|
|
729
|
+
comment: string;
|
|
730
|
+
extra?: string;
|
|
731
|
+
}
|
|
721
732
|
export interface AddCommentRequest {
|
|
722
733
|
objectType: CommentObjectType;
|
|
723
734
|
objectID: number;
|
|
724
735
|
comment: string;
|
|
736
|
+
uid?: string;
|
|
725
737
|
}
|
|
726
|
-
export interface
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
738
|
+
export interface UpdateCommentRequest {
|
|
739
|
+
comment: string;
|
|
740
|
+
uid?: string;
|
|
741
|
+
}
|
|
742
|
+
export interface CommentListResponse {
|
|
743
|
+
page: number;
|
|
744
|
+
total: number;
|
|
745
|
+
limit: number;
|
|
746
|
+
comments: Comment[];
|
|
730
747
|
}
|
package/json-args.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zzp123/mcp-zentao",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "禅道项目管理系统的高级API
|
|
3
|
+
"version": "1.17.0",
|
|
4
|
+
"description": "禅道项目管理系统的高级API集成包 - 完整版,包含所有94个工具。另有产品经理、测试工程师、开发工程师专用精简版本可选",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"bin": {
|
|
9
|
-
"zentao": "
|
|
9
|
+
"mcp-zentao": "dist/index.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|