@structured-world/gitlab-mcp 4.0.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.
Files changed (176) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +486 -0
  3. package/dist/config.d.ts +31 -0
  4. package/dist/config.js +115 -0
  5. package/dist/config.js.map +1 -0
  6. package/dist/entities/core/index.d.ts +7 -0
  7. package/dist/entities/core/index.js +31 -0
  8. package/dist/entities/core/index.js.map +1 -0
  9. package/dist/entities/core/registry.d.ts +5 -0
  10. package/dist/entities/core/registry.js +584 -0
  11. package/dist/entities/core/registry.js.map +1 -0
  12. package/dist/entities/core/schema-readonly.d.ts +302 -0
  13. package/dist/entities/core/schema-readonly.js +364 -0
  14. package/dist/entities/core/schema-readonly.js.map +1 -0
  15. package/dist/entities/core/schema.d.ts +87 -0
  16. package/dist/entities/core/schema.js +143 -0
  17. package/dist/entities/core/schema.js.map +1 -0
  18. package/dist/entities/files/index.d.ts +7 -0
  19. package/dist/entities/files/index.js +31 -0
  20. package/dist/entities/files/index.js.map +1 -0
  21. package/dist/entities/files/registry.d.ts +5 -0
  22. package/dist/entities/files/registry.js +199 -0
  23. package/dist/entities/files/registry.js.map +1 -0
  24. package/dist/entities/files/schema-readonly.d.ts +78 -0
  25. package/dist/entities/files/schema-readonly.js +50 -0
  26. package/dist/entities/files/schema-readonly.js.map +1 -0
  27. package/dist/entities/files/schema.d.ts +42 -0
  28. package/dist/entities/files/schema.js +38 -0
  29. package/dist/entities/files/schema.js.map +1 -0
  30. package/dist/entities/index.d.ts +10 -0
  31. package/dist/entities/index.js +27 -0
  32. package/dist/entities/index.js.map +1 -0
  33. package/dist/entities/labels/index.d.ts +7 -0
  34. package/dist/entities/labels/index.js +31 -0
  35. package/dist/entities/labels/index.js.map +1 -0
  36. package/dist/entities/labels/registry.d.ts +5 -0
  37. package/dist/entities/labels/registry.js +186 -0
  38. package/dist/entities/labels/registry.js.map +1 -0
  39. package/dist/entities/labels/schema-readonly.d.ts +16 -0
  40. package/dist/entities/labels/schema-readonly.js +29 -0
  41. package/dist/entities/labels/schema-readonly.js.map +1 -0
  42. package/dist/entities/labels/schema.d.ts +26 -0
  43. package/dist/entities/labels/schema.js +50 -0
  44. package/dist/entities/labels/schema.js.map +1 -0
  45. package/dist/entities/milestones/index.d.ts +7 -0
  46. package/dist/entities/milestones/index.js +31 -0
  47. package/dist/entities/milestones/index.js.map +1 -0
  48. package/dist/entities/milestones/registry.d.ts +5 -0
  49. package/dist/entities/milestones/registry.js +316 -0
  50. package/dist/entities/milestones/registry.js.map +1 -0
  51. package/dist/entities/milestones/schema-readonly.d.ts +63 -0
  52. package/dist/entities/milestones/schema-readonly.js +68 -0
  53. package/dist/entities/milestones/schema-readonly.js.map +1 -0
  54. package/dist/entities/milestones/schema.d.ts +36 -0
  55. package/dist/entities/milestones/schema.js +52 -0
  56. package/dist/entities/milestones/schema.js.map +1 -0
  57. package/dist/entities/mrs/index.d.ts +7 -0
  58. package/dist/entities/mrs/index.js +31 -0
  59. package/dist/entities/mrs/index.js.map +1 -0
  60. package/dist/entities/mrs/registry.d.ts +5 -0
  61. package/dist/entities/mrs/registry.js +629 -0
  62. package/dist/entities/mrs/registry.js.map +1 -0
  63. package/dist/entities/mrs/schema-readonly.d.ts +127 -0
  64. package/dist/entities/mrs/schema-readonly.js +213 -0
  65. package/dist/entities/mrs/schema-readonly.js.map +1 -0
  66. package/dist/entities/mrs/schema.d.ts +285 -0
  67. package/dist/entities/mrs/schema.js +161 -0
  68. package/dist/entities/mrs/schema.js.map +1 -0
  69. package/dist/entities/pipelines/index.d.ts +7 -0
  70. package/dist/entities/pipelines/index.js +31 -0
  71. package/dist/entities/pipelines/index.js.map +1 -0
  72. package/dist/entities/pipelines/registry.d.ts +5 -0
  73. package/dist/entities/pipelines/registry.js +369 -0
  74. package/dist/entities/pipelines/registry.js.map +1 -0
  75. package/dist/entities/pipelines/schema-readonly.d.ts +238 -0
  76. package/dist/entities/pipelines/schema-readonly.js +257 -0
  77. package/dist/entities/pipelines/schema-readonly.js.map +1 -0
  78. package/dist/entities/pipelines/schema.d.ts +49 -0
  79. package/dist/entities/pipelines/schema.js +44 -0
  80. package/dist/entities/pipelines/schema.js.map +1 -0
  81. package/dist/entities/shared.d.ts +291 -0
  82. package/dist/entities/shared.js +277 -0
  83. package/dist/entities/shared.js.map +1 -0
  84. package/dist/entities/utils.d.ts +3 -0
  85. package/dist/entities/utils.js +22 -0
  86. package/dist/entities/utils.js.map +1 -0
  87. package/dist/entities/variables/index.d.ts +7 -0
  88. package/dist/entities/variables/index.js +31 -0
  89. package/dist/entities/variables/index.js.map +1 -0
  90. package/dist/entities/variables/registry.d.ts +5 -0
  91. package/dist/entities/variables/registry.js +192 -0
  92. package/dist/entities/variables/registry.js.map +1 -0
  93. package/dist/entities/variables/schema-readonly.d.ts +17 -0
  94. package/dist/entities/variables/schema-readonly.js +35 -0
  95. package/dist/entities/variables/schema-readonly.js.map +1 -0
  96. package/dist/entities/variables/schema.d.ts +45 -0
  97. package/dist/entities/variables/schema.js +127 -0
  98. package/dist/entities/variables/schema.js.map +1 -0
  99. package/dist/entities/wiki/index.d.ts +7 -0
  100. package/dist/entities/wiki/index.js +31 -0
  101. package/dist/entities/wiki/index.js.map +1 -0
  102. package/dist/entities/wiki/registry.d.ts +5 -0
  103. package/dist/entities/wiki/registry.js +195 -0
  104. package/dist/entities/wiki/registry.js.map +1 -0
  105. package/dist/entities/wiki/schema-readonly.d.ts +24 -0
  106. package/dist/entities/wiki/schema-readonly.js +34 -0
  107. package/dist/entities/wiki/schema-readonly.js.map +1 -0
  108. package/dist/entities/wiki/schema.d.ts +24 -0
  109. package/dist/entities/wiki/schema.js +37 -0
  110. package/dist/entities/wiki/schema.js.map +1 -0
  111. package/dist/entities/workitems/index.d.ts +7 -0
  112. package/dist/entities/workitems/index.js +31 -0
  113. package/dist/entities/workitems/index.js.map +1 -0
  114. package/dist/entities/workitems/registry.d.ts +5 -0
  115. package/dist/entities/workitems/registry.js +183 -0
  116. package/dist/entities/workitems/registry.js.map +1 -0
  117. package/dist/entities/workitems/schema-readonly.d.ts +46 -0
  118. package/dist/entities/workitems/schema-readonly.js +38 -0
  119. package/dist/entities/workitems/schema-readonly.js.map +1 -0
  120. package/dist/entities/workitems/schema.d.ts +37 -0
  121. package/dist/entities/workitems/schema.js +29 -0
  122. package/dist/entities/workitems/schema.js.map +1 -0
  123. package/dist/graphql/DynamicWorkItemsQuery.d.ts +56 -0
  124. package/dist/graphql/DynamicWorkItemsQuery.js +190 -0
  125. package/dist/graphql/DynamicWorkItemsQuery.js.map +1 -0
  126. package/dist/graphql/client.d.ts +15 -0
  127. package/dist/graphql/client.js +50 -0
  128. package/dist/graphql/client.js.map +1 -0
  129. package/dist/graphql/index.d.ts +2 -0
  130. package/dist/graphql/index.js +21 -0
  131. package/dist/graphql/index.js.map +1 -0
  132. package/dist/graphql/workItems.d.ts +430 -0
  133. package/dist/graphql/workItems.js +559 -0
  134. package/dist/graphql/workItems.js.map +1 -0
  135. package/dist/handlers.d.ts +2 -0
  136. package/dist/handlers.js +132 -0
  137. package/dist/handlers.js.map +1 -0
  138. package/dist/http-client.d.ts +1 -0
  139. package/dist/http-client.js +13 -0
  140. package/dist/http-client.js.map +1 -0
  141. package/dist/logger.d.ts +2 -0
  142. package/dist/logger.js +21 -0
  143. package/dist/logger.js.map +1 -0
  144. package/dist/main.d.ts +2 -0
  145. package/dist/main.js +10 -0
  146. package/dist/main.js.map +1 -0
  147. package/dist/registry-manager.d.ts +25 -0
  148. package/dist/registry-manager.js +176 -0
  149. package/dist/registry-manager.js.map +1 -0
  150. package/dist/server.d.ts +25 -0
  151. package/dist/server.js +129 -0
  152. package/dist/server.js.map +1 -0
  153. package/dist/services/ConnectionManager.d.ts +27 -0
  154. package/dist/services/ConnectionManager.js +144 -0
  155. package/dist/services/ConnectionManager.js.map +1 -0
  156. package/dist/services/GitLabVersionDetector.d.ts +53 -0
  157. package/dist/services/GitLabVersionDetector.js +216 -0
  158. package/dist/services/GitLabVersionDetector.js.map +1 -0
  159. package/dist/services/SchemaIntrospector.d.ts +39 -0
  160. package/dist/services/SchemaIntrospector.js +188 -0
  161. package/dist/services/SchemaIntrospector.js.map +1 -0
  162. package/dist/services/ToolAvailability.d.ts +18 -0
  163. package/dist/services/ToolAvailability.js +373 -0
  164. package/dist/services/ToolAvailability.js.map +1 -0
  165. package/dist/services/WidgetAvailability.d.ts +14 -0
  166. package/dist/services/WidgetAvailability.js +84 -0
  167. package/dist/services/WidgetAvailability.js.map +1 -0
  168. package/dist/structured-world-gitlab-mcp-4.0.0.tgz +0 -0
  169. package/dist/tsconfig.build.tsbuildinfo +1 -0
  170. package/dist/types.d.ts +21 -0
  171. package/dist/types.js +10 -0
  172. package/dist/types.js.map +1 -0
  173. package/dist/utils/fetch.d.ts +9 -0
  174. package/dist/utils/fetch.js +164 -0
  175. package/dist/utils/fetch.js.map +1 -0
  176. package/package.json +90 -0
@@ -0,0 +1,629 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mrsToolRegistry = void 0;
4
+ exports.getMrsReadOnlyToolNames = getMrsReadOnlyToolNames;
5
+ exports.getMrsToolDefinitions = getMrsToolDefinitions;
6
+ exports.getFilteredMrsTools = getFilteredMrsTools;
7
+ const zod_to_json_schema_1 = require("zod-to-json-schema");
8
+ const schema_readonly_1 = require("./schema-readonly");
9
+ const schema_1 = require("./schema");
10
+ const fetch_1 = require("../../utils/fetch");
11
+ exports.mrsToolRegistry = new Map([
12
+ [
13
+ 'get_branch_diffs',
14
+ {
15
+ name: 'get_branch_diffs',
16
+ description: 'Get the changes/diffs between two branches or commits in a GitLab project',
17
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_readonly_1.GetBranchDiffsSchema),
18
+ handler: async (args) => {
19
+ const options = schema_readonly_1.GetBranchDiffsSchema.parse(args);
20
+ const { project_id, from, to, straight } = options;
21
+ const queryParams = new URLSearchParams();
22
+ if (straight !== undefined) {
23
+ queryParams.set('straight', String(straight));
24
+ }
25
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(project_id)}/repository/compare?from=${encodeURIComponent(from)}&to=${encodeURIComponent(to)}&${queryParams}`;
26
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
27
+ headers: {
28
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
29
+ },
30
+ });
31
+ if (!response.ok) {
32
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
33
+ }
34
+ const diff = await response.json();
35
+ return diff;
36
+ },
37
+ },
38
+ ],
39
+ [
40
+ 'get_merge_request',
41
+ {
42
+ name: 'get_merge_request',
43
+ description: 'Get details of a merge request (Either mergeRequestIid or branchName must be provided)',
44
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_readonly_1.GetMergeRequestSchema),
45
+ handler: async (args) => {
46
+ const options = schema_readonly_1.GetMergeRequestSchema.parse(args);
47
+ const { project_id, merge_request_iid, branch_name } = options;
48
+ let apiUrl;
49
+ if (merge_request_iid) {
50
+ apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(project_id)}/merge_requests/${merge_request_iid}`;
51
+ }
52
+ else if (branch_name) {
53
+ apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(project_id)}/merge_requests?source_branch=${encodeURIComponent(branch_name)}`;
54
+ }
55
+ else {
56
+ throw new Error('Either merge_request_iid or branch_name must be provided');
57
+ }
58
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
59
+ headers: {
60
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
61
+ },
62
+ });
63
+ if (!response.ok) {
64
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
65
+ }
66
+ const result = await response.json();
67
+ if (branch_name) {
68
+ if (Array.isArray(result) && result.length > 0) {
69
+ return result[0];
70
+ }
71
+ else {
72
+ throw new Error('No merge request found for branch');
73
+ }
74
+ }
75
+ return result;
76
+ },
77
+ },
78
+ ],
79
+ [
80
+ 'list_merge_requests',
81
+ {
82
+ name: 'list_merge_requests',
83
+ description: 'List merge requests in a GitLab project with filtering options',
84
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_readonly_1.ListMergeRequestsSchema),
85
+ handler: async (args) => {
86
+ const options = schema_readonly_1.ListMergeRequestsSchema.parse(args);
87
+ const queryParams = new URLSearchParams();
88
+ Object.entries(options).forEach(([key, value]) => {
89
+ if (value !== undefined && value !== null && key !== 'project_id') {
90
+ queryParams.set(key, String(value));
91
+ }
92
+ });
93
+ const apiUrl = options.project_id
94
+ ? `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(options.project_id)}/merge_requests?${queryParams}`
95
+ : `${process.env.GITLAB_API_URL}/api/v4/merge_requests?${queryParams}`;
96
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
97
+ headers: {
98
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
99
+ },
100
+ });
101
+ if (!response.ok) {
102
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
103
+ }
104
+ const mergeRequests = await response.json();
105
+ return mergeRequests;
106
+ },
107
+ },
108
+ ],
109
+ [
110
+ 'get_merge_request_diffs',
111
+ {
112
+ name: 'get_merge_request_diffs',
113
+ description: 'Get the changes/diffs of a merge request (Either mergeRequestIid or branchName must be provided)',
114
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_readonly_1.GetMergeRequestDiffsSchema),
115
+ handler: async (args) => {
116
+ const options = schema_readonly_1.GetMergeRequestDiffsSchema.parse(args);
117
+ const { project_id, merge_request_iid, page, per_page } = options;
118
+ const queryParams = new URLSearchParams();
119
+ if (page !== undefined) {
120
+ queryParams.set('page', String(page));
121
+ }
122
+ if (per_page !== undefined) {
123
+ queryParams.set('per_page', String(per_page));
124
+ }
125
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(project_id)}/merge_requests/${merge_request_iid}/changes?${queryParams}`;
126
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
127
+ headers: {
128
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
129
+ },
130
+ });
131
+ if (!response.ok) {
132
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
133
+ }
134
+ const diffs = await response.json();
135
+ return diffs;
136
+ },
137
+ },
138
+ ],
139
+ [
140
+ 'list_merge_request_diffs',
141
+ {
142
+ name: 'list_merge_request_diffs',
143
+ description: 'List merge request diffs with pagination support (Either mergeRequestIid or branchName must be provided)',
144
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_readonly_1.ListMergeRequestDiffsSchema),
145
+ handler: async (args) => {
146
+ const options = schema_readonly_1.ListMergeRequestDiffsSchema.parse(args);
147
+ const { project_id, merge_request_iid, page, per_page } = options;
148
+ const queryParams = new URLSearchParams();
149
+ if (page !== undefined) {
150
+ queryParams.set('page', String(page));
151
+ }
152
+ if (per_page !== undefined) {
153
+ queryParams.set('per_page', String(per_page));
154
+ }
155
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(project_id)}/merge_requests/${merge_request_iid}/diffs?${queryParams}`;
156
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
157
+ headers: {
158
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
159
+ },
160
+ });
161
+ if (!response.ok) {
162
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
163
+ }
164
+ const diffs = await response.json();
165
+ return diffs;
166
+ },
167
+ },
168
+ ],
169
+ [
170
+ 'mr_discussions',
171
+ {
172
+ name: 'mr_discussions',
173
+ description: 'List discussion items for a merge request',
174
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_readonly_1.ListMergeRequestDiscussionsSchema),
175
+ handler: async (args) => {
176
+ const options = schema_readonly_1.ListMergeRequestDiscussionsSchema.parse(args);
177
+ const { project_id, merge_request_iid } = options;
178
+ const queryParams = new URLSearchParams();
179
+ Object.entries(options).forEach(([key, value]) => {
180
+ if (value !== undefined && key !== 'project_id' && key !== 'merge_request_iid') {
181
+ queryParams.set(key, String(value));
182
+ }
183
+ });
184
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(project_id)}/merge_requests/${merge_request_iid}/discussions?${queryParams}`;
185
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
186
+ headers: {
187
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
188
+ },
189
+ });
190
+ if (!response.ok) {
191
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
192
+ }
193
+ const discussions = await response.json();
194
+ return discussions;
195
+ },
196
+ },
197
+ ],
198
+ [
199
+ 'get_draft_note',
200
+ {
201
+ name: 'get_draft_note',
202
+ description: 'Get a single draft note from a merge request',
203
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_readonly_1.GetDraftNoteSchema),
204
+ handler: async (args) => {
205
+ const options = schema_readonly_1.GetDraftNoteSchema.parse(args);
206
+ const { project_id, merge_request_iid, draft_note_id } = options;
207
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(project_id)}/merge_requests/${merge_request_iid}/draft_notes/${draft_note_id}`;
208
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
209
+ headers: {
210
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
211
+ },
212
+ });
213
+ if (!response.ok) {
214
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
215
+ }
216
+ const draftNote = await response.json();
217
+ return draftNote;
218
+ },
219
+ },
220
+ ],
221
+ [
222
+ 'list_draft_notes',
223
+ {
224
+ name: 'list_draft_notes',
225
+ description: 'List draft notes for a merge request',
226
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_readonly_1.ListDraftNotesSchema),
227
+ handler: async (args) => {
228
+ const options = schema_readonly_1.ListDraftNotesSchema.parse(args);
229
+ const { project_id, merge_request_iid } = options;
230
+ const queryParams = new URLSearchParams();
231
+ Object.entries(options).forEach(([key, value]) => {
232
+ if (value !== undefined && key !== 'project_id' && key !== 'merge_request_iid') {
233
+ queryParams.set(key, String(value));
234
+ }
235
+ });
236
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(project_id)}/merge_requests/${merge_request_iid}/draft_notes?${queryParams}`;
237
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
238
+ headers: {
239
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
240
+ },
241
+ });
242
+ if (!response.ok) {
243
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
244
+ }
245
+ const draftNotes = await response.json();
246
+ return draftNotes;
247
+ },
248
+ },
249
+ ],
250
+ [
251
+ 'create_merge_request',
252
+ {
253
+ name: 'create_merge_request',
254
+ description: 'Create a new merge request in a GitLab project',
255
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_1.CreateMergeRequestSchema),
256
+ handler: async (args) => {
257
+ const options = schema_1.CreateMergeRequestSchema.parse(args);
258
+ const body = new URLSearchParams();
259
+ Object.entries(options).forEach(([key, value]) => {
260
+ if (value !== undefined && value !== null) {
261
+ if (Array.isArray(value)) {
262
+ body.set(key, value.join(','));
263
+ }
264
+ else {
265
+ body.set(key, String(value));
266
+ }
267
+ }
268
+ });
269
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(options.project_id)}/merge_requests`;
270
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
271
+ method: 'POST',
272
+ headers: {
273
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
274
+ 'Content-Type': 'application/x-www-form-urlencoded',
275
+ },
276
+ body: body.toString(),
277
+ });
278
+ if (!response.ok) {
279
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
280
+ }
281
+ const mergeRequest = await response.json();
282
+ return mergeRequest;
283
+ },
284
+ },
285
+ ],
286
+ [
287
+ 'merge_merge_request',
288
+ {
289
+ name: 'merge_merge_request',
290
+ description: 'Merge a merge request in a GitLab project',
291
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_1.MergeMergeRequestSchema),
292
+ handler: async (args) => {
293
+ const options = schema_1.MergeMergeRequestSchema.parse(args);
294
+ const body = new URLSearchParams();
295
+ Object.entries(options).forEach(([key, value]) => {
296
+ if (value !== undefined && key !== 'project_id' && key !== 'merge_request_iid') {
297
+ body.set(key, String(value));
298
+ }
299
+ });
300
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(options.project_id)}/merge_requests/${options.merge_request_iid}/merge`;
301
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
302
+ method: 'PUT',
303
+ headers: {
304
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
305
+ 'Content-Type': 'application/x-www-form-urlencoded',
306
+ },
307
+ body: body.toString(),
308
+ });
309
+ if (!response.ok) {
310
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
311
+ }
312
+ const result = await response.json();
313
+ return result;
314
+ },
315
+ },
316
+ ],
317
+ [
318
+ 'create_note',
319
+ {
320
+ name: 'create_note',
321
+ description: 'Create a new note (comment) to an issue or merge request',
322
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_1.CreateNoteSchema),
323
+ handler: async (args) => {
324
+ const options = schema_1.CreateNoteSchema.parse(args);
325
+ const body = new URLSearchParams();
326
+ body.set('body', options.body);
327
+ if (options.created_at) {
328
+ body.set('created_at', options.created_at);
329
+ }
330
+ if (options.confidential !== undefined) {
331
+ body.set('confidential', String(options.confidential));
332
+ }
333
+ const resourceType = options.noteable_type === 'merge_request' ? 'merge_requests' : 'issues';
334
+ const resourceId = options.noteable_id;
335
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(options.project_id)}/${resourceType}/${resourceId}/notes`;
336
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
337
+ method: 'POST',
338
+ headers: {
339
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
340
+ 'Content-Type': 'application/x-www-form-urlencoded',
341
+ },
342
+ body: body.toString(),
343
+ });
344
+ if (!response.ok) {
345
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
346
+ }
347
+ const note = await response.json();
348
+ return note;
349
+ },
350
+ },
351
+ ],
352
+ [
353
+ 'create_draft_note',
354
+ {
355
+ name: 'create_draft_note',
356
+ description: 'Create a draft note for a merge request',
357
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_1.CreateDraftNoteSchema),
358
+ handler: async (args) => {
359
+ const options = schema_1.CreateDraftNoteSchema.parse(args);
360
+ const body = new URLSearchParams();
361
+ body.set('note', options.note);
362
+ if (options.position) {
363
+ body.set('position', JSON.stringify(options.position));
364
+ }
365
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(options.project_id)}/merge_requests/${options.merge_request_iid}/draft_notes`;
366
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
367
+ method: 'POST',
368
+ headers: {
369
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
370
+ 'Content-Type': 'application/x-www-form-urlencoded',
371
+ },
372
+ body: body.toString(),
373
+ });
374
+ if (!response.ok) {
375
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
376
+ }
377
+ const draftNote = await response.json();
378
+ return draftNote;
379
+ },
380
+ },
381
+ ],
382
+ [
383
+ 'publish_draft_note',
384
+ {
385
+ name: 'publish_draft_note',
386
+ description: 'Publish a single draft note',
387
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_1.PublishDraftNoteSchema),
388
+ handler: async (args) => {
389
+ const options = schema_1.PublishDraftNoteSchema.parse(args);
390
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(options.project_id)}/merge_requests/${options.merge_request_iid}/draft_notes/${options.draft_note_id}/publish`;
391
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
392
+ method: 'PUT',
393
+ headers: {
394
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
395
+ },
396
+ });
397
+ if (!response.ok) {
398
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
399
+ }
400
+ const result = await response.json();
401
+ return result;
402
+ },
403
+ },
404
+ ],
405
+ [
406
+ 'bulk_publish_draft_notes',
407
+ {
408
+ name: 'bulk_publish_draft_notes',
409
+ description: 'Publish all draft notes for a merge request',
410
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_1.BulkPublishDraftNotesSchema),
411
+ handler: async (args) => {
412
+ const options = schema_1.BulkPublishDraftNotesSchema.parse(args);
413
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(options.project_id)}/merge_requests/${options.merge_request_iid}/draft_notes/bulk_publish`;
414
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
415
+ method: 'POST',
416
+ headers: {
417
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
418
+ },
419
+ });
420
+ if (!response.ok) {
421
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
422
+ }
423
+ const result = await response.json();
424
+ return result;
425
+ },
426
+ },
427
+ ],
428
+ [
429
+ 'update_merge_request',
430
+ {
431
+ name: 'update_merge_request',
432
+ description: 'Update a merge request (Either mergeRequestIid or branchName must be provided)',
433
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_1.UpdateMergeRequestSchema),
434
+ handler: async (args) => {
435
+ const options = schema_1.UpdateMergeRequestSchema.parse(args);
436
+ const body = new URLSearchParams();
437
+ Object.entries(options).forEach(([key, value]) => {
438
+ if (value !== undefined && key !== 'project_id' && key !== 'merge_request_iid') {
439
+ if (Array.isArray(value)) {
440
+ body.set(key, value.join(','));
441
+ }
442
+ else {
443
+ body.set(key, String(value));
444
+ }
445
+ }
446
+ });
447
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(options.project_id)}/merge_requests/${options.merge_request_iid}`;
448
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
449
+ method: 'PUT',
450
+ headers: {
451
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
452
+ 'Content-Type': 'application/x-www-form-urlencoded',
453
+ },
454
+ body: body.toString(),
455
+ });
456
+ if (!response.ok) {
457
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
458
+ }
459
+ const mergeRequest = await response.json();
460
+ return mergeRequest;
461
+ },
462
+ },
463
+ ],
464
+ [
465
+ 'create_merge_request_thread',
466
+ {
467
+ name: 'create_merge_request_thread',
468
+ description: 'Create a new thread on a merge request',
469
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_1.CreateMergeRequestThreadSchema),
470
+ handler: async (args) => {
471
+ const options = schema_1.CreateMergeRequestThreadSchema.parse(args);
472
+ const body = new URLSearchParams();
473
+ body.set('body', options.body);
474
+ if (options.position) {
475
+ body.set('position', JSON.stringify(options.position));
476
+ }
477
+ if (options.commit_id) {
478
+ body.set('commit_id', options.commit_id);
479
+ }
480
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(options.project_id)}/merge_requests/${options.merge_request_iid}/discussions`;
481
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
482
+ method: 'POST',
483
+ headers: {
484
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
485
+ 'Content-Type': 'application/x-www-form-urlencoded',
486
+ },
487
+ body: body.toString(),
488
+ });
489
+ if (!response.ok) {
490
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
491
+ }
492
+ const discussion = await response.json();
493
+ return discussion;
494
+ },
495
+ },
496
+ ],
497
+ [
498
+ 'update_merge_request_note',
499
+ {
500
+ name: 'update_merge_request_note',
501
+ description: 'Modify an existing merge request thread note',
502
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_1.UpdateMergeRequestNoteSchema),
503
+ handler: async (args) => {
504
+ const options = schema_1.UpdateMergeRequestNoteSchema.parse(args);
505
+ const body = new URLSearchParams();
506
+ body.set('body', options.body);
507
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(options.project_id)}/merge_requests/${options.merge_request_iid}/notes/${options.note_id}`;
508
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
509
+ method: 'PUT',
510
+ headers: {
511
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
512
+ 'Content-Type': 'application/x-www-form-urlencoded',
513
+ },
514
+ body: body.toString(),
515
+ });
516
+ if (!response.ok) {
517
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
518
+ }
519
+ const note = await response.json();
520
+ return note;
521
+ },
522
+ },
523
+ ],
524
+ [
525
+ 'create_merge_request_note',
526
+ {
527
+ name: 'create_merge_request_note',
528
+ description: 'Add a new note to an existing merge request thread',
529
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_1.CreateMergeRequestNoteSchema),
530
+ handler: async (args) => {
531
+ const options = schema_1.CreateMergeRequestNoteSchema.parse(args);
532
+ const body = new URLSearchParams();
533
+ body.set('body', options.body);
534
+ if (options.created_at) {
535
+ body.set('created_at', options.created_at);
536
+ }
537
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(options.project_id)}/merge_requests/${options.merge_request_iid}/discussions/${options.discussion_id}/notes`;
538
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
539
+ method: 'POST',
540
+ headers: {
541
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
542
+ 'Content-Type': 'application/x-www-form-urlencoded',
543
+ },
544
+ body: body.toString(),
545
+ });
546
+ if (!response.ok) {
547
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
548
+ }
549
+ const note = await response.json();
550
+ return note;
551
+ },
552
+ },
553
+ ],
554
+ [
555
+ 'update_draft_note',
556
+ {
557
+ name: 'update_draft_note',
558
+ description: 'Update an existing draft note',
559
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_1.UpdateDraftNoteSchema),
560
+ handler: async (args) => {
561
+ const options = schema_1.UpdateDraftNoteSchema.parse(args);
562
+ const body = new URLSearchParams();
563
+ body.set('note', options.note);
564
+ if (options.position) {
565
+ body.set('position', JSON.stringify(options.position));
566
+ }
567
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(options.project_id)}/merge_requests/${options.merge_request_iid}/draft_notes/${options.draft_note_id}`;
568
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
569
+ method: 'PUT',
570
+ headers: {
571
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
572
+ 'Content-Type': 'application/x-www-form-urlencoded',
573
+ },
574
+ body: body.toString(),
575
+ });
576
+ if (!response.ok) {
577
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
578
+ }
579
+ const draftNote = await response.json();
580
+ return draftNote;
581
+ },
582
+ },
583
+ ],
584
+ [
585
+ 'delete_draft_note',
586
+ {
587
+ name: 'delete_draft_note',
588
+ description: 'Delete a draft note',
589
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(schema_1.DeleteDraftNoteSchema),
590
+ handler: async (args) => {
591
+ const options = schema_1.DeleteDraftNoteSchema.parse(args);
592
+ const apiUrl = `${process.env.GITLAB_API_URL}/api/v4/projects/${encodeURIComponent(options.project_id)}/merge_requests/${options.merge_request_iid}/draft_notes/${options.draft_note_id}`;
593
+ const response = await (0, fetch_1.enhancedFetch)(apiUrl, {
594
+ method: 'DELETE',
595
+ headers: {
596
+ Authorization: `Bearer ${process.env.GITLAB_TOKEN}`,
597
+ },
598
+ });
599
+ if (!response.ok) {
600
+ throw new Error(`GitLab API error: ${response.status} ${response.statusText}`);
601
+ }
602
+ return { success: true, message: 'Draft note deleted successfully' };
603
+ },
604
+ },
605
+ ],
606
+ ]);
607
+ function getMrsReadOnlyToolNames() {
608
+ return [
609
+ 'get_branch_diffs',
610
+ 'get_merge_request',
611
+ 'get_merge_request_diffs',
612
+ 'list_merge_request_diffs',
613
+ 'mr_discussions',
614
+ 'get_draft_note',
615
+ 'list_draft_notes',
616
+ 'list_merge_requests',
617
+ ];
618
+ }
619
+ function getMrsToolDefinitions() {
620
+ return Array.from(exports.mrsToolRegistry.values());
621
+ }
622
+ function getFilteredMrsTools(readOnlyMode = false) {
623
+ if (readOnlyMode) {
624
+ const readOnlyNames = getMrsReadOnlyToolNames();
625
+ return Array.from(exports.mrsToolRegistry.values()).filter((tool) => readOnlyNames.includes(tool.name));
626
+ }
627
+ return getMrsToolDefinitions();
628
+ }
629
+ //# sourceMappingURL=registry.js.map