@cnbcool/mcp-server 0.6.0 → 0.6.2
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,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBaseUrl = getBaseUrl;
|
|
4
|
+
exports.getToken = getToken;
|
|
5
|
+
/**
|
|
6
|
+
* baseUrl 降级获取
|
|
7
|
+
*
|
|
8
|
+
* 环境变量 API_BASE_URL(mcp 客户端配置)--不存在--> CNB 流水线提供的 CNB_API_ENDPOINT ---不存在--> 'https://api.cnb.cool'
|
|
9
|
+
*/
|
|
10
|
+
function getBaseUrl() {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const baseUrl = (_b = (_a = process.env.API_BASE_URL) !== null && _a !== void 0 ? _a : process.env.CNB_API_ENDPOINT) !== null && _b !== void 0 ? _b : 'https://api.cnb.cool';
|
|
13
|
+
return baseUrl;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* token 降级获取
|
|
17
|
+
*
|
|
18
|
+
* token --不存在--> 环境变量 API_TOKEN(mcp 客户端配置)--不存在--> CNB 流水线提供的 CNB_TOKEN ---不存在--> ''
|
|
19
|
+
*/
|
|
20
|
+
function getToken(token) {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
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 : '';
|
|
23
|
+
return newToken;
|
|
24
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createHeaders = createHeaders;
|
|
4
|
+
const getConfig_1 = require("../getConfig");
|
|
4
5
|
const cnb_1 = require("./cnb");
|
|
5
|
-
const baseURL =
|
|
6
|
+
const baseURL = (0, getConfig_1.getBaseUrl)();
|
|
6
7
|
const timeout = 10000; // 客户端10秒超时
|
|
7
8
|
const CnbFetcher = new cnb_1.CnbRequest({
|
|
8
9
|
baseURL,
|
|
@@ -11,7 +12,7 @@ const CnbFetcher = new cnb_1.CnbRequest({
|
|
|
11
12
|
exports.default = CnbFetcher;
|
|
12
13
|
function createHeaders(token) {
|
|
13
14
|
return {
|
|
14
|
-
Authorization: `Bearer ${
|
|
15
|
+
Authorization: `Bearer ${(0, getConfig_1.getToken)(token)}`,
|
|
15
16
|
Accept: 'application/vnd.cnb.api+json'
|
|
16
17
|
};
|
|
17
18
|
}
|
package/dist/tools/index.js
CHANGED
|
@@ -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 getConfig_js_1 = require("../helpers/getConfig.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"));
|
|
@@ -13,8 +14,8 @@ const pullTools_js_1 = __importDefault(require("./pullTools.js"));
|
|
|
13
14
|
const buildTools_js_1 = __importDefault(require("./buildTools.js"));
|
|
14
15
|
function registerTools(server, token) {
|
|
15
16
|
const client = new client_js_1.default({
|
|
16
|
-
baseUrl:
|
|
17
|
-
token:
|
|
17
|
+
baseUrl: (0, getConfig_js_1.getBaseUrl)(),
|
|
18
|
+
token: (0, getConfig_js_1.getToken)(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.
|
|
4
|
+
"version": "0.6.2",
|
|
5
5
|
"main": "./dist/stdio.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cnb-mcp-stdio": "dist/stdio.js",
|