@cnbcool/mcp-server 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,6 +2,41 @@
2
2
 
3
3
  CNB(https://cnb.cool) toolkits for LLMs supporting the MCP protocol
4
4
 
5
+ ## Tool List
6
+
7
+ | Tool Name | Tool Description |
8
+ | :----- | :------- |
9
+ | cnb_list_groups | Gets a list of top-level organizations for which the current user has permissions on the CNB platform. |
10
+ | cnb_list_sub_groups | Gets a list of sub-organizations for which the current user has permissions on the CNB platform under a specified organization. |
11
+ | cnb_get_group | Gets information about a specified organization on the CNB platform. |
12
+ | cnb_create_group | Creates a new organization on the CNB platform. |
13
+ | cnb_list_repositories | Gets a list of repositories for which the current user has permissions on the CNB platform. |
14
+ | cnb_list_group_repositories | Gets a list of repositories for which the current user has permissions on the CNB platform under a specified organization. |
15
+ | cnb_get_current_repository | Gets information about the CNB platform repository corresponding to the current workspace. |
16
+ | cnb_get_repository | Gets information about a specified repository on the CNB platform. |
17
+ | cnb_create_repository | Create a new repository on the CNB platform. |
18
+ | cnb_list_issues | Get a list of issues in a specified repository on the CNB platform. |
19
+ | cnb_get_issue | Get information about a specified issue on the CNB platform. |
20
+ | cnb_create_issue | Create a new issue in a specified repository on the CNB platform. To add labels, use the cnb_add_issue_labels tool. |
21
+ | cnb_update_issue | Update information about a specified issue on the CNB platform. To update labels, call the cnb_set_issue_labels tool separately. |
22
+ | cnb_list_issue_comments | Get a list of comments for a specified issue on the CNB platform. |
23
+ | cnb_create_issue_comment | Create a new comment on a specified issue on the CNB platform. |
24
+ | cnb_update_issue_comment | Update the content of a comment on a specified issue on the CNB platform. |
25
+ | cnb_list_issue_labels | Get a list of labels for a specified issue on the CNB platform. |
26
+ | cnb_add_issue_labels | Add one or more labels to a specified issue on the CNB platform. |
27
+ | cnb_set_issue_labels | Change the labels for a specified issue on the CNB platform. |
28
+ | cnb_clear_issue_labels | Clear the labels for a specified issue on the CNB platform. |
29
+ | cnb_remove_issue_label | Remove a specified label from a specified issue on the CNB platform. |
30
+ | cnb_list_pulls | Get a list of merge requests for a specified repository on the CNB platform. |
31
+ | cnb_get_pull | Get information about a merge request specified on the CNB platform |
32
+ | cnb_create_pull | Create a new merge request in a repository specified on the CNB platform |
33
+ | cnb_update_pull | Update information about a merge request specified on the CNB platform |
34
+ | cnb_merge_pull | Merge a merge request specified on the CNB platform |
35
+ | cnb_list_pull_comments | Get a list of comments for a merge request specified on the CNB platform |
36
+ | cnb_create_pull_comment | Create a new comment on a merge request specified on the CNB platform |
37
+ | cnb_list_workspaces | Get a list of the current user's cloud-native development environments on the CNB platform |
38
+ | cnb_delete_workspace | Delete a specified cloud-native development environment on the CNB platform |
39
+
5
40
  ## How to use
6
41
 
7
42
  ### STDIO
@@ -57,5 +92,3 @@ CNB(https://cnb.cool) toolkits for LLMs supporting the MCP protocol
57
92
  }
58
93
  }
59
94
  ```
60
-
61
-
package/README_zh.md CHANGED
@@ -2,6 +2,41 @@
2
2
 
3
3
  CNB(https://cnb.cool) 支持 MCP 协议的 MCP Server
4
4
 
5
+ ## 工具列表
6
+
7
+ | 工具名 | 工具描述 |
8
+ | :----- | :------- |
9
+ | cnb_list_groups | 获取当前用户在CNB平台里拥有权限的顶层组织列表 |
10
+ | cnb_list_sub_groups | 获取当前用户在CNB平台里指定组织下拥有权限的子组织列表 |
11
+ | cnb_get_group | 获取CNB平台指定组织的信息 |
12
+ | cnb_create_group | 在CNB平台创建一个新组织 |
13
+ | cnb_list_repositories | 获取当前用户在CNB平台里拥有权限的仓库列表 |
14
+ | cnb_list_group_repositories | 获取当前用户在CNB平台里指定组织下拥有权限的仓库列表 |
15
+ | cnb_get_current_repository | 获取当前工作区对应的CNB平台仓库信息 |
16
+ | cnb_get_repository | 获取CNB平台指定仓库的信息 |
17
+ | cnb_create_repository | 在CNB平台创建一个新仓库 |
18
+ | cnb_list_issues | 获取CNB平台指定仓库的ISSUE列表 |
19
+ | cnb_get_issue | 获取CNB平台指定ISSUE的信息 |
20
+ | cnb_create_issue | 在CNB平台指定的仓库创建一条新ISSUE。如需添加标签,另外调用cnb_add_issue_labels工具 |
21
+ | cnb_update_issue | 更新CNB平台指定ISSUE的信息。如需更新标签,另外调用cnb_set_issue_labels工具 |
22
+ | cnb_list_issue_comments | 获取CNB平台指定ISSUE的评论列表 |
23
+ | cnb_create_issue_comment | 在CNB平台指定的ISSUE创建一条新评论 |
24
+ | cnb_update_issue_comment | 更新CNB平台指定ISSUE评论的内容 |
25
+ | cnb_list_issue_labels | 获取CNB平台指定ISSUE的标签列表 |
26
+ | cnb_add_issue_labels | 为CNB平台指定的ISSUE添加一个或多个标签 |
27
+ | cnb_set_issue_labels | 变更CNB平台指定ISSUE的标签 |
28
+ | cnb_clear_issue_labels | 清除CNB平台指定ISSUE的标签 |
29
+ | cnb_remove_issue_label | 移除CNB平台指定ISSUE的指定标签 |
30
+ | cnb_list_pulls | 获取CNB平台指定仓库的合并请求列表 |
31
+ | cnb_get_pull | 获取CNB平台指定合并请求的信息 |
32
+ | cnb_create_pull | 在CNB平台指定的仓库创建一个新合并请求 |
33
+ | cnb_update_pull | 更新CNB平台指定合并请求的信息 |
34
+ | cnb_merge_pull | 合并CNB平台指定的合并请求 |
35
+ | cnb_list_pull_comments | 获取CNB平台指定合并请求的评论列表 |
36
+ | cnb_create_pull_comment | 在CNB平台指定的合并请求创建一条新评论 |
37
+ | cnb_list_workspaces | 获取当前用户在CNB平台的云原生开发环境列表 |
38
+ | cnb_delete_workspace | 在CNB平台删除指定的云原生开发环境 |
39
+
5
40
  ## 使用方法
6
41
 
7
42
  ### STDIO
@@ -1,7 +1,6 @@
1
- export default class CnbApiClient {
2
- static instance = null;
3
- _baseUrl;
4
- _token;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class CnbApiClient {
5
4
  constructor(options) {
6
5
  this._baseUrl = options.baseUrl;
7
6
  this._token = options.token;
@@ -26,7 +25,7 @@ export default class CnbApiClient {
26
25
  const headers = {
27
26
  Authorization: `Bearer ${this._token}`,
28
27
  Accept: 'application/vnd.cnb.api+json',
29
- ...(config?.header || {})
28
+ ...((config === null || config === void 0 ? void 0 : config.header) || {})
30
29
  };
31
30
  const options = {
32
31
  method,
@@ -47,3 +46,5 @@ export default class CnbApiClient {
47
46
  return response.json();
48
47
  }
49
48
  }
49
+ CnbApiClient.instance = null;
50
+ exports.default = CnbApiClient;
package/dist/api/group.js CHANGED
@@ -1,6 +1,15 @@
1
- import CnbApiClient from './client.js';
2
- export async function listGroups(params) {
3
- const cnbInst = CnbApiClient.getInstance();
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.listGroups = listGroups;
7
+ exports.listSubGroups = listSubGroups;
8
+ exports.getGroup = getGroup;
9
+ exports.createGroup = createGroup;
10
+ const client_js_1 = __importDefault(require("./client.js"));
11
+ async function listGroups(params) {
12
+ const cnbInst = client_js_1.default.getInstance();
4
13
  const url = new URL('/user/groups', cnbInst.baseUrl);
5
14
  if (params) {
6
15
  for (const [key, value] of Object.entries(params)) {
@@ -11,8 +20,8 @@ export async function listGroups(params) {
11
20
  }
12
21
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
13
22
  }
14
- export async function listSubGroups(group, params) {
15
- const cnbInst = CnbApiClient.getInstance();
23
+ async function listSubGroups(group, params) {
24
+ const cnbInst = client_js_1.default.getInstance();
16
25
  const url = new URL(`/user/groups/${group}`, cnbInst.baseUrl);
17
26
  if (params) {
18
27
  for (const [key, value] of Object.entries(params)) {
@@ -23,18 +32,18 @@ export async function listSubGroups(group, params) {
23
32
  }
24
33
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
25
34
  }
26
- export async function getGroup(group) {
27
- const cnbInst = CnbApiClient.getInstance();
35
+ async function getGroup(group) {
36
+ const cnbInst = client_js_1.default.getInstance();
28
37
  return cnbInst.request('GET', `/${group}`);
29
38
  }
30
- export async function createGroup(params) {
39
+ async function createGroup(params) {
31
40
  const body = Object.entries(params).reduce((acc, [key, value]) => {
32
41
  if (value === undefined)
33
42
  return acc;
34
43
  Object.assign(acc, { [key]: value });
35
44
  return acc;
36
45
  }, {});
37
- const response = await CnbApiClient.getInstance().request('POST', '/groups', body, {
46
+ const response = await client_js_1.default.getInstance().request('POST', '/groups', body, {
38
47
  header: { 'Content-Type': 'application/json' }
39
48
  }, 'raw');
40
49
  if (response.status === 201) {
package/dist/api/issue.js CHANGED
@@ -1,6 +1,23 @@
1
- import CnbApiClient from './client.js';
2
- export async function listIssues(repo, params) {
3
- const cnbInst = CnbApiClient.getInstance();
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.listIssues = listIssues;
7
+ exports.getIssue = getIssue;
8
+ exports.createIssue = createIssue;
9
+ exports.updateIssue = updateIssue;
10
+ exports.listIssueComments = listIssueComments;
11
+ exports.createIssueComment = createIssueComment;
12
+ exports.updateIssueComment = updateIssueComment;
13
+ exports.listIssueLabels = listIssueLabels;
14
+ exports.addIssueLabels = addIssueLabels;
15
+ exports.setIssueLabels = setIssueLabels;
16
+ exports.deleteIssueLabels = deleteIssueLabels;
17
+ exports.deleteIssueLabel = deleteIssueLabel;
18
+ const client_js_1 = __importDefault(require("./client.js"));
19
+ async function listIssues(repo, params) {
20
+ const cnbInst = client_js_1.default.getInstance();
4
21
  const url = new URL(`/${repo}/-/issues`, cnbInst.baseUrl);
5
22
  if (params) {
6
23
  for (const [key, value] of Object.entries(params)) {
@@ -11,27 +28,27 @@ export async function listIssues(repo, params) {
11
28
  }
12
29
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
13
30
  }
14
- export async function getIssue(repo, issueId) {
15
- return CnbApiClient.getInstance().request('GET', `/${repo}/-/issues/${issueId}`);
31
+ async function getIssue(repo, issueId) {
32
+ return client_js_1.default.getInstance().request('GET', `/${repo}/-/issues/${issueId}`);
16
33
  }
17
- export async function createIssue(repo, params) {
34
+ async function createIssue(repo, params) {
18
35
  const newParams = Object.entries(params).reduce((acc, [key, value]) => {
19
36
  if (value === undefined)
20
37
  return acc;
21
38
  Object.assign(acc, { [key]: value });
22
39
  return acc;
23
40
  }, {});
24
- return CnbApiClient.getInstance().request('POST', `/${repo}/-/issues`, newParams, {
41
+ return client_js_1.default.getInstance().request('POST', `/${repo}/-/issues`, newParams, {
25
42
  header: { 'Content-Type': 'application/json' }
26
43
  });
27
44
  }
28
- export async function updateIssue(repo, issueId, params) {
29
- return CnbApiClient.getInstance().request('PATCH', `/${repo}/-/issues/${issueId}`, params, {
45
+ async function updateIssue(repo, issueId, params) {
46
+ return client_js_1.default.getInstance().request('PATCH', `/${repo}/-/issues/${issueId}`, params, {
30
47
  header: { 'Content-Type': 'application/json' }
31
48
  });
32
49
  }
33
- export async function listIssueComments(repo, issueId, params) {
34
- const cnbInst = CnbApiClient.getInstance();
50
+ async function listIssueComments(repo, issueId, params) {
51
+ const cnbInst = client_js_1.default.getInstance();
35
52
  const url = new URL(`/${repo}/-/issues/${issueId}/comments`, cnbInst.baseUrl);
36
53
  if (params) {
37
54
  for (const [key, value] of Object.entries(params)) {
@@ -42,32 +59,32 @@ export async function listIssueComments(repo, issueId, params) {
42
59
  }
43
60
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
44
61
  }
45
- export async function createIssueComment(repo, issueId, params) {
46
- return CnbApiClient.getInstance().request('POST', `/${repo}/-/issues/${issueId}/comments`, params, {
62
+ async function createIssueComment(repo, issueId, params) {
63
+ return client_js_1.default.getInstance().request('POST', `/${repo}/-/issues/${issueId}/comments`, params, {
47
64
  header: { 'Content-Type': 'application/json' }
48
65
  });
49
66
  }
50
- export async function updateIssueComment(repo, issueId, commentId, params) {
51
- return CnbApiClient.getInstance().request('PATCH', `/${repo}/-/issues/${issueId}/comments/${commentId}`, params, {
67
+ async function updateIssueComment(repo, issueId, commentId, params) {
68
+ return client_js_1.default.getInstance().request('PATCH', `/${repo}/-/issues/${issueId}/comments/${commentId}`, params, {
52
69
  header: { 'Content-Type': 'application/json' }
53
70
  });
54
71
  }
55
- export async function listIssueLabels(repo, issueId) {
56
- return CnbApiClient.getInstance().request('GET', `/${repo}/-/issues/${issueId}/labels`);
72
+ async function listIssueLabels(repo, issueId) {
73
+ return client_js_1.default.getInstance().request('GET', `/${repo}/-/issues/${issueId}/labels`);
57
74
  }
58
- export async function addIssueLabels(repo, issueId, labels) {
59
- return CnbApiClient.getInstance().request('POST', `/${repo}/-/issues/${issueId}/labels`, { labels }, {
75
+ async function addIssueLabels(repo, issueId, labels) {
76
+ return client_js_1.default.getInstance().request('POST', `/${repo}/-/issues/${issueId}/labels`, { labels }, {
60
77
  header: { 'Content-Type': 'application/json' }
61
78
  });
62
79
  }
63
- export async function setIssueLabels(repo, issueId, labels) {
64
- return CnbApiClient.getInstance().request('PUT', `/${repo}/-/issues/${issueId}/labels`, { labels }, {
80
+ async function setIssueLabels(repo, issueId, labels) {
81
+ return client_js_1.default.getInstance().request('PUT', `/${repo}/-/issues/${issueId}/labels`, { labels }, {
65
82
  header: { 'Content-Type': 'application/json' }
66
83
  });
67
84
  }
68
- export async function deleteIssueLabels(repo, issueId) {
69
- await CnbApiClient.getInstance().request('DELETE', `/${repo}/-/issues/${issueId}/labels`);
85
+ async function deleteIssueLabels(repo, issueId) {
86
+ await client_js_1.default.getInstance().request('DELETE', `/${repo}/-/issues/${issueId}/labels`);
70
87
  }
71
- export async function deleteIssueLabel(repo, issueId, labelName) {
72
- await CnbApiClient.getInstance().request('DELETE', `/${repo}/-/issues/${issueId}/labels/${encodeURIComponent(labelName)}`);
88
+ async function deleteIssueLabel(repo, issueId, labelName) {
89
+ await client_js_1.default.getInstance().request('DELETE', `/${repo}/-/issues/${issueId}/labels/${encodeURIComponent(labelName)}`);
73
90
  }
package/dist/api/pull.js CHANGED
@@ -1,6 +1,18 @@
1
- import CnbApiClient from './client.js';
2
- export async function listPulls(repo, params) {
3
- const cnbInst = CnbApiClient.getInstance();
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.listPulls = listPulls;
7
+ exports.getPull = getPull;
8
+ exports.createPull = createPull;
9
+ exports.updatePull = updatePull;
10
+ exports.mergePull = mergePull;
11
+ exports.listPullComments = listPullComments;
12
+ exports.createPullComment = createPullComment;
13
+ const client_js_1 = __importDefault(require("./client.js"));
14
+ async function listPulls(repo, params) {
15
+ const cnbInst = client_js_1.default.getInstance();
4
16
  const url = new URL(`/${repo}/-/pulls`, cnbInst.baseUrl);
5
17
  if (params) {
6
18
  for (const [key, value] of Object.entries(params)) {
@@ -11,26 +23,26 @@ export async function listPulls(repo, params) {
11
23
  }
12
24
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
13
25
  }
14
- export async function getPull(repo, number) {
15
- return CnbApiClient.getInstance().request('GET', `/${repo}/-/pulls/${number}`);
26
+ async function getPull(repo, number) {
27
+ return client_js_1.default.getInstance().request('GET', `/${repo}/-/pulls/${number}`);
16
28
  }
17
- export async function createPull(repo, params) {
18
- return CnbApiClient.getInstance().request('POST', `/${repo}/-/pulls`, params, {
29
+ async function createPull(repo, params) {
30
+ return client_js_1.default.getInstance().request('POST', `/${repo}/-/pulls`, params, {
19
31
  header: { 'Content-Type': 'application/json' }
20
32
  });
21
33
  }
22
- export async function updatePull(repo, number, params) {
23
- return CnbApiClient.getInstance().request('PATCH', `/${repo}/-/pulls/${number}`, params, {
34
+ async function updatePull(repo, number, params) {
35
+ return client_js_1.default.getInstance().request('PATCH', `/${repo}/-/pulls/${number}`, params, {
24
36
  header: { 'Content-Type': 'application/json' }
25
37
  });
26
38
  }
27
- export async function mergePull(repo, number, params) {
28
- return CnbApiClient.getInstance().request('PUT', `/${repo}/-/pulls/${number}/merge`, params, {
39
+ async function mergePull(repo, number, params) {
40
+ return client_js_1.default.getInstance().request('PUT', `/${repo}/-/pulls/${number}/merge`, params, {
29
41
  header: { 'Content-Type': 'application/json' }
30
42
  });
31
43
  }
32
- export async function listPullComments(repo, number, params) {
33
- const cnbInst = CnbApiClient.getInstance();
44
+ async function listPullComments(repo, number, params) {
45
+ const cnbInst = client_js_1.default.getInstance();
34
46
  const url = new URL(`/${repo}/-/pulls/${number}/comments`, cnbInst.baseUrl);
35
47
  if (params) {
36
48
  for (const [key, value] of Object.entries(params)) {
@@ -41,8 +53,8 @@ export async function listPullComments(repo, number, params) {
41
53
  }
42
54
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
43
55
  }
44
- export async function createPullComment(repo, number, params) {
45
- const response = await CnbApiClient.getInstance().request('POST', `/${repo}/-/pulls/${number}/comments`, params, {
56
+ async function createPullComment(repo, number, params) {
57
+ const response = await client_js_1.default.getInstance().request('POST', `/${repo}/-/pulls/${number}/comments`, params, {
46
58
  header: { 'Content-Type': 'application/json' }
47
59
  }, 'raw');
48
60
  if (response.status === 201) {
@@ -1,6 +1,15 @@
1
- import CnbApiClient from './client.js';
2
- export async function listRepositories(params) {
3
- const cnbInst = CnbApiClient.getInstance();
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.listRepositories = listRepositories;
7
+ exports.listGroupRepositories = listGroupRepositories;
8
+ exports.getRepository = getRepository;
9
+ exports.createRepository = createRepository;
10
+ const client_js_1 = __importDefault(require("./client.js"));
11
+ async function listRepositories(params) {
12
+ const cnbInst = client_js_1.default.getInstance();
4
13
  const url = new URL('/user/repos', cnbInst.baseUrl);
5
14
  if (params) {
6
15
  for (const [key, value] of Object.entries(params)) {
@@ -11,8 +20,8 @@ export async function listRepositories(params) {
11
20
  }
12
21
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
13
22
  }
14
- export async function listGroupRepositories(group, params) {
15
- const cnbInst = CnbApiClient.getInstance();
23
+ async function listGroupRepositories(group, params) {
24
+ const cnbInst = client_js_1.default.getInstance();
16
25
  const url = new URL(`/${group}/-/repos`, cnbInst.baseUrl);
17
26
  if (params) {
18
27
  for (const [key, value] of Object.entries(params)) {
@@ -23,17 +32,17 @@ export async function listGroupRepositories(group, params) {
23
32
  }
24
33
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
25
34
  }
26
- export async function getRepository(repo) {
27
- return CnbApiClient.getInstance().request('GET', `/${repo}`);
35
+ async function getRepository(repo) {
36
+ return client_js_1.default.getInstance().request('GET', `/${repo}`);
28
37
  }
29
- export async function createRepository(group, params) {
38
+ async function createRepository(group, params) {
30
39
  const body = Object.entries(params).reduce((acc, [key, value]) => {
31
40
  if (value === undefined)
32
41
  return acc;
33
42
  Object.assign(acc, { [key]: value });
34
43
  return acc;
35
44
  }, {});
36
- const response = await CnbApiClient.getInstance().request('POST', `/${group}/-/repos`, body, {
45
+ const response = await client_js_1.default.getInstance().request('POST', `/${group}/-/repos`, body, {
37
46
  header: { 'Content-Type': 'application/json' }
38
47
  }, 'raw');
39
48
  if (response.status === 201) {
package/dist/api/user.js CHANGED
@@ -1,5 +1,11 @@
1
- import CnbApiClient from './client.js';
2
- export async function getUser() {
3
- const cnbInst = CnbApiClient.getInstance();
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.getUser = getUser;
7
+ const client_js_1 = __importDefault(require("./client.js"));
8
+ async function getUser() {
9
+ const cnbInst = client_js_1.default.getInstance();
4
10
  return cnbInst.request('GET', '/user');
5
11
  }
@@ -1,6 +1,13 @@
1
- import CnbApiClient from './client.js';
2
- export async function listWorkspace(params) {
3
- const cnbInst = CnbApiClient.getInstance();
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.listWorkspace = listWorkspace;
7
+ exports.deleteWorkspace = deleteWorkspace;
8
+ const client_js_1 = __importDefault(require("./client.js"));
9
+ async function listWorkspace(params) {
10
+ const cnbInst = client_js_1.default.getInstance();
4
11
  const url = new URL('/workspace/list', cnbInst.baseUrl);
5
12
  if (params) {
6
13
  for (const [key, value] of Object.entries(params)) {
@@ -11,8 +18,8 @@ export async function listWorkspace(params) {
11
18
  }
12
19
  return cnbInst.request('GET', `${url.pathname}${url.search}`);
13
20
  }
14
- export async function deleteWorkspace(params) {
15
- const cnbInst = CnbApiClient.getInstance();
21
+ async function deleteWorkspace(params) {
22
+ const cnbInst = client_js_1.default.getInstance();
16
23
  const url = new URL('/workspace/delete', cnbInst.baseUrl);
17
24
  return cnbInst.request('POST', `${url.pathname}`, params, {
18
25
  header: { 'Content-Type': 'application/json' }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RepoVisibility = void 0;
4
+ var RepoVisibility;
5
+ (function (RepoVisibility) {
6
+ RepoVisibility["private"] = "Private";
7
+ RepoVisibility["public"] = "Public";
8
+ RepoVisibility["secret"] = "Secret";
9
+ })(RepoVisibility || (exports.RepoVisibility = RepoVisibility = {}));
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toolDescriptions = void 0;
4
+ const toolNames_1 = require("./toolNames");
5
+ exports.toolDescriptions = {
6
+ // 组织工具
7
+ [toolNames_1.ToolNames.LIST_GROUPS]: '获取当前用户在CNB平台里拥有权限的顶层组织列表',
8
+ [toolNames_1.ToolNames.LIST_SUB_GROUPS]: '获取当前用户在CNB平台里指定组织下拥有权限的子组织列表',
9
+ [toolNames_1.ToolNames.GET_GROUP]: '获取CNB平台指定组织的信息',
10
+ [toolNames_1.ToolNames.CREATE_GROUP]: '在CNB平台创建一个新组织',
11
+ // 仓库工具
12
+ [toolNames_1.ToolNames.LIST_REPOSITORIES]: '获取当前用户在CNB平台里拥有权限的仓库列表',
13
+ [toolNames_1.ToolNames.LIST_GROUP_REPOSITORIES]: '获取当前用户在CNB平台里指定组织下拥有权限的仓库列表',
14
+ [toolNames_1.ToolNames.GET_CURRENT_REPOSITORY]: '获取当前工作区对应的CNB平台仓库信息',
15
+ [toolNames_1.ToolNames.GET_REPOSITORY]: '获取CNB平台指定仓库的信息',
16
+ [toolNames_1.ToolNames.CREATE_REPOSITORY]: '在CNB平台创建一个新仓库',
17
+ // ISSUE 工具
18
+ [toolNames_1.ToolNames.LIST_ISSUES]: '获取CNB平台指定仓库的ISSUE列表',
19
+ [toolNames_1.ToolNames.GET_ISSUE]: '获取CNB平台指定ISSUE的信息',
20
+ [toolNames_1.ToolNames.CREATE_ISSUE]: `在CNB平台指定的仓库创建一条新ISSUE。如需添加标签,另外调用${toolNames_1.ToolNames.ADD_ISSUE_LABELS}工具`,
21
+ [toolNames_1.ToolNames.UPDATE_ISSUE]: `更新CNB平台指定ISSUE的信息。如需更新标签,另外调用${toolNames_1.ToolNames.SET_ISSUE_LABELS}工具`,
22
+ [toolNames_1.ToolNames.LIST_ISSUE_COMMENTS]: '获取CNB平台指定ISSUE的评论列表',
23
+ [toolNames_1.ToolNames.CREATE_ISSUE_COMMENT]: '在CNB平台指定的ISSUE创建一条新评论',
24
+ [toolNames_1.ToolNames.UPDATE_ISSUE_COMMENT]: '更新CNB平台指定ISSUE评论的内容',
25
+ [toolNames_1.ToolNames.LIST_ISSUE_LABELS]: '获取CNB平台指定ISSUE的标签列表',
26
+ [toolNames_1.ToolNames.ADD_ISSUE_LABELS]: '为CNB平台指定的ISSUE添加一个或多个标签',
27
+ [toolNames_1.ToolNames.SET_ISSUE_LABELS]: '变更CNB平台指定ISSUE的标签',
28
+ [toolNames_1.ToolNames.CLEAR_ISSUE_LABELS]: '清除CNB平台指定ISSUE的标签',
29
+ [toolNames_1.ToolNames.REMOVE_ISSUE_LABEL]: '移除CNB平台指定ISSUE的指定标签',
30
+ // 合并请求工具
31
+ [toolNames_1.ToolNames.LIST_PULLS]: '获取CNB平台指定仓库的合并请求列表',
32
+ [toolNames_1.ToolNames.GET_PULL]: '获取CNB平台指定合并请求的信息',
33
+ [toolNames_1.ToolNames.CREATE_PULL]: '在CNB平台指定的仓库创建一个新合并请求',
34
+ [toolNames_1.ToolNames.UPDATE_PULL]: '更新CNB平台指定合并请求的信息',
35
+ [toolNames_1.ToolNames.MERGE_PULL]: '合并CNB平台指定的合并请求',
36
+ [toolNames_1.ToolNames.LIST_PULL_COMMENTS]: '获取CNB平台指定合并请求的评论列表',
37
+ [toolNames_1.ToolNames.CREATE_PULL_COMMENT]: '在CNB平台指定的合并请求创建一条新评论',
38
+ // 云原生开发工具
39
+ [toolNames_1.ToolNames.LIST_WORKSPACES]: '获取当前用户在CNB平台的云原生开发环境列表',
40
+ [toolNames_1.ToolNames.DELETE_WORKSPACE]: '在CNB平台删除指定的云原生开发环境'
41
+ };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ToolNames = void 0;
4
+ var ToolNames;
5
+ (function (ToolNames) {
6
+ // 组织工具
7
+ ToolNames["LIST_GROUPS"] = "cnb_list_groups";
8
+ ToolNames["LIST_SUB_GROUPS"] = "cnb_list_sub_groups";
9
+ ToolNames["GET_GROUP"] = "cnb_get_group";
10
+ ToolNames["CREATE_GROUP"] = "cnb_create_group";
11
+ // 仓库工具
12
+ ToolNames["LIST_REPOSITORIES"] = "cnb_list_repositories";
13
+ ToolNames["LIST_GROUP_REPOSITORIES"] = "cnb_list_group_repositories";
14
+ ToolNames["GET_CURRENT_REPOSITORY"] = "cnb_get_current_repository";
15
+ ToolNames["GET_REPOSITORY"] = "cnb_get_repository";
16
+ ToolNames["CREATE_REPOSITORY"] = "cnb_create_repository";
17
+ // ISSUE 工具
18
+ ToolNames["LIST_ISSUES"] = "cnb_list_issues";
19
+ ToolNames["GET_ISSUE"] = "cnb_get_issue";
20
+ ToolNames["CREATE_ISSUE"] = "cnb_create_issue";
21
+ ToolNames["UPDATE_ISSUE"] = "cnb_update_issue";
22
+ ToolNames["LIST_ISSUE_COMMENTS"] = "cnb_list_issue_comments";
23
+ ToolNames["CREATE_ISSUE_COMMENT"] = "cnb_create_issue_comment";
24
+ ToolNames["UPDATE_ISSUE_COMMENT"] = "cnb_update_issue_comment";
25
+ ToolNames["LIST_ISSUE_LABELS"] = "cnb_list_issue_labels";
26
+ ToolNames["ADD_ISSUE_LABELS"] = "cnb_add_issue_labels";
27
+ ToolNames["SET_ISSUE_LABELS"] = "cnb_set_issue_labels";
28
+ ToolNames["CLEAR_ISSUE_LABELS"] = "cnb_clear_issue_labels";
29
+ ToolNames["REMOVE_ISSUE_LABEL"] = "cnb_remove_issue_label";
30
+ // 合并请求工具
31
+ ToolNames["LIST_PULLS"] = "cnb_list_pulls";
32
+ ToolNames["GET_PULL"] = "cnb_get_pull";
33
+ ToolNames["CREATE_PULL"] = "cnb_create_pull";
34
+ ToolNames["UPDATE_PULL"] = "cnb_update_pull";
35
+ ToolNames["MERGE_PULL"] = "cnb_merge_pull";
36
+ ToolNames["LIST_PULL_COMMENTS"] = "cnb_list_pull_comments";
37
+ ToolNames["CREATE_PULL_COMMENT"] = "cnb_create_pull_comment";
38
+ // 云原生开发工具
39
+ ToolNames["LIST_WORKSPACES"] = "cnb_list_workspaces";
40
+ ToolNames["DELETE_WORKSPACE"] = "cnb_delete_workspace";
41
+ })(ToolNames || (exports.ToolNames = ToolNames = {}));
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRepoPublic = isRepoPublic;
4
+ const index_js_1 = require("../constants/index.js");
5
+ const repository_js_1 = require("../api/repository.js");
6
+ const formatRepoUrl_js_1 = require("./formatRepoUrl.js");
7
+ async function isRepoPublic(url) {
8
+ const repoPath = (0, formatRepoUrl_js_1.getRepoPath)(url);
9
+ if (!repoPath)
10
+ return true;
11
+ try {
12
+ const { visibility_level } = await (0, repository_js_1.getRepository)(repoPath);
13
+ // @ts-expect-error 字段类型转换过,但 swagger 无法感知
14
+ return visibility_level === index_js_1.RepoVisibility.public;
15
+ }
16
+ catch (_a) {
17
+ return true;
18
+ }
19
+ }
@@ -1,13 +1,16 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { registerTools } from '../tools/index.js';
3
- // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#import-attributes
4
- import packageJSON from '../../package.json' with { type: 'json' };
5
- export function createMcpServer(req) {
6
- const mcpServer = new McpServer({
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createMcpServer = createMcpServer;
4
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
5
+ const index_js_1 = require("../tools/index.js");
6
+ const package_json_1 = require("../../package.json");
7
+ function createMcpServer(req) {
8
+ var _a;
9
+ const mcpServer = new mcp_js_1.McpServer({
7
10
  name: 'cnb-mcp-server',
8
- version: packageJSON.version
11
+ version: package_json_1.version
9
12
  });
10
- const token = req?.headers['authorization']?.split(' ')[1];
11
- registerTools(mcpServer, token);
13
+ const token = (_a = req === null || req === void 0 ? void 0 : req.headers['authorization']) === null || _a === void 0 ? void 0 : _a.split(' ')[1];
14
+ (0, index_js_1.registerTools)(mcpServer, token);
12
15
  return mcpServer;
13
16
  }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRepoPath = getRepoPath;
4
+ function getRepoPath(url) {
5
+ let repoPath = '';
6
+ if (!url)
7
+ return repoPath;
8
+ try {
9
+ const urlObj = new URL(url);
10
+ // Remove leading /
11
+ repoPath = urlObj.pathname.substring(1);
12
+ }
13
+ catch (_a) {
14
+ // ssh format address
15
+ repoPath = url.split(':')[1];
16
+ }
17
+ // Remove tailing .git
18
+ repoPath = repoPath.replace(/\.git$/, '');
19
+ return repoPath;
20
+ }
@@ -1,4 +1,8 @@
1
- export function formatTextToolResult(text, toolName) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatTextToolResult = formatTextToolResult;
4
+ exports.formatToolError = formatToolError;
5
+ function formatTextToolResult(text, toolName) {
2
6
  return {
3
7
  content: [
4
8
  {
@@ -8,7 +12,7 @@ export function formatTextToolResult(text, toolName) {
8
12
  ]
9
13
  };
10
14
  }
11
- export function formatToolError(error, toolName) {
15
+ function formatToolError(error, toolName) {
12
16
  return {
13
17
  content: [
14
18
  {
@@ -1,4 +1,7 @@
1
- export function stopWithWrongTransport(res) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stopWithWrongTransport = stopWithWrongTransport;
4
+ function stopWithWrongTransport(res) {
2
5
  res.status(400).json({
3
6
  jsonrpc: '2.0',
4
7
  error: {