@cnbcool/mcp-server 0.1.0 → 0.1.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/CHANGELOG.md +15 -0
- package/README.md +6 -1
- package/dist/CnbApiClient.js +11 -0
- package/dist/index.js +4 -2
- package/dist/tools.js +29 -0
- package/package.json +6 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## 0.1.1 (March 25, 2025)
|
|
2
|
+
|
|
3
|
+
### New Features
|
|
4
|
+
|
|
5
|
+
- Supports list group repositories with various filters
|
|
6
|
+
|
|
7
|
+
## 0.1.0 (March 17, 2025)
|
|
8
|
+
|
|
9
|
+
### New Features
|
|
10
|
+
|
|
11
|
+
- Supports list user repositories with various filters
|
|
12
|
+
- Supports get repository details
|
|
13
|
+
- Supports list repository issues with various filters
|
|
14
|
+
- Supports get issue details
|
|
15
|
+
- Supports create repository issue
|
package/README.md
CHANGED
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
CNB(https://cnb.cool) toolkits for LLMs supporting the MCP protocol
|
|
4
4
|
|
|
5
|
+
## Prerequisite
|
|
6
|
+
|
|
7
|
+
1. node >= 18
|
|
8
|
+
2. typescript >=5.5
|
|
9
|
+
|
|
5
10
|
## How to develop
|
|
6
11
|
|
|
7
12
|
1. `npm install`
|
|
8
13
|
2. `npx openapi-typescript@5.4.2 https://api.cnb.cool/swagger.json -o src/schema.d.ts`
|
|
9
14
|
3. Rename `.env.example` to `.env` and fill in the values
|
|
10
15
|
4. `npm build`
|
|
11
|
-
5. `npx @modelcontextprotocol/inspector node dist/index.js`
|
|
16
|
+
5. `npx @modelcontextprotocol/inspector -e API_TOKEN=xxxxxxxxxx node dist/index.js`
|
|
12
17
|
|
|
13
18
|
## How to configure
|
|
14
19
|
|
package/dist/CnbApiClient.js
CHANGED
|
@@ -35,6 +35,17 @@ export class CnbApiClient {
|
|
|
35
35
|
}
|
|
36
36
|
return this.request('GET', `${url.pathname}${url.search}`);
|
|
37
37
|
}
|
|
38
|
+
async listGroupRepositories(group, params) {
|
|
39
|
+
const url = new URL(`/${group}/-/repos`, this.baseUrl);
|
|
40
|
+
if (params) {
|
|
41
|
+
for (const [key, value] of Object.entries(params)) {
|
|
42
|
+
if (value === undefined)
|
|
43
|
+
continue;
|
|
44
|
+
url.searchParams.set(key, value.toString());
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return this.request('GET', `${url.pathname}${url.search}`);
|
|
48
|
+
}
|
|
38
49
|
async getRepository(repo) {
|
|
39
50
|
return this.request('GET', `/${repo}`);
|
|
40
51
|
}
|
package/dist/index.js
CHANGED
|
@@ -4,14 +4,16 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
4
4
|
import dotenv from "dotenv";
|
|
5
5
|
import { CnbApiClient } from "./CnbApiClient.js";
|
|
6
6
|
import { registerTools } from "./tools.js";
|
|
7
|
+
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#import-attributes
|
|
8
|
+
import packageJSON from "../package.json" with { type: 'json' };
|
|
7
9
|
dotenv.config();
|
|
8
10
|
const cnbApiClient = new CnbApiClient({
|
|
9
11
|
baseUrl: process.env.API_BASE_URL || "https://api.cnb.cool",
|
|
10
12
|
token: process.env.API_TOKEN || ""
|
|
11
13
|
});
|
|
12
14
|
const server = new McpServer({
|
|
13
|
-
name: "cnb-
|
|
14
|
-
version:
|
|
15
|
+
name: "cnb-mcp-server",
|
|
16
|
+
version: packageJSON.version
|
|
15
17
|
});
|
|
16
18
|
registerTools(server, cnbApiClient);
|
|
17
19
|
async function main() {
|
package/dist/tools.js
CHANGED
|
@@ -28,6 +28,35 @@ export function registerTools(server, cnbApi) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
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
|
+
});
|
|
31
60
|
server.tool("get-repository", "获取指定仓库信息", {
|
|
32
61
|
repoId: z.string().describe("仓库 ID")
|
|
33
62
|
}, async ({ repoId }) => {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cnbcool/mcp-server",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "0.1.
|
|
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.1.2",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"
|
|
7
|
+
"cnb-mcp-server": "dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "https://cnb.cool/cnb/tools/mcp-server"
|
|
16
|
+
"url": "https://cnb.cool/cnb/tools/cnb-mcp-server"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
19
|
"cnb",
|
|
@@ -25,10 +25,11 @@
|
|
|
25
25
|
"files": [
|
|
26
26
|
"dist/",
|
|
27
27
|
"package.json",
|
|
28
|
+
"CHANGELOG.md",
|
|
28
29
|
"README.md"
|
|
29
30
|
],
|
|
30
31
|
"engines": {
|
|
31
|
-
"node": ">=
|
|
32
|
+
"node": ">= 18",
|
|
32
33
|
"typescript": ">=5.5"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|