@zzp123/mcp-zentao 1.1.2 → 1.2.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/dist/api/zentaoApi.d.ts +4 -1
- package/dist/api/zentaoApi.js +60 -0
- package/dist/index.js +39 -0
- package/dist/types/zentao.d.ts +24 -0
- package/package.json +3 -1
package/dist/api/zentaoApi.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssignFeedbackRequest, Bug, BugResolution, BugStatus, Build, CloseFeedbackRequest, CreateBuildRequest, CreateBugRequest, CreateExecutionRequest, CreateFeedbackRequest, CreatePlanRequest, CreateProductRequest, CreateProgramRequest, CreateProjectRequest, CreateStoryRequest, CreateTaskRequest, CreateTestCaseRequest, CreateTicketRequest, CreateUserRequest, Execution, Feedback, Plan, Product, Program, Project, Release, Story, Task, TaskStatus, TaskUpdate, TestCase, Ticket, UpdateBuildRequest, UpdateBugRequest, UpdateExecutionRequest, UpdateFeedbackRequest, UpdatePlanRequest, UpdateProductRequest, UpdateProgramRequest, UpdateProjectRequest, UpdateStoryRequest, UpdateTestCaseRequest, UpdateTicketRequest, UpdateUserRequest, UserDetail, ZentaoConfig } from '../types/zentao';
|
|
1
|
+
import { AssignFeedbackRequest, Bug, BugResolution, BugStatus, Build, CloseFeedbackRequest, CreateBuildRequest, CreateBugRequest, CreateExecutionRequest, CreateFeedbackRequest, CreatePlanRequest, CreateProductRequest, CreateProgramRequest, CreateProjectRequest, CreateStoryRequest, CreateTaskRequest, CreateTestCaseRequest, CreateTicketRequest, CreateUserRequest, Execution, Feedback, FileUploadResponse, Module, ModuleType, Plan, Product, Program, Project, Release, Story, Task, TaskStatus, TaskUpdate, TestCase, Ticket, UpdateBuildRequest, UpdateBugRequest, UpdateExecutionRequest, UpdateFeedbackRequest, UpdatePlanRequest, UpdateProductRequest, UpdateProgramRequest, UpdateProjectRequest, UpdateStoryRequest, UpdateTestCaseRequest, UpdateTicketRequest, UpdateUserRequest, UploadFileRequest, UserDetail, ZentaoConfig } from '../types/zentao';
|
|
2
2
|
export declare class ZentaoAPI {
|
|
3
3
|
private config;
|
|
4
4
|
private client;
|
|
@@ -148,4 +148,7 @@ export declare class ZentaoAPI {
|
|
|
148
148
|
deleteTicket(ticketId: number): Promise<{
|
|
149
149
|
message: string;
|
|
150
150
|
}>;
|
|
151
|
+
getModules(type: ModuleType, id: number): Promise<Module[]>;
|
|
152
|
+
uploadFile(uploadRequest: UploadFileRequest): Promise<FileUploadResponse>;
|
|
153
|
+
downloadFile(fileId: number): Promise<Buffer>;
|
|
151
154
|
}
|
package/dist/api/zentaoApi.js
CHANGED
|
@@ -1116,4 +1116,64 @@ export class ZentaoAPI {
|
|
|
1116
1116
|
throw error;
|
|
1117
1117
|
}
|
|
1118
1118
|
}
|
|
1119
|
+
// 模块相关API
|
|
1120
|
+
async getModules(type, id) {
|
|
1121
|
+
try {
|
|
1122
|
+
console.log(`正在获取模块列表,类型: ${type}, ID: ${id}...`);
|
|
1123
|
+
const params = { type, id };
|
|
1124
|
+
const response = await this.request('GET', '/modules', params);
|
|
1125
|
+
console.log('获取模块列表响应:', response);
|
|
1126
|
+
return response.modules;
|
|
1127
|
+
}
|
|
1128
|
+
catch (error) {
|
|
1129
|
+
console.error('获取模块列表失败:', error);
|
|
1130
|
+
throw error;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
// 文件相关API
|
|
1134
|
+
async uploadFile(uploadRequest) {
|
|
1135
|
+
try {
|
|
1136
|
+
console.log(`正在上传文件: ${uploadRequest.filename}...`);
|
|
1137
|
+
const token = await this.getToken();
|
|
1138
|
+
// 创建FormData
|
|
1139
|
+
const FormData = (await import('form-data')).default;
|
|
1140
|
+
const formData = new FormData();
|
|
1141
|
+
formData.append('imgFile', uploadRequest.file, uploadRequest.filename);
|
|
1142
|
+
const params = uploadRequest.uid ? { uid: uploadRequest.uid } : undefined;
|
|
1143
|
+
const response = await this.client.request({
|
|
1144
|
+
method: 'POST',
|
|
1145
|
+
url: '/files',
|
|
1146
|
+
params,
|
|
1147
|
+
data: formData,
|
|
1148
|
+
headers: {
|
|
1149
|
+
Token: token,
|
|
1150
|
+
...formData.getHeaders()
|
|
1151
|
+
},
|
|
1152
|
+
});
|
|
1153
|
+
console.log('上传文件响应:', response.data);
|
|
1154
|
+
return response.data;
|
|
1155
|
+
}
|
|
1156
|
+
catch (error) {
|
|
1157
|
+
console.error('上传文件失败:', error);
|
|
1158
|
+
throw error;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
async downloadFile(fileId) {
|
|
1162
|
+
try {
|
|
1163
|
+
console.log(`正在下载文件 ${fileId}...`);
|
|
1164
|
+
const token = await this.getToken();
|
|
1165
|
+
const response = await this.client.request({
|
|
1166
|
+
method: 'GET',
|
|
1167
|
+
url: `/files/${fileId}`,
|
|
1168
|
+
headers: { Token: token },
|
|
1169
|
+
responseType: 'arraybuffer'
|
|
1170
|
+
});
|
|
1171
|
+
console.log('下载文件成功');
|
|
1172
|
+
return Buffer.from(response.data);
|
|
1173
|
+
}
|
|
1174
|
+
catch (error) {
|
|
1175
|
+
console.error('下载文件失败:', error);
|
|
1176
|
+
throw error;
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1119
1179
|
}
|
package/dist/index.js
CHANGED
|
@@ -920,6 +920,45 @@ server.tool("deleteTicket", { ticketId: z.number() }, async ({ ticketId }) => {
|
|
|
920
920
|
throw new Error("Please initialize Zentao API first");
|
|
921
921
|
return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.deleteTicket(ticketId), null, 2) }] };
|
|
922
922
|
});
|
|
923
|
+
// 模块相关工具
|
|
924
|
+
server.tool("getModules", {
|
|
925
|
+
type: z.enum(['story', 'task', 'bug', 'case', 'feedback', 'product']),
|
|
926
|
+
id: z.number()
|
|
927
|
+
}, async ({ type, id }) => {
|
|
928
|
+
if (!zentaoApi)
|
|
929
|
+
throw new Error("Please initialize Zentao API first");
|
|
930
|
+
const modules = await zentaoApi.getModules(type, id);
|
|
931
|
+
return { content: [{ type: "text", text: JSON.stringify(modules, null, 2) }] };
|
|
932
|
+
});
|
|
933
|
+
// 文件相关工具
|
|
934
|
+
server.tool("uploadFile", {
|
|
935
|
+
filePath: z.string(),
|
|
936
|
+
uid: z.string().optional()
|
|
937
|
+
}, async ({ filePath, uid }) => {
|
|
938
|
+
if (!zentaoApi)
|
|
939
|
+
throw new Error("Please initialize Zentao API first");
|
|
940
|
+
const fs = await import('fs');
|
|
941
|
+
const path = await import('path');
|
|
942
|
+
const fileBuffer = fs.readFileSync(filePath);
|
|
943
|
+
const filename = path.basename(filePath);
|
|
944
|
+
const result = await zentaoApi.uploadFile({
|
|
945
|
+
file: fileBuffer,
|
|
946
|
+
filename,
|
|
947
|
+
uid
|
|
948
|
+
});
|
|
949
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
950
|
+
});
|
|
951
|
+
server.tool("downloadFile", {
|
|
952
|
+
fileId: z.number(),
|
|
953
|
+
savePath: z.string()
|
|
954
|
+
}, async ({ fileId, savePath }) => {
|
|
955
|
+
if (!zentaoApi)
|
|
956
|
+
throw new Error("Please initialize Zentao API first");
|
|
957
|
+
const fs = await import('fs');
|
|
958
|
+
const fileBuffer = await zentaoApi.downloadFile(fileId);
|
|
959
|
+
fs.writeFileSync(savePath, fileBuffer);
|
|
960
|
+
return { content: [{ type: "text", text: `文件已下载到: ${savePath}` }] };
|
|
961
|
+
});
|
|
923
962
|
// Start receiving messages on stdin and sending messages on stdout
|
|
924
963
|
const transport = new StdioServerTransport();
|
|
925
964
|
await server.connect(transport).catch(console.error);
|
package/dist/types/zentao.d.ts
CHANGED
|
@@ -611,3 +611,27 @@ export interface UpdateTicketRequest {
|
|
|
611
611
|
type?: string;
|
|
612
612
|
desc?: string;
|
|
613
613
|
}
|
|
614
|
+
export interface Module {
|
|
615
|
+
id: string;
|
|
616
|
+
root: string;
|
|
617
|
+
branch: string;
|
|
618
|
+
name: string;
|
|
619
|
+
parent: string;
|
|
620
|
+
path: string;
|
|
621
|
+
grade: string;
|
|
622
|
+
order: string;
|
|
623
|
+
type: string;
|
|
624
|
+
owner: string;
|
|
625
|
+
collector?: string;
|
|
626
|
+
short?: string;
|
|
627
|
+
}
|
|
628
|
+
export type ModuleType = 'story' | 'task' | 'bug' | 'case' | 'feedback' | 'product';
|
|
629
|
+
export interface FileUploadResponse {
|
|
630
|
+
id: number;
|
|
631
|
+
url: string;
|
|
632
|
+
}
|
|
633
|
+
export interface UploadFileRequest {
|
|
634
|
+
file: Buffer | Blob;
|
|
635
|
+
filename: string;
|
|
636
|
+
uid?: string;
|
|
637
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zzp123/mcp-zentao",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "禅道项目管理系统的高级API集成包,提供任务管理、Bug跟踪等功能的完整封装,专为Cursor IDE设计的MCP扩展",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -45,11 +45,13 @@
|
|
|
45
45
|
"@zzp123/mcp-zentao": "^1.1.0",
|
|
46
46
|
"axios": "^1.6.7",
|
|
47
47
|
"chalk": "^4.1.2",
|
|
48
|
+
"form-data": "^4.0.4",
|
|
48
49
|
"fs": "^0.0.1-security",
|
|
49
50
|
"table": "^6.8.1",
|
|
50
51
|
"yargs": "^17.7.2"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
54
|
+
"@types/form-data": "^2.2.1",
|
|
53
55
|
"@types/jest": "^29.5.12",
|
|
54
56
|
"@types/node": "^20.11.19",
|
|
55
57
|
"@types/table": "^6.3.2",
|