@zereight/mcp-gitlab 1.0.33 → 1.0.34
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/build/index.js +48 -1
- package/build/schemas.js +13 -4
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { GitLabForkSchema, GitLabReferenceSchema, GitLabRepositorySchema, GitLab
|
|
|
17
17
|
// Discussion Schemas
|
|
18
18
|
GitLabDiscussionNoteSchema, // Added
|
|
19
19
|
GitLabDiscussionSchema, UpdateMergeRequestNoteSchema, // Added
|
|
20
|
-
ListMergeRequestDiscussionsSchema, } from "./schemas.js";
|
|
20
|
+
ListMergeRequestDiscussionsSchema, GitLabTreeItemSchema, GetRepositoryTreeSchema, } from "./schemas.js";
|
|
21
21
|
/**
|
|
22
22
|
* Read version from package.json
|
|
23
23
|
*/
|
|
@@ -280,6 +280,11 @@ const allTools = [
|
|
|
280
280
|
description: "Delete a wiki page from a GitLab project",
|
|
281
281
|
inputSchema: zodToJsonSchema(DeleteWikiPageSchema),
|
|
282
282
|
},
|
|
283
|
+
{
|
|
284
|
+
name: "get_repository_tree",
|
|
285
|
+
description: "Get the repository tree for a GitLab project (list files and directories)",
|
|
286
|
+
inputSchema: zodToJsonSchema(GetRepositoryTreeSchema),
|
|
287
|
+
},
|
|
283
288
|
];
|
|
284
289
|
// Define which tools are read-only
|
|
285
290
|
const readOnlyTools = [
|
|
@@ -1401,6 +1406,41 @@ async function deleteWikiPage(projectId, slug) {
|
|
|
1401
1406
|
});
|
|
1402
1407
|
await handleGitLabError(response);
|
|
1403
1408
|
}
|
|
1409
|
+
/**
|
|
1410
|
+
* Get the repository tree for a project
|
|
1411
|
+
* @param {string} projectId - The ID or URL-encoded path of the project
|
|
1412
|
+
* @param {GetRepositoryTreeOptions} options - Options for the tree
|
|
1413
|
+
* @returns {Promise<GitLabTreeItem[]>}
|
|
1414
|
+
*/
|
|
1415
|
+
async function getRepositoryTree(options) {
|
|
1416
|
+
const queryParams = new URLSearchParams();
|
|
1417
|
+
if (options.path)
|
|
1418
|
+
queryParams.append("path", options.path);
|
|
1419
|
+
if (options.ref)
|
|
1420
|
+
queryParams.append("ref", options.ref);
|
|
1421
|
+
if (options.recursive)
|
|
1422
|
+
queryParams.append("recursive", "true");
|
|
1423
|
+
if (options.per_page)
|
|
1424
|
+
queryParams.append("per_page", options.per_page.toString());
|
|
1425
|
+
if (options.page_token)
|
|
1426
|
+
queryParams.append("page_token", options.page_token);
|
|
1427
|
+
if (options.pagination)
|
|
1428
|
+
queryParams.append("pagination", options.pagination);
|
|
1429
|
+
const response = await fetch(`${GITLAB_API_URL}/projects/${encodeURIComponent(options.project_id)}/repository/tree?${queryParams.toString()}`, {
|
|
1430
|
+
headers: {
|
|
1431
|
+
Authorization: `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`,
|
|
1432
|
+
"Content-Type": "application/json",
|
|
1433
|
+
},
|
|
1434
|
+
});
|
|
1435
|
+
if (response.status === 404) {
|
|
1436
|
+
throw new Error("Repository or path not found");
|
|
1437
|
+
}
|
|
1438
|
+
if (!response.ok) {
|
|
1439
|
+
throw new Error(`Failed to get repository tree: ${response.statusText}`);
|
|
1440
|
+
}
|
|
1441
|
+
const data = await response.json();
|
|
1442
|
+
return z.array(GitLabTreeItemSchema).parse(data);
|
|
1443
|
+
}
|
|
1404
1444
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
1405
1445
|
// Apply read-only filter first
|
|
1406
1446
|
const tools0 = GITLAB_READ_ONLY_MODE
|
|
@@ -1803,6 +1843,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1803
1843
|
],
|
|
1804
1844
|
};
|
|
1805
1845
|
}
|
|
1846
|
+
case "get_repository_tree": {
|
|
1847
|
+
const args = GetRepositoryTreeSchema.parse(request.params.arguments);
|
|
1848
|
+
const tree = await getRepositoryTree(args);
|
|
1849
|
+
return {
|
|
1850
|
+
content: [{ type: "text", text: JSON.stringify(tree, null, 2) }],
|
|
1851
|
+
};
|
|
1852
|
+
}
|
|
1806
1853
|
default:
|
|
1807
1854
|
throw new Error(`Unknown tool: ${request.params.name}`);
|
|
1808
1855
|
}
|
package/build/schemas.js
CHANGED
|
@@ -146,16 +146,25 @@ export const FileOperationSchema = z.object({
|
|
|
146
146
|
content: z.string(),
|
|
147
147
|
});
|
|
148
148
|
// Tree and commit schemas
|
|
149
|
-
export const
|
|
150
|
-
id: z.string(),
|
|
149
|
+
export const GitLabTreeItemSchema = z.object({
|
|
150
|
+
id: z.string(),
|
|
151
151
|
name: z.string(),
|
|
152
|
-
type: z.enum(["
|
|
152
|
+
type: z.enum(["tree", "blob"]),
|
|
153
153
|
path: z.string(),
|
|
154
154
|
mode: z.string(),
|
|
155
155
|
});
|
|
156
|
+
export const GetRepositoryTreeSchema = z.object({
|
|
157
|
+
project_id: z.string().describe("The ID or URL-encoded path of the project"),
|
|
158
|
+
path: z.string().optional().describe("The path inside the repository"),
|
|
159
|
+
ref: z.string().optional().describe("The name of a repository branch or tag. Defaults to the default branch."),
|
|
160
|
+
recursive: z.boolean().optional().describe("Boolean value to get a recursive tree"),
|
|
161
|
+
per_page: z.number().optional().describe("Number of results to show per page"),
|
|
162
|
+
page_token: z.string().optional().describe("The tree record ID for pagination"),
|
|
163
|
+
pagination: z.string().optional().describe("Pagination method (keyset)")
|
|
164
|
+
});
|
|
156
165
|
export const GitLabTreeSchema = z.object({
|
|
157
166
|
id: z.string(), // Changed from sha to match GitLab API
|
|
158
|
-
tree: z.array(
|
|
167
|
+
tree: z.array(GitLabTreeItemSchema),
|
|
159
168
|
});
|
|
160
169
|
export const GitLabCommitSchema = z.object({
|
|
161
170
|
id: z.string(), // Changed from sha to match GitLab API
|