@zzp123/mcp-zentao 1.0.2 → 1.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/dist/index.js CHANGED
@@ -160,6 +160,764 @@ server.tool("resolveBug", {
160
160
  content: [{ type: "text", text: JSON.stringify(bug, null, 2) }]
161
161
  };
162
162
  });
163
+ // Add getPrograms tool
164
+ server.tool("getPrograms", {
165
+ order: z.string().optional()
166
+ }, async ({ order }) => {
167
+ if (!zentaoApi)
168
+ throw new Error("Please initialize Zentao API first");
169
+ const programs = await zentaoApi.getPrograms(order);
170
+ return {
171
+ content: [{ type: "text", text: JSON.stringify(programs, null, 2) }]
172
+ };
173
+ });
174
+ // Add getProductPlans tool
175
+ server.tool("getProductPlans", {
176
+ productId: z.number(),
177
+ branch: z.number().optional(),
178
+ begin: z.string().optional(),
179
+ end: z.string().optional(),
180
+ status: z.string().optional(),
181
+ parent: z.number().optional()
182
+ }, async ({ productId, branch, begin, end, status, parent }) => {
183
+ if (!zentaoApi)
184
+ throw new Error("Please initialize Zentao API first");
185
+ const plans = await zentaoApi.getProductPlans(productId, branch, begin, end, status, parent);
186
+ return {
187
+ content: [{ type: "text", text: JSON.stringify(plans, null, 2) }]
188
+ };
189
+ });
190
+ // Add createTask tool
191
+ server.tool("createTask", {
192
+ name: z.string(),
193
+ execution: z.number(),
194
+ desc: z.string().optional(),
195
+ pri: z.number().min(1).max(4).optional(),
196
+ estimate: z.number().optional(),
197
+ project: z.number().optional(),
198
+ module: z.number().optional(),
199
+ story: z.number().optional(),
200
+ type: z.string().optional(),
201
+ assignedTo: z.string().optional(),
202
+ estStarted: z.string().optional(),
203
+ deadline: z.string().optional()
204
+ }, async ({ name, execution, desc, pri, estimate, project, module, story, type, assignedTo, estStarted, deadline }) => {
205
+ if (!zentaoApi)
206
+ throw new Error("Please initialize Zentao API first");
207
+ const task = await zentaoApi.createTask({
208
+ name,
209
+ execution,
210
+ desc,
211
+ pri,
212
+ estimate,
213
+ project,
214
+ module,
215
+ story,
216
+ type,
217
+ assignedTo,
218
+ estStarted,
219
+ deadline
220
+ });
221
+ return {
222
+ content: [{ type: "text", text: JSON.stringify(task, null, 2) }]
223
+ };
224
+ });
225
+ // Add createStory tool
226
+ server.tool("createStory", {
227
+ title: z.string(),
228
+ product: z.number(),
229
+ pri: z.number(),
230
+ category: z.string().optional(),
231
+ spec: z.string().optional(),
232
+ verify: z.string().optional(),
233
+ source: z.string().optional(),
234
+ sourceNote: z.string().optional(),
235
+ estimate: z.number().optional(),
236
+ keywords: z.string().optional()
237
+ }, async ({ title, product, pri, category, spec, verify, source, sourceNote, estimate, keywords }) => {
238
+ if (!zentaoApi)
239
+ throw new Error("Please initialize Zentao API first");
240
+ const story = await zentaoApi.createStory({
241
+ title,
242
+ product,
243
+ pri,
244
+ category,
245
+ spec,
246
+ verify,
247
+ source,
248
+ sourceNote,
249
+ estimate,
250
+ keywords
251
+ });
252
+ return {
253
+ content: [{ type: "text", text: JSON.stringify(story, null, 2) }]
254
+ };
255
+ });
256
+ // Add getPlanDetail tool
257
+ server.tool("getPlanDetail", {
258
+ planId: z.number()
259
+ }, async ({ planId }) => {
260
+ if (!zentaoApi)
261
+ throw new Error("Please initialize Zentao API first");
262
+ const plan = await zentaoApi.getPlanDetail(planId);
263
+ return {
264
+ content: [{ type: "text", text: JSON.stringify(plan, null, 2) }]
265
+ };
266
+ });
267
+ // Add updatePlan tool
268
+ server.tool("updatePlan", {
269
+ planId: z.number(),
270
+ update: z.object({
271
+ branch: z.number().optional(),
272
+ title: z.string().optional(),
273
+ begin: z.string().optional(),
274
+ end: z.string().optional(),
275
+ desc: z.string().optional()
276
+ })
277
+ }, async ({ planId, update }) => {
278
+ if (!zentaoApi)
279
+ throw new Error("Please initialize Zentao API first");
280
+ const plan = await zentaoApi.updatePlan(planId, update);
281
+ return {
282
+ content: [{ type: "text", text: JSON.stringify(plan, null, 2) }]
283
+ };
284
+ });
285
+ // Add deletePlan tool
286
+ server.tool("deletePlan", {
287
+ planId: z.number()
288
+ }, async ({ planId }) => {
289
+ if (!zentaoApi)
290
+ throw new Error("Please initialize Zentao API first");
291
+ const result = await zentaoApi.deletePlan(planId);
292
+ return {
293
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
294
+ };
295
+ });
296
+ // Add linkStoriesToPlan tool
297
+ server.tool("linkStoriesToPlan", {
298
+ planId: z.number(),
299
+ storyIds: z.array(z.number())
300
+ }, async ({ planId, storyIds }) => {
301
+ if (!zentaoApi)
302
+ throw new Error("Please initialize Zentao API first");
303
+ const plan = await zentaoApi.linkStoriesToPlan(planId, storyIds);
304
+ return {
305
+ content: [{ type: "text", text: JSON.stringify(plan, null, 2) }]
306
+ };
307
+ });
308
+ // Add unlinkStoriesFromPlan tool
309
+ server.tool("unlinkStoriesFromPlan", {
310
+ planId: z.number(),
311
+ storyIds: z.array(z.number())
312
+ }, async ({ planId, storyIds }) => {
313
+ if (!zentaoApi)
314
+ throw new Error("Please initialize Zentao API first");
315
+ const plan = await zentaoApi.unlinkStoriesFromPlan(planId, storyIds);
316
+ return {
317
+ content: [{ type: "text", text: JSON.stringify(plan, null, 2) }]
318
+ };
319
+ });
320
+ // Add linkBugsToPlan tool
321
+ server.tool("linkBugsToPlan", {
322
+ planId: z.number(),
323
+ bugIds: z.array(z.number())
324
+ }, async ({ planId, bugIds }) => {
325
+ if (!zentaoApi)
326
+ throw new Error("Please initialize Zentao API first");
327
+ const plan = await zentaoApi.linkBugsToPlan(planId, bugIds);
328
+ return {
329
+ content: [{ type: "text", text: JSON.stringify(plan, null, 2) }]
330
+ };
331
+ });
332
+ // Add unlinkBugsFromPlan tool
333
+ server.tool("unlinkBugsFromPlan", {
334
+ planId: z.number(),
335
+ bugIds: z.array(z.number())
336
+ }, async ({ planId, bugIds }) => {
337
+ if (!zentaoApi)
338
+ throw new Error("Please initialize Zentao API first");
339
+ const plan = await zentaoApi.unlinkBugsFromPlan(planId, bugIds);
340
+ return {
341
+ content: [{ type: "text", text: JSON.stringify(plan, null, 2) }]
342
+ };
343
+ });
344
+ // Add getProjectReleases tool
345
+ server.tool("getProjectReleases", {
346
+ projectId: z.number()
347
+ }, async ({ projectId }) => {
348
+ if (!zentaoApi)
349
+ throw new Error("Please initialize Zentao API first");
350
+ const releases = await zentaoApi.getProjectReleases(projectId);
351
+ return {
352
+ content: [{ type: "text", text: JSON.stringify(releases, null, 2) }]
353
+ };
354
+ });
355
+ // Add getStoryDetail tool
356
+ server.tool("getStoryDetail", {
357
+ storyId: z.number()
358
+ }, async ({ storyId }) => {
359
+ if (!zentaoApi)
360
+ throw new Error("Please initialize Zentao API first");
361
+ const story = await zentaoApi.getStoryDetail(storyId);
362
+ return {
363
+ content: [{ type: "text", text: JSON.stringify(story, null, 2) }]
364
+ };
365
+ });
366
+ // Add createBug tool
367
+ server.tool("createBug", {
368
+ productId: z.number(),
369
+ title: z.string(),
370
+ severity: z.number(),
371
+ pri: z.number(),
372
+ type: z.string(),
373
+ branch: z.number().optional(),
374
+ module: z.number().optional(),
375
+ execution: z.number().optional(),
376
+ keywords: z.string().optional(),
377
+ os: z.string().optional(),
378
+ browser: z.string().optional(),
379
+ steps: z.string().optional(),
380
+ task: z.number().optional(),
381
+ story: z.number().optional(),
382
+ deadline: z.string().optional(),
383
+ openedBuild: z.array(z.string()).optional()
384
+ }, async ({ productId, title, severity, pri, type, branch, module, execution, keywords, os, browser, steps, task, story, deadline, openedBuild }) => {
385
+ if (!zentaoApi)
386
+ throw new Error("Please initialize Zentao API first");
387
+ const bug = await zentaoApi.createBug(productId, {
388
+ title,
389
+ severity,
390
+ pri,
391
+ type,
392
+ branch,
393
+ module,
394
+ execution,
395
+ keywords,
396
+ os,
397
+ browser,
398
+ steps,
399
+ task,
400
+ story,
401
+ deadline,
402
+ openedBuild
403
+ });
404
+ return {
405
+ content: [{ type: "text", text: JSON.stringify(bug, null, 2) }]
406
+ };
407
+ });
408
+ // Add getProjectExecutions tool
409
+ server.tool("getProjectExecutions", {
410
+ projectId: z.number()
411
+ }, async ({ projectId }) => {
412
+ if (!zentaoApi)
413
+ throw new Error("Please initialize Zentao API first");
414
+ const executions = await zentaoApi.getProjectExecutions(projectId);
415
+ return {
416
+ content: [{ type: "text", text: JSON.stringify(executions, null, 2) }]
417
+ };
418
+ });
419
+ // Add createPlan tool
420
+ server.tool("createPlan", {
421
+ productId: z.number(),
422
+ title: z.string(),
423
+ branch: z.number().optional(),
424
+ begin: z.string().optional(),
425
+ end: z.string().optional(),
426
+ desc: z.string().optional(),
427
+ parent: z.number().optional()
428
+ }, async ({ productId, title, branch, begin, end, desc, parent }) => {
429
+ if (!zentaoApi)
430
+ throw new Error("Please initialize Zentao API first");
431
+ const plan = await zentaoApi.createPlan(productId, {
432
+ title,
433
+ branch,
434
+ begin,
435
+ end,
436
+ desc,
437
+ parent
438
+ });
439
+ return {
440
+ content: [{ type: "text", text: JSON.stringify(plan, null, 2) }]
441
+ };
442
+ });
443
+ // Add getProjects tool
444
+ server.tool("getProjects", {
445
+ page: z.number().optional(),
446
+ limit: z.number().optional()
447
+ }, async ({ page, limit }) => {
448
+ if (!zentaoApi)
449
+ throw new Error("Please initialize Zentao API first");
450
+ const projects = await zentaoApi.getProjects(page, limit);
451
+ return {
452
+ content: [{ type: "text", text: JSON.stringify(projects, null, 2) }]
453
+ };
454
+ });
455
+ // Add updateStory tool
456
+ server.tool("updateStory", {
457
+ storyId: z.number(),
458
+ update: z.object({
459
+ module: z.number().optional(),
460
+ source: z.string().optional(),
461
+ sourceNote: z.string().optional(),
462
+ pri: z.number().optional(),
463
+ category: z.string().optional(),
464
+ estimate: z.number().optional(),
465
+ keywords: z.string().optional()
466
+ })
467
+ }, async ({ storyId, update }) => {
468
+ if (!zentaoApi)
469
+ throw new Error("Please initialize Zentao API first");
470
+ const story = await zentaoApi.updateStory(storyId, update);
471
+ return {
472
+ content: [{ type: "text", text: JSON.stringify(story, null, 2) }]
473
+ };
474
+ });
475
+ // Add deleteTask tool
476
+ server.tool("deleteTask", {
477
+ taskId: z.number()
478
+ }, async ({ taskId }) => {
479
+ if (!zentaoApi)
480
+ throw new Error("Please initialize Zentao API first");
481
+ const result = await zentaoApi.deleteTask(taskId);
482
+ return {
483
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
484
+ };
485
+ });
486
+ // Add getProductStories tool
487
+ server.tool("getProductStories", {
488
+ productId: z.number()
489
+ }, async ({ productId }) => {
490
+ if (!zentaoApi)
491
+ throw new Error("Please initialize Zentao API first");
492
+ const stories = await zentaoApi.getProductStories(productId);
493
+ return {
494
+ content: [{ type: "text", text: JSON.stringify(stories, null, 2) }]
495
+ };
496
+ });
497
+ // Program tools
498
+ server.tool("getProgramDetail", { programId: z.number() }, async ({ programId }) => {
499
+ if (!zentaoApi)
500
+ throw new Error("Please initialize Zentao API first");
501
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getProgramDetail(programId), null, 2) }] };
502
+ });
503
+ server.tool("createProgram", {
504
+ name: z.string().optional(), parent: z.string().optional(), PM: z.string().optional(),
505
+ budget: z.number().optional(), budgetUnit: z.string().optional(), desc: z.string().optional(),
506
+ begin: z.string().optional(), end: z.string().optional(), acl: z.string().optional(),
507
+ whitelist: z.array(z.string()).optional()
508
+ }, async (params) => {
509
+ if (!zentaoApi)
510
+ throw new Error("Please initialize Zentao API first");
511
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.createProgram(params), null, 2) }] };
512
+ });
513
+ server.tool("updateProgram", {
514
+ programId: z.number(),
515
+ update: z.object({
516
+ name: z.string().optional(), parent: z.string().optional(), PM: z.string().optional(),
517
+ budget: z.number().optional(), budgetUnit: z.string().optional(), desc: z.string().optional(),
518
+ begin: z.string().optional(), end: z.string().optional(), acl: z.string().optional(),
519
+ whitelist: z.array(z.string()).optional()
520
+ })
521
+ }, async ({ programId, update }) => {
522
+ if (!zentaoApi)
523
+ throw new Error("Please initialize Zentao API first");
524
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.updateProgram(programId, update), null, 2) }] };
525
+ });
526
+ server.tool("deleteProgram", { programId: z.number() }, async ({ programId }) => {
527
+ if (!zentaoApi)
528
+ throw new Error("Please initialize Zentao API first");
529
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.deleteProgram(programId), null, 2) }] };
530
+ });
531
+ // Product tools
532
+ server.tool("getProductDetail", { productId: z.number() }, async ({ productId }) => {
533
+ if (!zentaoApi)
534
+ throw new Error("Please initialize Zentao API first");
535
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getProductDetail(productId), null, 2) }] };
536
+ });
537
+ server.tool("createProduct", {
538
+ name: z.string(), code: z.string(), program: z.number().optional(), line: z.number().optional(),
539
+ PO: z.string().optional(), QD: z.string().optional(), RD: z.string().optional(),
540
+ type: z.string().optional(), desc: z.string().optional(), acl: z.string().optional(),
541
+ whitelist: z.array(z.string()).optional()
542
+ }, async (params) => {
543
+ if (!zentaoApi)
544
+ throw new Error("Please initialize Zentao API first");
545
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.createProduct(params), null, 2) }] };
546
+ });
547
+ server.tool("updateProduct", {
548
+ productId: z.number(),
549
+ update: z.object({
550
+ name: z.string().optional(), code: z.string().optional(), type: z.string().optional(),
551
+ line: z.number().optional(), program: z.number().optional(), status: z.string().optional(),
552
+ desc: z.string().optional()
553
+ })
554
+ }, async ({ productId, update }) => {
555
+ if (!zentaoApi)
556
+ throw new Error("Please initialize Zentao API first");
557
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.updateProduct(productId, update), null, 2) }] };
558
+ });
559
+ server.tool("deleteProduct", { productId: z.number() }, async ({ productId }) => {
560
+ if (!zentaoApi)
561
+ throw new Error("Please initialize Zentao API first");
562
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.deleteProduct(productId), null, 2) }] };
563
+ });
564
+ // Project tools
565
+ server.tool("getProjectDetail", { projectId: z.number() }, async ({ projectId }) => {
566
+ if (!zentaoApi)
567
+ throw new Error("Please initialize Zentao API first");
568
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getProjectDetail(projectId), null, 2) }] };
569
+ });
570
+ server.tool("createProject", {
571
+ name: z.string(), begin: z.string(), end: z.string(), products: z.array(z.number()),
572
+ code: z.string(), model: z.string().optional(), parent: z.number().optional()
573
+ }, async (params) => {
574
+ if (!zentaoApi)
575
+ throw new Error("Please initialize Zentao API first");
576
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.createProject(params), null, 2) }] };
577
+ });
578
+ server.tool("updateProject", {
579
+ projectId: z.number(),
580
+ update: z.object({
581
+ name: z.string().optional(), code: z.string().optional(), parent: z.number().optional(),
582
+ PM: z.string().optional(), budget: z.number().optional(), budgetUnit: z.string().optional(),
583
+ days: z.number().optional(), desc: z.string().optional(), acl: z.string().optional(),
584
+ whitelist: z.array(z.string()).optional(), auth: z.string().optional()
585
+ })
586
+ }, async ({ projectId, update }) => {
587
+ if (!zentaoApi)
588
+ throw new Error("Please initialize Zentao API first");
589
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.updateProject(projectId, update), null, 2) }] };
590
+ });
591
+ server.tool("deleteProject", { projectId: z.number() }, async ({ projectId }) => {
592
+ if (!zentaoApi)
593
+ throw new Error("Please initialize Zentao API first");
594
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.deleteProject(projectId), null, 2) }] };
595
+ });
596
+ // Execution tools
597
+ server.tool("createExecution", {
598
+ projectId: z.number(), project: z.number(), name: z.string(), code: z.string(),
599
+ begin: z.string(), end: z.string(), days: z.number().optional(), lifetime: z.string().optional(),
600
+ PO: z.string().optional(), PM: z.string().optional(), QD: z.string().optional(),
601
+ RD: z.string().optional(), teamMembers: z.array(z.string()).optional(),
602
+ desc: z.string().optional(), acl: z.string().optional(), whitelist: z.array(z.string()).optional()
603
+ }, async ({ projectId, ...params }) => {
604
+ if (!zentaoApi)
605
+ throw new Error("Please initialize Zentao API first");
606
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.createExecution(projectId, params), null, 2) }] };
607
+ });
608
+ server.tool("getExecutionDetail", { executionId: z.number() }, async ({ executionId }) => {
609
+ if (!zentaoApi)
610
+ throw new Error("Please initialize Zentao API first");
611
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getExecutionDetail(executionId), null, 2) }] };
612
+ });
613
+ server.tool("updateExecution", {
614
+ executionId: z.number(),
615
+ update: z.object({
616
+ project: z.number().optional(), name: z.string().optional(), code: z.string().optional(),
617
+ begin: z.string().optional(), end: z.string().optional(), days: z.number().optional(),
618
+ lifetime: z.string().optional(), PO: z.string().optional(), PM: z.string().optional(),
619
+ QD: z.string().optional(), RD: z.string().optional(), teamMembers: z.array(z.string()).optional(),
620
+ desc: z.string().optional(), acl: z.string().optional(), whitelist: z.array(z.string()).optional()
621
+ })
622
+ }, async ({ executionId, update }) => {
623
+ if (!zentaoApi)
624
+ throw new Error("Please initialize Zentao API first");
625
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.updateExecution(executionId, update), null, 2) }] };
626
+ });
627
+ server.tool("deleteExecution", { executionId: z.number() }, async ({ executionId }) => {
628
+ if (!zentaoApi)
629
+ throw new Error("Please initialize Zentao API first");
630
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.deleteExecution(executionId), null, 2) }] };
631
+ });
632
+ // Story tools
633
+ server.tool("deleteStory", { storyId: z.number() }, async ({ storyId }) => {
634
+ if (!zentaoApi)
635
+ throw new Error("Please initialize Zentao API first");
636
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.deleteStory(storyId), null, 2) }] };
637
+ });
638
+ // Bug tools
639
+ server.tool("updateBug", {
640
+ bugId: z.number(),
641
+ update: z.object({
642
+ branch: z.number().optional(), module: z.number().optional(), execution: z.number().optional(),
643
+ title: z.string().optional(), keywords: z.string().optional(), severity: z.number().optional(),
644
+ pri: z.number().optional(), type: z.string().optional(), os: z.string().optional(),
645
+ browser: z.string().optional(), steps: z.string().optional(), assignedTo: z.string().optional(),
646
+ deadline: z.string().optional()
647
+ })
648
+ }, async ({ bugId, update }) => {
649
+ if (!zentaoApi)
650
+ throw new Error("Please initialize Zentao API first");
651
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.updateBug(bugId, update), null, 2) }] };
652
+ });
653
+ server.tool("deleteBug", { bugId: z.number() }, async ({ bugId }) => {
654
+ if (!zentaoApi)
655
+ throw new Error("Please initialize Zentao API first");
656
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.deleteBug(bugId), null, 2) }] };
657
+ });
658
+ // 反馈模块工具
659
+ server.tool("getFeedbacks", {
660
+ solution: z.string().optional(),
661
+ orderBy: z.string().optional(),
662
+ page: z.number().optional(),
663
+ limit: z.number().optional()
664
+ }, async (params) => {
665
+ if (!zentaoApi)
666
+ throw new Error("Please initialize Zentao API first");
667
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getFeedbacks(params), null, 2) }] };
668
+ });
669
+ server.tool("getFeedbackDetail", { feedbackId: z.number() }, async ({ feedbackId }) => {
670
+ if (!zentaoApi)
671
+ throw new Error("Please initialize Zentao API first");
672
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getFeedbackDetail(feedbackId), null, 2) }] };
673
+ });
674
+ server.tool("createFeedback", {
675
+ product: z.number(),
676
+ module: z.number().optional(),
677
+ title: z.string(),
678
+ type: z.string().optional(),
679
+ desc: z.string().optional(),
680
+ public: z.number().optional(),
681
+ notify: z.number().optional(),
682
+ notifyEmail: z.string().optional(),
683
+ feedbackBy: z.string().optional()
684
+ }, async (params) => {
685
+ if (!zentaoApi)
686
+ throw new Error("Please initialize Zentao API first");
687
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.createFeedback(params), null, 2) }] };
688
+ });
689
+ server.tool("updateFeedback", {
690
+ feedbackId: z.number(),
691
+ product: z.number().optional(),
692
+ module: z.number().optional(),
693
+ title: z.string().optional(),
694
+ type: z.string().optional(),
695
+ desc: z.string().optional(),
696
+ public: z.number().optional(),
697
+ notify: z.number().optional(),
698
+ notifyEmail: z.string().optional(),
699
+ feedbackBy: z.string().optional()
700
+ }, async ({ feedbackId, ...params }) => {
701
+ if (!zentaoApi)
702
+ throw new Error("Please initialize Zentao API first");
703
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.updateFeedback(feedbackId, params), null, 2) }] };
704
+ });
705
+ server.tool("deleteFeedback", { feedbackId: z.number() }, async ({ feedbackId }) => {
706
+ if (!zentaoApi)
707
+ throw new Error("Please initialize Zentao API first");
708
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.deleteFeedback(feedbackId), null, 2) }] };
709
+ });
710
+ server.tool("assignFeedback", {
711
+ feedbackId: z.number(),
712
+ assignedTo: z.string().optional(),
713
+ comment: z.string().optional(),
714
+ mailto: z.string().optional()
715
+ }, async ({ feedbackId, ...params }) => {
716
+ if (!zentaoApi)
717
+ throw new Error("Please initialize Zentao API first");
718
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.assignFeedback(feedbackId, params), null, 2) }] };
719
+ });
720
+ server.tool("closeFeedback", {
721
+ feedbackId: z.number(),
722
+ closedReason: z.string().optional(),
723
+ comment: z.string().optional()
724
+ }, async ({ feedbackId, ...params }) => {
725
+ if (!zentaoApi)
726
+ throw new Error("Please initialize Zentao API first");
727
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.closeFeedback(feedbackId, params), null, 2) }] };
728
+ });
729
+ // 测试用例模块工具
730
+ server.tool("getProductTestCases", { productId: z.number() }, async ({ productId }) => {
731
+ if (!zentaoApi)
732
+ throw new Error("Please initialize Zentao API first");
733
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getProductTestCases(productId), null, 2) }] };
734
+ });
735
+ server.tool("createTestCase", {
736
+ productId: z.number(),
737
+ branch: z.number().optional(),
738
+ module: z.number().optional(),
739
+ story: z.number().optional(),
740
+ title: z.string(),
741
+ type: z.string(),
742
+ stage: z.string().optional(),
743
+ precondition: z.string().optional(),
744
+ pri: z.number().optional(),
745
+ steps: z.array(z.object({ desc: z.string(), expect: z.string() })),
746
+ keywords: z.string().optional()
747
+ }, async ({ productId, ...params }) => {
748
+ if (!zentaoApi)
749
+ throw new Error("Please initialize Zentao API first");
750
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.createTestCase(productId, params), null, 2) }] };
751
+ });
752
+ server.tool("getTestCaseDetail", { testCaseId: z.number() }, async ({ testCaseId }) => {
753
+ if (!zentaoApi)
754
+ throw new Error("Please initialize Zentao API first");
755
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getTestCaseDetail(testCaseId), null, 2) }] };
756
+ });
757
+ server.tool("updateTestCase", {
758
+ testCaseId: z.number(),
759
+ branch: z.number().optional(),
760
+ module: z.number().optional(),
761
+ story: z.number().optional(),
762
+ title: z.string().optional(),
763
+ type: z.string().optional(),
764
+ stage: z.string().optional(),
765
+ precondition: z.string().optional(),
766
+ pri: z.number().optional(),
767
+ steps: z.array(z.object({ desc: z.string(), expect: z.string() })).optional(),
768
+ keywords: z.string().optional()
769
+ }, async ({ testCaseId, ...params }) => {
770
+ if (!zentaoApi)
771
+ throw new Error("Please initialize Zentao API first");
772
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.updateTestCase(testCaseId, params), null, 2) }] };
773
+ });
774
+ server.tool("deleteTestCase", { testCaseId: z.number() }, async ({ testCaseId }) => {
775
+ if (!zentaoApi)
776
+ throw new Error("Please initialize Zentao API first");
777
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.deleteTestCase(testCaseId), null, 2) }] };
778
+ });
779
+ // 版本/构建模块工具
780
+ server.tool("getProjectBuilds", { projectId: z.number() }, async ({ projectId }) => {
781
+ if (!zentaoApi)
782
+ throw new Error("Please initialize Zentao API first");
783
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getProjectBuilds(projectId), null, 2) }] };
784
+ });
785
+ server.tool("getExecutionBuilds", { executionId: z.number() }, async ({ executionId }) => {
786
+ if (!zentaoApi)
787
+ throw new Error("Please initialize Zentao API first");
788
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getExecutionBuilds(executionId), null, 2) }] };
789
+ });
790
+ server.tool("createBuild", {
791
+ projectId: z.number(),
792
+ execution: z.number(),
793
+ product: z.number(),
794
+ branch: z.number().optional(),
795
+ name: z.string(),
796
+ builder: z.string(),
797
+ date: z.string().optional(),
798
+ scmPath: z.string().optional(),
799
+ filePath: z.string().optional(),
800
+ desc: z.string().optional()
801
+ }, async ({ projectId, ...params }) => {
802
+ if (!zentaoApi)
803
+ throw new Error("Please initialize Zentao API first");
804
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.createBuild(projectId, params), null, 2) }] };
805
+ });
806
+ server.tool("getBuildDetail", { buildId: z.number() }, async ({ buildId }) => {
807
+ if (!zentaoApi)
808
+ throw new Error("Please initialize Zentao API first");
809
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getBuildDetail(buildId), null, 2) }] };
810
+ });
811
+ server.tool("updateBuild", {
812
+ buildId: z.number(),
813
+ name: z.string().optional(),
814
+ builder: z.string().optional(),
815
+ date: z.string().optional(),
816
+ scmPath: z.string().optional(),
817
+ filePath: z.string().optional(),
818
+ desc: z.string().optional()
819
+ }, async ({ buildId, ...params }) => {
820
+ if (!zentaoApi)
821
+ throw new Error("Please initialize Zentao API first");
822
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.updateBuild(buildId, params), null, 2) }] };
823
+ });
824
+ server.tool("deleteBuild", { buildId: z.number() }, async ({ buildId }) => {
825
+ if (!zentaoApi)
826
+ throw new Error("Please initialize Zentao API first");
827
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.deleteBuild(buildId), null, 2) }] };
828
+ });
829
+ // 用户模块工具
830
+ server.tool("getUserDetail", { userId: z.number() }, async ({ userId }) => {
831
+ if (!zentaoApi)
832
+ throw new Error("Please initialize Zentao API first");
833
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getUserDetail(userId), null, 2) }] };
834
+ });
835
+ server.tool("getMyProfile", {}, async () => {
836
+ if (!zentaoApi)
837
+ throw new Error("Please initialize Zentao API first");
838
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getMyProfile(), null, 2) }] };
839
+ });
840
+ server.tool("getUsers", {
841
+ page: z.number().optional(),
842
+ limit: z.number().optional()
843
+ }, async (params) => {
844
+ if (!zentaoApi)
845
+ throw new Error("Please initialize Zentao API first");
846
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getUsers(params), null, 2) }] };
847
+ });
848
+ server.tool("createUser", {
849
+ account: z.string(),
850
+ password: z.string(),
851
+ realname: z.string().optional(),
852
+ visions: z.array(z.string()).optional()
853
+ }, async (params) => {
854
+ if (!zentaoApi)
855
+ throw new Error("Please initialize Zentao API first");
856
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.createUser(params), null, 2) }] };
857
+ });
858
+ server.tool("updateUser", {
859
+ userId: z.number(),
860
+ dept: z.number().optional(),
861
+ role: z.string().optional(),
862
+ mobile: z.string().optional(),
863
+ realname: z.string().optional(),
864
+ email: z.string().optional(),
865
+ phone: z.string().optional()
866
+ }, async ({ userId, ...params }) => {
867
+ if (!zentaoApi)
868
+ throw new Error("Please initialize Zentao API first");
869
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.updateUser(userId, params), null, 2) }] };
870
+ });
871
+ server.tool("deleteUser", { userId: z.number() }, async ({ userId }) => {
872
+ if (!zentaoApi)
873
+ throw new Error("Please initialize Zentao API first");
874
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.deleteUser(userId), null, 2) }] };
875
+ });
876
+ // 工单模块工具
877
+ server.tool("getTickets", {
878
+ browseType: z.string().optional(),
879
+ param: z.string().optional(),
880
+ orderBy: z.string().optional(),
881
+ page: z.number().optional(),
882
+ limit: z.number().optional()
883
+ }, async (params) => {
884
+ if (!zentaoApi)
885
+ throw new Error("Please initialize Zentao API first");
886
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getTickets(params), null, 2) }] };
887
+ });
888
+ server.tool("getTicketDetail", { ticketId: z.number() }, async ({ ticketId }) => {
889
+ if (!zentaoApi)
890
+ throw new Error("Please initialize Zentao API first");
891
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.getTicketDetail(ticketId), null, 2) }] };
892
+ });
893
+ server.tool("createTicket", {
894
+ product: z.number(),
895
+ module: z.number(),
896
+ title: z.string(),
897
+ type: z.string().optional(),
898
+ desc: z.string().optional()
899
+ }, async (params) => {
900
+ if (!zentaoApi)
901
+ throw new Error("Please initialize Zentao API first");
902
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.createTicket(params), null, 2) }] };
903
+ });
904
+ server.tool("updateTicket", {
905
+ ticketId: z.number(),
906
+ product: z.number().optional(),
907
+ module: z.number().optional(),
908
+ title: z.string().optional(),
909
+ type: z.string().optional(),
910
+ desc: z.string().optional()
911
+ }, async ({ ticketId, ...params }) => {
912
+ if (!zentaoApi)
913
+ throw new Error("Please initialize Zentao API first");
914
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.updateTicket(ticketId, params), null, 2) }] };
915
+ });
916
+ server.tool("deleteTicket", { ticketId: z.number() }, async ({ ticketId }) => {
917
+ if (!zentaoApi)
918
+ throw new Error("Please initialize Zentao API first");
919
+ return { content: [{ type: "text", text: JSON.stringify(await zentaoApi.deleteTicket(ticketId), null, 2) }] };
920
+ });
163
921
  // Start receiving messages on stdin and sending messages on stdout
164
922
  const transport = new StdioServerTransport();
165
923
  await server.connect(transport).catch(console.error);