@cnbcool/mcp-server 0.3.0-beta.0 → 0.3.0-beta.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.
- package/dist/api/client.js +5 -5
- package/dist/api/issue.js +5 -3
- package/dist/api/repository.js +1 -1
- package/dist/api/workspace.js +6 -6
- package/dist/index.js +10 -10
- package/dist/tools/index.js +6 -6
- package/dist/tools/issueTools.js +73 -49
- package/dist/tools/repoTools.js +60 -40
- package/dist/tools/workspaceTools.js +33 -48
- package/package.json +27 -7
package/dist/api/client.js
CHANGED
|
@@ -6,6 +6,9 @@ export default class CnbApiClient {
|
|
|
6
6
|
this._baseUrl = options.baseUrl;
|
|
7
7
|
this._token = options.token;
|
|
8
8
|
}
|
|
9
|
+
get baseUrl() {
|
|
10
|
+
return this._baseUrl;
|
|
11
|
+
}
|
|
9
12
|
static initialize(options) {
|
|
10
13
|
if (!CnbApiClient.instance) {
|
|
11
14
|
CnbApiClient.instance = new CnbApiClient(options);
|
|
@@ -17,14 +20,11 @@ export default class CnbApiClient {
|
|
|
17
20
|
}
|
|
18
21
|
return CnbApiClient.instance;
|
|
19
22
|
}
|
|
20
|
-
get baseUrl() {
|
|
21
|
-
return this._baseUrl;
|
|
22
|
-
}
|
|
23
23
|
async request(method, path, body, config) {
|
|
24
24
|
const url = `${this._baseUrl}${path}`;
|
|
25
25
|
const headers = {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
Authorization: `Bearer ${this._token}`,
|
|
27
|
+
Accept: 'application/vnd.cnb.api+json',
|
|
28
28
|
...(config?.header || {})
|
|
29
29
|
};
|
|
30
30
|
const options = {
|
package/dist/api/issue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import CnbApiClient from
|
|
1
|
+
import CnbApiClient from './client.js';
|
|
2
2
|
export async function listIssues(repo, params) {
|
|
3
3
|
const cnbInst = CnbApiClient.getInstance();
|
|
4
4
|
const url = new URL(`/${repo}/-/issues`, cnbInst.baseUrl);
|
|
@@ -18,8 +18,10 @@ export async function createIssue(repo, params) {
|
|
|
18
18
|
const newParams = Object.entries(params).reduce((acc, [key, value]) => {
|
|
19
19
|
if (value === undefined)
|
|
20
20
|
return acc;
|
|
21
|
-
Object.assign(acc, { key: value });
|
|
21
|
+
Object.assign(acc, { [key]: value });
|
|
22
22
|
return acc;
|
|
23
23
|
}, {});
|
|
24
|
-
return CnbApiClient.getInstance().request('POST', `/${repo}/-/issues`, newParams, {
|
|
24
|
+
return CnbApiClient.getInstance().request('POST', `/${repo}/-/issues`, newParams, {
|
|
25
|
+
header: { 'Content-Type': 'application/json' }
|
|
26
|
+
});
|
|
25
27
|
}
|
package/dist/api/repository.js
CHANGED
package/dist/api/workspace.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import CnbApiClient from
|
|
1
|
+
import CnbApiClient from './client.js';
|
|
2
2
|
export async function listWorkspace(params) {
|
|
3
3
|
const cnbInst = CnbApiClient.getInstance();
|
|
4
|
-
const url = new URL(
|
|
4
|
+
const url = new URL('/workspace/list', cnbInst.baseUrl);
|
|
5
5
|
if (params) {
|
|
6
6
|
for (const [key, value] of Object.entries(params)) {
|
|
7
7
|
if (value === undefined)
|
|
@@ -9,12 +9,12 @@ export async function listWorkspace(params) {
|
|
|
9
9
|
url.searchParams.set(key, value.toString());
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
return cnbInst.request(
|
|
12
|
+
return cnbInst.request('GET', `${url.pathname}${url.search}`);
|
|
13
13
|
}
|
|
14
14
|
export async function deleteWorkspace(params) {
|
|
15
15
|
const cnbInst = CnbApiClient.getInstance();
|
|
16
|
-
const url = new URL(
|
|
17
|
-
return cnbInst.request(
|
|
18
|
-
header: {
|
|
16
|
+
const url = new URL('/workspace/delete', cnbInst.baseUrl);
|
|
17
|
+
return cnbInst.request('POST', `${url.pathname}`, params, {
|
|
18
|
+
header: { 'Content-Type': 'application/json' }
|
|
19
19
|
});
|
|
20
20
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { McpServer } from
|
|
3
|
-
import { StdioServerTransport } from
|
|
4
|
-
import dotenv from
|
|
5
|
-
import { registerTools } from
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import dotenv from 'dotenv';
|
|
5
|
+
import { registerTools } from './tools/index.js';
|
|
6
6
|
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#import-attributes
|
|
7
|
-
import packageJSON from
|
|
7
|
+
import packageJSON from '../package.json' with { type: 'json' };
|
|
8
8
|
dotenv.config();
|
|
9
9
|
const server = new McpServer({
|
|
10
|
-
name:
|
|
10
|
+
name: 'cnb-mcp-server',
|
|
11
11
|
version: packageJSON.version
|
|
12
12
|
});
|
|
13
13
|
registerTools(server);
|
|
14
14
|
async function main() {
|
|
15
|
-
console.error(
|
|
15
|
+
console.error('server starting...');
|
|
16
16
|
const transport = new StdioServerTransport();
|
|
17
17
|
await server.connect(transport);
|
|
18
|
-
console.error(
|
|
18
|
+
console.error('server connected');
|
|
19
19
|
}
|
|
20
|
-
main().catch(error => {
|
|
21
|
-
console.error(
|
|
20
|
+
main().catch((error) => {
|
|
21
|
+
console.error('Fatal error:', error);
|
|
22
22
|
process.exit(1);
|
|
23
23
|
});
|
package/dist/tools/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import CnbApiClient from
|
|
2
|
-
import registerRepoTools from
|
|
3
|
-
import registerIssueTools from
|
|
4
|
-
import registerWorkspaceTools from
|
|
1
|
+
import CnbApiClient from '../api/client.js';
|
|
2
|
+
import registerRepoTools from './repoTools.js';
|
|
3
|
+
import registerIssueTools from './issueTools.js';
|
|
4
|
+
import registerWorkspaceTools from './workspaceTools.js';
|
|
5
5
|
export function registerTools(server) {
|
|
6
6
|
CnbApiClient.initialize({
|
|
7
|
-
baseUrl: process.env.API_BASE_URL ||
|
|
8
|
-
token: process.env.API_TOKEN ||
|
|
7
|
+
baseUrl: process.env.API_BASE_URL || 'https://api.cnb.cool',
|
|
8
|
+
token: process.env.API_TOKEN || ''
|
|
9
9
|
});
|
|
10
10
|
registerRepoTools(server);
|
|
11
11
|
registerIssueTools(server);
|
package/dist/tools/issueTools.js
CHANGED
|
@@ -1,72 +1,92 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { createIssue, getIssue, listIssues } from
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createIssue, getIssue, listIssues } from '../api/issue.js';
|
|
3
3
|
export default function registerIssueTools(server) {
|
|
4
|
-
server.tool(
|
|
5
|
-
|
|
6
|
-
page: z.number().optional().describe(
|
|
7
|
-
page_size: z.number().optional().describe(
|
|
8
|
-
state: z.enum([
|
|
9
|
-
keyword: z.string().optional().describe(
|
|
10
|
-
priority: z.string().optional().describe(
|
|
11
|
-
labels: z.string().optional().describe(
|
|
12
|
-
authors: z.string().optional().describe(
|
|
13
|
-
assignees: z.string().optional().describe(
|
|
14
|
-
updated_time_begin: z.string().optional().describe(
|
|
15
|
-
updated_time_end: z.string().optional().describe(
|
|
16
|
-
order_by: z.string().optional().describe(
|
|
17
|
-
}, async ({
|
|
4
|
+
server.tool('list-issues', '查询仓库的 Issues', {
|
|
5
|
+
repo: z.string().describe('仓库路径'),
|
|
6
|
+
page: z.number().optional().describe('第几页,从1开始'),
|
|
7
|
+
page_size: z.number().optional().describe('每页多少条数据'),
|
|
8
|
+
state: z.enum(['open', 'closed']).optional().describe('Issue 状态'),
|
|
9
|
+
keyword: z.string().optional().describe('Issue 关键字'),
|
|
10
|
+
priority: z.string().optional().describe('Issue 优先级'),
|
|
11
|
+
labels: z.string().optional().describe('Issue 标签'),
|
|
12
|
+
authors: z.string().optional().describe('Issue 作者的名字'),
|
|
13
|
+
assignees: z.string().optional().describe('Issue 处理人'),
|
|
14
|
+
updated_time_begin: z.string().optional().describe('Issue 更新时间的范围,开始时间点'),
|
|
15
|
+
updated_time_end: z.string().optional().describe('Issue 更新时间的范围,结束时间点'),
|
|
16
|
+
order_by: z.string().optional().describe('Issue 排序顺序')
|
|
17
|
+
}, async ({ repo, page, page_size, state, keyword, priority, labels, authors, assignees, updated_time_begin, updated_time_end, order_by }) => {
|
|
18
18
|
try {
|
|
19
|
-
const issues = await listIssues(
|
|
19
|
+
const issues = await listIssues(repo, {
|
|
20
|
+
page,
|
|
21
|
+
page_size,
|
|
22
|
+
state,
|
|
23
|
+
keyword,
|
|
24
|
+
priority,
|
|
25
|
+
labels,
|
|
26
|
+
authors,
|
|
27
|
+
assignees,
|
|
28
|
+
updated_time_begin,
|
|
29
|
+
updated_time_end,
|
|
30
|
+
order_by
|
|
31
|
+
});
|
|
20
32
|
return {
|
|
21
|
-
content: [
|
|
22
|
-
|
|
33
|
+
content: [
|
|
34
|
+
{
|
|
35
|
+
type: 'text',
|
|
23
36
|
text: JSON.stringify(issues, null, 2)
|
|
24
|
-
}
|
|
37
|
+
}
|
|
38
|
+
]
|
|
25
39
|
};
|
|
26
40
|
}
|
|
27
41
|
catch (error) {
|
|
28
42
|
return {
|
|
29
|
-
content: [
|
|
30
|
-
|
|
43
|
+
content: [
|
|
44
|
+
{
|
|
45
|
+
type: 'text',
|
|
31
46
|
text: `Error listing issues: ${error instanceof Error ? error.message : String(error)}`
|
|
32
|
-
}
|
|
47
|
+
}
|
|
48
|
+
],
|
|
33
49
|
isError: true
|
|
34
50
|
};
|
|
35
51
|
}
|
|
36
52
|
});
|
|
37
|
-
server.tool(
|
|
38
|
-
|
|
39
|
-
issueId: z.number().describe(
|
|
40
|
-
}, async ({
|
|
53
|
+
server.tool('get-issue', '获取指定 Issue 信息', {
|
|
54
|
+
repo: z.string().describe('仓库路径'),
|
|
55
|
+
issueId: z.number().describe('Issue ID')
|
|
56
|
+
}, async ({ repo, issueId }) => {
|
|
41
57
|
try {
|
|
42
|
-
const issues = await getIssue(
|
|
58
|
+
const issues = await getIssue(repo, issueId);
|
|
43
59
|
return {
|
|
44
|
-
content: [
|
|
45
|
-
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: 'text',
|
|
46
63
|
text: JSON.stringify(issues, null, 2)
|
|
47
|
-
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
48
66
|
};
|
|
49
67
|
}
|
|
50
68
|
catch (error) {
|
|
51
69
|
return {
|
|
52
|
-
content: [
|
|
53
|
-
|
|
70
|
+
content: [
|
|
71
|
+
{
|
|
72
|
+
type: 'text',
|
|
54
73
|
text: `Error listing issues: ${error instanceof Error ? error.message : String(error)}`
|
|
55
|
-
}
|
|
74
|
+
}
|
|
75
|
+
],
|
|
56
76
|
isError: true
|
|
57
77
|
};
|
|
58
78
|
}
|
|
59
79
|
});
|
|
60
|
-
server.tool(
|
|
61
|
-
|
|
62
|
-
title: z.string().describe(
|
|
63
|
-
body: z.string().optional().describe(
|
|
64
|
-
assignees: z.array(z.string()).optional().describe(
|
|
65
|
-
labels: z.array(z.string()).optional().describe(
|
|
66
|
-
priority: z.string().optional().describe(
|
|
67
|
-
}, async ({
|
|
80
|
+
server.tool('create-issue', '创建一个 Issue', {
|
|
81
|
+
repo: z.string().describe('仓库路径'),
|
|
82
|
+
title: z.string().describe('Issue 标题'),
|
|
83
|
+
body: z.string().optional().describe('Issue 描述'),
|
|
84
|
+
assignees: z.array(z.string()).optional().describe('一个或多个 Issue 处理人的用户名'),
|
|
85
|
+
labels: z.array(z.string()).optional().describe('一个或多个 Issue 标签'),
|
|
86
|
+
priority: z.string().optional().describe('Issue 优先级')
|
|
87
|
+
}, async ({ repo, title, body, assignees, labels, priority }) => {
|
|
68
88
|
try {
|
|
69
|
-
const issue = await createIssue(
|
|
89
|
+
const issue = await createIssue(repo, {
|
|
70
90
|
title,
|
|
71
91
|
body,
|
|
72
92
|
assignees,
|
|
@@ -74,18 +94,22 @@ export default function registerIssueTools(server) {
|
|
|
74
94
|
priority
|
|
75
95
|
});
|
|
76
96
|
return {
|
|
77
|
-
content: [
|
|
78
|
-
|
|
97
|
+
content: [
|
|
98
|
+
{
|
|
99
|
+
type: 'text',
|
|
79
100
|
text: `Issue created successfully:\n${JSON.stringify(issue, null, 2)}`
|
|
80
|
-
}
|
|
101
|
+
}
|
|
102
|
+
]
|
|
81
103
|
};
|
|
82
104
|
}
|
|
83
105
|
catch (error) {
|
|
84
106
|
return {
|
|
85
|
-
content: [
|
|
86
|
-
|
|
107
|
+
content: [
|
|
108
|
+
{
|
|
109
|
+
type: 'text',
|
|
87
110
|
text: `Error creating issue: ${error instanceof Error ? error.message : String(error)}`
|
|
88
|
-
}
|
|
111
|
+
}
|
|
112
|
+
],
|
|
89
113
|
isError: true
|
|
90
114
|
};
|
|
91
115
|
}
|
package/dist/tools/repoTools.js
CHANGED
|
@@ -1,81 +1,101 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { getRepository, listGroupRepositories, listRepositories } from
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getRepository, listGroupRepositories, listRepositories } from '../api/repository.js';
|
|
3
3
|
export default function registerRepoTools(server) {
|
|
4
|
-
server.tool(
|
|
5
|
-
page: z.number().default(1).describe(
|
|
6
|
-
page_size: z.number().default(20).describe(
|
|
7
|
-
search: z.string().optional().describe(
|
|
8
|
-
filter_type: z.enum([
|
|
9
|
-
role: z.enum([
|
|
10
|
-
order_by: z.enum([
|
|
11
|
-
desc: z.boolean().optional().describe(
|
|
4
|
+
server.tool('list-repositories', '获取当前用户拥有指定权限及其以上权限的仓库', {
|
|
5
|
+
page: z.number().default(1).describe('第几页,从1开始'),
|
|
6
|
+
page_size: z.number().default(20).describe('每页多少条数据'),
|
|
7
|
+
search: z.string().optional().describe('仓库关键字'),
|
|
8
|
+
filter_type: z.enum(['private', 'public', 'encrypted']).optional().describe('仓库类型'),
|
|
9
|
+
role: z.enum(['Reporter', 'Developer', 'Master', 'Owner']).optional().describe('最小仓库权限'),
|
|
10
|
+
order_by: z.enum(['created_at', 'last_updated_at', 'stars']).optional().describe('排序类型'),
|
|
11
|
+
desc: z.boolean().optional().describe('排序顺序')
|
|
12
12
|
}, async ({ page, page_size, search, filter_type, role, order_by, desc }) => {
|
|
13
13
|
try {
|
|
14
14
|
const repos = await listRepositories({ page, page_size, search, filter_type, role, order_by, desc });
|
|
15
15
|
return {
|
|
16
|
-
content: [
|
|
17
|
-
|
|
16
|
+
content: [
|
|
17
|
+
{
|
|
18
|
+
type: 'text',
|
|
18
19
|
text: JSON.stringify(repos, null, 2)
|
|
19
|
-
}
|
|
20
|
+
}
|
|
21
|
+
]
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
catch (error) {
|
|
23
25
|
return {
|
|
24
|
-
content: [
|
|
25
|
-
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
type: 'text',
|
|
26
29
|
text: `Error listing repositories: ${error instanceof Error ? error.message : String(error)}`
|
|
27
|
-
}
|
|
30
|
+
}
|
|
31
|
+
],
|
|
28
32
|
isError: true
|
|
29
33
|
};
|
|
30
34
|
}
|
|
31
35
|
});
|
|
32
|
-
server.tool(
|
|
33
|
-
group: z.string().describe(
|
|
34
|
-
page: z.number().default(1).describe(
|
|
35
|
-
page_size: z.number().default(20).describe(
|
|
36
|
-
search: z.string().optional().describe(
|
|
37
|
-
filter_type: z.enum([
|
|
38
|
-
descendant: z.enum([
|
|
39
|
-
order_by: z.enum([
|
|
40
|
-
desc: z.boolean().optional().describe(
|
|
36
|
+
server.tool('list-group-repositories', '获取分组里当前用户有权限的仓库', {
|
|
37
|
+
group: z.string().describe('组织名称'),
|
|
38
|
+
page: z.number().default(1).describe('第几页,从1开始'),
|
|
39
|
+
page_size: z.number().default(20).describe('每页多少条数据'),
|
|
40
|
+
search: z.string().optional().describe('仓库关键字'),
|
|
41
|
+
filter_type: z.enum(['private', 'public', 'encrypted']).optional().describe('仓库类型'),
|
|
42
|
+
descendant: z.enum(['all', 'sub', 'grand']).optional().describe('查全部、直接属于当前组织的仓库、子组织的仓库'),
|
|
43
|
+
order_by: z.enum(['created_at', 'last_updated_at', 'stars', 'slug_path']).optional().describe('排序类型'),
|
|
44
|
+
desc: z.boolean().optional().describe('排序顺序')
|
|
41
45
|
}, async ({ group, page, page_size, search, filter_type, descendant, order_by, desc }) => {
|
|
42
46
|
try {
|
|
43
|
-
const repos = await listGroupRepositories(group, {
|
|
47
|
+
const repos = await listGroupRepositories(group, {
|
|
48
|
+
page,
|
|
49
|
+
page_size,
|
|
50
|
+
search,
|
|
51
|
+
filter_type,
|
|
52
|
+
descendant,
|
|
53
|
+
order_by,
|
|
54
|
+
desc
|
|
55
|
+
});
|
|
44
56
|
return {
|
|
45
|
-
content: [
|
|
46
|
-
|
|
57
|
+
content: [
|
|
58
|
+
{
|
|
59
|
+
type: 'text',
|
|
47
60
|
text: JSON.stringify(repos, null, 2)
|
|
48
|
-
}
|
|
61
|
+
}
|
|
62
|
+
]
|
|
49
63
|
};
|
|
50
64
|
}
|
|
51
65
|
catch (error) {
|
|
52
66
|
return {
|
|
53
|
-
content: [
|
|
54
|
-
|
|
67
|
+
content: [
|
|
68
|
+
{
|
|
69
|
+
type: 'text',
|
|
55
70
|
text: `Error listing repositories: ${error instanceof Error ? error.message : String(error)}`
|
|
56
|
-
}
|
|
71
|
+
}
|
|
72
|
+
],
|
|
57
73
|
isError: true
|
|
58
74
|
};
|
|
59
75
|
}
|
|
60
76
|
});
|
|
61
|
-
server.tool(
|
|
62
|
-
repoId: z.string().describe(
|
|
77
|
+
server.tool('get-repository', '获取指定仓库信息', {
|
|
78
|
+
repoId: z.string().describe('仓库 ID')
|
|
63
79
|
}, async ({ repoId }) => {
|
|
64
80
|
try {
|
|
65
81
|
const repo = await getRepository(repoId);
|
|
66
82
|
return {
|
|
67
|
-
content: [
|
|
68
|
-
|
|
83
|
+
content: [
|
|
84
|
+
{
|
|
85
|
+
type: 'text',
|
|
69
86
|
text: JSON.stringify(repo, null, 2)
|
|
70
|
-
}
|
|
87
|
+
}
|
|
88
|
+
]
|
|
71
89
|
};
|
|
72
90
|
}
|
|
73
91
|
catch (error) {
|
|
74
92
|
return {
|
|
75
|
-
content: [
|
|
76
|
-
|
|
93
|
+
content: [
|
|
94
|
+
{
|
|
95
|
+
type: 'text',
|
|
77
96
|
text: `Error getting repository: ${error instanceof Error ? error.message : String(error)}`
|
|
78
|
-
}
|
|
97
|
+
}
|
|
98
|
+
],
|
|
79
99
|
isError: true
|
|
80
100
|
};
|
|
81
101
|
}
|
|
@@ -1,92 +1,77 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { deleteWorkspace, listWorkspace } from
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { deleteWorkspace, listWorkspace } from '../api/workspace.js';
|
|
3
3
|
export default function registerWorkspaceTools(server) {
|
|
4
|
-
server.tool(
|
|
5
|
-
branch: z.string().optional().describe(
|
|
4
|
+
server.tool('list-workspace', '获取我的云原生开发环境列表', {
|
|
5
|
+
branch: z.string().optional().describe('分支名,例如:main'),
|
|
6
6
|
start: z
|
|
7
7
|
.string()
|
|
8
8
|
.optional()
|
|
9
|
-
.describe(
|
|
10
|
-
end: z
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
page: z.number().optional().describe("分页页码,从 1 开始,默认为 1"),
|
|
15
|
-
pageSize: z.number().optional().describe("每页条数,默认为 20,最高 100"),
|
|
16
|
-
slug: z
|
|
17
|
-
.string()
|
|
18
|
-
.optional()
|
|
19
|
-
.describe("仓库路径,例如:groupname/reponame"),
|
|
9
|
+
.describe('查询结束时间,格式:YYYY-MM-DD HH:mm:ssZZ,例如:2024-12-01 00:00:00+0800'),
|
|
10
|
+
end: z.string().optional().describe('查询开始时间,格式:YYYY-MM-DD HH:mm:ssZZ,例如:2024-12-01 00:00:00+0800'),
|
|
11
|
+
page: z.number().optional().describe('分页页码,从 1 开始,默认为 1'),
|
|
12
|
+
page_size: z.number().optional().describe('每页条数,默认为 20,最高 100'),
|
|
13
|
+
slug: z.string().optional().describe('仓库路径,例如:groupname/reponame'),
|
|
20
14
|
status: z
|
|
21
|
-
.enum([
|
|
15
|
+
.enum(['running', 'closed'])
|
|
22
16
|
.optional()
|
|
23
|
-
.describe(
|
|
24
|
-
}, async ({ branch, page,
|
|
25
|
-
console.log("list-workspace", {
|
|
26
|
-
branch,
|
|
27
|
-
page,
|
|
28
|
-
pageSize,
|
|
29
|
-
start,
|
|
30
|
-
end,
|
|
31
|
-
slug,
|
|
32
|
-
status,
|
|
33
|
-
});
|
|
17
|
+
.describe('开发环境状态,running: 开发环境已启动,closed:开发环境已关闭,默认为所有状态')
|
|
18
|
+
}, async ({ branch, page, page_size, start, end, slug, status }) => {
|
|
34
19
|
try {
|
|
35
20
|
const workspaces = await listWorkspace({
|
|
36
21
|
branch,
|
|
37
22
|
page,
|
|
38
|
-
pageSize,
|
|
23
|
+
pageSize: page_size,
|
|
39
24
|
start,
|
|
40
25
|
end,
|
|
41
26
|
slug,
|
|
42
|
-
status
|
|
27
|
+
status
|
|
43
28
|
});
|
|
44
29
|
return {
|
|
45
30
|
content: [
|
|
46
31
|
{
|
|
47
|
-
type:
|
|
48
|
-
text: JSON.stringify(workspaces, null, 2)
|
|
49
|
-
}
|
|
50
|
-
]
|
|
32
|
+
type: 'text',
|
|
33
|
+
text: JSON.stringify(workspaces, null, 2)
|
|
34
|
+
}
|
|
35
|
+
]
|
|
51
36
|
};
|
|
52
37
|
}
|
|
53
38
|
catch (error) {
|
|
54
39
|
return {
|
|
55
40
|
content: [
|
|
56
41
|
{
|
|
57
|
-
type:
|
|
58
|
-
text: `Error listing workspace: ${error instanceof Error ? error.message : String(error)}
|
|
59
|
-
}
|
|
42
|
+
type: 'text',
|
|
43
|
+
text: `Error listing workspace: ${error instanceof Error ? error.message : String(error)}`
|
|
44
|
+
}
|
|
60
45
|
],
|
|
61
|
-
isError: true
|
|
46
|
+
isError: true
|
|
62
47
|
};
|
|
63
48
|
}
|
|
64
49
|
});
|
|
65
|
-
server.tool(
|
|
66
|
-
pipelineId: z.string().describe(
|
|
50
|
+
server.tool('delete-workspace', '删除我的云原生开发环境', {
|
|
51
|
+
pipelineId: z.string().describe('开发环境 ID')
|
|
67
52
|
}, async ({ pipelineId }) => {
|
|
68
53
|
try {
|
|
69
54
|
const result = await deleteWorkspace({
|
|
70
|
-
pipelineId
|
|
55
|
+
pipelineId
|
|
71
56
|
});
|
|
72
57
|
return {
|
|
73
58
|
content: [
|
|
74
59
|
{
|
|
75
|
-
type:
|
|
76
|
-
text: JSON.stringify(result, null, 2)
|
|
77
|
-
}
|
|
78
|
-
]
|
|
60
|
+
type: 'text',
|
|
61
|
+
text: JSON.stringify(result, null, 2)
|
|
62
|
+
}
|
|
63
|
+
]
|
|
79
64
|
};
|
|
80
65
|
}
|
|
81
66
|
catch (error) {
|
|
82
67
|
return {
|
|
83
68
|
content: [
|
|
84
69
|
{
|
|
85
|
-
type:
|
|
86
|
-
text: `error delete workspace: ${error instanceof Error ? error.message : String(error)}
|
|
87
|
-
}
|
|
70
|
+
type: 'text',
|
|
71
|
+
text: `error delete workspace: ${error instanceof Error ? error.message : String(error)}`
|
|
72
|
+
}
|
|
88
73
|
],
|
|
89
|
-
isError: true
|
|
74
|
+
isError: true
|
|
90
75
|
};
|
|
91
76
|
}
|
|
92
77
|
});
|
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.3.0-beta.
|
|
4
|
+
"version": "0.3.0-beta.2",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cnb-mcp-server": "dist/index.js"
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsc",
|
|
12
|
-
"start": "node dist/index.js"
|
|
12
|
+
"start": "node dist/index.js",
|
|
13
|
+
"prepare": "husky",
|
|
14
|
+
"lint": "eslint src",
|
|
15
|
+
"format": "prettier --check src"
|
|
13
16
|
},
|
|
14
17
|
"repository": {
|
|
15
18
|
"type": "git",
|
|
@@ -33,12 +36,29 @@
|
|
|
33
36
|
"typescript": ">=5.5"
|
|
34
37
|
},
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"@modelcontextprotocol/sdk": "
|
|
37
|
-
"dotenv": "
|
|
38
|
-
"zod": "
|
|
39
|
+
"@modelcontextprotocol/sdk": "1.6.1",
|
|
40
|
+
"dotenv": "16.4.7",
|
|
41
|
+
"zod": "3.24.2"
|
|
39
42
|
},
|
|
40
43
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"
|
|
44
|
+
"@commitlint/cli": "19.8.0",
|
|
45
|
+
"@commitlint/config-conventional": "19.8.0",
|
|
46
|
+
"@eslint/js": "9.24.0",
|
|
47
|
+
"@types/node": "22.13.9",
|
|
48
|
+
"eslint": "9.24.0",
|
|
49
|
+
"eslint-config-prettier": "10.1.2",
|
|
50
|
+
"eslint-plugin-prettier": "5.2.6",
|
|
51
|
+
"globals": "16.0.0",
|
|
52
|
+
"husky": "9.1.7",
|
|
53
|
+
"lint-staged": "15.5.1",
|
|
54
|
+
"prettier": "3.5.3",
|
|
55
|
+
"typescript": "5.8.2",
|
|
56
|
+
"typescript-eslint": "8.30.1"
|
|
57
|
+
},
|
|
58
|
+
"lint-staged": {
|
|
59
|
+
"**/*": [
|
|
60
|
+
"eslint --fix src",
|
|
61
|
+
"prettier --write --ignore-unknown src"
|
|
62
|
+
]
|
|
43
63
|
}
|
|
44
64
|
}
|