@zereight/mcp-gitlab 1.0.53 → 1.0.55
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 +54 -53
- package/build/index.js +138 -4
- package/build/schemas.js +75 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,7 +91,6 @@ $ sh scripts/image_push.sh docker_user_name
|
|
|
91
91
|
## Tools 🛠️
|
|
92
92
|
|
|
93
93
|
+<!-- TOOLS-START -->
|
|
94
|
-
|
|
95
94
|
1. `create_or_update_file` - Create or update a single file in a GitLab project
|
|
96
95
|
2. `search_repositories` - Search for GitLab projects
|
|
97
96
|
3. `create_repository` - Create a new GitLab project
|
|
@@ -103,56 +102,58 @@ $ sh scripts/image_push.sh docker_user_name
|
|
|
103
102
|
9. `create_branch` - Create a new branch in a GitLab project
|
|
104
103
|
10. `get_merge_request` - Get details of a merge request (Either mergeRequestIid or branchName must be provided)
|
|
105
104
|
11. `get_merge_request_diffs` - Get the changes/diffs of a merge request (Either mergeRequestIid or branchName must be provided)
|
|
106
|
-
12. `
|
|
107
|
-
13. `
|
|
108
|
-
14. `
|
|
109
|
-
15. `
|
|
110
|
-
16. `
|
|
111
|
-
17. `
|
|
112
|
-
18. `
|
|
113
|
-
19. `
|
|
114
|
-
20. `
|
|
115
|
-
21. `
|
|
116
|
-
22. `
|
|
117
|
-
23. `
|
|
118
|
-
24. `
|
|
119
|
-
25. `
|
|
120
|
-
26. `
|
|
121
|
-
27. `
|
|
122
|
-
28. `
|
|
123
|
-
29. `
|
|
124
|
-
30. `
|
|
125
|
-
31. `
|
|
126
|
-
32. `
|
|
127
|
-
33. `
|
|
128
|
-
34. `
|
|
129
|
-
35. `
|
|
130
|
-
36. `
|
|
131
|
-
37. `
|
|
132
|
-
38. `
|
|
133
|
-
39. `
|
|
134
|
-
40. `
|
|
135
|
-
41. `
|
|
136
|
-
42. `
|
|
137
|
-
43. `
|
|
138
|
-
44. `
|
|
139
|
-
45. `
|
|
140
|
-
46. `
|
|
141
|
-
47. `
|
|
142
|
-
48. `
|
|
143
|
-
49. `
|
|
144
|
-
50. `
|
|
145
|
-
51. `
|
|
146
|
-
52. `
|
|
147
|
-
53. `
|
|
148
|
-
54. `
|
|
149
|
-
55. `
|
|
150
|
-
56. `
|
|
151
|
-
57. `
|
|
152
|
-
58. `
|
|
153
|
-
59. `
|
|
154
|
-
60. `
|
|
155
|
-
61. `
|
|
156
|
-
62. `
|
|
157
|
-
63. `
|
|
105
|
+
12. `get_branch_diffs` - Get the changes/diffs between two branches or commits in a GitLab project
|
|
106
|
+
13. `update_merge_request` - Update a merge request (Either mergeRequestIid or branchName must be provided)
|
|
107
|
+
14. `create_note` - Create a new note (comment) to an issue or merge request
|
|
108
|
+
15. `create_merge_request_thread` - Create a new thread on a merge request
|
|
109
|
+
16. `mr_discussions` - List discussion items for a merge request
|
|
110
|
+
17. `update_merge_request_note` - Modify an existing merge request thread note
|
|
111
|
+
18. `create_merge_request_note` - Add a new note to an existing merge request thread
|
|
112
|
+
19. `update_issue_note` - Modify an existing issue thread note
|
|
113
|
+
20. `create_issue_note` - Add a new note to an existing issue thread
|
|
114
|
+
21. `list_issues` - List issues in a GitLab project with filtering options
|
|
115
|
+
22. `get_issue` - Get details of a specific issue in a GitLab project
|
|
116
|
+
23. `update_issue` - Update an issue in a GitLab project
|
|
117
|
+
24. `delete_issue` - Delete an issue from a GitLab project
|
|
118
|
+
25. `list_issue_links` - List all issue links for a specific issue
|
|
119
|
+
26. `list_issue_discussions` - List discussions for an issue in a GitLab project
|
|
120
|
+
27. `get_issue_link` - Get a specific issue link
|
|
121
|
+
28. `create_issue_link` - Create an issue link between two issues
|
|
122
|
+
29. `delete_issue_link` - Delete an issue link
|
|
123
|
+
30. `list_namespaces` - List all namespaces available to the current user
|
|
124
|
+
31. `get_namespace` - Get details of a namespace by ID or path
|
|
125
|
+
32. `verify_namespace` - Verify if a namespace path exists
|
|
126
|
+
33. `get_project` - Get details of a specific project
|
|
127
|
+
34. `list_projects` - List projects accessible by the current user
|
|
128
|
+
35. `list_labels` - List labels for a project
|
|
129
|
+
36. `get_label` - Get a single label from a project
|
|
130
|
+
37. `create_label` - Create a new label in a project
|
|
131
|
+
38. `update_label` - Update an existing label in a project
|
|
132
|
+
39. `delete_label` - Delete a label from a project
|
|
133
|
+
40. `list_group_projects` - List projects in a GitLab group with filtering options
|
|
134
|
+
41. `list_wiki_pages` - List wiki pages in a GitLab project
|
|
135
|
+
42. `get_wiki_page` - Get details of a specific wiki page
|
|
136
|
+
43. `create_wiki_page` - Create a new wiki page in a GitLab project
|
|
137
|
+
44. `update_wiki_page` - Update an existing wiki page in a GitLab project
|
|
138
|
+
45. `delete_wiki_page` - Delete a wiki page from a GitLab project
|
|
139
|
+
46. `get_repository_tree` - Get the repository tree for a GitLab project (list files and directories)
|
|
140
|
+
47. `list_pipelines` - List pipelines in a GitLab project with filtering options
|
|
141
|
+
48. `get_pipeline` - Get details of a specific pipeline in a GitLab project
|
|
142
|
+
49. `list_pipeline_jobs` - List all jobs in a specific pipeline
|
|
143
|
+
50. `get_pipeline_job` - Get details of a GitLab pipeline job number
|
|
144
|
+
51. `get_pipeline_job_output` - Get the output/trace of a GitLab pipeline job number
|
|
145
|
+
52. `create_pipeline` - Create a new pipeline for a branch or tag
|
|
146
|
+
53. `retry_pipeline` - Retry a failed or canceled pipeline
|
|
147
|
+
54. `cancel_pipeline` - Cancel a running pipeline
|
|
148
|
+
55. `list_merge_requests` - List merge requests in a GitLab project with filtering options
|
|
149
|
+
56. `list_milestones` - List milestones in a GitLab project with filtering options
|
|
150
|
+
57. `get_milestone` - Get details of a specific milestone
|
|
151
|
+
58. `create_milestone` - Create a new milestone in a GitLab project
|
|
152
|
+
59. `edit_milestone` - Edit an existing milestone in a GitLab project
|
|
153
|
+
60. `delete_milestone` - Delete a milestone from a GitLab project
|
|
154
|
+
61. `get_milestone_issue` - Get issues associated with a specific milestone
|
|
155
|
+
62. `get_milestone_merge_requests` - Get merge requests associated with a specific milestone
|
|
156
|
+
63. `promote_milestone` - Promote a milestone to the next stage
|
|
157
|
+
64. `get_milestone_burndown_events` - Get burndown events for a specific milestone
|
|
158
|
+
65. `get_users` - Get GitLab user details by usernames
|
|
158
159
|
<!-- TOOLS-END -->
|
package/build/index.js
CHANGED
|
@@ -12,15 +12,18 @@ import { fileURLToPath } from "url";
|
|
|
12
12
|
import { dirname } from "path";
|
|
13
13
|
import fs from "fs";
|
|
14
14
|
import path from "path";
|
|
15
|
+
// Add type imports for proxy agents
|
|
16
|
+
import { Agent } from "http";
|
|
17
|
+
import { Agent as HttpsAgent } from 'https';
|
|
15
18
|
import { URL } from "url";
|
|
16
|
-
import { GitLabForkSchema, GitLabReferenceSchema, GitLabRepositorySchema, GitLabIssueSchema, GitLabMergeRequestSchema, GitLabContentSchema, GitLabCreateUpdateFileResponseSchema, GitLabSearchResponseSchema, GitLabTreeSchema, GitLabCommitSchema, GitLabNamespaceSchema, GitLabNamespaceExistsResponseSchema, GitLabProjectSchema, CreateOrUpdateFileSchema, SearchRepositoriesSchema, CreateRepositorySchema, GetFileContentsSchema, PushFilesSchema, CreateIssueSchema, CreateMergeRequestSchema, ForkRepositorySchema, CreateBranchSchema,
|
|
19
|
+
import { GitLabForkSchema, GitLabReferenceSchema, GitLabRepositorySchema, GitLabIssueSchema, GitLabMergeRequestSchema, GitLabContentSchema, GitLabCreateUpdateFileResponseSchema, GitLabSearchResponseSchema, GitLabTreeSchema, GitLabCommitSchema, GitLabNamespaceSchema, GitLabNamespaceExistsResponseSchema, GitLabProjectSchema, GitLabUserSchema, GitLabUsersResponseSchema, GetUsersSchema, CreateOrUpdateFileSchema, SearchRepositoriesSchema, CreateRepositorySchema, GetFileContentsSchema, PushFilesSchema, CreateIssueSchema, CreateMergeRequestSchema, ForkRepositorySchema, CreateBranchSchema, GitLabDiffSchema, GetMergeRequestSchema, GetMergeRequestDiffsSchema, UpdateMergeRequestSchema, ListIssuesSchema, GetIssueSchema, UpdateIssueSchema, DeleteIssueSchema, GitLabIssueLinkSchema, GitLabIssueWithLinkDetailsSchema, ListIssueLinksSchema, ListIssueDiscussionsSchema, GetIssueLinkSchema, CreateIssueLinkSchema, DeleteIssueLinkSchema, ListNamespacesSchema, GetNamespaceSchema, VerifyNamespaceSchema, GetProjectSchema, ListProjectsSchema, ListLabelsSchema, GetLabelSchema, CreateLabelSchema, UpdateLabelSchema, DeleteLabelSchema, CreateNoteSchema, CreateMergeRequestThreadSchema, ListGroupProjectsSchema, ListWikiPagesSchema, GetWikiPageSchema, CreateWikiPageSchema, UpdateWikiPageSchema, DeleteWikiPageSchema, GitLabWikiPageSchema, GetRepositoryTreeSchema, GitLabTreeItemSchema, GitLabPipelineSchema, GetPipelineSchema, ListPipelinesSchema, ListPipelineJobsSchema, CreatePipelineSchema, RetryPipelineSchema, CancelPipelineSchema,
|
|
17
20
|
// pipeline job schemas
|
|
18
21
|
GetPipelineJobOutputSchema, GitLabPipelineJobSchema,
|
|
19
22
|
// Discussion Schemas
|
|
20
23
|
GitLabDiscussionNoteSchema, // Added
|
|
21
24
|
GitLabDiscussionSchema, UpdateMergeRequestNoteSchema, // Added
|
|
22
25
|
CreateMergeRequestNoteSchema, // Added
|
|
23
|
-
ListMergeRequestDiscussionsSchema, UpdateIssueNoteSchema, CreateIssueNoteSchema, ListMergeRequestsSchema, GitLabMilestonesSchema, ListProjectMilestonesSchema, GetProjectMilestoneSchema, CreateProjectMilestoneSchema, EditProjectMilestoneSchema, DeleteProjectMilestoneSchema, GetMilestoneIssuesSchema, GetMilestoneMergeRequestsSchema, PromoteProjectMilestoneSchema, GetMilestoneBurndownEventsSchema, } from "./schemas.js";
|
|
26
|
+
ListMergeRequestDiscussionsSchema, UpdateIssueNoteSchema, CreateIssueNoteSchema, ListMergeRequestsSchema, GitLabMilestonesSchema, ListProjectMilestonesSchema, GetProjectMilestoneSchema, CreateProjectMilestoneSchema, EditProjectMilestoneSchema, DeleteProjectMilestoneSchema, GetMilestoneIssuesSchema, GetMilestoneMergeRequestsSchema, PromoteProjectMilestoneSchema, GetMilestoneBurndownEventsSchema, GitLabCompareResultSchema, GetBranchDiffsSchema, } from "./schemas.js";
|
|
24
27
|
/**
|
|
25
28
|
* Read version from package.json
|
|
26
29
|
*/
|
|
@@ -53,6 +56,16 @@ const USE_PIPELINE = process.env.USE_PIPELINE === "true";
|
|
|
53
56
|
// Add proxy configuration
|
|
54
57
|
const HTTP_PROXY = process.env.HTTP_PROXY;
|
|
55
58
|
const HTTPS_PROXY = process.env.HTTPS_PROXY;
|
|
59
|
+
const NODE_TLS_REJECT_UNAUTHORIZED = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
|
|
60
|
+
const GITLAB_CA_CERT_PATH = process.env.GITLAB_CA_CERT_PATH;
|
|
61
|
+
let sslOptions = undefined;
|
|
62
|
+
if (NODE_TLS_REJECT_UNAUTHORIZED === '0') {
|
|
63
|
+
sslOptions = { rejectUnauthorized: false };
|
|
64
|
+
}
|
|
65
|
+
else if (GITLAB_CA_CERT_PATH) {
|
|
66
|
+
const ca = fs.readFileSync(GITLAB_CA_CERT_PATH);
|
|
67
|
+
sslOptions = { ca };
|
|
68
|
+
}
|
|
56
69
|
// Configure proxy agents if proxies are set
|
|
57
70
|
let httpAgent = undefined;
|
|
58
71
|
let httpsAgent = undefined;
|
|
@@ -69,9 +82,11 @@ if (HTTPS_PROXY) {
|
|
|
69
82
|
httpsAgent = new SocksProxyAgent(HTTPS_PROXY);
|
|
70
83
|
}
|
|
71
84
|
else {
|
|
72
|
-
httpsAgent = new HttpsProxyAgent(HTTPS_PROXY);
|
|
85
|
+
httpsAgent = new HttpsProxyAgent(HTTPS_PROXY, sslOptions);
|
|
73
86
|
}
|
|
74
87
|
}
|
|
88
|
+
httpsAgent = httpsAgent || new HttpsAgent(sslOptions);
|
|
89
|
+
httpAgent = httpAgent || new Agent();
|
|
75
90
|
// Modify DEFAULT_HEADERS to include agent configuration
|
|
76
91
|
const DEFAULT_HEADERS = {
|
|
77
92
|
Accept: "application/json",
|
|
@@ -145,6 +160,11 @@ const allTools = [
|
|
|
145
160
|
description: "Get the changes/diffs of a merge request (Either mergeRequestIid or branchName must be provided)",
|
|
146
161
|
inputSchema: zodToJsonSchema(GetMergeRequestDiffsSchema),
|
|
147
162
|
},
|
|
163
|
+
{
|
|
164
|
+
name: "get_branch_diffs",
|
|
165
|
+
description: "Get the changes/diffs between two branches or commits in a GitLab project",
|
|
166
|
+
inputSchema: zodToJsonSchema(GetBranchDiffsSchema),
|
|
167
|
+
},
|
|
148
168
|
{
|
|
149
169
|
name: "update_merge_request",
|
|
150
170
|
description: "Update a merge request (Either mergeRequestIid or branchName must be provided)",
|
|
@@ -405,6 +425,11 @@ const allTools = [
|
|
|
405
425
|
description: "Get burndown events for a specific milestone",
|
|
406
426
|
inputSchema: zodToJsonSchema(GetMilestoneBurndownEventsSchema),
|
|
407
427
|
},
|
|
428
|
+
{
|
|
429
|
+
name: "get_users",
|
|
430
|
+
description: "Get GitLab user details by usernames",
|
|
431
|
+
inputSchema: zodToJsonSchema(GetUsersSchema),
|
|
432
|
+
},
|
|
408
433
|
];
|
|
409
434
|
// Define which tools are read-only
|
|
410
435
|
const readOnlyTools = [
|
|
@@ -412,6 +437,7 @@ const readOnlyTools = [
|
|
|
412
437
|
"get_file_contents",
|
|
413
438
|
"get_merge_request",
|
|
414
439
|
"get_merge_request_diffs",
|
|
440
|
+
"get_branch_diffs",
|
|
415
441
|
"mr_discussions",
|
|
416
442
|
"list_issues",
|
|
417
443
|
"list_merge_requests",
|
|
@@ -440,6 +466,7 @@ const readOnlyTools = [
|
|
|
440
466
|
"get_milestone_burndown_events",
|
|
441
467
|
"list_wiki_pages",
|
|
442
468
|
"get_wiki_page",
|
|
469
|
+
"get_users",
|
|
443
470
|
];
|
|
444
471
|
// Define which tools are related to wiki and can be toggled by USE_GITLAB_WIKI
|
|
445
472
|
const wikiToolNames = [
|
|
@@ -873,6 +900,9 @@ async function createMergeRequest(projectId, options) {
|
|
|
873
900
|
description: options.description,
|
|
874
901
|
source_branch: options.source_branch,
|
|
875
902
|
target_branch: options.target_branch,
|
|
903
|
+
assignee_ids: options.assignee_ids,
|
|
904
|
+
reviewer_ids: options.reviewer_ids,
|
|
905
|
+
labels: options.labels?.join(","),
|
|
876
906
|
allow_collaboration: options.allow_collaboration,
|
|
877
907
|
draft: options.draft,
|
|
878
908
|
}),
|
|
@@ -1313,7 +1343,34 @@ async function getMergeRequestDiffs(projectId, mergeRequestIid, branchName, view
|
|
|
1313
1343
|
});
|
|
1314
1344
|
await handleGitLabError(response);
|
|
1315
1345
|
const data = (await response.json());
|
|
1316
|
-
return z.array(
|
|
1346
|
+
return z.array(GitLabDiffSchema).parse(data.changes);
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Get branch comparison diffs
|
|
1350
|
+
*
|
|
1351
|
+
* @param {string} projectId - The ID or URL-encoded path of the project
|
|
1352
|
+
* @param {string} from - The branch name or commit SHA to compare from
|
|
1353
|
+
* @param {string} to - The branch name or commit SHA to compare to
|
|
1354
|
+
* @param {boolean} [straight] - Comparison method: false for '...' (default), true for '--'
|
|
1355
|
+
* @returns {Promise<GitLabCompareResult>} Branch comparison results
|
|
1356
|
+
*/
|
|
1357
|
+
async function getBranchDiffs(projectId, from, to, straight) {
|
|
1358
|
+
projectId = decodeURIComponent(projectId); // Decode project ID
|
|
1359
|
+
const url = new URL(`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/repository/compare`);
|
|
1360
|
+
url.searchParams.append("from", from);
|
|
1361
|
+
url.searchParams.append("to", to);
|
|
1362
|
+
if (straight !== undefined) {
|
|
1363
|
+
url.searchParams.append("straight", straight.toString());
|
|
1364
|
+
}
|
|
1365
|
+
const response = await fetch(url.toString(), {
|
|
1366
|
+
...DEFAULT_FETCH_CONFIG,
|
|
1367
|
+
});
|
|
1368
|
+
if (!response.ok) {
|
|
1369
|
+
const errorBody = await response.text();
|
|
1370
|
+
throw new Error(`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}`);
|
|
1371
|
+
}
|
|
1372
|
+
const data = await response.json();
|
|
1373
|
+
return GitLabCompareResultSchema.parse(data);
|
|
1317
1374
|
}
|
|
1318
1375
|
/**
|
|
1319
1376
|
* Update a merge request
|
|
@@ -2144,6 +2201,58 @@ async function getMilestoneBurndownEvents(projectId, milestoneId) {
|
|
|
2144
2201
|
const data = await response.json();
|
|
2145
2202
|
return data;
|
|
2146
2203
|
}
|
|
2204
|
+
/**
|
|
2205
|
+
* Get a single user from GitLab
|
|
2206
|
+
*
|
|
2207
|
+
* @param {string} username - The username to look up
|
|
2208
|
+
* @returns {Promise<GitLabUser | null>} The user data or null if not found
|
|
2209
|
+
*/
|
|
2210
|
+
async function getUser(username) {
|
|
2211
|
+
try {
|
|
2212
|
+
const url = new URL(`${GITLAB_API_URL}/users`);
|
|
2213
|
+
url.searchParams.append("username", username);
|
|
2214
|
+
const response = await fetch(url.toString(), {
|
|
2215
|
+
...DEFAULT_FETCH_CONFIG,
|
|
2216
|
+
});
|
|
2217
|
+
await handleGitLabError(response);
|
|
2218
|
+
const users = await response.json();
|
|
2219
|
+
// GitLab returns an array of users that match the username
|
|
2220
|
+
if (Array.isArray(users) && users.length > 0) {
|
|
2221
|
+
// Find exact match for username (case-sensitive)
|
|
2222
|
+
const exactMatch = users.find(user => user.username === username);
|
|
2223
|
+
if (exactMatch) {
|
|
2224
|
+
return GitLabUserSchema.parse(exactMatch);
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
// No matching user found
|
|
2228
|
+
return null;
|
|
2229
|
+
}
|
|
2230
|
+
catch (error) {
|
|
2231
|
+
console.error(`Error fetching user by username '${username}':`, error);
|
|
2232
|
+
return null;
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
/**
|
|
2236
|
+
* Get multiple users from GitLab
|
|
2237
|
+
*
|
|
2238
|
+
* @param {string[]} usernames - Array of usernames to look up
|
|
2239
|
+
* @returns {Promise<GitLabUsersResponse>} Object with usernames as keys and user objects or null as values
|
|
2240
|
+
*/
|
|
2241
|
+
async function getUsers(usernames) {
|
|
2242
|
+
const users = {};
|
|
2243
|
+
// Process usernames sequentially to avoid rate limiting
|
|
2244
|
+
for (const username of usernames) {
|
|
2245
|
+
try {
|
|
2246
|
+
const user = await getUser(username);
|
|
2247
|
+
users[username] = user;
|
|
2248
|
+
}
|
|
2249
|
+
catch (error) {
|
|
2250
|
+
console.error(`Error processing username '${username}':`, error);
|
|
2251
|
+
users[username] = null;
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
return GitLabUsersResponseSchema.parse(users);
|
|
2255
|
+
}
|
|
2147
2256
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
2148
2257
|
// Apply read-only filter first
|
|
2149
2258
|
const tools0 = GITLAB_READ_ONLY_MODE
|
|
@@ -2225,6 +2334,24 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
2225
2334
|
content: [{ type: "text", text: JSON.stringify(branch, null, 2) }],
|
|
2226
2335
|
};
|
|
2227
2336
|
}
|
|
2337
|
+
case "get_branch_diffs": {
|
|
2338
|
+
const args = GetBranchDiffsSchema.parse(request.params.arguments);
|
|
2339
|
+
const diffResp = await getBranchDiffs(args.project_id, args.from, args.to, args.straight);
|
|
2340
|
+
if (args.excluded_file_patterns?.length) {
|
|
2341
|
+
const regexPatterns = args.excluded_file_patterns.map(pattern => new RegExp(pattern));
|
|
2342
|
+
// Helper function to check if a path matches any regex pattern
|
|
2343
|
+
const matchesAnyPattern = (path) => {
|
|
2344
|
+
if (!path)
|
|
2345
|
+
return false;
|
|
2346
|
+
return regexPatterns.some(regex => regex.test(path));
|
|
2347
|
+
};
|
|
2348
|
+
// Filter out files that match any of the regex patterns on new files
|
|
2349
|
+
diffResp.diffs = diffResp.diffs.filter(diff => !matchesAnyPattern(diff.new_path));
|
|
2350
|
+
}
|
|
2351
|
+
return {
|
|
2352
|
+
content: [{ type: "text", text: JSON.stringify(diffResp, null, 2) }],
|
|
2353
|
+
};
|
|
2354
|
+
}
|
|
2228
2355
|
case "search_repositories": {
|
|
2229
2356
|
const args = SearchRepositoriesSchema.parse(request.params.arguments);
|
|
2230
2357
|
const results = await searchProjects(args.search, args.page, args.per_page);
|
|
@@ -2406,6 +2533,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
2406
2533
|
content: [{ type: "text", text: JSON.stringify(projects, null, 2) }],
|
|
2407
2534
|
};
|
|
2408
2535
|
}
|
|
2536
|
+
case "get_users": {
|
|
2537
|
+
const args = GetUsersSchema.parse(request.params.arguments);
|
|
2538
|
+
const usersMap = await getUsers(args.usernames);
|
|
2539
|
+
return {
|
|
2540
|
+
content: [{ type: "text", text: JSON.stringify(usersMap, null, 2) }],
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2409
2543
|
case "create_note": {
|
|
2410
2544
|
const args = CreateNoteSchema.parse(request.params.arguments);
|
|
2411
2545
|
const { project_id, noteable_type, noteable_iid, body } = args;
|
package/build/schemas.js
CHANGED
|
@@ -177,10 +177,28 @@ export const GetPipelineJobOutputSchema = z.object({
|
|
|
177
177
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
|
178
178
|
job_id: z.number().describe("The ID of the job"),
|
|
179
179
|
});
|
|
180
|
+
// User schemas
|
|
181
|
+
export const GitLabUserSchema = z.object({
|
|
182
|
+
username: z.string(), // Changed from login to match GitLab API
|
|
183
|
+
id: z.number(),
|
|
184
|
+
name: z.string(),
|
|
185
|
+
avatar_url: z.string().nullable(),
|
|
186
|
+
web_url: z.string(), // Changed from html_url to match GitLab API
|
|
187
|
+
});
|
|
188
|
+
export const GetUsersSchema = z.object({
|
|
189
|
+
usernames: z.array(z.string()).describe("Array of usernames to search for"),
|
|
190
|
+
});
|
|
191
|
+
export const GitLabUsersResponseSchema = z.record(z.string(), z.object({
|
|
192
|
+
id: z.number(),
|
|
193
|
+
username: z.string(),
|
|
194
|
+
name: z.string(),
|
|
195
|
+
avatar_url: z.string(),
|
|
196
|
+
web_url: z.string(),
|
|
197
|
+
}).nullable());
|
|
180
198
|
// Namespace related schemas
|
|
181
199
|
// Base schema for project-related operations
|
|
182
200
|
const ProjectParamsSchema = z.object({
|
|
183
|
-
project_id: z.string().describe("Project ID or URL-encoded path"), // Changed from owner/repo to match GitLab API
|
|
201
|
+
project_id: z.string().describe("Project ID or complete URL-encoded path to project"), // Changed from owner/repo to match GitLab API
|
|
184
202
|
});
|
|
185
203
|
export const GitLabNamespaceSchema = z.object({
|
|
186
204
|
id: z.number(),
|
|
@@ -269,6 +287,7 @@ export const GitLabRepositorySchema = z.object({
|
|
|
269
287
|
container_registry_access_level: z.string().optional(),
|
|
270
288
|
issues_enabled: z.boolean().optional(),
|
|
271
289
|
merge_requests_enabled: z.boolean().optional(),
|
|
290
|
+
merge_requests_template: z.string().optional(),
|
|
272
291
|
wiki_enabled: z.boolean().optional(),
|
|
273
292
|
jobs_enabled: z.boolean().optional(),
|
|
274
293
|
snippets_enabled: z.boolean().optional(),
|
|
@@ -397,12 +416,25 @@ export const CreateMergeRequestOptionsSchema = z.object({
|
|
|
397
416
|
description: z.string().optional(), // Changed from body to match GitLab API
|
|
398
417
|
source_branch: z.string(), // Changed from head to match GitLab API
|
|
399
418
|
target_branch: z.string(), // Changed from base to match GitLab API
|
|
419
|
+
assignee_ids: z
|
|
420
|
+
.array(z.number())
|
|
421
|
+
.optional(),
|
|
422
|
+
reviewer_ids: z
|
|
423
|
+
.array(z.number())
|
|
424
|
+
.optional(),
|
|
425
|
+
labels: z.array(z.string()).optional(),
|
|
400
426
|
allow_collaboration: z.boolean().optional(), // Changed from maintainer_can_modify to match GitLab API
|
|
401
427
|
draft: z.boolean().optional(),
|
|
402
428
|
});
|
|
403
|
-
export const
|
|
404
|
-
|
|
405
|
-
|
|
429
|
+
export const GitLabDiffSchema = z.object({
|
|
430
|
+
old_path: z.string(),
|
|
431
|
+
new_path: z.string(),
|
|
432
|
+
a_mode: z.string(),
|
|
433
|
+
b_mode: z.string(),
|
|
434
|
+
diff: z.string(),
|
|
435
|
+
new_file: z.boolean(),
|
|
436
|
+
renamed_file: z.boolean(),
|
|
437
|
+
deleted_file: z.boolean(),
|
|
406
438
|
});
|
|
407
439
|
// Response schemas for operations
|
|
408
440
|
export const GitLabCreateUpdateFileResponseSchema = z.object({
|
|
@@ -417,6 +449,25 @@ export const GitLabSearchResponseSchema = z.object({
|
|
|
417
449
|
current_page: z.number().optional(),
|
|
418
450
|
items: z.array(GitLabRepositorySchema),
|
|
419
451
|
});
|
|
452
|
+
// create branch schemas
|
|
453
|
+
export const CreateBranchOptionsSchema = z.object({
|
|
454
|
+
name: z.string(), // Changed from ref to match GitLab API
|
|
455
|
+
ref: z.string(), // The source branch/commit for the new branch
|
|
456
|
+
});
|
|
457
|
+
export const GitLabCompareResultSchema = z.object({
|
|
458
|
+
commit: z.object({
|
|
459
|
+
id: z.string().optional(),
|
|
460
|
+
short_id: z.string().optional(),
|
|
461
|
+
title: z.string().optional(),
|
|
462
|
+
author_name: z.string().optional(),
|
|
463
|
+
author_email: z.string().optional(),
|
|
464
|
+
created_at: z.string().optional(),
|
|
465
|
+
}).optional(),
|
|
466
|
+
commits: z.array(GitLabCommitSchema),
|
|
467
|
+
diffs: z.array(GitLabDiffSchema),
|
|
468
|
+
compare_timeout: z.boolean().optional(),
|
|
469
|
+
compare_same_ref: z.boolean().optional(),
|
|
470
|
+
});
|
|
420
471
|
// Issue related schemas
|
|
421
472
|
export const GitLabLabelSchema = z.object({
|
|
422
473
|
id: z.number(),
|
|
@@ -432,13 +483,6 @@ export const GitLabLabelSchema = z.object({
|
|
|
432
483
|
priority: z.number().nullable().optional(),
|
|
433
484
|
is_project_label: z.boolean().optional(),
|
|
434
485
|
});
|
|
435
|
-
export const GitLabUserSchema = z.object({
|
|
436
|
-
username: z.string(), // Changed from login to match GitLab API
|
|
437
|
-
id: z.number(),
|
|
438
|
-
name: z.string(),
|
|
439
|
-
avatar_url: z.string().nullable(),
|
|
440
|
-
web_url: z.string(), // Changed from html_url to match GitLab API
|
|
441
|
-
});
|
|
442
486
|
export const GitLabMilestoneSchema = z.object({
|
|
443
487
|
id: z.number(),
|
|
444
488
|
iid: z.number(), // Added to match GitLab API
|
|
@@ -522,6 +566,7 @@ export const GitLabMergeRequestSchema = z.object({
|
|
|
522
566
|
draft: z.boolean().optional(),
|
|
523
567
|
author: GitLabUserSchema,
|
|
524
568
|
assignees: z.array(GitLabUserSchema).optional(),
|
|
569
|
+
reviewers: z.array(GitLabUserSchema).optional(),
|
|
525
570
|
source_branch: z.string(),
|
|
526
571
|
target_branch: z.string(),
|
|
527
572
|
diff_refs: GitLabMergeRequestDiffRefSchema.nullable().optional(),
|
|
@@ -692,25 +737,34 @@ export const CreateMergeRequestSchema = ProjectParamsSchema.extend({
|
|
|
692
737
|
description: z.string().optional().describe("Merge request description"),
|
|
693
738
|
source_branch: z.string().describe("Branch containing changes"),
|
|
694
739
|
target_branch: z.string().describe("Branch to merge into"),
|
|
740
|
+
assignee_ids: z
|
|
741
|
+
.array(z.number())
|
|
742
|
+
.optional()
|
|
743
|
+
.describe("The ID of the users to assign the MR to"),
|
|
744
|
+
reviewer_ids: z
|
|
745
|
+
.array(z.number())
|
|
746
|
+
.optional()
|
|
747
|
+
.describe("The ID of the users to assign as reviewers of the MR"),
|
|
748
|
+
labels: z.array(z.string()).optional().describe("Labels for the MR"),
|
|
695
749
|
draft: z.boolean().optional().describe("Create as draft merge request"),
|
|
696
|
-
allow_collaboration: z
|
|
750
|
+
allow_collaboration: z
|
|
751
|
+
.boolean()
|
|
752
|
+
.optional()
|
|
753
|
+
.describe("Allow commits from upstream members"),
|
|
697
754
|
});
|
|
698
755
|
export const ForkRepositorySchema = ProjectParamsSchema.extend({
|
|
699
756
|
namespace: z.string().optional().describe("Namespace to fork to (full path)"),
|
|
700
757
|
});
|
|
758
|
+
// Branch related schemas
|
|
701
759
|
export const CreateBranchSchema = ProjectParamsSchema.extend({
|
|
702
760
|
branch: z.string().describe("Name for the new branch"),
|
|
703
761
|
ref: z.string().optional().describe("Source branch/commit for new branch"),
|
|
704
762
|
});
|
|
705
|
-
export const
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
diff: z.string(),
|
|
711
|
-
new_file: z.boolean(),
|
|
712
|
-
renamed_file: z.boolean(),
|
|
713
|
-
deleted_file: z.boolean(),
|
|
763
|
+
export const GetBranchDiffsSchema = ProjectParamsSchema.extend({
|
|
764
|
+
from: z.string().describe("The base branch or commit SHA to compare from"),
|
|
765
|
+
to: z.string().describe("The target branch or commit SHA to compare to"),
|
|
766
|
+
straight: z.boolean().optional().describe("Comparison method: false for '...' (default), true for '--'"),
|
|
767
|
+
excluded_file_patterns: z.array(z.string()).optional().describe("Array of regex patterns to exclude files from the diff results. Each pattern is a JavaScript-compatible regular expression that matches file paths to ignore. Examples: [\"^test/mocks/\", \"\\.spec\\.ts$\", \"package-lock\\.json\"]"),
|
|
714
768
|
});
|
|
715
769
|
export const GetMergeRequestSchema = ProjectParamsSchema.extend({
|
|
716
770
|
merge_request_iid: z.number().optional().describe("The IID of a merge request"),
|