@cnbcool/mcp-server 0.5.1 → 0.6.1

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 (32) hide show
  1. package/README.md +7 -0
  2. package/README_zh.md +7 -0
  3. package/dist/api/build/build-logs-delete.js +39 -0
  4. package/dist/api/build/build-runner-download-log.js +39 -0
  5. package/dist/api/build/get-build-logs.js +40 -0
  6. package/dist/api/build/get-build-stage.js +39 -0
  7. package/dist/api/build/get-build-status.js +39 -0
  8. package/dist/api/build/start-build.js +41 -0
  9. package/dist/api/build/stop-build.js +39 -0
  10. package/dist/api/interfaces/die.weberror.js +15 -0
  11. package/dist/api/interfaces/dto.buildlogsdeleteresult.js +15 -0
  12. package/dist/api/interfaces/dto.buildlogsresult.js +15 -0
  13. package/dist/api/interfaces/dto.buildresult.js +15 -0
  14. package/dist/api/interfaces/dto.buildstageresult.js +15 -0
  15. package/dist/api/interfaces/dto.buildstatusresult.js +15 -0
  16. package/dist/api/interfaces/dto.startbuildreq.js +15 -0
  17. package/dist/constants/header.js +8 -0
  18. package/dist/constants/toolDescriptions.js +8 -0
  19. package/dist/constants/toolNames.js +8 -0
  20. package/dist/helpers/checkRepoVisibility.js +1 -1
  21. package/dist/helpers/createTransport.js +0 -1
  22. package/dist/helpers/getToken.js +13 -0
  23. package/dist/helpers/request/cnb/index.js +121 -0
  24. package/dist/helpers/request/cnb/types.js +2 -0
  25. package/dist/helpers/request/index.js +21 -0
  26. package/dist/helpers/request/types.js +2 -0
  27. package/dist/middlewares/logMiddleware.js +49 -0
  28. package/dist/streamable.js +2 -0
  29. package/dist/tools/buildTools.js +158 -0
  30. package/dist/tools/index.js +7 -1
  31. package/dist/tools/repoTools.js +2 -2
  32. package/package.json +20 -17
package/README.md CHANGED
@@ -34,6 +34,13 @@ CNB(https://cnb.cool) toolkits for LLMs supporting the MCP protocol
34
34
  | cnb_merge_pull | Merge a merge request specified on the CNB platform |
35
35
  | cnb_list_pull_comments | Get a list of comments for a merge request specified on the CNB platform |
36
36
  | cnb_create_pull_comment | Create a new comment on a merge request specified on the CNB platform |
37
+ | cnb_buildLogsDelete | Delete pipeline or cloud-native build log content |
38
+ | cnb_buildRunnerDownloadLog | Download pipeline or cloud-native build runner logs |
39
+ | cnb_getBuildLogs | Query pipeline or cloud-native build list |
40
+ | cnb_getBuildStage | Query pipeline or cloud-native build stage details |
41
+ | cnb_getBuildStatus | Query pipeline or cloud-native build status |
42
+ | cnb_startBuild | Start a build |
43
+ | cnb_stopBuild | Stop a build |
37
44
  | cnb_list_workspaces | Get a list of the current user's cloud-native development environments on the CNB platform |
38
45
  | cnb_delete_workspace | Delete a specified cloud-native development environment on the CNB platform |
39
46
 
package/README_zh.md CHANGED
@@ -34,6 +34,13 @@ CNB(https://cnb.cool) 支持 MCP 协议的 MCP Server
34
34
  | cnb_merge_pull | 合并CNB平台指定的合并请求 |
35
35
  | cnb_list_pull_comments | 获取CNB平台指定合并请求的评论列表 |
36
36
  | cnb_create_pull_comment | 在CNB平台指定的合并请求创建一条新评论 |
37
+ | cnb_buildLogsDelete | 删除流水线或云原生构建日志内容 |
38
+ | cnb_buildRunnerDownloadLog | 流水线或云原生构建runner日志下载 |
39
+ | cnb_getBuildLogs | 查询流水线或云原生构建构建列表 |
40
+ | cnb_getBuildStage | 查询流水线或云原生构建Stage详情 |
41
+ | cnb_getBuildStatus | 查询流水线或云原生构建构建状态 |
42
+ | cnb_startBuild | 开始一个构建 |
43
+ | cnb_stopBuild | 停止一个构建 |
37
44
  | cnb_list_workspaces | 获取当前用户在CNB平台的云原生开发环境列表 |
38
45
  | cnb_delete_workspace | 在CNB平台删除指定的云原生开发环境 |
39
46
 
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /*
6
+ * -------------------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA CNB-API-GENERATE ##
8
+ * -------------------------------------------------------------------------
9
+ * @Version 1.5.0
10
+ * @Source /{repo}/-/build/logs/{sn}
11
+ */
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.buildLogsDelete = buildLogsDelete;
17
+ const request_1 = __importDefault(require("../../helpers/request"));
18
+ /**
19
+ * @description 访问令牌调用此接口需包含以下权限。Required permissions for access token.
20
+ * repo-cnb-trigger:rw
21
+ * @tags Build
22
+ * @name buildLogsDelete
23
+ * @summary 删除流水线日志内容。Delete pipeline logs content.
24
+ * @request delete:/{repo}/-/build/logs/{sn}
25
+
26
+ ----------------------------------
27
+ * @param {BuildLogsDeleteParams} arg0 - buildLogsDelete request params
28
+ * @param {RequestConfig} arg1 - Other reuqest params
29
+ */
30
+ async function buildLogsDelete({ repo, sn }, { req, options, ...axiosConfig } = {}) {
31
+ return await request_1.default.request({
32
+ ...axiosConfig,
33
+ _next_req: req,
34
+ options: options,
35
+ url: `/${repo}/-/build/logs/${sn}`,
36
+ _apiTag: '/{repo}/-/build/logs/{sn}',
37
+ method: 'delete'
38
+ });
39
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /*
6
+ * -------------------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA CNB-API-GENERATE ##
8
+ * -------------------------------------------------------------------------
9
+ * @Version 1.5.0
10
+ * @Source /{repo}/-/build/runner/download/log/{pipelineId}
11
+ */
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.buildRunnerDownloadLog = buildRunnerDownloadLog;
17
+ const request_1 = __importDefault(require("../../helpers/request"));
18
+ /**
19
+ * @description 访问令牌调用此接口需包含以下权限。Required permissions for access token.
20
+ * repo-cnb-trigger:r
21
+ * @tags Build
22
+ * @name buildRunnerDownloadLog
23
+ * @summary 流水线runner日志下载。Pipeline runner log download.
24
+ * @request get:/{repo}/-/build/runner/download/log/{pipelineId}
25
+
26
+ ----------------------------------
27
+ * @param {BuildRunnerDownloadLogParams} arg0 - buildRunnerDownloadLog request params
28
+ * @param {RequestConfig} arg1 - Other reuqest params
29
+ */
30
+ async function buildRunnerDownloadLog({ repo, pipelineId }, { req, options, ...axiosConfig } = {}) {
31
+ return await request_1.default.request({
32
+ ...axiosConfig,
33
+ _next_req: req,
34
+ options: options,
35
+ url: `/${repo}/-/build/runner/download/log/${pipelineId}`,
36
+ _apiTag: '/{repo}/-/build/runner/download/log/{pipelineId}',
37
+ method: 'get'
38
+ });
39
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /*
6
+ * -------------------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA CNB-API-GENERATE ##
8
+ * -------------------------------------------------------------------------
9
+ * @Version 1.5.0
10
+ * @Source /{repo}/-/build/logs
11
+ */
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.getBuildLogs = getBuildLogs;
17
+ const request_1 = __importDefault(require("../../helpers/request"));
18
+ /**
19
+ * @description 访问令牌调用此接口需包含以下权限。Required permissions for access token.
20
+ * repo-cnb-trigger:r
21
+ * @tags Build
22
+ * @name getBuildLogs
23
+ * @summary 查询流水线构建列表。List pipeline builds.
24
+ * @request get:/{repo}/-/build/logs
25
+
26
+ ----------------------------------
27
+ * @param {GetBuildLogsParams} arg0 - getBuildLogs request params
28
+ * @param {RequestConfig} arg1 - Other reuqest params
29
+ */
30
+ async function getBuildLogs({ repo, ...query }, { req, options, ...axiosConfig } = {}) {
31
+ return await request_1.default.request({
32
+ ...axiosConfig,
33
+ _next_req: req,
34
+ options: options,
35
+ url: `/${repo}/-/build/logs`,
36
+ _apiTag: '/{repo}/-/build/logs',
37
+ method: 'get',
38
+ params: query
39
+ });
40
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /*
6
+ * -------------------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA CNB-API-GENERATE ##
8
+ * -------------------------------------------------------------------------
9
+ * @Version 1.5.0
10
+ * @Source /{repo}/-/build/logs/stage/{sn}/{pipelineId}/{stageId}
11
+ */
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.getBuildStage = getBuildStage;
17
+ const request_1 = __importDefault(require("../../helpers/request"));
18
+ /**
19
+ * @description 访问令牌调用此接口需包含以下权限。Required permissions for access token.
20
+ * repo-cnb-trigger:r
21
+ * @tags Build
22
+ * @name getBuildStage
23
+ * @summary 查询流水线Stage详情。Get pipeline build stage detail.
24
+ * @request get:/{repo}/-/build/logs/stage/{sn}/{pipelineId}/{stageId}
25
+
26
+ ----------------------------------
27
+ * @param {GetBuildStageParams} arg0 - getBuildStage request params
28
+ * @param {RequestConfig} arg1 - Other reuqest params
29
+ */
30
+ async function getBuildStage({ repo, sn, pipelineId, stageId }, { req, options, ...axiosConfig } = {}) {
31
+ return await request_1.default.request({
32
+ ...axiosConfig,
33
+ _next_req: req,
34
+ options: options,
35
+ url: `/${repo}/-/build/logs/stage/${sn}/${pipelineId}/${stageId}`,
36
+ _apiTag: '/{repo}/-/build/logs/stage/{sn}/{pipelineId}/{stageId}',
37
+ method: 'get'
38
+ });
39
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /*
6
+ * -------------------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA CNB-API-GENERATE ##
8
+ * -------------------------------------------------------------------------
9
+ * @Version 1.5.0
10
+ * @Source /{repo}/-/build/status/{sn}
11
+ */
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.getBuildStatus = getBuildStatus;
17
+ const request_1 = __importDefault(require("../../helpers/request"));
18
+ /**
19
+ * @description 访问令牌调用此接口需包含以下权限。Required permissions for access token.
20
+ * repo-cnb-trigger:r
21
+ * @tags Build
22
+ * @name getBuildStatus
23
+ * @summary 查询流水线构建状态。Get pipeline build status.
24
+ * @request get:/{repo}/-/build/status/{sn}
25
+
26
+ ----------------------------------
27
+ * @param {GetBuildStatusParams} arg0 - getBuildStatus request params
28
+ * @param {RequestConfig} arg1 - Other reuqest params
29
+ */
30
+ async function getBuildStatus({ repo, sn }, { req, options, ...axiosConfig } = {}) {
31
+ return await request_1.default.request({
32
+ ...axiosConfig,
33
+ _next_req: req,
34
+ options: options,
35
+ url: `/${repo}/-/build/status/${sn}`,
36
+ _apiTag: '/{repo}/-/build/status/{sn}',
37
+ method: 'get'
38
+ });
39
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /*
6
+ * -------------------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA CNB-API-GENERATE ##
8
+ * -------------------------------------------------------------------------
9
+ * @Version 1.5.0
10
+ * @Source /{repo}/-/build/start
11
+ */
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.startBuild = startBuild;
17
+ const request_1 = __importDefault(require("../../helpers/request"));
18
+ /**
19
+ * @description 访问令牌调用此接口需包含以下权限。Required permissions for access token.
20
+ * repo-cnb-trigger:rw
21
+ * @tags Build
22
+ * @name startBuild
23
+ * @summary 开始一个构建。Start a build.
24
+ * @request post:/{repo}/-/build/start
25
+
26
+ ----------------------------------
27
+ * @param {string} arg0
28
+ * @param {DtoStartBuildReq} arg1
29
+ * @param {RequestConfig} arg2 - Other reuqest params
30
+ */
31
+ async function startBuild(repo, request, { req, options, ...axiosConfig } = {}) {
32
+ return await request_1.default.request({
33
+ ...axiosConfig,
34
+ _next_req: req,
35
+ options: options,
36
+ url: `/${repo}-/build/start`,
37
+ _apiTag: '/{repo}/-/build/start',
38
+ method: 'post',
39
+ data: request
40
+ });
41
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /*
6
+ * -------------------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA CNB-API-GENERATE ##
8
+ * -------------------------------------------------------------------------
9
+ * @Version 1.5.0
10
+ * @Source /{repo}/-/build/stop/{sn}
11
+ */
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.stopBuild = stopBuild;
17
+ const request_1 = __importDefault(require("../../helpers/request"));
18
+ /**
19
+ * @description 访问令牌调用此接口需包含以下权限。Required permissions for access token.
20
+ * repo-cnb-trigger:rw
21
+ * @tags Build
22
+ * @name stopBuild
23
+ * @summary 停止一个构建。 Stop a build.
24
+ * @request post:/{repo}/-/build/stop/{sn}
25
+
26
+ ----------------------------------
27
+ * @param {StopBuildParams} arg0 - stopBuild request params
28
+ * @param {RequestConfig} arg1 - Other reuqest params
29
+ */
30
+ async function stopBuild({ repo, sn }, { req, options, ...axiosConfig } = {}) {
31
+ return await request_1.default.request({
32
+ ...axiosConfig,
33
+ _next_req: req,
34
+ options: options,
35
+ url: `/${repo}/-/build/stop/${sn}`,
36
+ _apiTag: '/{repo}/-/build/stop/{sn}',
37
+ method: 'post'
38
+ });
39
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /*
6
+ * -------------------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA CNB-API-GENERATE ##
8
+ * ## ##
9
+ * ## AUTHOR: bapelin ##
10
+ * ## SOURCE: https://cnb.woa.com/cnb/frontend-science/cnb-api-generate ##
11
+ * -------------------------------------------------------------------------
12
+ * @Version 1.5.0
13
+ * @Source die.WebError
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /*
6
+ * -------------------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA CNB-API-GENERATE ##
8
+ * ## ##
9
+ * ## AUTHOR: bapelin ##
10
+ * ## SOURCE: https://cnb.woa.com/cnb/frontend-science/cnb-api-generate ##
11
+ * -------------------------------------------------------------------------
12
+ * @Version 1.5.0
13
+ * @Source dto.BuildLogsDeleteResult
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /*
6
+ * -------------------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA CNB-API-GENERATE ##
8
+ * ## ##
9
+ * ## AUTHOR: bapelin ##
10
+ * ## SOURCE: https://cnb.woa.com/cnb/frontend-science/cnb-api-generate ##
11
+ * -------------------------------------------------------------------------
12
+ * @Version 1.5.0
13
+ * @Source dto.BuildLogsResult
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /*
6
+ * -------------------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA CNB-API-GENERATE ##
8
+ * ## ##
9
+ * ## AUTHOR: bapelin ##
10
+ * ## SOURCE: https://cnb.woa.com/cnb/frontend-science/cnb-api-generate ##
11
+ * -------------------------------------------------------------------------
12
+ * @Version 1.5.0
13
+ * @Source dto.BuildResult
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /*
6
+ * -------------------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA CNB-API-GENERATE ##
8
+ * ## ##
9
+ * ## AUTHOR: bapelin ##
10
+ * ## SOURCE: https://cnb.woa.com/cnb/frontend-science/cnb-api-generate ##
11
+ * -------------------------------------------------------------------------
12
+ * @Version 1.5.0
13
+ * @Source dto.BuildStageResult
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /*
6
+ * -------------------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA CNB-API-GENERATE ##
8
+ * ## ##
9
+ * ## AUTHOR: bapelin ##
10
+ * ## SOURCE: https://cnb.woa.com/cnb/frontend-science/cnb-api-generate ##
11
+ * -------------------------------------------------------------------------
12
+ * @Version 1.5.0
13
+ * @Source dto.BuildStatusResult
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /*
6
+ * -------------------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA CNB-API-GENERATE ##
8
+ * ## ##
9
+ * ## AUTHOR: bapelin ##
10
+ * ## SOURCE: https://cnb.woa.com/cnb/frontend-science/cnb-api-generate ##
11
+ * -------------------------------------------------------------------------
12
+ * @Version 1.5.0
13
+ * @Source dto.StartBuildReq
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.API_PRIVATE_RESPONSE_HEADER_PAGE_SIZE = exports.API_PRIVATE_RESPONSE_HEADER_PAGE = exports.API_PRIVATE_RESPONSE_HEADER_PAGE_TOTAL = exports.API_PRIVATE_RESPONSE_HEADER_COUNT = exports.API_PRIVATE_RESPONSE_HEADER_PREFIX = void 0;
4
+ exports.API_PRIVATE_RESPONSE_HEADER_PREFIX = 'x-cnb';
5
+ exports.API_PRIVATE_RESPONSE_HEADER_COUNT = 'x-cnb-count';
6
+ exports.API_PRIVATE_RESPONSE_HEADER_PAGE_TOTAL = 'x-cnb-total';
7
+ exports.API_PRIVATE_RESPONSE_HEADER_PAGE = 'x-cnb-page';
8
+ exports.API_PRIVATE_RESPONSE_HEADER_PAGE_SIZE = 'x-cnb-page-size';
@@ -35,6 +35,14 @@ exports.toolDescriptions = {
35
35
  [toolNames_1.ToolNames.MERGE_PULL]: '合并CNB平台指定的合并请求',
36
36
  [toolNames_1.ToolNames.LIST_PULL_COMMENTS]: '获取CNB平台指定合并请求的评论列表',
37
37
  [toolNames_1.ToolNames.CREATE_PULL_COMMENT]: '在CNB平台指定的合并请求创建一条新评论',
38
+ // 云原生构建工具
39
+ [toolNames_1.ToolNames.BUILD_LOGS_DELETE]: '删除流水线或云原生构建日志内容',
40
+ [toolNames_1.ToolNames.BUILD_RUNNER_DOWNLOAD_LOG]: '流水线或云原生构建runner日志下载',
41
+ [toolNames_1.ToolNames.GET_BUILD_LOGS]: '查询流水线或云原生构建构建列表',
42
+ [toolNames_1.ToolNames.GET_BUILD_STAGE]: '查询流水线或云原生构建Stage详情',
43
+ [toolNames_1.ToolNames.GET_BUILD_STATUS]: '查询流水线或云原生构建构建状态',
44
+ [toolNames_1.ToolNames.START_BUILD]: '开始一个构建',
45
+ [toolNames_1.ToolNames.STOP_BUILD]: '停止一个构建',
38
46
  // 云原生开发工具
39
47
  [toolNames_1.ToolNames.LIST_WORKSPACES]: '获取当前用户在CNB平台的云原生开发环境列表',
40
48
  [toolNames_1.ToolNames.DELETE_WORKSPACE]: '在CNB平台删除指定的云原生开发环境'
@@ -35,6 +35,14 @@ var ToolNames;
35
35
  ToolNames["MERGE_PULL"] = "cnb_merge_pull";
36
36
  ToolNames["LIST_PULL_COMMENTS"] = "cnb_list_pull_comments";
37
37
  ToolNames["CREATE_PULL_COMMENT"] = "cnb_create_pull_comment";
38
+ // 云原生构建工具
39
+ ToolNames["BUILD_LOGS_DELETE"] = "cnb_buildLogsDelete";
40
+ ToolNames["BUILD_RUNNER_DOWNLOAD_LOG"] = "cnb_buildRunnerDownloadLog";
41
+ ToolNames["GET_BUILD_LOGS"] = "cnb_getBuildLogs";
42
+ ToolNames["GET_BUILD_STAGE"] = "cnb_getBuildStage";
43
+ ToolNames["GET_BUILD_STATUS"] = "cnb_getBuildStatus";
44
+ ToolNames["START_BUILD"] = "cnb_startBuild";
45
+ ToolNames["STOP_BUILD"] = "cnb_stopBuild";
38
46
  // 云原生开发工具
39
47
  ToolNames["LIST_WORKSPACES"] = "cnb_list_workspaces";
40
48
  ToolNames["DELETE_WORKSPACE"] = "cnb_delete_workspace";
@@ -10,7 +10,7 @@ async function isRepoPublic(client, url) {
10
10
  return true;
11
11
  try {
12
12
  const { visibility_level } = await (0, repository_js_1.getRepository)(client, repoPath);
13
- // @ts-expect-error 字段类型转换过,但 swagger 无法感知
13
+ // 字段类型转换过,但 swagger 无法感知
14
14
  return visibility_level === index_js_1.RepoVisibility.public;
15
15
  }
16
16
  catch (_a) {
@@ -55,7 +55,6 @@ async function createStatelessStreamableTransport(req, res) {
55
55
  sessionIdGenerator: undefined
56
56
  });
57
57
  res.on('close', () => {
58
- console.log('Request closed');
59
58
  void transport.close();
60
59
  void mcpServer.close();
61
60
  });
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = getToken;
4
+ /**
5
+ * token 降级获取
6
+ *
7
+ * token --不存在--> 环境变量 API_TOKEN(mcp 客户端配置)--不存在--> CNB 流水线提供的 CNB_TOKEN ---不存在--> ''
8
+ */
9
+ function getToken(token) {
10
+ var _a, _b;
11
+ const newToken = (_b = (_a = token !== null && token !== void 0 ? token : process.env.API_TOKEN) !== null && _a !== void 0 ? _a : process.env.CNB_TOKEN) !== null && _b !== void 0 ? _b : '';
12
+ return newToken;
13
+ }
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.CnbRequest = exports.CNB_AXIOS_CANCEL_ERROR_CODE = exports.CNB_AXIOS_ERROR_CODE = void 0;
21
+ const header_1 = require("../../../constants/header");
22
+ const axios_1 = __importDefault(require("axios"));
23
+ exports.CNB_AXIOS_ERROR_CODE = -1;
24
+ exports.CNB_AXIOS_CANCEL_ERROR_CODE = -2;
25
+ class CnbRequest {
26
+ constructor(config) {
27
+ this.axiosInstance = axios_1.default.create(config);
28
+ this.config = config;
29
+ }
30
+ formatResponse(res, error) {
31
+ var _a, _b;
32
+ let status = res === null || res === void 0 ? void 0 : res.status;
33
+ let resultData = null;
34
+ let resultError = null;
35
+ const headers = {};
36
+ const responseHeader = (res === null || res === void 0 ? void 0 : res.headers) || ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.headers) || {};
37
+ // 根据约定响应头返回响应头数据
38
+ if (responseHeader) {
39
+ const regexp = new RegExp(`${header_1.API_PRIVATE_RESPONSE_HEADER_PREFIX}(-.+)+`);
40
+ const headerKeys = Object.keys(responseHeader);
41
+ for (const key of headerKeys) {
42
+ if (regexp.test(key) === true) {
43
+ headers[key] = responseHeader[key];
44
+ }
45
+ }
46
+ }
47
+ const formatError = (status, errData) => {
48
+ resultData = null;
49
+ resultError = {
50
+ code: errData.errcode,
51
+ message: errData.errmsg || 'unknown error',
52
+ param: errData.errparam || null,
53
+ status
54
+ };
55
+ };
56
+ if (error) {
57
+ const axiosError = error;
58
+ const isAxiosError = 'response' in axiosError;
59
+ if (!isAxiosError) {
60
+ const errorObj = {
61
+ code: (error === null || error === void 0 ? void 0 : error.code) === 'ERR_CANCELED' ? exports.CNB_AXIOS_CANCEL_ERROR_CODE : exports.CNB_AXIOS_ERROR_CODE,
62
+ message: error.message || 'unknown error',
63
+ status: error === null || error === void 0 ? void 0 : error.status
64
+ };
65
+ const { config: _, request, ...restErrorInfo } = error;
66
+ const errorPrototype = {};
67
+ // 在原型对象上定义_error属性,用于存储原始错误的详细信息
68
+ Object.defineProperty(errorPrototype, '_error', {
69
+ value: restErrorInfo,
70
+ enumerable: true,
71
+ configurable: true
72
+ });
73
+ const newError = Object.assign(Object.create(errorPrototype), errorObj);
74
+ const errorResponse = {
75
+ status,
76
+ result: null,
77
+ error: newError,
78
+ headers
79
+ };
80
+ return errorResponse;
81
+ }
82
+ status = error.response.status;
83
+ formatError(status, axiosError.response.data);
84
+ }
85
+ // 基于webapi统一返回进行处理
86
+ if (((_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.errcode) !== undefined) {
87
+ formatError(res.status, res.data);
88
+ }
89
+ else {
90
+ resultData = res ? res.data : null;
91
+ }
92
+ return { status, result: resultData, error: resultError, headers };
93
+ }
94
+ async request(config) {
95
+ var _a;
96
+ const format = (_a = config.options) === null || _a === void 0 ? void 0 : _a.formatResponse;
97
+ let result;
98
+ try {
99
+ const res = await this.axiosInstance.request(config);
100
+ result = this.formatResponse(res, null);
101
+ if (typeof format === 'function') {
102
+ result = format(result, res);
103
+ }
104
+ }
105
+ catch (err) {
106
+ result = this.formatResponse(null, err);
107
+ if (typeof format === 'function') {
108
+ result = format(result, err.response);
109
+ }
110
+ }
111
+ if (result.error) {
112
+ const { onError = this.config.onError } = config.options || {};
113
+ if (onError !== null && typeof onError === 'function') {
114
+ onError === null || onError === void 0 ? void 0 : onError(result.error);
115
+ }
116
+ }
117
+ return result;
118
+ }
119
+ }
120
+ exports.CnbRequest = CnbRequest;
121
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createHeaders = createHeaders;
7
+ const getToken_1 = __importDefault(require("../getToken"));
8
+ const cnb_1 = require("./cnb");
9
+ const baseURL = process.env.API_BASE_URL || 'https://api.cnb.cool';
10
+ const timeout = 10000; // 客户端10秒超时
11
+ const CnbFetcher = new cnb_1.CnbRequest({
12
+ baseURL,
13
+ timeout
14
+ });
15
+ exports.default = CnbFetcher;
16
+ function createHeaders(token) {
17
+ return {
18
+ Authorization: `Bearer ${(0, getToken_1.default)(token)}`,
19
+ Accept: 'application/vnd.cnb.api+json'
20
+ };
21
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.logMiddleware = logMiddleware;
7
+ const node_crypto_1 = require("node:crypto");
8
+ const winston_1 = __importDefault(require("winston"));
9
+ const logger = winston_1.default.createLogger({
10
+ level: 'info',
11
+ format: winston_1.default.format.combine(winston_1.default.format.timestamp(), winston_1.default.format.errors({ stack: true }), winston_1.default.format.json()),
12
+ defaultMeta: { service: 'cnb-mcp-server' },
13
+ transports: [
14
+ new winston_1.default.transports.Console({
15
+ format: winston_1.default.format.combine(winston_1.default.format.colorize(), winston_1.default.format.simple())
16
+ })
17
+ ]
18
+ });
19
+ function logMiddleware(req, res, next) {
20
+ var _a;
21
+ const startTime = Date.now();
22
+ const requestId = (0, node_crypto_1.randomUUID)();
23
+ logger.info('Incoming request', {
24
+ method: req.method,
25
+ url: req.url,
26
+ headers: {
27
+ traceparent: req.headers['traceparent']
28
+ },
29
+ body: req.body ? JSON.stringify(req.body).substring(0, 500) : undefined,
30
+ ip: req.headers['x-client-ip'] || req.headers['x-real-ip'] || req.ip || req.connection.remoteAddress,
31
+ authLength: (_a = req.headers['authorization']) === null || _a === void 0 ? void 0 : _a.length,
32
+ requestId
33
+ });
34
+ res.on('finish', () => {
35
+ logger.info('Request finished', {
36
+ statusCode: res.statusCode,
37
+ duration: Date.now() - startTime,
38
+ requestId
39
+ });
40
+ });
41
+ res.on('close', () => {
42
+ logger.info('Request closed', {
43
+ statusCode: res.statusCode,
44
+ duration: Date.now() - startTime,
45
+ requestId
46
+ });
47
+ });
48
+ next();
49
+ }
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  const express_1 = __importDefault(require("express"));
9
9
  const sse_js_1 = require("@modelcontextprotocol/sdk/server/sse.js");
10
10
  const dotenv_1 = __importDefault(require("dotenv"));
11
+ const logMiddleware_js_1 = require("./middlewares/logMiddleware.js");
11
12
  const createMcpServer_js_1 = require("./helpers/createMcpServer.js");
12
13
  const sendResponse_js_1 = require("./helpers/sendResponse.js");
13
14
  const createTransport_js_1 = require("./helpers/createTransport.js");
@@ -15,6 +16,7 @@ dotenv_1.default.config();
15
16
  const DEFAULT_APP_PORT = 3000;
16
17
  const app = (0, express_1.default)();
17
18
  app.use(express_1.default.json());
19
+ app.use(logMiddleware_js_1.logMiddleware);
18
20
  app.post('/mcp', async (req, res) => {
19
21
  let transport;
20
22
  try {
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = registerBuildTools;
4
+ const zod_1 = require("zod");
5
+ const toolNames_js_1 = require("../constants/toolNames.js");
6
+ const toolDescriptions_js_1 = require("../constants/toolDescriptions.js");
7
+ const formatToolResult_js_1 = require("../helpers/formatToolResult.js");
8
+ const index_js_1 = require("../helpers/request/index.js");
9
+ const build_logs_delete_js_1 = require("../api/build/build-logs-delete.js");
10
+ const build_runner_download_log_js_1 = require("../api/build/build-runner-download-log.js");
11
+ const get_build_logs_js_1 = require("../api/build/get-build-logs.js");
12
+ const get_build_stage_js_1 = require("../api/build/get-build-stage.js");
13
+ const get_build_status_js_1 = require("../api/build/get-build-status.js");
14
+ const start_build_js_1 = require("../api/build/start-build.js");
15
+ const stop_build_js_1 = require("../api/build/stop-build.js");
16
+ function registerBuildTools(server, token) {
17
+ const headers = (0, index_js_1.createHeaders)(token);
18
+ server.tool(toolNames_js_1.ToolNames.BUILD_LOGS_DELETE, toolDescriptions_js_1.toolDescriptions[toolNames_js_1.ToolNames.BUILD_LOGS_DELETE], {
19
+ repo: zod_1.z.string().describe('仓库路径'),
20
+ sn: zod_1.z.string().describe('构建 ID')
21
+ }, async ({ repo, sn }) => {
22
+ try {
23
+ const { error, result } = await (0, build_logs_delete_js_1.buildLogsDelete)({ repo, sn }, { headers });
24
+ if (error)
25
+ throw new Error(`ERROR ${error.code}: ${error.message}`);
26
+ return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(result, null, 2), toolNames_js_1.ToolNames.BUILD_LOGS_DELETE);
27
+ }
28
+ catch (error) {
29
+ return (0, formatToolResult_js_1.formatToolError)(error, toolNames_js_1.ToolNames.BUILD_LOGS_DELETE);
30
+ }
31
+ });
32
+ server.tool(toolNames_js_1.ToolNames.BUILD_RUNNER_DOWNLOAD_LOG, toolDescriptions_js_1.toolDescriptions[toolNames_js_1.ToolNames.BUILD_RUNNER_DOWNLOAD_LOG], {
33
+ repo: zod_1.z.string().describe('仓库路径'),
34
+ pipelineId: zod_1.z.string().describe('流水线 ID')
35
+ }, async ({ repo, pipelineId }) => {
36
+ try {
37
+ const { error, result } = await (0, build_runner_download_log_js_1.buildRunnerDownloadLog)({ repo, pipelineId }, { headers });
38
+ if (error)
39
+ throw new Error(`ERROR ${error.code}: ${error.message}`);
40
+ return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(result, null, 2), toolNames_js_1.ToolNames.BUILD_RUNNER_DOWNLOAD_LOG);
41
+ }
42
+ catch (error) {
43
+ return (0, formatToolResult_js_1.formatToolError)(error, toolNames_js_1.ToolNames.BUILD_RUNNER_DOWNLOAD_LOG);
44
+ }
45
+ });
46
+ server.tool(toolNames_js_1.ToolNames.GET_BUILD_LOGS, toolDescriptions_js_1.toolDescriptions[toolNames_js_1.ToolNames.GET_BUILD_LOGS], {
47
+ repo: zod_1.z.string().describe('仓库路径'),
48
+ createTime: zod_1.z
49
+ .preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
50
+ .describe('构建开始时间,格式为 YYYY-MM-DD'),
51
+ endTime: zod_1.z
52
+ .preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
53
+ .describe('构建结束时间,格式为 YYYY-MM-DD'),
54
+ event: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('触发事件'),
55
+ page: zod_1.z.number().default(1).describe('页码'),
56
+ pagesize: zod_1.z.number().max(100).default(30).describe('每页数据的条数'),
57
+ sha: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('Commit ID'),
58
+ sn: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('构建 ID'),
59
+ sourceRef: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('源分支名'),
60
+ status: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('构建状态'),
61
+ targetRef: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('目标分支名'),
62
+ userId: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('用户 ID'),
63
+ userName: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('用户名')
64
+ }, async (params) => {
65
+ try {
66
+ console.error(params, headers);
67
+ const { error, result } = await (0, get_build_logs_js_1.getBuildLogs)(params, { headers });
68
+ if (error)
69
+ throw new Error(`ERROR ${error.code}: ${error.message}`);
70
+ return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(result, null, 2), toolNames_js_1.ToolNames.GET_BUILD_LOGS);
71
+ }
72
+ catch (error) {
73
+ return (0, formatToolResult_js_1.formatToolError)(error, toolNames_js_1.ToolNames.GET_BUILD_LOGS);
74
+ }
75
+ });
76
+ server.tool(toolNames_js_1.ToolNames.GET_BUILD_STAGE, toolDescriptions_js_1.toolDescriptions[toolNames_js_1.ToolNames.GET_BUILD_STAGE], {
77
+ repo: zod_1.z.string().describe('仓库路径'),
78
+ sn: zod_1.z.string().describe('构建序列号或 ID'),
79
+ pipelineId: zod_1.z
80
+ .string()
81
+ .describe('流水线 ID,一个构建可以包含多条流水线。格式 {sn}-001, {sn}-002 等等,001 为起始,加一递增'),
82
+ stageId: zod_1.z
83
+ .string()
84
+ .describe('流水线阶段 ID,一条流水线可以包含多个阶段。格式 prepare, beforeEnd, end, stage-0, stage-1 等等,0 为起始,加一递增')
85
+ }, async (params) => {
86
+ const { sn, pipelineId, stageId } = params;
87
+ // 流水线 ID 格式检查
88
+ const pipelineIdRegexp = new RegExp(`^${sn}-\\d{3}$`);
89
+ if (!pipelineIdRegexp.test(pipelineId)) {
90
+ return (0, formatToolResult_js_1.formatToolError)('流水线 ID 格式错误。正确格式:<构建 ID>-<三位序号>,001 为起始,加一递增', toolNames_js_1.ToolNames.GET_BUILD_STAGE);
91
+ }
92
+ // 流水线阶段 ID 格式检查
93
+ const fixedStageId = ['prepare', 'beforeEnd', 'end'];
94
+ const stageIdRegexp = /^stage-\d$/;
95
+ if (!fixedStageId.includes(stageId) && !stageIdRegexp.test(stageId)) {
96
+ return (0, formatToolResult_js_1.formatToolError)('流水线阶段 ID 格式错误。正确格式:prepare、beforeEnd、end、stage-<序号>,0 为起始,加一递增', toolNames_js_1.ToolNames.GET_BUILD_STAGE);
97
+ }
98
+ try {
99
+ const { error, result } = await (0, get_build_stage_js_1.getBuildStage)(params, { headers });
100
+ if (error)
101
+ throw new Error(`ERROR ${error.code}: ${error.message}`);
102
+ return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(result, null, 2), toolNames_js_1.ToolNames.GET_BUILD_STAGE);
103
+ }
104
+ catch (error) {
105
+ return (0, formatToolResult_js_1.formatToolError)(error, toolNames_js_1.ToolNames.GET_BUILD_STAGE);
106
+ }
107
+ });
108
+ server.tool(toolNames_js_1.ToolNames.GET_BUILD_STATUS, toolDescriptions_js_1.toolDescriptions[toolNames_js_1.ToolNames.GET_BUILD_STATUS], {
109
+ repo: zod_1.z.string().describe('仓库路径'),
110
+ sn: zod_1.z.string().describe('构建 ID')
111
+ }, async ({ repo, sn }) => {
112
+ try {
113
+ const { error, result } = await (0, get_build_status_js_1.getBuildStatus)({ repo, sn }, { headers });
114
+ if (error)
115
+ throw new Error(`ERROR ${error.code}: ${error.message}`);
116
+ return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(result, null, 2), toolNames_js_1.ToolNames.GET_BUILD_STATUS);
117
+ }
118
+ catch (error) {
119
+ return (0, formatToolResult_js_1.formatToolError)(error, toolNames_js_1.ToolNames.GET_BUILD_STATUS);
120
+ }
121
+ });
122
+ server.tool(toolNames_js_1.ToolNames.START_BUILD, toolDescriptions_js_1.toolDescriptions[toolNames_js_1.ToolNames.START_BUILD], {
123
+ repo: zod_1.z.string().describe('仓库路径'),
124
+ branch: zod_1.z.string().describe('分支名'),
125
+ event: zod_1.z.string().describe('触发事件'),
126
+ sync: zod_1.z.string().default('false').describe('同步模式,等待请求完成'),
127
+ config: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('配置'),
128
+ env: zod_1.z
129
+ .preprocess((val) => (val === null ? undefined : val), zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional())
130
+ .describe('环境变量'),
131
+ sha: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('Commit ID'),
132
+ tag: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('git tag')
133
+ }, async ({ repo, ...body }) => {
134
+ try {
135
+ const { error, result } = await (0, start_build_js_1.startBuild)(repo, body, { headers });
136
+ if (error)
137
+ throw new Error(`ERROR ${error.code}: ${error.message}`);
138
+ return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(result, null, 2), toolNames_js_1.ToolNames.START_BUILD);
139
+ }
140
+ catch (error) {
141
+ return (0, formatToolResult_js_1.formatToolError)(error, toolNames_js_1.ToolNames.START_BUILD);
142
+ }
143
+ });
144
+ server.tool(toolNames_js_1.ToolNames.STOP_BUILD, toolDescriptions_js_1.toolDescriptions[toolNames_js_1.ToolNames.STOP_BUILD], {
145
+ repo: zod_1.z.string().describe('仓库路径'),
146
+ sn: zod_1.z.string().describe('构建 ID')
147
+ }, async ({ repo, sn }) => {
148
+ try {
149
+ const { error, result } = await (0, stop_build_js_1.stopBuild)({ repo, sn }, { headers });
150
+ if (error)
151
+ throw new Error(`ERROR ${error.code}: ${error.message}`);
152
+ return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(result, null, 2), toolNames_js_1.ToolNames.STOP_BUILD);
153
+ }
154
+ catch (error) {
155
+ return (0, formatToolResult_js_1.formatToolError)(error, toolNames_js_1.ToolNames.STOP_BUILD);
156
+ }
157
+ });
158
+ }
@@ -4,20 +4,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.registerTools = registerTools;
7
+ const getToken_js_1 = __importDefault(require("../helpers/getToken.js"));
7
8
  const client_js_1 = __importDefault(require("../api/client.js"));
8
9
  const groupTools_js_1 = __importDefault(require("./groupTools.js"));
9
10
  const repoTools_js_1 = __importDefault(require("./repoTools.js"));
10
11
  const issueTools_js_1 = __importDefault(require("./issueTools.js"));
11
12
  const workspaceTools_js_1 = __importDefault(require("./workspaceTools.js"));
12
13
  const pullTools_js_1 = __importDefault(require("./pullTools.js"));
14
+ const buildTools_js_1 = __importDefault(require("./buildTools.js"));
13
15
  function registerTools(server, token) {
14
16
  const client = new client_js_1.default({
15
17
  baseUrl: process.env.API_BASE_URL || 'https://api.cnb.cool',
16
- token: process.env.API_TOKEN || token || ''
18
+ token: (0, getToken_js_1.default)(token)
17
19
  });
18
20
  (0, groupTools_js_1.default)(server, client);
19
21
  (0, repoTools_js_1.default)(server, client);
20
22
  (0, issueTools_js_1.default)(server, client);
21
23
  (0, workspaceTools_js_1.default)(server, client);
22
24
  (0, pullTools_js_1.default)(server, client);
25
+ // ================
26
+ // 使用 cnb-request
27
+ // ================
28
+ (0, buildTools_js_1.default)(server, token);
23
29
  }
@@ -16,7 +16,7 @@ function registerRepoTools(server, client) {
16
16
  page_size: zod_1.z.number().default(10).describe('每页多少条数据,默认值为10'),
17
17
  search: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('查询关键字'),
18
18
  filter_type: zod_1.z
19
- .preprocess((val) => (val === null ? undefined : val), zod_1.z.enum(['private', 'public', 'encrypted']).optional())
19
+ .preprocess((val) => (val === null ? undefined : val), zod_1.z.enum(['private', 'public', 'secret']).optional())
20
20
  .describe('仓库类型,为空表示所有仓库类型,默认值为空'),
21
21
  role: zod_1.z
22
22
  .preprocess((val) => (val === null ? undefined : val), zod_1.z.enum(['Reporter', 'Developer', 'Master', 'Owner']).optional())
@@ -46,7 +46,7 @@ function registerRepoTools(server, client) {
46
46
  page_size: zod_1.z.number().default(10).describe('每页多少条数据,默认值为10'),
47
47
  search: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('仓库关键字'),
48
48
  filter_type: zod_1.z
49
- .preprocess((val) => (val === null ? undefined : val), zod_1.z.enum(['private', 'public', 'encrypted']).optional())
49
+ .preprocess((val) => (val === null ? undefined : val), zod_1.z.enum(['private', 'public', 'secret']).optional())
50
50
  .describe('仓库类型'),
51
51
  descendant: zod_1.z
52
52
  .preprocess((val) => (val === null ? undefined : val), zod_1.z.enum(['all', 'sub', 'grand']).optional())
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cnbcool/mcp-server",
3
3
  "description": "CNB MCP Server. A comprehensive MCP server that provides seamless integration to the CNB's API(https://cnb.cool), offering a wide range of tools for repository management, pipelines operations and collaboration features",
4
- "version": "0.5.1",
4
+ "version": "0.6.1",
5
5
  "main": "./dist/stdio.js",
6
6
  "bin": {
7
7
  "cnb-mcp-stdio": "dist/stdio.js",
@@ -15,7 +15,8 @@
15
15
  "lint": "eslint src",
16
16
  "lint:fix": "eslint --fix src",
17
17
  "format:check": "prettier --check src",
18
- "format:fix": "prettier --write src"
18
+ "format:fix": "prettier --write src",
19
+ "build:bundle": "webpack --mode=production"
19
20
  },
20
21
  "repository": {
21
22
  "type": "git",
@@ -40,27 +41,29 @@
40
41
  "typescript": ">=5.5"
41
42
  },
42
43
  "dependencies": {
43
- "@modelcontextprotocol/sdk": "1.12.1",
44
- "dotenv": "16.5.0",
45
- "express": "5.1.0",
46
- "zod": "3.24.3"
44
+ "@modelcontextprotocol/sdk": "1.22.0",
45
+ "axios": "1.8.2",
46
+ "dotenv": "17.2.3",
47
+ "express": "5.2.1",
48
+ "winston": "3.19.0",
49
+ "zod": "3.25.76"
47
50
  },
48
51
  "devDependencies": {
49
- "@commitlint/cli": "19.8.1",
50
- "@commitlint/config-conventional": "19.8.1",
51
- "@eslint/js": "9.33.0",
52
- "@modelcontextprotocol/inspector": "^0.16.2",
53
- "@types/express": "5.0.1",
54
- "@types/node": "^18.19.123",
55
- "eslint": "9.33.0",
52
+ "@commitlint/cli": "20.3.0",
53
+ "@commitlint/config-conventional": "20.3.0",
54
+ "@eslint/js": "9.39.2",
55
+ "@modelcontextprotocol/inspector": "0.15.0",
56
+ "@types/express": "5.0.6",
57
+ "@types/node": "^18",
58
+ "eslint": "9.39.2",
56
59
  "eslint-config-prettier": "10.1.8",
57
60
  "eslint-plugin-prettier": "5.5.4",
58
- "globals": "16.3.0",
61
+ "globals": "17.0.0",
59
62
  "husky": "9.1.7",
60
63
  "lint-staged": "15.5.2",
61
- "prettier": "3.6.2",
62
- "typescript": "5.9.2",
63
- "typescript-eslint": "8.40.0"
64
+ "prettier": "3.7.4",
65
+ "typescript": "5.9.3",
66
+ "typescript-eslint": "8.52.0"
64
67
  },
65
68
  "lint-staged": {
66
69
  "**/*": [