@cnbcool/mcp-server 0.3.0 → 0.3.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.
- package/README.md +4 -0
- package/dist/tools/index.js +2 -2
- package/dist/tools/issueTools.js +31 -15
- package/dist/tools/repoTools.js +28 -16
- package/dist/tools/workspaceTools.js +17 -9
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -19,6 +19,10 @@ https://cnb.cool/examples/ecosystem/cnb-mcp-client-with-ollama
|
|
|
19
19
|
4. `npm build`
|
|
20
20
|
5. `npx @modelcontextprotocol/inspector -e API_TOKEN=xxxxxxxxxx node dist/index.js`
|
|
21
21
|
|
|
22
|
+
> @modelcontextprotocol/inspector requires Node.js: ^22.7.5
|
|
23
|
+
|
|
24
|
+
> https://github.com/modelcontextprotocol/inspector?tab=readme-ov-file#requirements
|
|
25
|
+
|
|
22
26
|
## How to configure
|
|
23
27
|
|
|
24
28
|
### Local
|
package/dist/tools/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import CnbApiClient from '../api/client.js';
|
|
|
2
2
|
import registerRepoTools from './repoTools.js';
|
|
3
3
|
import registerIssueTools from './issueTools.js';
|
|
4
4
|
import registerWorkspaceTools from './workspaceTools.js';
|
|
5
|
-
export function registerTools(server) {
|
|
5
|
+
export function registerTools(server, token) {
|
|
6
6
|
CnbApiClient.initialize({
|
|
7
7
|
baseUrl: process.env.API_BASE_URL || 'https://api.cnb.cool',
|
|
8
|
-
token: process.env.API_TOKEN || ''
|
|
8
|
+
token: process.env.API_TOKEN || token || ''
|
|
9
9
|
});
|
|
10
10
|
registerRepoTools(server);
|
|
11
11
|
registerIssueTools(server);
|
package/dist/tools/issueTools.js
CHANGED
|
@@ -3,17 +3,29 @@ import { createIssue, getIssue, listIssues } from '../api/issue.js';
|
|
|
3
3
|
export default function registerIssueTools(server) {
|
|
4
4
|
server.tool('list-issues', '查询仓库的 Issues', {
|
|
5
5
|
repo: z.string().describe('仓库路径'),
|
|
6
|
-
page: z.number().
|
|
7
|
-
page_size: z.number().
|
|
8
|
-
state: z
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
page: z.number().default(1).describe('第几页,从1开始'),
|
|
7
|
+
page_size: z.number().default(10).describe('每页多少条数据'),
|
|
8
|
+
state: z
|
|
9
|
+
.preprocess((val) => (val === null ? undefined : val), z.enum(['open', 'closed']).optional())
|
|
10
|
+
.describe('Issue 状态'),
|
|
11
|
+
keyword: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 关键字'),
|
|
12
|
+
priority: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 优先级'),
|
|
13
|
+
labels: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 标签'),
|
|
14
|
+
authors: z
|
|
15
|
+
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
16
|
+
.describe('Issue 作者的名字'),
|
|
17
|
+
assignees: z
|
|
18
|
+
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
19
|
+
.describe('Issue 处理人'),
|
|
20
|
+
updated_time_begin: z
|
|
21
|
+
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
22
|
+
.describe('Issue 更新时间的范围,开始时间点'),
|
|
23
|
+
updated_time_end: z
|
|
24
|
+
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
25
|
+
.describe('Issue 更新时间的范围,结束时间点'),
|
|
26
|
+
order_by: z
|
|
27
|
+
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
28
|
+
.describe('Issue 排序顺序')
|
|
17
29
|
}, async ({ repo, page, page_size, state, keyword, priority, labels, authors, assignees, updated_time_begin, updated_time_end, order_by }) => {
|
|
18
30
|
try {
|
|
19
31
|
const issues = await listIssues(repo, {
|
|
@@ -80,10 +92,14 @@ export default function registerIssueTools(server) {
|
|
|
80
92
|
server.tool('create-issue', '创建一个 Issue', {
|
|
81
93
|
repo: z.string().describe('仓库路径'),
|
|
82
94
|
title: z.string().describe('Issue 标题'),
|
|
83
|
-
body: z.string().optional().describe('Issue 描述'),
|
|
84
|
-
assignees: z
|
|
85
|
-
|
|
86
|
-
|
|
95
|
+
body: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 描述'),
|
|
96
|
+
assignees: z
|
|
97
|
+
.preprocess((val) => (val === null ? undefined : val), z.array(z.string()).optional())
|
|
98
|
+
.describe('一个或多个 Issue 处理人的用户名'),
|
|
99
|
+
labels: z
|
|
100
|
+
.preprocess((val) => (val === null ? undefined : val), z.array(z.string()).optional())
|
|
101
|
+
.describe('一个或多个 Issue 标签'),
|
|
102
|
+
priority: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 优先级')
|
|
87
103
|
}, async ({ repo, title, body, assignees, labels, priority }) => {
|
|
88
104
|
try {
|
|
89
105
|
const issue = await createIssue(repo, {
|
package/dist/tools/repoTools.js
CHANGED
|
@@ -3,12 +3,18 @@ import { getRepository, listGroupRepositories, listRepositories } from '../api/r
|
|
|
3
3
|
export default function registerRepoTools(server) {
|
|
4
4
|
server.tool('list-repositories', '获取当前用户拥有指定权限及其以上权限的仓库', {
|
|
5
5
|
page: z.number().default(1).describe('第几页,从1开始'),
|
|
6
|
-
page_size: z.number().default(
|
|
7
|
-
search: z.string().optional().describe('仓库关键字'),
|
|
8
|
-
filter_type: z
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
page_size: z.number().default(10).describe('每页多少条数据'),
|
|
7
|
+
search: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('仓库关键字'),
|
|
8
|
+
filter_type: z
|
|
9
|
+
.preprocess((val) => (val === null ? undefined : val), z.enum(['private', 'public', 'encrypted']).optional())
|
|
10
|
+
.describe('仓库类型'),
|
|
11
|
+
role: z
|
|
12
|
+
.preprocess((val) => (val === null ? undefined : val), z.enum(['Reporter', 'Developer', 'Master', 'Owner']).optional())
|
|
13
|
+
.describe('最小仓库权限'),
|
|
14
|
+
order_by: z
|
|
15
|
+
.preprocess((val) => (val === null ? undefined : val), z.enum(['created_at', 'last_updated_at', 'stars']).optional())
|
|
16
|
+
.describe('排序类型'),
|
|
17
|
+
desc: z.preprocess((val) => (val === null ? undefined : val), z.boolean().optional()).describe('排序顺序')
|
|
12
18
|
}, async ({ page, page_size, search, filter_type, role, order_by, desc }) => {
|
|
13
19
|
try {
|
|
14
20
|
const repos = await listRepositories({ page, page_size, search, filter_type, role, order_by, desc });
|
|
@@ -36,12 +42,18 @@ export default function registerRepoTools(server) {
|
|
|
36
42
|
server.tool('list-group-repositories', '获取分组里当前用户有权限的仓库', {
|
|
37
43
|
group: z.string().describe('组织名称'),
|
|
38
44
|
page: z.number().default(1).describe('第几页,从1开始'),
|
|
39
|
-
page_size: z.number().default(
|
|
40
|
-
search: z.string().optional().describe('仓库关键字'),
|
|
41
|
-
filter_type: z
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
page_size: z.number().default(10).describe('每页多少条数据'),
|
|
46
|
+
search: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('仓库关键字'),
|
|
47
|
+
filter_type: z
|
|
48
|
+
.preprocess((val) => (val === null ? undefined : val), z.enum(['private', 'public', 'encrypted']).optional())
|
|
49
|
+
.describe('仓库类型'),
|
|
50
|
+
descendant: z
|
|
51
|
+
.preprocess((val) => (val === null ? undefined : val), z.enum(['all', 'sub', 'grand']).optional())
|
|
52
|
+
.describe('查全部、直接属于当前组织的仓库、子组织的仓库'),
|
|
53
|
+
order_by: z
|
|
54
|
+
.preprocess((val) => (val === null ? undefined : val), z.enum(['created_at', 'last_updated_at', 'stars', 'slug_path']).optional())
|
|
55
|
+
.describe('排序类型'),
|
|
56
|
+
desc: z.preprocess((val) => (val === null ? undefined : val), z.boolean().optional()).describe('排序顺序')
|
|
45
57
|
}, async ({ group, page, page_size, search, filter_type, descendant, order_by, desc }) => {
|
|
46
58
|
try {
|
|
47
59
|
const repos = await listGroupRepositories(group, {
|
|
@@ -75,15 +87,15 @@ export default function registerRepoTools(server) {
|
|
|
75
87
|
}
|
|
76
88
|
});
|
|
77
89
|
server.tool('get-repository', '获取指定仓库信息', {
|
|
78
|
-
|
|
79
|
-
}, async ({
|
|
90
|
+
repo: z.string().describe('仓库路径')
|
|
91
|
+
}, async ({ repo }) => {
|
|
80
92
|
try {
|
|
81
|
-
const
|
|
93
|
+
const data = await getRepository(repo);
|
|
82
94
|
return {
|
|
83
95
|
content: [
|
|
84
96
|
{
|
|
85
97
|
type: 'text',
|
|
86
|
-
text: JSON.stringify(
|
|
98
|
+
text: JSON.stringify(data, null, 2)
|
|
87
99
|
}
|
|
88
100
|
]
|
|
89
101
|
};
|
|
@@ -2,18 +2,26 @@ import { z } from 'zod';
|
|
|
2
2
|
import { deleteWorkspace, listWorkspace } from '../api/workspace.js';
|
|
3
3
|
export default function registerWorkspaceTools(server) {
|
|
4
4
|
server.tool('list-workspace', '获取我的云原生开发环境列表', {
|
|
5
|
-
branch: z
|
|
5
|
+
branch: z
|
|
6
|
+
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
7
|
+
.describe('分支名,例如:main'),
|
|
6
8
|
start: z
|
|
7
|
-
.string()
|
|
8
|
-
.optional()
|
|
9
|
+
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
9
10
|
.describe('查询结束时间,格式:YYYY-MM-DD HH:mm:ssZZ,例如:2024-12-01 00:00:00+0800'),
|
|
10
|
-
end: z
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
end: z
|
|
12
|
+
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
13
|
+
.describe('查询开始时间,格式:YYYY-MM-DD HH:mm:ssZZ,例如:2024-12-01 00:00:00+0800'),
|
|
14
|
+
page: z
|
|
15
|
+
.preprocess((val) => (val === null ? undefined : val), z.number().optional())
|
|
16
|
+
.describe('分页页码,从 1 开始,默认为 1'),
|
|
17
|
+
page_size: z
|
|
18
|
+
.preprocess((val) => (val === null ? undefined : val), z.number().optional())
|
|
19
|
+
.describe('每页条数,默认为 20,最高 100'),
|
|
20
|
+
slug: z
|
|
21
|
+
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
22
|
+
.describe('仓库路径,例如:groupname/reponame'),
|
|
14
23
|
status: z
|
|
15
|
-
.enum(['running', 'closed'])
|
|
16
|
-
.optional()
|
|
24
|
+
.preprocess((val) => (val === null ? undefined : val), z.enum(['running', 'closed']).optional())
|
|
17
25
|
.describe('开发环境状态,running: 开发环境已启动,closed:开发环境已关闭,默认为所有状态')
|
|
18
26
|
}, async ({ branch, page, page_size, start, end, slug, status }) => {
|
|
19
27
|
try {
|
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.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cnb-mcp-server": "dist/index.js"
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"typescript": ">=5.5"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@modelcontextprotocol/sdk": "1.
|
|
41
|
-
"dotenv": "16.
|
|
42
|
-
"zod": "3.24.
|
|
40
|
+
"@modelcontextprotocol/sdk": "1.10.2",
|
|
41
|
+
"dotenv": "16.5.0",
|
|
42
|
+
"zod": "3.24.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@commitlint/cli": "19.8.0",
|