@taole/deploy-helper 1.0.1 → 1.0.3

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.
Files changed (29) hide show
  1. package/README.md +1 -4
  2. package/lib/offlinePkg.mjs +21 -2
  3. package/lib/pipelineApi.mjs +17 -16
  4. package/lib/yunxiaoFlowApi.mjs +115 -0
  5. package/package.json +4 -5
  6. package/modules/alibabacloud-devops-mcp-server/dist/common/errors.js +0 -69
  7. package/modules/alibabacloud-devops-mcp-server/dist/common/modularTemplates.js +0 -483
  8. package/modules/alibabacloud-devops-mcp-server/dist/common/pipelineTemplates.js +0 -19
  9. package/modules/alibabacloud-devops-mcp-server/dist/common/types.js +0 -1119
  10. package/modules/alibabacloud-devops-mcp-server/dist/common/utils.js +0 -353
  11. package/modules/alibabacloud-devops-mcp-server/dist/common/version.js +0 -1
  12. package/modules/alibabacloud-devops-mcp-server/dist/index.js +0 -1067
  13. package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/branches.js +0 -144
  14. package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/changeRequestComments.js +0 -89
  15. package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/changeRequests.js +0 -203
  16. package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/compare.js +0 -26
  17. package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/files.js +0 -233
  18. package/modules/alibabacloud-devops-mcp-server/dist/operations/codeup/repositories.js +0 -64
  19. package/modules/alibabacloud-devops-mcp-server/dist/operations/flow/hostGroup.js +0 -48
  20. package/modules/alibabacloud-devops-mcp-server/dist/operations/flow/pipeline.js +0 -514
  21. package/modules/alibabacloud-devops-mcp-server/dist/operations/flow/pipelineJob.js +0 -113
  22. package/modules/alibabacloud-devops-mcp-server/dist/operations/flow/serviceConnection.js +0 -23
  23. package/modules/alibabacloud-devops-mcp-server/dist/operations/organization/members.js +0 -94
  24. package/modules/alibabacloud-devops-mcp-server/dist/operations/organization/organization.js +0 -73
  25. package/modules/alibabacloud-devops-mcp-server/dist/operations/packages/artifacts.js +0 -64
  26. package/modules/alibabacloud-devops-mcp-server/dist/operations/packages/repositories.js +0 -35
  27. package/modules/alibabacloud-devops-mcp-server/dist/operations/projex/project.js +0 -206
  28. package/modules/alibabacloud-devops-mcp-server/dist/operations/projex/sprint.js +0 -30
  29. package/modules/alibabacloud-devops-mcp-server/dist/operations/projex/workitem.js +0 -264
@@ -1,1067 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
- import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
- import { z } from 'zod';
6
- import { zodToJsonSchema } from 'zod-to-json-schema';
7
- import * as branches from './operations/codeup/branches.js';
8
- import * as files from './operations/codeup/files.js';
9
- import * as repositories from './operations/codeup/repositories.js';
10
- import * as changeRequests from './operations/codeup/changeRequests.js';
11
- import * as changeRequestComments from './operations/codeup/changeRequestComments.js';
12
- import * as organization from './operations/organization/organization.js';
13
- import * as members from './operations/organization/members.js';
14
- import * as project from './operations/projex/project.js';
15
- import * as workitem from './operations/projex/workitem.js';
16
- import * as compare from './operations/codeup/compare.js';
17
- import * as pipeline from './operations/flow/pipeline.js';
18
- import * as pipelineJob from './operations/flow/pipelineJob.js';
19
- import * as serviceConnection from './operations/flow/serviceConnection.js';
20
- import * as packageRepositories from './operations/packages/repositories.js';
21
- import * as artifacts from './operations/packages/artifacts.js';
22
- import { isYunxiaoError, YunxiaoValidationError } from "./common/errors.js";
23
- import { VERSION } from "./common/version.js";
24
- import { config } from "dotenv";
25
- import * as types from "./common/types.js";
26
- const server = new Server({
27
- name: "alibabacloud-devops-mcp-server",
28
- version: VERSION,
29
- }, {
30
- capabilities: {
31
- tools: {},
32
- },
33
- });
34
- function formatYunxiaoError(error) {
35
- let message = `Yunxiao API Error: ${error.message}`;
36
- if (error instanceof YunxiaoValidationError) {
37
- message = `Parameter validation failed: ${error.message}`;
38
- if (error.response) {
39
- message += `\n errorMessage: ${JSON.stringify(error.response, null, 2)}`;
40
- }
41
- // 添加常见参数错误的提示
42
- if (error.message.includes('name')) {
43
- message += `\n Suggestion: Please check whether the pipeline name meets the requirements.`;
44
- }
45
- if (error.message.includes('content') || error.message.includes('yaml')) {
46
- message += `\n Suggestion: Please check whether the generated YAML format is correct.`;
47
- }
48
- }
49
- else {
50
- // 处理通用的Yunxiao错误
51
- message = `Yunxiao API error (${error.status}): ${error.message}`;
52
- if (error.response) {
53
- const response = error.response;
54
- if (response.errorCode) {
55
- message += `\n errorCode: ${response.errorCode}`;
56
- }
57
- if (response.errorMessage && response.errorMessage !== error.message) {
58
- message += `\n errorMessage: ${response.errorMessage}`;
59
- }
60
- if (response.data && typeof response.data === 'object') {
61
- message += `\n data: ${JSON.stringify(response.data, null, 2)}`;
62
- }
63
- }
64
- // 根据状态码提供通用建议
65
- switch (error.status) {
66
- case 400:
67
- message += `\n Suggestion: Please check whether the request parameters are correct, especially whether all required parameters have been provided.`;
68
- break;
69
- case 500:
70
- message += `\n Suggestion: Internal server error. Please try again later or contact technical support.`;
71
- break;
72
- case 502:
73
- case 503:
74
- case 504:
75
- message += `\n Suggestion: The service is temporarily unavailable. Please try again later.`;
76
- break;
77
- }
78
- }
79
- return message;
80
- }
81
- server.setRequestHandler(ListToolsRequestSchema, async () => {
82
- return {
83
- tools: [
84
- // Branch Operations
85
- {
86
- name: "create_branch",
87
- description: "[Code Management] Create a new branch in a Codeup repository",
88
- inputSchema: zodToJsonSchema(types.CreateBranchSchema),
89
- },
90
- {
91
- name: "get_branch",
92
- description: "[Code Management] Get information about a branch in a Codeup repository",
93
- inputSchema: zodToJsonSchema(types.GetBranchSchema),
94
- },
95
- {
96
- name: "delete_branch",
97
- description: "[Code Management] Delete a branch from a Codeup repository",
98
- inputSchema: zodToJsonSchema(types.DeleteBranchSchema),
99
- },
100
- {
101
- name: "list_branches",
102
- description: "[Code Management] List branches in a Codeup repository",
103
- inputSchema: zodToJsonSchema(types.ListBranchesSchema),
104
- },
105
- // File Operations
106
- {
107
- name: "get_file_blobs",
108
- description: "[Code Management] Get file content from a Codeup repository",
109
- inputSchema: zodToJsonSchema(types.GetFileBlobsSchema),
110
- },
111
- {
112
- name: "create_file",
113
- description: "[Code Management] Create a new file in a Codeup repository",
114
- inputSchema: zodToJsonSchema(types.CreateFileSchema),
115
- },
116
- {
117
- name: "update_file",
118
- description: "[Code Management] Update an existing file in a Codeup repository",
119
- inputSchema: zodToJsonSchema(types.UpdateFileSchema),
120
- },
121
- {
122
- name: "delete_file",
123
- description: "[Code Management] Delete a file from a Codeup repository",
124
- inputSchema: zodToJsonSchema(types.DeleteFileSchema),
125
- },
126
- {
127
- name: "compare",
128
- description: "[Code Management] Query code to compare content",
129
- inputSchema: zodToJsonSchema(types.GetCompareSchema),
130
- },
131
- // Repository Operations
132
- {
133
- name: "get_repository",
134
- description: "[Code Management] Get information about a Codeup repository",
135
- inputSchema: zodToJsonSchema(types.GetRepositorySchema),
136
- },
137
- {
138
- name: "list_repositories",
139
- description: "[Code Management] Get the CodeUp Repository List.\n" +
140
- "\n" +
141
- "A Repository serves as a unit for managing source code and is distinct from a Project.\n" +
142
- "\n" +
143
- "Use Case:\n" +
144
- "\n" +
145
- "View my repositories",
146
- inputSchema: zodToJsonSchema(types.ListRepositoriesSchema),
147
- },
148
- // Change Request Operations
149
- {
150
- name: "get_change_request",
151
- description: "[Code Management] Get information about a change request",
152
- inputSchema: zodToJsonSchema(types.GetChangeRequestSchema),
153
- },
154
- {
155
- name: "list_change_requests",
156
- description: "[Code Management] List change requests",
157
- inputSchema: zodToJsonSchema(types.ListChangeRequestsSchema),
158
- },
159
- {
160
- name: "create_change_request",
161
- description: "[Code Management] Create a new change request",
162
- inputSchema: zodToJsonSchema(types.CreateChangeRequestSchema),
163
- },
164
- {
165
- name: "create_change_request_comment",
166
- description: "[Code Management] Create a comment on a change request",
167
- inputSchema: zodToJsonSchema(types.CreateChangeRequestCommentSchema),
168
- },
169
- {
170
- name: "list_change_request_comments",
171
- description: "[Code Management] List comments on a change request",
172
- inputSchema: zodToJsonSchema(types.ListChangeRequestCommentsSchema),
173
- },
174
- {
175
- name: "list_change_request_patch_sets",
176
- description: "[Code Management] List patch sets for a change request",
177
- inputSchema: zodToJsonSchema(types.ListChangeRequestPatchSetsSchema),
178
- },
179
- // Organization Operations
180
- {
181
- name: "get_current_organization_info",
182
- description: "Get information about the current user and organization based on the token. In the absence of an explicitly specified organization ID, this result will take precedence.",
183
- inputSchema: zodToJsonSchema(z.object({})),
184
- },
185
- {
186
- name: "get_user_organizations",
187
- description: "Get the list of organizations the current user belongs to",
188
- inputSchema: zodToJsonSchema(z.object({})),
189
- },
190
- {
191
- name: "get_current_user",
192
- description: "Get information about the current user based on the token. In the absence of an explicitly specified user ID, this result will take precedence.",
193
- inputSchema: zodToJsonSchema(z.object({})),
194
- },
195
- {
196
- name: "get_organization_departments",
197
- description: "Get the list of departments in an organization",
198
- inputSchema: zodToJsonSchema(types.GetOrganizationDepartmentsSchema),
199
- },
200
- {
201
- name: "get_organization_department_info",
202
- description: "Get information about a department in an organization",
203
- inputSchema: zodToJsonSchema(types.GetOrganizationDepartmentInfoSchema),
204
- },
205
- {
206
- name: "get_organization_department_ancestors",
207
- description: "Get the ancestors of a department in an organization",
208
- inputSchema: zodToJsonSchema(types.GetOrganizationDepartmentAncestorsSchema),
209
- },
210
- {
211
- name: "get_organization_members",
212
- description: "Get the list of members in an organization",
213
- inputSchema: zodToJsonSchema(types.GetOrganizationMembersSchema),
214
- },
215
- {
216
- name: "get_organization_member_info",
217
- description: "Get information about a member in an organization",
218
- inputSchema: zodToJsonSchema(types.GetOrganizationMemberInfoSchema),
219
- },
220
- {
221
- name: "get_organization_member_info_by_user_id",
222
- description: "Get information about a member in an organization by user ID",
223
- inputSchema: zodToJsonSchema(types.GetOrganizationMemberByUserIdInfoSchema),
224
- },
225
- {
226
- name: "search_organization_members",
227
- description: "[Organization Management] Search for organization members",
228
- inputSchema: zodToJsonSchema(types.SearchOrganizationMembersSchema),
229
- },
230
- {
231
- name: "list_organization_roles",
232
- description: "[Organization Management] List organization roles",
233
- inputSchema: zodToJsonSchema(types.ListOrganizationRolesSchema),
234
- },
235
- {
236
- name: "get_organization_role",
237
- description: "[Organization Management] Get information about an organization role",
238
- inputSchema: zodToJsonSchema(types.GetOrganizationRoleSchema),
239
- },
240
- // Project Operations
241
- {
242
- name: "get_project",
243
- description: "[Project Management] Get information about a Yunxiao project",
244
- inputSchema: zodToJsonSchema(types.GetProjectSchema),
245
- },
246
- {
247
- name: "search_projects",
248
- description: "[Project Management] Search for Yunxiao Project List. A Project is a project management unit that includes work items and sprints, and it is different from a code repository (Repository).\n" +
249
- "\n" +
250
- "Use Cases:\n" +
251
- "\n" +
252
- "Query projects I am involved in\n" +
253
- "Query projects I have created",
254
- inputSchema: zodToJsonSchema(types.SearchProjectsSchema),
255
- },
256
- // Sprint Operations
257
- // {
258
- // name: "get_sprint",
259
- // description: "Get information about a sprint",
260
- // inputSchema: zodToJsonSchema(sprint.GetSprintSchema),
261
- // },
262
- // {
263
- // name: "list_sprints",
264
- // description: "List sprints in a project",
265
- // inputSchema: zodToJsonSchema(sprint.ListSprintsSchema),
266
- // },
267
- // Work Item Operations
268
- {
269
- name: "get_work_item",
270
- description: "[Project Management] Get information about a work item",
271
- inputSchema: zodToJsonSchema(types.GetWorkItemSchema),
272
- },
273
- {
274
- name: "create_work_item",
275
- description: "[Project Management] Create a work item",
276
- inputSchema: zodToJsonSchema(types.CreateWorkItemSchema),
277
- },
278
- {
279
- name: "search_workitems",
280
- description: "[Project Management] Search work items with various filter conditions",
281
- inputSchema: zodToJsonSchema(types.SearchWorkitemsSchema),
282
- },
283
- {
284
- name: "get_work_item_types",
285
- description: "[Project Management] Get the list of work item types for a project",
286
- inputSchema: zodToJsonSchema(z.object({
287
- organizationId: z.string().describe("Organization ID"),
288
- id: z.string().describe("Project unique identifier"),
289
- category: z.string().describe("Work item type category, optional values: Req, Bug, Task, etc.")
290
- })),
291
- },
292
- // Pipeline Operations
293
- {
294
- name: "get_pipeline",
295
- description: "[Pipeline Management] Get details of a specific pipeline in an organization",
296
- inputSchema: zodToJsonSchema(types.GetPipelineSchema),
297
- },
298
- {
299
- name: "list_pipelines",
300
- description: "[Pipeline Management] Get a list of pipelines in an organization with filtering options",
301
- inputSchema: zodToJsonSchema(types.ListPipelinesSchema),
302
- },
303
- {
304
- name: "generate_pipeline_yaml",
305
- description: "[Pipeline Management] Generate only the YAML configuration for a pipeline without creating it.\n\n" +
306
- "**📋 Use Cases:**\n" +
307
- "- Preview YAML before creating pipeline\n" +
308
- "- Generate YAML for manual deployment\n" +
309
- "- Debug pipeline configuration\n\n" +
310
- "**📖 Recommended Workflow:**\n" +
311
- "1. 🎯 Parse user description for explicit parameters\n" +
312
- "2. 🔍 If missing context, prefer IDE detection (terminal + file reading) over API calls\n" +
313
- "3. 🚀 Call this tool with collected parameters\n\n" +
314
- "**💡 Parameter Collection Strategy:**\n" +
315
- "- For QUICK pipeline creation: Use IDE detection (git config, file reading)\n" +
316
- "- For PRECISE parameter selection: Consider list_repositories, list_service_connections when needed\n" +
317
- "- Balance efficiency vs. accuracy based on user intent\n\n" +
318
- "**⚡ Built-in capabilities:** Handles default service connections internally, auto-extracts project name from repo URL",
319
- inputSchema: zodToJsonSchema(types.CreatePipelineFromDescriptionSchema),
320
- },
321
- {
322
- name: "create_pipeline_from_description",
323
- description: "[Pipeline Management] Create a pipeline using structured parameters extracted from user descriptions and environment context.\n\n" +
324
- "**🔧 Built-in Capabilities:**\n" +
325
- "- ✅ Automatically retrieves default service connection IDs when not specified\n" +
326
- "- ✅ Handles repository and service connection logic internally\n" +
327
- "- ✅ Auto-extracts project name from repository URL (git@host:org/repo.git → repo)\n" +
328
- "- ✅ Supports both IDE detection and explicit parameter specification\n\n" +
329
- "**📖 Recommended Workflow:**\n" +
330
- "1. 🎯 PARSE user description for explicit parameters\n" +
331
- "2. 🔍 DETECT missing info from IDE environment FIRST:\n" +
332
- " - Run `git config --get remote.origin.url` → repoUrl\n" +
333
- " - Run `git branch --show-current` → branch\n" +
334
- " - Auto-extract serviceName from repoUrl\n" +
335
- " - Check project files for tech stack:\n" +
336
- " * pom.xml → buildLanguage='java', buildTool='maven'\n" +
337
- " * build.gradle → buildLanguage='java', buildTool='gradle'\n" +
338
- " * package.json + package-lock.json → buildLanguage='nodejs', buildTool='npm'\n" +
339
- " * package.json + yarn.lock → buildLanguage='nodejs', buildTool='yarn'\n" +
340
- " * requirements.txt → buildLanguage='python', buildTool='pip'\n" +
341
- " * go.mod → buildLanguage='go', buildTool='go'\n" +
342
- " * *.csproj → buildLanguage='dotnet', buildTool='dotnet'\n" +
343
- "3. 🚀 CALL this tool with collected parameters\n\n" +
344
- "**⚠️ Important Guidelines:**\n" +
345
- "- DO NOT call list_repositories unless user explicitly asks to choose from available repositories\n" +
346
- "- DO NOT call list_service_connections unless user explicitly asks to choose from available connections\n" +
347
- "- ALWAYS try IDE detection first before making any API calls\n" +
348
- "- If IDE detection fails, THEN consider API calls as fallback\n\n" +
349
- "**🎯 Parameter Priority:**\n" +
350
- "1. 👤 USER EXPLICIT (highest) - buildLanguage, buildTool, versions, deployTarget\n" +
351
- "2. 🔍 IDE DETECTION (preferred) - repoUrl, branch, serviceName, tech stack\n" +
352
- "3. 🤖 TOOL DEFAULTS (automatic) - serviceConnectionId, organizationId\n\n" +
353
- "**🔍 IDE Detection Rules (MUST TRY FIRST):**\n" +
354
- "- 📂 Repository: `git config --get remote.origin.url` → repoUrl\n" +
355
- "- 🌿 Branch: `git branch --show-current` → branch\n" +
356
- "- 🏷️ Service Name: Auto-extracted from repoUrl (git@host:org/repo.git → repo)\n" +
357
- "- ☕ Java Maven: pom.xml exists → buildLanguage='java', buildTool='maven'\n" +
358
- "- 🏗️ Java Gradle: build.gradle exists → buildLanguage='java', buildTool='gradle'\n" +
359
- "- 🟢 Node npm: package.json + package-lock.json → buildLanguage='nodejs', buildTool='npm'\n" +
360
- "- 🧶 Node yarn: package.json + yarn.lock → buildLanguage='nodejs', buildTool='yarn'\n" +
361
- "- 🐍 Python: requirements.txt → buildLanguage='python', buildTool='pip'\n" +
362
- "- 🐹 Go: go.mod → buildLanguage='go', buildTool='go'\n" +
363
- "- 💙 .NET: *.csproj → buildLanguage='dotnet', buildTool='dotnet'\n\n" +
364
- "**📝 Version Detection (from project files):**\n" +
365
- "- ☕ JDK: Read pom.xml <maven.compiler.source> → jdkVersion\n" +
366
- "- 🟢 Node: Read package.json engines.node → nodeVersion\n" +
367
- "- 🐍 Python: Read .python-version, pyproject.toml → pythonVersion\n" +
368
- "- 🐹 Go: Read go.mod go directive → goVersion\n\n" +
369
- "**🎯 Deployment Parsing:**\n" +
370
- "- '部署到主机/VM/虚拟机' → deployTarget='vm'\n" +
371
- "- '部署到Kubernetes/K8s' → deployTarget='k8s'\n" +
372
- "- '只构建/构建制品' → deployTarget='none'\n\n" +
373
- "**🔗 Service Connection Strategy (3 scenarios):**\n" +
374
- "1. **User specifies ID explicitly** (e.g., '使用服务连接ID abc123')\n" +
375
- " → ✅ Pass serviceConnectionId=abc123 directly, NO list_service_connections call needed\n" +
376
- "2. **User doesn't specify any ID** (most common case)\n" +
377
- " → ✅ Pass serviceConnectionId=null, tool will auto-retrieve default ID internally\n" +
378
- "3. **User wants to choose from available options** (e.g., '显示可用的服务连接让我选择')\n" +
379
- " → 🔍 Call list_service_connections first, then let user choose, then create pipeline\n\n" +
380
- "**🤔 When to Use Other Tools:**\n" +
381
- "- User asks to \"select from available repositories\" → use list_repositories first\n" +
382
- "- User wants to \"choose from service connections\" → use list_service_connections first\n" +
383
- "- User wants to see options before deciding → gather info first, then create\n" +
384
- "- For quick creation with current repo → directly use IDE detection\n\n" +
385
- "**✅ Required:** organizationId, name, buildLanguage, buildTool",
386
- inputSchema: zodToJsonSchema(types.CreatePipelineFromDescriptionSchema),
387
- },
388
- {
389
- name: "smart_list_pipelines",
390
- description: "[Pipeline Management] Intelligently search pipelines with natural language time references (e.g., 'today', 'this week')",
391
- inputSchema: zodToJsonSchema(z.object({
392
- organizationId: z.string().describe("Organization ID"),
393
- timeReference: z.string().optional().describe("Natural language time reference such as 'today', 'yesterday', 'this week', 'last month', etc."),
394
- pipelineName: z.string().optional().describe("Pipeline name filter"),
395
- statusList: z.string().optional().describe("Pipeline status list, comma separated (SUCCESS,RUNNING,FAIL,CANCELED,WAITING)"),
396
- perPage: z.number().int().min(1).max(30).default(10).optional().describe("Number of items per page"),
397
- page: z.number().int().min(1).default(1).optional().describe("Page number")
398
- })),
399
- },
400
- {
401
- name: "create_pipeline_run",
402
- description: "[Pipeline Management] Run a pipeline with optional parameters",
403
- inputSchema: zodToJsonSchema(types.CreatePipelineRunSchema),
404
- },
405
- {
406
- name: "get_latest_pipeline_run",
407
- description: "[Pipeline Management] Get information about the latest pipeline run",
408
- inputSchema: zodToJsonSchema(types.GetLatestPipelineRunSchema),
409
- },
410
- {
411
- name: "get_pipeline_run",
412
- description: "[Pipeline Management] Get details of a specific pipeline run instance",
413
- inputSchema: zodToJsonSchema(types.GetPipelineRunSchema),
414
- },
415
- {
416
- name: "list_pipeline_runs",
417
- description: "[Pipeline Management] Get a list of pipeline run instances with filtering options",
418
- inputSchema: zodToJsonSchema(types.ListPipelineRunsSchema),
419
- },
420
- {
421
- name: "list_pipeline_jobs_by_category",
422
- description: "[Pipeline Management] Get pipeline execution tasks by category. Currently only supports DEPLOY category.",
423
- inputSchema: zodToJsonSchema(types.ListPipelineJobsByCategorySchema),
424
- },
425
- {
426
- name: "list_pipeline_job_historys",
427
- description: "[Pipeline Management] Get the execution history of a pipeline task. Retrieve all execution records for a specific task in a pipeline.",
428
- inputSchema: zodToJsonSchema(types.ListPipelineJobHistorysSchema),
429
- },
430
- {
431
- name: "execute_pipeline_job_run",
432
- description: "[Pipeline Management] Manually run a pipeline task. Start a specific job in a pipeline run instance.",
433
- inputSchema: zodToJsonSchema(types.ExecutePipelineJobRunSchema),
434
- },
435
- {
436
- name: "get_pipeline_job_run_log",
437
- description: "[Pipeline Management] Get the execution logs of a pipeline job. Retrieve the log content for a specific job in a pipeline run.",
438
- inputSchema: zodToJsonSchema(types.GetPipelineJobRunLogSchema),
439
- },
440
- // Package Repository Operations
441
- {
442
- name: "list_package_repositories",
443
- description: "[Packages Management] List package repositories in an organization with filtering options",
444
- inputSchema: zodToJsonSchema(types.ListPackageRepositoriesSchema),
445
- },
446
- // Package Artifact Operations
447
- {
448
- name: "list_artifacts",
449
- description: "[Packages Management] List artifacts in a package repository with filtering options",
450
- inputSchema: zodToJsonSchema(types.ListArtifactsSchema),
451
- },
452
- {
453
- name: "get_artifact",
454
- description: "[Packages Management] Get information about a single artifact in a package repository",
455
- inputSchema: zodToJsonSchema(types.GetArtifactSchema),
456
- },
457
- // Service Connection Operations
458
- {
459
- name: "list_service_connections",
460
- description: "[Service Connection Management] List service connections in an organization with filtering options",
461
- inputSchema: zodToJsonSchema(types.ListServiceConnectionsSchema),
462
- }
463
- ],
464
- };
465
- });
466
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
467
- try {
468
- if (!request.params.arguments) {
469
- throw new Error("Arguments are required");
470
- }
471
- switch (request.params.name) {
472
- // Branch Operations
473
- case "create_branch": {
474
- const args = types.CreateBranchSchema.parse(request.params.arguments);
475
- const branch = await branches.createBranchFunc(args.organizationId, args.repositoryId, args.branch, args.ref);
476
- return {
477
- content: [{ type: "text", text: JSON.stringify(branch, null, 2) }],
478
- };
479
- }
480
- case "get_branch": {
481
- const args = types.GetBranchSchema.parse(request.params.arguments);
482
- const branch = await branches.getBranchFunc(args.organizationId, args.repositoryId, args.branchName);
483
- return {
484
- content: [{ type: "text", text: JSON.stringify(branch, null, 2) }],
485
- };
486
- }
487
- case "delete_branch": {
488
- const args = types.DeleteBranchSchema.parse(request.params.arguments);
489
- const result = await branches.deleteBranchFunc(args.organizationId, args.repositoryId, args.branchName);
490
- return {
491
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
492
- };
493
- }
494
- case "list_branches": {
495
- const args = types.ListBranchesSchema.parse(request.params.arguments);
496
- const branchList = await branches.listBranchesFunc(args.organizationId, args.repositoryId, args.page, args.perPage, args.sort, args.search ?? undefined);
497
- return {
498
- content: [{ type: "text", text: JSON.stringify(branchList, null, 2) }],
499
- };
500
- }
501
- // File Operations
502
- case "get_file_blobs": {
503
- const args = types.GetFileBlobsSchema.parse(request.params.arguments);
504
- const fileContent = await files.getFileBlobsFunc(args.organizationId, args.repositoryId, args.filePath, args.ref);
505
- return {
506
- content: [{ type: "text", text: JSON.stringify(fileContent, null, 2) }],
507
- };
508
- }
509
- case "create_file": {
510
- const args = types.CreateFileSchema.parse(request.params.arguments);
511
- const result = await files.createFileFunc(args.organizationId, args.repositoryId, args.filePath, args.content, args.commitMessage, args.branch, args.encoding);
512
- return {
513
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
514
- };
515
- }
516
- case "update_file": {
517
- const args = types.UpdateFileSchema.parse(request.params.arguments);
518
- const result = await files.updateFileFunc(args.organizationId, args.repositoryId, args.filePath, args.content, args.commitMessage, args.branch, args.encoding);
519
- return {
520
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
521
- };
522
- }
523
- case "delete_file": {
524
- const args = types.DeleteFileSchema.parse(request.params.arguments);
525
- const result = await files.deleteFileFunc(args.organizationId, args.repositoryId, args.filePath, args.commitMessage, args.branch);
526
- return {
527
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
528
- };
529
- }
530
- case "list_files": {
531
- const args = types.ListFilesSchema.parse(request.params.arguments);
532
- const fileList = await files.listFilesFunc(args.organizationId, args.repositoryId, args.path, args.ref, args.type);
533
- return {
534
- content: [{ type: "text", text: JSON.stringify(fileList, null, 2) }],
535
- };
536
- }
537
- case "compare": {
538
- const args = types.GetCompareSchema.parse(request.params.arguments);
539
- const compareResult = await compare.getCompareFunc(args.organizationId, args.repositoryId, args.from, args.to, args.sourceType ?? undefined, args.targetType ?? undefined, args.straight ?? undefined);
540
- return {
541
- content: [{ type: "text", text: JSON.stringify(compareResult, null, 2) }],
542
- };
543
- }
544
- // Repository Operations
545
- case "get_repository": {
546
- const args = types.GetRepositorySchema.parse(request.params.arguments);
547
- const repository = await repositories.getRepositoryFunc(args.organizationId, args.repositoryId);
548
- return {
549
- content: [{ type: "text", text: JSON.stringify(repository, null, 2) }],
550
- };
551
- }
552
- case "list_repositories": {
553
- const args = types.ListRepositoriesSchema.parse(request.params.arguments);
554
- const repositoryList = await repositories.listRepositoriesFunc(args.organizationId, args.page, args.perPage, args.orderBy, args.sort, args.search ?? undefined, args.archived);
555
- return {
556
- content: [{ type: "text", text: JSON.stringify(repositoryList, null, 2) }],
557
- };
558
- }
559
- // Change Request Operations
560
- case "get_change_request": {
561
- const args = types.GetChangeRequestSchema.parse(request.params.arguments);
562
- const changeRequest = await changeRequests.getChangeRequestFunc(args.organizationId, args.repositoryId, args.localId);
563
- return {
564
- content: [{ type: "text", text: JSON.stringify(changeRequest, null, 2) }],
565
- };
566
- }
567
- case "list_change_requests": {
568
- const args = types.ListChangeRequestsSchema.parse(request.params.arguments);
569
- const changeRequestList = await changeRequests.listChangeRequestsFunc(args.organizationId, args.page, args.perPage, args.projectIds ?? undefined, args.authorIds ?? undefined, args.reviewerIds ?? undefined, args.state ?? undefined, args.search ?? undefined, args.orderBy, args.sort, args.createdBefore ?? undefined, args.createdAfter ?? undefined);
570
- return {
571
- content: [{ type: "text", text: JSON.stringify(changeRequestList, null, 2) }],
572
- };
573
- }
574
- case "create_change_request": {
575
- const args = types.CreateChangeRequestSchema.parse(request.params.arguments);
576
- const changeRequest = await changeRequests.createChangeRequestFunc(args.organizationId, args.repositoryId, args.title, args.sourceBranch, args.targetBranch, args.description ?? undefined, args.sourceProjectId, args.targetProjectId, args.reviewerUserIds ?? undefined, args.workItemIds ?? undefined, args.createFrom);
577
- return {
578
- content: [{ type: "text", text: JSON.stringify(changeRequest, null, 2) }],
579
- };
580
- }
581
- case "create_change_request_comment": {
582
- const args = types.CreateChangeRequestCommentSchema.parse(request.params.arguments);
583
- const comment = await changeRequestComments.createChangeRequestCommentFunc(args.organizationId, args.repositoryId, args.localId, args.comment_type, args.content, args.draft, args.resolved, args.patchset_biz_id, args.file_path ?? undefined, args.line_number ?? undefined, args.from_patchset_biz_id ?? undefined, args.to_patchset_biz_id ?? undefined, args.parent_comment_biz_id ?? undefined);
584
- return {
585
- content: [{ type: "text", text: JSON.stringify(comment, null, 2) }],
586
- };
587
- }
588
- case "list_change_request_comments": {
589
- const args = types.ListChangeRequestCommentsSchema.parse(request.params.arguments);
590
- const comments = await changeRequestComments.listChangeRequestCommentsFunc(args.organizationId, args.repositoryId, args.localId, args.patchSetBizIds ?? undefined, args.commentType, args.state, args.resolved, args.filePath ?? undefined);
591
- return {
592
- content: [{ type: "text", text: JSON.stringify(comments, null, 2) }],
593
- };
594
- }
595
- case "list_change_request_patch_sets": {
596
- const args = types.ListChangeRequestPatchSetsSchema.parse(request.params.arguments);
597
- const patchSets = await changeRequests.listChangeRequestPatchSetsFunc(args.organizationId, args.repositoryId, args.localId);
598
- return {
599
- content: [{ type: "text", text: JSON.stringify(patchSets, null, 2) }],
600
- };
601
- }
602
- // Organization Operations
603
- case "get_current_organization_info": {
604
- const currentOrgInfo = await organization.getCurrentOrganizationInfoFunc();
605
- return {
606
- content: [{ type: "text", text: JSON.stringify(currentOrgInfo, null, 2) }],
607
- };
608
- }
609
- case "get_user_organizations": {
610
- const userOrgs = await organization.getUserOrganizationsFunc();
611
- return {
612
- content: [{ type: "text", text: JSON.stringify(userOrgs, null, 2) }],
613
- };
614
- }
615
- case "get_current_user": {
616
- const currentUserInfo = await organization.getCurrentUserFunc();
617
- return {
618
- content: [{ type: "text", text: JSON.stringify(currentUserInfo, null, 2) }],
619
- };
620
- }
621
- case "get_organization_departments": {
622
- const args = types.GetOrganizationDepartmentsSchema.parse(request.params.arguments);
623
- const departments = await organization.getOrganizationDepartmentsFunc(args.organizationId, args.parentId ?? undefined);
624
- return {
625
- content: [{ type: "text", text: JSON.stringify(departments, null, 2) }],
626
- };
627
- }
628
- case "get_organization_department_info": {
629
- const args = types.GetOrganizationDepartmentInfoSchema.parse(request.params.arguments);
630
- const departmentInfo = await organization.getOrganizationDepartmentInfoFunc(args.organizationId, args.id);
631
- return {
632
- content: [{ type: "text", text: JSON.stringify(departmentInfo, null, 2) }],
633
- };
634
- }
635
- case "get_organization_department_ancestors": {
636
- const args = types.GetOrganizationDepartmentAncestorsSchema.parse(request.params.arguments);
637
- const ancestors = await organization.getOrganizationDepartmentAncestorsFunc(args.organizationId, args.id);
638
- return {
639
- content: [{ type: "text", text: JSON.stringify(ancestors, null, 2) }],
640
- };
641
- }
642
- case "get_organization_members": {
643
- const args = types.GetOrganizationMembersSchema.parse(request.params.arguments);
644
- const orgMembers = await members.getOrganizationMembersFunc(args.organizationId, args.page ?? 1, args.perPage ?? 100);
645
- return {
646
- content: [{ type: "text", text: JSON.stringify(orgMembers, null, 2) }]
647
- };
648
- }
649
- case "get_organization_member_info": {
650
- const args = types.GetOrganizationMemberInfoSchema.parse(request.params.arguments);
651
- const memberInfo = await members.getOrganizationMemberInfoFunc(args.organizationId, args.memberId);
652
- return {
653
- content: [{ type: "text", text: JSON.stringify(memberInfo, null, 2) }]
654
- };
655
- }
656
- case "get_organization_member_info_by_user_id": {
657
- const args = types.GetOrganizationMemberByUserIdInfoSchema.parse(request.params.arguments);
658
- const memberInfo = await members.getOrganizationMemberByUserIdInfoFunc(args.organizationId, args.userId);
659
- return {
660
- content: [{ type: "text", text: JSON.stringify(memberInfo, null, 2) }]
661
- };
662
- }
663
- case "search_organization_members": {
664
- const args = types.SearchOrganizationMembersSchema.parse(request.params.arguments);
665
- const membersResult = await members.searchOrganizationMembersFunc(args.organizationId, args.includeChildren ?? false, args.page ?? 1, args.perPage ?? 100, args.deptIds ?? undefined, args.nextToken ?? undefined, args.query ?? undefined, args.roleIds ?? undefined, args.statuses ?? undefined);
666
- return {
667
- content: [{ type: "text", text: JSON.stringify(membersResult, null, 2) }]
668
- };
669
- }
670
- case "list_organization_roles": {
671
- const args = types.ListOrganizationRolesSchema.parse(request.params.arguments);
672
- const roles = await organization.listOrganizationRolesFunc(args.organizationId);
673
- return {
674
- content: [{ type: "text", text: JSON.stringify(roles, null, 2) }]
675
- };
676
- }
677
- case "get_organization_role": {
678
- const args = types.GetOrganizationRoleSchema.parse(request.params.arguments);
679
- const role = await organization.getOrganizationRoleFunc(args.organizationId, args.roleId);
680
- return {
681
- content: [{ type: "text", text: JSON.stringify(role, null, 2) }]
682
- };
683
- }
684
- // Project Operations
685
- case "get_project": {
686
- const args = types.GetProjectSchema.parse(request.params.arguments);
687
- const projectInfo = await project.getProjectFunc(args.organizationId, args.id);
688
- return {
689
- content: [{ type: "text", text: JSON.stringify(projectInfo, null, 2) }],
690
- };
691
- }
692
- case "search_projects": {
693
- const args = types.SearchProjectsSchema.parse(request.params.arguments);
694
- const projects = await project.searchProjectsFunc(args.organizationId, args.name ?? undefined, args.status ?? undefined, args.createdAfter ?? undefined, args.createdBefore ?? undefined, args.creator ?? undefined, args.adminUserId ?? undefined, args.logicalStatus ?? undefined, args.advancedConditions ?? undefined, args.extraConditions ?? undefined, args.orderBy, args.page, args.perPage, args.sort, args.scenarioFilter ?? undefined, args.userId ?? undefined);
695
- return {
696
- content: [{ type: "text", text: JSON.stringify(projects, null, 2) }],
697
- };
698
- }
699
- // Sprint Operations
700
- // case "get_sprint": {
701
- // const args = sprint.GetSprintSchema.parse(request.params.arguments);
702
- // const sprintInfo = await sprint.getSprintFunc(
703
- // args.organizationId,
704
- // args.projectId,
705
- // args.id
706
- // );
707
- // return {
708
- // content: [{ type: "text", text: JSON.stringify(sprintInfo, null, 2) }],
709
- // };
710
- // }
711
- // case "list_sprints": {
712
- // const args = sprint.ListSprintsSchema.parse(request.params.arguments);
713
- // const sprints = await sprint.listSprintsFunc(
714
- // args.organizationId,
715
- // args.id,
716
- // args.status,
717
- // args.page,
718
- // args.perPage
719
- // );
720
- // return {
721
- // content: [{ type: "text", text: JSON.stringify(sprints, null, 2) }],
722
- // };
723
- // }
724
- // Work Item Operations
725
- case "get_work_item": {
726
- const args = types.GetWorkItemSchema.parse(request.params.arguments);
727
- const workItemInfo = await workitem.getWorkItemFunc(args.organizationId, args.workItemId);
728
- return {
729
- content: [{ type: "text", text: JSON.stringify(workItemInfo, null, 2) }],
730
- };
731
- }
732
- case "create_work_item": {
733
- const args = types.CreateWorkItemSchema.parse(request.params.arguments);
734
- const workItemInfo = await workitem.createWorkItemFunc(args.organizationId, args.assignedTo, args.spaceId, args.subject, args.workitemTypeId, args.customFieldValues, args.description, args.labels, args.parentId, args.participants, args.sprint, args.trackers, args.verifier, args.versions);
735
- return {
736
- content: [{ type: "text", text: JSON.stringify(workItemInfo, null, 2) }],
737
- };
738
- }
739
- case "search_workitems": {
740
- const args = types.SearchWorkitemsSchema.parse(request.params.arguments);
741
- const workItems = await workitem.searchWorkitemsFunc(args.organizationId, args.category, args.spaceId, args.subject ?? undefined, args.status ?? undefined, args.createdAfter ?? undefined, args.createdBefore ?? undefined, args.updatedAfter ?? undefined, args.updatedBefore ?? undefined, args.creator ?? undefined, args.assignedTo ?? undefined, args.advancedConditions ?? undefined, args.orderBy ?? "gmtCreate", args.includeDetails ?? false);
742
- return {
743
- content: [{ type: "text", text: JSON.stringify(workItems, null, 2) }],
744
- };
745
- }
746
- case "get_work_item_types": {
747
- const args = z.object({
748
- organizationId: z.string().describe("organization id"),
749
- id: z.string().describe("project id or space id"),
750
- category: z.string().describe("Req、Task、Bug etc.")
751
- }).parse(request.params.arguments);
752
- const workItemTypes = await workitem.getWorkItemTypesFunc(args.organizationId, args.id, args.category);
753
- return {
754
- content: [{ type: "text", text: JSON.stringify(workItemTypes, null, 2) }],
755
- };
756
- }
757
- // Pipeline Operations
758
- case "get_pipeline": {
759
- const args = types.GetPipelineSchema.parse(request.params.arguments);
760
- const pipelineInfo = await pipeline.getPipelineFunc(args.organizationId, args.pipelineId);
761
- return {
762
- content: [{ type: "text", text: JSON.stringify(pipelineInfo, null, 2) }],
763
- };
764
- }
765
- case "list_pipelines": {
766
- const args = types.ListPipelinesSchema.parse(request.params.arguments);
767
- const pipelines = await pipeline.listPipelinesFunc(args.organizationId, {
768
- createStartTime: args.createStartTime,
769
- createEndTime: args.createEndTime,
770
- executeStartTime: args.executeStartTime,
771
- executeEndTime: args.executeEndTime,
772
- pipelineName: args.pipelineName,
773
- statusList: args.statusList,
774
- perPage: args.perPage,
775
- page: args.page
776
- });
777
- return {
778
- content: [{ type: "text", text: JSON.stringify(pipelines, null, 2) }],
779
- };
780
- }
781
- case "generate_pipeline_yaml": {
782
- try {
783
- const args = types.CreatePipelineFromDescriptionSchema.parse(request.params.arguments);
784
- // 检查必需的参数
785
- if (!args.buildLanguage) {
786
- throw new Error("The build language parameter is missing.");
787
- }
788
- if (!args.buildTool) {
789
- throw new Error("The build tool parameter is missing.");
790
- }
791
- const yamlContent = await pipeline.generatePipelineYamlFunc({
792
- buildLanguage: args.buildLanguage,
793
- buildTool: args.buildTool,
794
- deployTarget: args.deployTarget,
795
- // Repository configuration
796
- repoUrl: args.repoUrl,
797
- branch: args.branch,
798
- serviceName: args.serviceName,
799
- serviceConnectionId: args.serviceConnectionId,
800
- // Version configuration
801
- jdkVersion: args.jdkVersion,
802
- mavenVersion: args.mavenVersion,
803
- nodeVersion: args.nodeVersion,
804
- pythonVersion: args.pythonVersion,
805
- goVersion: args.goVersion,
806
- // Build configuration
807
- buildCommand: args.buildCommand,
808
- testCommand: args.testCommand,
809
- // Artifact upload configuration
810
- uploadType: args.uploadType,
811
- packagesServiceConnection: args.packagesServiceConnection,
812
- artifactName: args.artifactName,
813
- artifactVersion: args.artifactVersion,
814
- packagesRepoId: args.packagesRepoId,
815
- includePathInArtifact: args.includePathInArtifact,
816
- // VM deployment configuration
817
- machineGroupId: args.machineGroupId,
818
- executeUser: args.executeUser,
819
- artifactDownloadPath: args.artifactDownloadPath,
820
- deployCommand: args.deployCommand,
821
- pauseStrategy: args.pauseStrategy,
822
- batchNumber: args.batchNumber,
823
- // Kubernetes deployment configuration
824
- kubernetesClusterId: args.kubernetesClusterId,
825
- kubectlVersion: args.kubectlVersion,
826
- namespace: args.namespace,
827
- yamlPath: args.yamlPath,
828
- dockerImage: args.dockerImage,
829
- });
830
- return {
831
- content: [{ type: "text", text: yamlContent }],
832
- };
833
- }
834
- catch (error) {
835
- if (error instanceof Error && error.message.includes("build language parameter is missing")) {
836
- throw error; // 重新抛出我们自定义的错误
837
- }
838
- if (error instanceof Error && error.message.includes("build tool parameter is missing")) {
839
- throw error; // 重新抛出我们自定义的错误
840
- }
841
- // 处理YAML生成过程中的错误
842
- if (error instanceof Error) {
843
- throw new Error(`YAML generation failed: ${error.message}`);
844
- }
845
- throw error;
846
- }
847
- }
848
- case "create_pipeline_from_description": {
849
- try {
850
- const args = types.CreatePipelineFromDescriptionSchema.parse(request.params.arguments);
851
- // 检查必需的参数
852
- if (!args.name) {
853
- throw new Error("The Pipeline name cannot be empty.");
854
- }
855
- if (!args.buildLanguage) {
856
- throw new Error("The build language parameter is missing.");
857
- }
858
- if (!args.buildTool) {
859
- throw new Error("The build tool parameter is missing.");
860
- }
861
- const result = await pipeline.createPipelineWithOptionsFunc(args.organizationId, {
862
- name: args.name,
863
- repoUrl: args.repoUrl,
864
- branch: args.branch,
865
- serviceConnectionId: args.serviceConnectionId,
866
- // 技术栈参数
867
- buildLanguage: args.buildLanguage,
868
- buildTool: args.buildTool,
869
- deployTarget: args.deployTarget,
870
- // 版本相关参数
871
- jdkVersion: args.jdkVersion,
872
- mavenVersion: args.mavenVersion,
873
- nodeVersion: args.nodeVersion,
874
- pythonVersion: args.pythonVersion,
875
- goVersion: args.goVersion,
876
- kubectlVersion: args.kubectlVersion,
877
- // 构建物上传相关参数
878
- uploadType: args.uploadType,
879
- artifactName: args.artifactName,
880
- artifactVersion: args.artifactVersion,
881
- packagesServiceConnection: args.packagesServiceConnection,
882
- packagesRepoId: args.packagesRepoId,
883
- includePathInArtifact: args.includePathInArtifact,
884
- // 部署相关参数
885
- executeUser: args.executeUser,
886
- artifactDownloadPath: args.artifactDownloadPath,
887
- machineGroupId: args.machineGroupId,
888
- pauseStrategy: args.pauseStrategy,
889
- batchNumber: args.batchNumber,
890
- kubernetesClusterId: args.kubernetesClusterId,
891
- yamlPath: args.yamlPath,
892
- namespace: args.namespace,
893
- dockerImage: args.dockerImage,
894
- // 自定义命令
895
- buildCommand: args.buildCommand,
896
- testCommand: args.testCommand,
897
- deployCommand: args.deployCommand,
898
- });
899
- return {
900
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
901
- };
902
- }
903
- catch (error) {
904
- if (error instanceof Error && error.message.includes("Pipeline name cannot be empty")) {
905
- throw error;
906
- }
907
- if (error instanceof Error && error.message.includes("build language parameter is missing")) {
908
- throw error;
909
- }
910
- if (error instanceof Error && error.message.includes("build language tool is missing")) {
911
- throw error;
912
- }
913
- // 处理流水线创建过程中的其他错误
914
- if (error instanceof Error) {
915
- throw new Error(`Create pipeline failed: ${error.message}\n Suggestion: Please check whether the organization ID, repository configuration, or other parameters are correct, and if generated YAML to check whether YAML content is invalid.`);
916
- }
917
- throw error;
918
- }
919
- }
920
- case "smart_list_pipelines": {
921
- // Parse arguments using the schema defined in the tool registration
922
- const args = z.object({
923
- organizationId: z.string(),
924
- timeReference: z.string().optional(),
925
- pipelineName: z.string().optional(),
926
- statusList: z.string().optional(),
927
- perPage: z.number().int().optional(),
928
- page: z.number().int().optional()
929
- }).parse(request.params.arguments);
930
- // Call the smart list function
931
- const pipelines = await pipeline.smartListPipelinesFunc(args.organizationId, args.timeReference, {
932
- pipelineName: args.pipelineName,
933
- statusList: args.statusList,
934
- perPage: args.perPage,
935
- page: args.page
936
- });
937
- return {
938
- content: [{ type: "text", text: JSON.stringify(pipelines, null, 2) }],
939
- };
940
- }
941
- case "create_pipeline_run": {
942
- const args = types.CreatePipelineRunSchema.parse(request.params.arguments);
943
- const runId = await pipeline.createPipelineRunFunc(args.organizationId, args.pipelineId, {
944
- params: args.params,
945
- description: args.description,
946
- branches: args.branches,
947
- branchMode: args.branchMode,
948
- releaseBranch: args.releaseBranch,
949
- createReleaseBranch: args.createReleaseBranch,
950
- environmentVariables: args.environmentVariables,
951
- repositories: args.repositories
952
- });
953
- return {
954
- content: [{ type: "text", text: JSON.stringify(runId, null, 2) }],
955
- };
956
- }
957
- case "get_latest_pipeline_run": {
958
- const args = types.GetLatestPipelineRunSchema.parse(request.params.arguments);
959
- const pipelineRun = await pipeline.getLatestPipelineRunFunc(args.organizationId, args.pipelineId);
960
- return {
961
- content: [{ type: "text", text: JSON.stringify(pipelineRun, null, 2) }],
962
- };
963
- }
964
- case "get_pipeline_run": {
965
- const args = types.GetPipelineRunSchema.parse(request.params.arguments);
966
- const pipelineRun = await pipeline.getPipelineRunFunc(args.organizationId, args.pipelineId, args.pipelineRunId);
967
- return {
968
- content: [{ type: "text", text: JSON.stringify(pipelineRun, null, 2) }],
969
- };
970
- }
971
- case "list_pipeline_runs": {
972
- const args = types.ListPipelineRunsSchema.parse(request.params.arguments);
973
- const pipelineRuns = await pipeline.listPipelineRunsFunc(args.organizationId, args.pipelineId, {
974
- perPage: args.perPage,
975
- page: args.page,
976
- startTime: args.startTime,
977
- endTime: args.endTime,
978
- status: args.status,
979
- triggerMode: args.triggerMode
980
- });
981
- return {
982
- content: [{ type: "text", text: JSON.stringify(pipelineRuns, null, 2) }],
983
- };
984
- }
985
- case "list_pipeline_jobs_by_category": {
986
- const args = types.ListPipelineJobsByCategorySchema.parse(request.params.arguments);
987
- const jobs = await pipelineJob.listPipelineJobsByCategoryFunc(args.organizationId, args.pipelineId, args.category);
988
- return {
989
- content: [{ type: "text", text: JSON.stringify(jobs, null, 2) }],
990
- };
991
- }
992
- case "list_pipeline_job_historys": {
993
- const args = types.ListPipelineJobHistorysSchema.parse(request.params.arguments);
994
- const jobHistorys = await pipelineJob.listPipelineJobHistorysFunc(args.organizationId, args.pipelineId, args.category, args.identifier, args.page, args.perPage);
995
- return {
996
- content: [{ type: "text", text: JSON.stringify(jobHistorys, null, 2) }],
997
- };
998
- }
999
- case "execute_pipeline_job_run": {
1000
- const args = types.ExecutePipelineJobRunSchema.parse(request.params.arguments);
1001
- const result = await pipelineJob.executePipelineJobRunFunc(args.organizationId, args.pipelineId, args.pipelineRunId, args.jobId);
1002
- return {
1003
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
1004
- };
1005
- }
1006
- case "get_pipeline_job_run_log": {
1007
- const args = types.GetPipelineJobRunLogSchema.parse(request.params.arguments);
1008
- const log = await pipelineJob.getPipelineJobRunLogFunc(args.organizationId, args.pipelineId, args.pipelineRunId, args.jobId);
1009
- return {
1010
- content: [{ type: "text", text: JSON.stringify(log, null, 2) }],
1011
- };
1012
- }
1013
- // Package Repository Operations
1014
- case "list_package_repositories": {
1015
- const args = types.ListPackageRepositoriesSchema.parse(request.params.arguments);
1016
- const packageRepoList = await packageRepositories.listPackageRepositoriesFunc(args.organizationId, args.repoTypes ?? undefined, args.repoCategories ?? undefined, args.perPage, args.page);
1017
- return {
1018
- content: [{ type: "text", text: JSON.stringify(packageRepoList, null, 2) }],
1019
- };
1020
- }
1021
- // Package Artifact Operations
1022
- case "list_artifacts": {
1023
- const args = types.ListArtifactsSchema.parse(request.params.arguments);
1024
- const artifactsList = await artifacts.listArtifactsFunc(args.organizationId, args.repoId, args.repoType, args.page, args.perPage, args.search ?? undefined, args.orderBy, args.sort);
1025
- return {
1026
- content: [{ type: "text", text: JSON.stringify(artifactsList, null, 2) }],
1027
- };
1028
- }
1029
- case "get_artifact": {
1030
- const args = types.GetArtifactSchema.parse(request.params.arguments);
1031
- const artifact = await artifacts.getArtifactFunc(args.organizationId, args.repoId, args.id, args.repoType);
1032
- return {
1033
- content: [{ type: "text", text: JSON.stringify(artifact, null, 2) }],
1034
- };
1035
- }
1036
- // Service Connection Operations
1037
- case "list_service_connections": {
1038
- const args = types.ListServiceConnectionsSchema.parse(request.params.arguments);
1039
- const serviceConnections = await serviceConnection.listServiceConnectionsFunc(args.organizationId, args.serviceConnectionType);
1040
- return {
1041
- content: [{ type: "text", text: JSON.stringify(serviceConnections, null, 2) }],
1042
- };
1043
- }
1044
- default:
1045
- throw new Error(`Unknown tool: ${request.params.name}`);
1046
- }
1047
- }
1048
- catch (error) {
1049
- if (error instanceof z.ZodError) {
1050
- throw new Error(`Invalid input: ${JSON.stringify(error.errors)}`);
1051
- }
1052
- if (isYunxiaoError(error)) {
1053
- throw new Error(formatYunxiaoError(error));
1054
- }
1055
- throw error;
1056
- }
1057
- });
1058
- config();
1059
- async function runServer() {
1060
- const transport = new StdioServerTransport();
1061
- await server.connect(transport);
1062
- console.error("Yunxiao MCP Server running on stdio");
1063
- }
1064
- runServer().catch((error) => {
1065
- console.error("Fatal error in main():", error);
1066
- process.exit(1);
1067
- });