@cnbcool/mcp-server 0.1.2 → 0.2.0-beta.0
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/index.js +1 -1
- package/dist/tools/index.js +6 -0
- package/dist/{tools.js → tools/issueTools.js} +1 -80
- package/dist/tools/repoTools.js +82 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import dotenv from "dotenv";
|
|
5
5
|
import { CnbApiClient } from "./CnbApiClient.js";
|
|
6
|
-
import { registerTools } from "./tools.js";
|
|
6
|
+
import { registerTools } from "./tools/index.js";
|
|
7
7
|
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#import-attributes
|
|
8
8
|
import packageJSON from "../package.json" with { type: 'json' };
|
|
9
9
|
dotenv.config();
|
|
@@ -1,84 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export function
|
|
3
|
-
server.tool("list-repositories", "获取当前用户拥有指定权限及其以上权限的仓库", {
|
|
4
|
-
page: z.number().default(1).describe("第几页,从1开始"),
|
|
5
|
-
page_size: z.number().default(20).describe("每页多少条数据"),
|
|
6
|
-
search: z.string().optional().describe("仓库关键字"),
|
|
7
|
-
filter_type: z.enum(["private", "public", "encrypted"]).optional().describe("仓库类型"),
|
|
8
|
-
role: z.enum(["Reporter", "Developer", "Master", "Owner"]).optional().describe("最小仓库权限"),
|
|
9
|
-
order_by: z.enum(["created_at", "last_updated_at", "stars"]).optional().describe("排序类型"),
|
|
10
|
-
desc: z.boolean().optional().describe("排序顺序")
|
|
11
|
-
}, async ({ page, page_size, search, filter_type, role, order_by, desc }) => {
|
|
12
|
-
try {
|
|
13
|
-
const repos = await cnbApi.listRepositories({ page, page_size, search, filter_type, role, order_by, desc });
|
|
14
|
-
return {
|
|
15
|
-
content: [{
|
|
16
|
-
type: "text",
|
|
17
|
-
text: JSON.stringify(repos, null, 2)
|
|
18
|
-
}]
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
return {
|
|
23
|
-
content: [{
|
|
24
|
-
type: "text",
|
|
25
|
-
text: `Error listing repositories: ${error instanceof Error ? error.message : String(error)}`
|
|
26
|
-
}],
|
|
27
|
-
isError: true
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
server.tool("list-group-repositories", "获取分组里当前用户有权限的仓库", {
|
|
32
|
-
group: z.string().describe("组织名称"),
|
|
33
|
-
page: z.number().default(1).describe("第几页,从1开始"),
|
|
34
|
-
page_size: z.number().default(20).describe("每页多少条数据"),
|
|
35
|
-
search: z.string().optional().describe("仓库关键字"),
|
|
36
|
-
filter_type: z.enum(["private", "public", "encrypted"]).optional().describe("仓库类型"),
|
|
37
|
-
descendant: z.enum(["all", "sub", "grand"]).optional().describe("查全部、直接属于当前组织的仓库、子组织的仓库"),
|
|
38
|
-
order_by: z.enum(["created_at", "last_updated_at", "stars", "slug_path"]).optional().describe("排序类型"),
|
|
39
|
-
desc: z.boolean().optional().describe("排序顺序")
|
|
40
|
-
}, async ({ group, page, page_size, search, filter_type, descendant, order_by, desc }) => {
|
|
41
|
-
try {
|
|
42
|
-
const repos = await cnbApi.listGroupRepositories(group, { page, page_size, search, filter_type, descendant, order_by, desc });
|
|
43
|
-
return {
|
|
44
|
-
content: [{
|
|
45
|
-
type: "text",
|
|
46
|
-
text: JSON.stringify(repos, null, 2)
|
|
47
|
-
}]
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
return {
|
|
52
|
-
content: [{
|
|
53
|
-
type: "text",
|
|
54
|
-
text: `Error listing repositories: ${error instanceof Error ? error.message : String(error)}`
|
|
55
|
-
}],
|
|
56
|
-
isError: true
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
server.tool("get-repository", "获取指定仓库信息", {
|
|
61
|
-
repoId: z.string().describe("仓库 ID")
|
|
62
|
-
}, async ({ repoId }) => {
|
|
63
|
-
try {
|
|
64
|
-
const repo = await cnbApi.getRepository(repoId);
|
|
65
|
-
return {
|
|
66
|
-
content: [{
|
|
67
|
-
type: "text",
|
|
68
|
-
text: JSON.stringify(repo, null, 2)
|
|
69
|
-
}]
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
return {
|
|
74
|
-
content: [{
|
|
75
|
-
type: "text",
|
|
76
|
-
text: `Error getting repository: ${error instanceof Error ? error.message : String(error)}`
|
|
77
|
-
}],
|
|
78
|
-
isError: true
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
});
|
|
2
|
+
export default function registerIssueTools(server, cnbApi) {
|
|
82
3
|
server.tool("list-issues", "查询仓库的 Issues", {
|
|
83
4
|
repoId: z.string().describe("仓库 ID"),
|
|
84
5
|
page: z.number().optional().describe("第几页,从1开始"),
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export default function registerRepoTools(server, cnbApi) {
|
|
3
|
+
server.tool("list-repositories", "获取当前用户拥有指定权限及其以上权限的仓库", {
|
|
4
|
+
page: z.number().default(1).describe("第几页,从1开始"),
|
|
5
|
+
page_size: z.number().default(20).describe("每页多少条数据"),
|
|
6
|
+
search: z.string().optional().describe("仓库关键字"),
|
|
7
|
+
filter_type: z.enum(["private", "public", "encrypted"]).optional().describe("仓库类型"),
|
|
8
|
+
role: z.enum(["Reporter", "Developer", "Master", "Owner"]).optional().describe("最小仓库权限"),
|
|
9
|
+
order_by: z.enum(["created_at", "last_updated_at", "stars"]).optional().describe("排序类型"),
|
|
10
|
+
desc: z.boolean().optional().describe("排序顺序")
|
|
11
|
+
}, async ({ page, page_size, search, filter_type, role, order_by, desc }) => {
|
|
12
|
+
try {
|
|
13
|
+
const repos = await cnbApi.listRepositories({ page, page_size, search, filter_type, role, order_by, desc });
|
|
14
|
+
return {
|
|
15
|
+
content: [{
|
|
16
|
+
type: "text",
|
|
17
|
+
text: JSON.stringify(repos, null, 2)
|
|
18
|
+
}]
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return {
|
|
23
|
+
content: [{
|
|
24
|
+
type: "text",
|
|
25
|
+
text: `Error listing repositories: ${error instanceof Error ? error.message : String(error)}`
|
|
26
|
+
}],
|
|
27
|
+
isError: true
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
server.tool("list-group-repositories", "获取分组里当前用户有权限的仓库", {
|
|
32
|
+
group: z.string().describe("组织名称"),
|
|
33
|
+
page: z.number().default(1).describe("第几页,从1开始"),
|
|
34
|
+
page_size: z.number().default(20).describe("每页多少条数据"),
|
|
35
|
+
search: z.string().optional().describe("仓库关键字"),
|
|
36
|
+
filter_type: z.enum(["private", "public", "encrypted"]).optional().describe("仓库类型"),
|
|
37
|
+
descendant: z.enum(["all", "sub", "grand"]).optional().describe("查全部、直接属于当前组织的仓库、子组织的仓库"),
|
|
38
|
+
order_by: z.enum(["created_at", "last_updated_at", "stars", "slug_path"]).optional().describe("排序类型"),
|
|
39
|
+
desc: z.boolean().optional().describe("排序顺序")
|
|
40
|
+
}, async ({ group, page, page_size, search, filter_type, descendant, order_by, desc }) => {
|
|
41
|
+
try {
|
|
42
|
+
const repos = await cnbApi.listGroupRepositories(group, { page, page_size, search, filter_type, descendant, order_by, desc });
|
|
43
|
+
return {
|
|
44
|
+
content: [{
|
|
45
|
+
type: "text",
|
|
46
|
+
text: JSON.stringify(repos, null, 2)
|
|
47
|
+
}]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return {
|
|
52
|
+
content: [{
|
|
53
|
+
type: "text",
|
|
54
|
+
text: `Error listing repositories: ${error instanceof Error ? error.message : String(error)}`
|
|
55
|
+
}],
|
|
56
|
+
isError: true
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
server.tool("get-repository", "获取指定仓库信息", {
|
|
61
|
+
repoId: z.string().describe("仓库 ID")
|
|
62
|
+
}, async ({ repoId }) => {
|
|
63
|
+
try {
|
|
64
|
+
const repo = await cnbApi.getRepository(repoId);
|
|
65
|
+
return {
|
|
66
|
+
content: [{
|
|
67
|
+
type: "text",
|
|
68
|
+
text: JSON.stringify(repo, null, 2)
|
|
69
|
+
}]
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
return {
|
|
74
|
+
content: [{
|
|
75
|
+
type: "text",
|
|
76
|
+
text: `Error getting repository: ${error instanceof Error ? error.message : String(error)}`
|
|
77
|
+
}],
|
|
78
|
+
isError: true
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
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.
|
|
4
|
+
"version": "0.2.0-beta.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cnb-mcp-server": "dist/index.js"
|