@cnbcool/mcp-server 0.4.0-beta.5 → 0.4.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.
@@ -154,4 +154,57 @@ export default function registerRepoTools(server) {
154
154
  };
155
155
  }
156
156
  });
157
+ server.tool('get-current-repo', '获取当前仓库对应的CNB仓库信息', {
158
+ remote_url: z.string().describe('远程仓库URL, 需要先执行`git remote get-url origin`命令获取')
159
+ }, async ({ remote_url }) => {
160
+ try {
161
+ let repoPath = '';
162
+ if (remote_url.startsWith('git@')) {
163
+ // SSH 格式: git@example.com:group/repo.git
164
+ const match = remote_url.match(/git@[^:]+:(.+?)(?:\.git)?$/);
165
+ if (match) {
166
+ repoPath = match[1];
167
+ }
168
+ }
169
+ else if (remote_url.startsWith('http')) {
170
+ // HTTPS 格式: https://example.com/group/repo.git
171
+ const match = remote_url.match(/https?:\/\/[^/]+\/(.+?)(?:\.git)?$/);
172
+ if (match) {
173
+ repoPath = match[1];
174
+ }
175
+ }
176
+ if (!repoPath) {
177
+ return {
178
+ content: [
179
+ {
180
+ type: 'text',
181
+ text: `无法从远程仓库URL解析出仓库路径: ${remote_url}`
182
+ }
183
+ ],
184
+ isError: true
185
+ };
186
+ }
187
+ // 获取仓库信息
188
+ const data = await getRepository(repoPath);
189
+ return {
190
+ content: [
191
+ {
192
+ type: 'text',
193
+ text: JSON.stringify(data, null, 2)
194
+ }
195
+ ]
196
+ };
197
+ }
198
+ catch (error) {
199
+ return {
200
+ content: [
201
+ {
202
+ type: 'text',
203
+ text: `Error getting current repository: ${error instanceof Error ? error.message : String(error)}`
204
+ }
205
+ ],
206
+ isError: true
207
+ };
208
+ }
209
+ });
157
210
  }
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.0-beta.5",
4
+ "version": "0.4.0",
5
5
  "main": "./dist/stdio.js",
6
6
  "bin": {
7
7
  "cnb-mcp-stdio": "dist/stdio.js",