@cnbcool/mcp-server 0.6.0 → 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.
@@ -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
+ }
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.createHeaders = createHeaders;
7
+ const getToken_1 = __importDefault(require("../getToken"));
4
8
  const cnb_1 = require("./cnb");
5
9
  const baseURL = process.env.API_BASE_URL || 'https://api.cnb.cool';
6
10
  const timeout = 10000; // 客户端10秒超时
@@ -11,7 +15,7 @@ const CnbFetcher = new cnb_1.CnbRequest({
11
15
  exports.default = CnbFetcher;
12
16
  function createHeaders(token) {
13
17
  return {
14
- Authorization: `Bearer ${process.env.API_TOKEN || token || ''}`,
18
+ Authorization: `Bearer ${(0, getToken_1.default)(token)}`,
15
19
  Accept: 'application/vnd.cnb.api+json'
16
20
  };
17
21
  }
@@ -4,6 +4,7 @@ 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"));
@@ -14,7 +15,7 @@ const buildTools_js_1 = __importDefault(require("./buildTools.js"));
14
15
  function registerTools(server, token) {
15
16
  const client = new client_js_1.default({
16
17
  baseUrl: process.env.API_BASE_URL || 'https://api.cnb.cool',
17
- token: process.env.API_TOKEN || token || ''
18
+ token: (0, getToken_js_1.default)(token)
18
19
  });
19
20
  (0, groupTools_js_1.default)(server, client);
20
21
  (0, repoTools_js_1.default)(server, client);
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.6.0",
4
+ "version": "0.6.1",
5
5
  "main": "./dist/stdio.js",
6
6
  "bin": {
7
7
  "cnb-mcp-stdio": "dist/stdio.js",