@zereight/mcp-gitlab 2.1.69 → 2.2.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 (155) hide show
  1. package/README.ko.md +10 -4
  2. package/README.md +238 -233
  3. package/README.pt-BR.md +4 -4
  4. package/README.zh-CN.md +6 -4
  5. package/build/config.js +12 -4
  6. package/build/deprecated-env.js +47 -0
  7. package/build/index.js +456 -237
  8. package/build/oauth-device-flow.js +80 -0
  9. package/build/oauth.js +135 -18
  10. package/build/schemas.js +1 -1
  11. package/build/server/remote-http-stack.js +39 -0
  12. package/build/tools/discover-activation.js +38 -0
  13. package/build/tools/exposed-tools.js +35 -0
  14. package/build/tools/listed-tools.js +76 -0
  15. package/build/tools/registry.js +226 -57
  16. package/build/tools/tool-profile.js +66 -0
  17. package/build/utils/compact-tool-allowlist.js +14 -0
  18. package/build/utils/logger.js +34 -12
  19. package/build/utils/url.js +15 -0
  20. package/package.json +3 -3
  21. package/build/scripts/check-skill-sync.js +0 -143
  22. package/build/scripts/generate-server-card.js +0 -39
  23. package/build/scripts/generate-tool-coverage.js +0 -58
  24. package/build/scripts/generate-tool-docs.js +0 -430
  25. package/build/scripts/tool-coverage/coverage.js +0 -341
  26. package/build/scripts/tool-coverage/coverage.test.js +0 -142
  27. package/build/test/callback-proxy-tests.js +0 -321
  28. package/build/test/cli/args.test.js +0 -175
  29. package/build/test/cli/boolean-flags.test.js +0 -106
  30. package/build/test/cli/compact-mcp-result.test.js +0 -93
  31. package/build/test/cli/exposure.test.js +0 -104
  32. package/build/test/cli/load-config-snapshot.js +0 -5
  33. package/build/test/cli/output.test.js +0 -74
  34. package/build/test/cli/replay-command.test.js +0 -37
  35. package/build/test/cli/router.test.js +0 -183
  36. package/build/test/client-pool-test.js +0 -109
  37. package/build/test/clients/client.js +0 -34
  38. package/build/test/clients/custom-header-client.js +0 -122
  39. package/build/test/clients/sse-client.js +0 -95
  40. package/build/test/clients/stdio-client.js +0 -113
  41. package/build/test/clients/streamable-http-client.js +0 -95
  42. package/build/test/config-allowed-groups.test.js +0 -97
  43. package/build/test/create-commit-actions.test.js +0 -102
  44. package/build/test/draft-note-schema.test.js +0 -44
  45. package/build/test/dynamic-api-url-allowlist.test.js +0 -121
  46. package/build/test/dynamic-api-url-test.js +0 -304
  47. package/build/test/dynamic-routing-tests.js +0 -495
  48. package/build/test/get-merge-request-discussion-schema.test.js +0 -30
  49. package/build/test/gitlab-artifact-entry-schema.test.js +0 -44
  50. package/build/test/gitlab-diff-schema.test.js +0 -36
  51. package/build/test/gitlab-pipeline-schedule-schema.test.js +0 -32
  52. package/build/test/gitlab-tag-schema.test.js +0 -51
  53. package/build/test/group-milestone-schema.test.js +0 -45
  54. package/build/test/mcp-oauth-tests.js +0 -905
  55. package/build/test/mcp-server-name.test.js +0 -87
  56. package/build/test/merge-merge-request-schema.test.js +0 -75
  57. package/build/test/multi-server-test.js +0 -190
  58. package/build/test/no-proxy-integration-test.js +0 -183
  59. package/build/test/no-proxy-test.js +0 -149
  60. package/build/test/nullable-gitlab-response-fields.test.js +0 -37
  61. package/build/test/nullish-tool-arguments-schema.test.js +0 -118
  62. package/build/test/oauth-device-flow-tests.js +0 -450
  63. package/build/test/oauth-startup.test.js +0 -204
  64. package/build/test/oauth-tests.js +0 -428
  65. package/build/test/path-segment-encoding.test.js +0 -98
  66. package/build/test/remote-auth-simple-test.js +0 -277
  67. package/build/test/remote-auth-tests.js +0 -314
  68. package/build/test/response-masking.test.js +0 -445
  69. package/build/test/schema-tests.js +0 -1679
  70. package/build/test/server/metrics.test.js +0 -47
  71. package/build/test/server/request-helpers.test.js +0 -48
  72. package/build/test/server/version.test.js +0 -13
  73. package/build/test/sse-auth-guard.test.js +0 -96
  74. package/build/test/sse-session-limits.test.js +0 -273
  75. package/build/test/stateless/callback-proxy.test.js +0 -510
  76. package/build/test/stateless/client-id.test.js +0 -177
  77. package/build/test/stateless/codec.test.js +0 -328
  78. package/build/test/stateless/config-ttl.test.js +0 -149
  79. package/build/test/stateless/consumed-proxy-code-cache.test.js +0 -150
  80. package/build/test/stateless/session-id-integration.test.js +0 -675
  81. package/build/test/stateless/session-id.test.js +0 -157
  82. package/build/test/streamable-http-concurrent-session.test.js +0 -171
  83. package/build/test/streamable-http-dns-rebinding.test.js +0 -185
  84. package/build/test/streamable-http-sse-stream.test.js +0 -350
  85. package/build/test/streamable-http-static-token-auth.test.js +0 -157
  86. package/build/test/streamable-http-unauthenticated-discovery.test.js +0 -207
  87. package/build/test/test-all-transport-server.js +0 -255
  88. package/build/test/test-auth-retry.js +0 -195
  89. package/build/test/test-blank-filters.js +0 -156
  90. package/build/test/test-ci-catalog.js +0 -177
  91. package/build/test/test-ci-lint.js +0 -191
  92. package/build/test/test-ci-variables.js +0 -309
  93. package/build/test/test-create-repository.js +0 -120
  94. package/build/test/test-dependency-proxy.js +0 -195
  95. package/build/test/test-deployment-tools.js +0 -463
  96. package/build/test/test-download-attachment.js +0 -190
  97. package/build/test/test-dynamic-project-scope.js +0 -524
  98. package/build/test/test-empty-toolsets.js +0 -535
  99. package/build/test/test-get-file-blame.js +0 -145
  100. package/build/test/test-get-file-contents.js +0 -128
  101. package/build/test/test-geteffectiveprojectid.js +0 -812
  102. package/build/test/test-health-check.js +0 -115
  103. package/build/test/test-issue-description-patch.js +0 -256
  104. package/build/test/test-job-artifacts.js +0 -275
  105. package/build/test/test-json-schema.js +0 -166
  106. package/build/test/test-list-group-members.js +0 -150
  107. package/build/test/test-list-group-merge-requests.js +0 -165
  108. package/build/test/test-list-issues.js +0 -170
  109. package/build/test/test-list-merge-requests.js +0 -201
  110. package/build/test/test-list-milestones.js +0 -145
  111. package/build/test/test-list-project-members.js +0 -132
  112. package/build/test/test-merge-request-approval-state-tools.js +0 -213
  113. package/build/test/test-merge-request-approvals.js +0 -187
  114. package/build/test/test-merge-request-pipelines.js +0 -106
  115. package/build/test/test-mr-diffs-filter.js +0 -132
  116. package/build/test/test-mr-file-diffs.js +0 -251
  117. package/build/test/test-oauth-proxy-rate-limit.js +0 -133
  118. package/build/test/test-orbit.js +0 -155
  119. package/build/test/test-permission-mode.js +0 -424
  120. package/build/test/test-pipeline-schedules.js +0 -482
  121. package/build/test/test-protected-branches.js +0 -174
  122. package/build/test/test-remote-downloads.js +0 -510
  123. package/build/test/test-search-code.js +0 -275
  124. package/build/test/test-snippets.js +0 -735
  125. package/build/test/test-tags.js +0 -220
  126. package/build/test/test-todos.js +0 -195
  127. package/build/test/test-token-optimizations.js +0 -691
  128. package/build/test/test-toolset-filtering.js +0 -499
  129. package/build/test/test-update-issue-slim.js +0 -141
  130. package/build/test/test-update-project.js +0 -112
  131. package/build/test/test-upload-markdown.js +0 -206
  132. package/build/test/test-vulnerabilities.js +0 -399
  133. package/build/test/test-webhooks.js +0 -218
  134. package/build/test/tool-description-quality.test.js +0 -50
  135. package/build/test/utils/bulk-publish-options.test.js +0 -32
  136. package/build/test/utils/download-token.test.js +0 -35
  137. package/build/test/utils/forwarded-public-base-url.test.js +0 -46
  138. package/build/test/utils/gitlab-instance-version.test.js +0 -32
  139. package/build/test/utils/gitlab-version-gate.test.js +0 -74
  140. package/build/test/utils/graphql-query.test.js +0 -168
  141. package/build/test/utils/helpers-path.test.js +0 -104
  142. package/build/test/utils/jmespath-tool-result.test.js +0 -91
  143. package/build/test/utils/masking.test.js +0 -384
  144. package/build/test/utils/merge-request-position.test.js +0 -57
  145. package/build/test/utils/mock-gitlab-server.js +0 -614
  146. package/build/test/utils/proxy-client-ip.test.js +0 -28
  147. package/build/test/utils/redact-sensitive.test.js +0 -32
  148. package/build/test/utils/safe-redirect-fetch.test.js +0 -463
  149. package/build/test/utils/server-launcher.js +0 -231
  150. package/build/test/utils/tool-args.test.js +0 -210
  151. package/build/test/utils/url.test.js +0 -128
  152. package/build/test/utils/version-check.test.js +0 -239
  153. package/build/test/utils/wiki-title.test.js +0 -21
  154. package/build/test-note.js +0 -54
  155. package/build/test-resolve-issue-note.js +0 -127
@@ -1,535 +0,0 @@
1
- import { after, before, describe, it } from "node:test";
2
- import assert from "node:assert";
3
- import { spawn } from "child_process";
4
- import { MockGitLabServer, findMockServerPort } from "./utils/mock-gitlab-server.js";
5
- const MOCK_TOKEN = "glpat-mock-token-empty-toolsets";
6
- const TEST_PROJECT_ID = "123";
7
- const TEST_GROUP_ID = "10";
8
- const TEST_LABEL_ID = "1";
9
- const TEST_MILESTONE_ID = "1";
10
- const TEST_WIKI_SLUG = "Home";
11
- const TEST_TAG_NAME = "v1.0.0";
12
- const TEST_ASSET_PATH = "hello-asset";
13
- const ISO_NOW = "2026-03-13T10:00:00.000Z";
14
- function buildUser() {
15
- return { id: "1", username: "tester", name: "Test User" };
16
- }
17
- function buildLabel(overrides = {}) {
18
- return {
19
- id: TEST_LABEL_ID,
20
- name: "bug",
21
- color: "#FF0000",
22
- text_color: "#FFFFFF",
23
- description: "A bug",
24
- description_html: "<p>A bug</p>",
25
- ...overrides,
26
- };
27
- }
28
- function buildWikiPage(overrides = {}) {
29
- return {
30
- title: "Home",
31
- slug: TEST_WIKI_SLUG,
32
- format: "markdown",
33
- content: "hello wiki",
34
- ...overrides,
35
- };
36
- }
37
- function buildProjectMilestone(overrides = {}) {
38
- return {
39
- id: TEST_MILESTONE_ID,
40
- iid: "1",
41
- project_id: TEST_PROJECT_ID,
42
- title: "v1",
43
- description: "First milestone",
44
- due_date: null,
45
- start_date: null,
46
- state: "active",
47
- updated_at: ISO_NOW,
48
- created_at: ISO_NOW,
49
- expired: false,
50
- ...overrides,
51
- };
52
- }
53
- function buildGroupMilestone(overrides = {}) {
54
- return {
55
- id: TEST_MILESTONE_ID,
56
- iid: "1",
57
- group_id: TEST_GROUP_ID,
58
- title: "v1",
59
- description: "First group milestone",
60
- due_date: null,
61
- start_date: null,
62
- state: "active",
63
- updated_at: ISO_NOW,
64
- created_at: ISO_NOW,
65
- expired: false,
66
- ...overrides,
67
- };
68
- }
69
- function buildIssue(overrides = {}) {
70
- return {
71
- id: "1",
72
- iid: "1",
73
- project_id: TEST_PROJECT_ID,
74
- title: "Issue one",
75
- description: "",
76
- state: "opened",
77
- author: buildUser(),
78
- assignees: [],
79
- labels: [],
80
- milestone: null,
81
- created_at: ISO_NOW,
82
- updated_at: ISO_NOW,
83
- closed_at: null,
84
- web_url: `https://gitlab.mock/project/${TEST_PROJECT_ID}/issues/1`,
85
- ...overrides,
86
- };
87
- }
88
- function buildMergeRequest(overrides = {}) {
89
- return {
90
- id: "1",
91
- iid: "1",
92
- project_id: TEST_PROJECT_ID,
93
- title: "MR one",
94
- description: "desc",
95
- state: "opened",
96
- author: buildUser(),
97
- source_branch: "feature",
98
- target_branch: "main",
99
- web_url: `https://gitlab.mock/project/${TEST_PROJECT_ID}/merge_requests/1`,
100
- created_at: ISO_NOW,
101
- updated_at: ISO_NOW,
102
- merged_at: null,
103
- closed_at: null,
104
- merge_commit_sha: null,
105
- ...overrides,
106
- };
107
- }
108
- function buildRelease(overrides = {}) {
109
- return {
110
- tag_name: TEST_TAG_NAME,
111
- name: TEST_TAG_NAME,
112
- description: "Release notes",
113
- created_at: ISO_NOW,
114
- ...overrides,
115
- };
116
- }
117
- function buildBurndownEvent() {
118
- return { created_at: ISO_NOW, action: "created" };
119
- }
120
- async function callTool(toolName, args, env) {
121
- return new Promise((resolve, reject) => {
122
- const proc = spawn("node", ["build/index.js"], {
123
- stdio: ["pipe", "pipe", "pipe"],
124
- env: {
125
- ...process.env,
126
- ...env,
127
- },
128
- });
129
- let output = "";
130
- let errorOutput = "";
131
- proc.stdout?.on("data", (d) => (output += d));
132
- proc.stderr?.on("data", (d) => (errorOutput += d));
133
- proc.on("close", code => {
134
- if (code !== 0) {
135
- return reject(new Error(`Process exited with code ${code}: ${errorOutput}`));
136
- }
137
- const line = output.split("\n").find(l => l.startsWith("{"));
138
- if (!line) {
139
- return reject(new Error("No JSON output found"));
140
- }
141
- try {
142
- const response = JSON.parse(line);
143
- if (response.error) {
144
- reject(response.error);
145
- return;
146
- }
147
- const content = response.result?.content?.[0]?.text;
148
- if (!content) {
149
- resolve(response.result);
150
- return;
151
- }
152
- try {
153
- resolve(JSON.parse(content));
154
- }
155
- catch {
156
- resolve(content);
157
- }
158
- }
159
- catch (error) {
160
- reject(error);
161
- }
162
- });
163
- proc.stdin?.end(JSON.stringify({
164
- jsonrpc: "2.0",
165
- id: 1,
166
- method: "tools/call",
167
- params: { name: toolName, arguments: args },
168
- }) + "\n");
169
- });
170
- }
171
- function isRecord(value) {
172
- return typeof value === "object" && value !== null;
173
- }
174
- describe("When covering labels wiki milestones releases", () => {
175
- describe("with GITLAB_TOOLSETS labels,wiki,milestones,releases", () => {
176
- let mockGitLab;
177
- let mockGitLabUrl;
178
- before(async () => {
179
- const mockPort = await findMockServerPort();
180
- mockGitLab = new MockGitLabServer({
181
- port: mockPort,
182
- validTokens: [MOCK_TOKEN],
183
- });
184
- const projectLabels = `/projects/${TEST_PROJECT_ID}/labels`;
185
- const projectLabel = `${projectLabels}/${TEST_LABEL_ID}`;
186
- const projectWikis = `/projects/${TEST_PROJECT_ID}/wikis`;
187
- const projectWiki = `${projectWikis}/${encodeURIComponent(TEST_WIKI_SLUG)}`;
188
- const groupWikis = `/groups/${TEST_GROUP_ID}/wikis`;
189
- const groupWiki = `${groupWikis}/${encodeURIComponent(TEST_WIKI_SLUG)}`;
190
- const projectMilestones = `/projects/${TEST_PROJECT_ID}/milestones`;
191
- const projectMilestone = `${projectMilestones}/${TEST_MILESTONE_ID}`;
192
- const groupMilestones = `/groups/${TEST_GROUP_ID}/milestones`;
193
- const groupMilestone = `${groupMilestones}/${TEST_MILESTONE_ID}`;
194
- const projectReleases = `/projects/${TEST_PROJECT_ID}/releases`;
195
- const projectRelease = `${projectReleases}/${encodeURIComponent(TEST_TAG_NAME)}`;
196
- mockGitLab.addMockHandler("get", projectLabels, (_req, res) => {
197
- res.json([buildLabel()]);
198
- });
199
- mockGitLab.addMockHandler("get", projectLabel, (_req, res) => {
200
- res.json(buildLabel());
201
- });
202
- mockGitLab.addMockHandler("post", projectLabels, (_req, res) => {
203
- res.json(buildLabel());
204
- });
205
- mockGitLab.addMockHandler("put", projectLabel, (_req, res) => {
206
- res.json(buildLabel({ name: "bugfix" }));
207
- });
208
- mockGitLab.addMockHandler("delete", projectLabel, (_req, res) => {
209
- res.status(204).send();
210
- });
211
- mockGitLab.addMockHandler("get", projectWikis, (_req, res) => {
212
- res.json([buildWikiPage()]);
213
- });
214
- mockGitLab.addMockHandler("get", projectWiki, (_req, res) => {
215
- res.json(buildWikiPage());
216
- });
217
- mockGitLab.addMockHandler("post", projectWikis, (_req, res) => {
218
- res.json(buildWikiPage());
219
- });
220
- mockGitLab.addMockHandler("put", projectWiki, (_req, res) => {
221
- res.json(buildWikiPage({ content: "updated wiki" }));
222
- });
223
- mockGitLab.addMockHandler("delete", projectWiki, (_req, res) => {
224
- res.status(204).send();
225
- });
226
- mockGitLab.addMockHandler("get", groupWikis, (_req, res) => {
227
- res.json([buildWikiPage({ title: "Group Home" })]);
228
- });
229
- mockGitLab.addMockHandler("get", groupWiki, (_req, res) => {
230
- res.json(buildWikiPage({ title: "Group Home" }));
231
- });
232
- mockGitLab.addMockHandler("post", groupWikis, (_req, res) => {
233
- res.json(buildWikiPage({ title: "Group Home" }));
234
- });
235
- mockGitLab.addMockHandler("put", groupWiki, (_req, res) => {
236
- res.json(buildWikiPage({ title: "Group Home", content: "updated group wiki" }));
237
- });
238
- mockGitLab.addMockHandler("delete", groupWiki, (_req, res) => {
239
- res.status(204).send();
240
- });
241
- mockGitLab.addMockHandler("get", projectMilestones, (_req, res) => {
242
- res.json([buildProjectMilestone()]);
243
- });
244
- mockGitLab.addMockHandler("get", projectMilestone, (_req, res) => {
245
- res.json(buildProjectMilestone());
246
- });
247
- mockGitLab.addMockHandler("post", projectMilestones, (_req, res) => {
248
- res.json(buildProjectMilestone());
249
- });
250
- mockGitLab.addMockHandler("put", projectMilestone, (_req, res) => {
251
- res.json(buildProjectMilestone({ title: "v1-edited" }));
252
- });
253
- mockGitLab.addMockHandler("delete", projectMilestone, (_req, res) => {
254
- res.status(204).send();
255
- });
256
- mockGitLab.addMockHandler("get", `${projectMilestone}/issues`, (_req, res) => {
257
- res.json([buildIssue()]);
258
- });
259
- mockGitLab.addMockHandler("get", `${projectMilestone}/merge_requests`, (_req, res) => {
260
- res.json([buildMergeRequest()]);
261
- });
262
- mockGitLab.addMockHandler("post", `${projectMilestone}/promote`, (_req, res) => {
263
- res.json(buildGroupMilestone());
264
- });
265
- mockGitLab.addMockHandler("get", `${projectMilestone}/burndown_events`, (_req, res) => {
266
- res.json([buildBurndownEvent()]);
267
- });
268
- mockGitLab.addMockHandler("get", groupMilestones, (_req, res) => {
269
- res.json([buildGroupMilestone()]);
270
- });
271
- mockGitLab.addMockHandler("get", groupMilestone, (_req, res) => {
272
- res.json(buildGroupMilestone());
273
- });
274
- mockGitLab.addMockHandler("post", groupMilestones, (_req, res) => {
275
- res.json(buildGroupMilestone());
276
- });
277
- mockGitLab.addMockHandler("put", groupMilestone, (_req, res) => {
278
- res.json(buildGroupMilestone({ title: "v1-group-edited" }));
279
- });
280
- mockGitLab.addMockHandler("delete", groupMilestone, (_req, res) => {
281
- res.status(204).send();
282
- });
283
- mockGitLab.addMockHandler("get", `${groupMilestone}/issues`, (_req, res) => {
284
- res.json([buildIssue()]);
285
- });
286
- mockGitLab.addMockHandler("get", `${groupMilestone}/merge_requests`, (_req, res) => {
287
- res.json([buildMergeRequest()]);
288
- });
289
- mockGitLab.addMockHandler("get", `${groupMilestone}/burndown_events`, (_req, res) => {
290
- res.json([buildBurndownEvent()]);
291
- });
292
- mockGitLab.addMockHandler("get", projectReleases, (_req, res) => {
293
- res.json([buildRelease()]);
294
- });
295
- mockGitLab.addMockHandler("get", projectRelease, (_req, res) => {
296
- res.json(buildRelease());
297
- });
298
- mockGitLab.addMockHandler("post", projectReleases, (_req, res) => {
299
- res.json(buildRelease());
300
- });
301
- mockGitLab.addMockHandler("put", projectRelease, (_req, res) => {
302
- res.json(buildRelease({ description: "updated notes" }));
303
- });
304
- mockGitLab.addMockHandler("delete", projectRelease, (_req, res) => {
305
- res.json(buildRelease());
306
- });
307
- mockGitLab.addMockHandler("post", `${projectRelease}/evidence`, (_req, res) => {
308
- res.status(201).send();
309
- });
310
- mockGitLab.addMockHandler("get", `${projectRelease}/downloads/${TEST_ASSET_PATH}`, (_req, res) => {
311
- res.send("asset-bytes");
312
- });
313
- await mockGitLab.start();
314
- mockGitLabUrl = mockGitLab.getUrl();
315
- });
316
- after(async () => {
317
- await mockGitLab.stop();
318
- });
319
- const env = () => ({
320
- GITLAB_API_URL: `${mockGitLabUrl}/api/v4`,
321
- GITLAB_PERSONAL_ACCESS_TOKEN: MOCK_TOKEN,
322
- GITLAB_TOOLSETS: "labels,wiki,milestones,releases",
323
- });
324
- it("should return a label from list_labels", async () => {
325
- const result = await callTool("list_labels", { project_id: TEST_PROJECT_ID }, env());
326
- assert.ok(Array.isArray(result));
327
- assert.strictEqual(result[0].name, "bug");
328
- });
329
- it("should return a label from get_label", async () => {
330
- const result = await callTool("get_label", { project_id: TEST_PROJECT_ID, label_id: TEST_LABEL_ID }, env());
331
- assert.ok(isRecord(result));
332
- assert.strictEqual(result.name, "bug");
333
- });
334
- it("should create a label with create_label", async () => {
335
- const result = await callTool("create_label", { project_id: TEST_PROJECT_ID, name: "bug", color: "#FF0000" }, env());
336
- assert.ok(isRecord(result));
337
- assert.strictEqual(result.color, "#FF0000");
338
- });
339
- it("should update a label with update_label", async () => {
340
- const result = await callTool("update_label", { project_id: TEST_PROJECT_ID, label_id: TEST_LABEL_ID, new_name: "bugfix" }, env());
341
- assert.ok(isRecord(result));
342
- assert.strictEqual(result.name, "bugfix");
343
- });
344
- it("should delete a label with delete_label", async () => {
345
- const result = await callTool("delete_label", { project_id: TEST_PROJECT_ID, label_id: TEST_LABEL_ID }, env());
346
- assert.ok(isRecord(result));
347
- assert.strictEqual(result.status, "success");
348
- });
349
- it("should return wiki pages from list_wiki_pages", async () => {
350
- const result = await callTool("list_wiki_pages", { project_id: TEST_PROJECT_ID }, env());
351
- assert.ok(Array.isArray(result));
352
- assert.strictEqual(result[0].slug, TEST_WIKI_SLUG);
353
- });
354
- it("should return a wiki page from get_wiki_page", async () => {
355
- const result = await callTool("get_wiki_page", { project_id: TEST_PROJECT_ID, slug: TEST_WIKI_SLUG }, env());
356
- assert.ok(isRecord(result));
357
- assert.strictEqual(result.slug, TEST_WIKI_SLUG);
358
- });
359
- it("should create a wiki page with create_wiki_page", async () => {
360
- const result = await callTool("create_wiki_page", { project_id: TEST_PROJECT_ID, title: "Home", content: "hello wiki" }, env());
361
- assert.ok(isRecord(result));
362
- assert.strictEqual(result.title, "Home");
363
- });
364
- it("should update a wiki page with update_wiki_page", async () => {
365
- const result = await callTool("update_wiki_page", { project_id: TEST_PROJECT_ID, slug: TEST_WIKI_SLUG, content: "updated wiki" }, env());
366
- assert.ok(isRecord(result));
367
- assert.strictEqual(result.content, "updated wiki");
368
- });
369
- it("should delete a wiki page with delete_wiki_page", async () => {
370
- const result = await callTool("delete_wiki_page", { project_id: TEST_PROJECT_ID, slug: TEST_WIKI_SLUG }, env());
371
- assert.ok(isRecord(result));
372
- assert.strictEqual(result.status, "success");
373
- });
374
- it("should return group wiki pages from list_group_wiki_pages", async () => {
375
- const result = await callTool("list_group_wiki_pages", { group_id: TEST_GROUP_ID }, env());
376
- assert.ok(Array.isArray(result));
377
- assert.strictEqual(result[0].title, "Group Home");
378
- });
379
- it("should return a group wiki page from get_group_wiki_page", async () => {
380
- const result = await callTool("get_group_wiki_page", { group_id: TEST_GROUP_ID, slug: TEST_WIKI_SLUG }, env());
381
- assert.ok(isRecord(result));
382
- assert.strictEqual(result.title, "Group Home");
383
- });
384
- it("should create a group wiki page with create_group_wiki_page", async () => {
385
- const result = await callTool("create_group_wiki_page", { group_id: TEST_GROUP_ID, title: "Home", content: "hello wiki" }, env());
386
- assert.ok(isRecord(result));
387
- assert.strictEqual(result.title, "Group Home");
388
- });
389
- it("should update a group wiki page with update_group_wiki_page", async () => {
390
- const result = await callTool("update_group_wiki_page", { group_id: TEST_GROUP_ID, slug: TEST_WIKI_SLUG, content: "updated group wiki" }, env());
391
- assert.ok(isRecord(result));
392
- assert.strictEqual(result.content, "updated group wiki");
393
- });
394
- it("should delete a group wiki page with delete_group_wiki_page", async () => {
395
- const result = await callTool("delete_group_wiki_page", { group_id: TEST_GROUP_ID, slug: TEST_WIKI_SLUG }, env());
396
- assert.ok(isRecord(result));
397
- assert.strictEqual(result.status, "success");
398
- });
399
- it("should return milestones from list_milestones", async () => {
400
- const result = await callTool("list_milestones", { project_id: TEST_PROJECT_ID }, env());
401
- assert.ok(Array.isArray(result));
402
- assert.strictEqual(result[0].title, "v1");
403
- });
404
- it("should return a milestone from get_milestone", async () => {
405
- const result = await callTool("get_milestone", { project_id: TEST_PROJECT_ID, milestone_id: TEST_MILESTONE_ID }, env());
406
- assert.ok(isRecord(result));
407
- assert.strictEqual(result.id, TEST_MILESTONE_ID);
408
- });
409
- it("should create a milestone with create_milestone", async () => {
410
- const result = await callTool("create_milestone", { project_id: TEST_PROJECT_ID, title: "v1" }, env());
411
- assert.ok(isRecord(result));
412
- assert.strictEqual(result.title, "v1");
413
- });
414
- it("should edit a milestone with edit_milestone", async () => {
415
- const result = await callTool("edit_milestone", {
416
- project_id: TEST_PROJECT_ID,
417
- milestone_id: TEST_MILESTONE_ID,
418
- title: "v1-edited",
419
- }, env());
420
- assert.ok(isRecord(result));
421
- assert.strictEqual(result.title, "v1-edited");
422
- });
423
- it("should delete a milestone with delete_milestone", async () => {
424
- const result = await callTool("delete_milestone", { project_id: TEST_PROJECT_ID, milestone_id: TEST_MILESTONE_ID }, env());
425
- assert.ok(isRecord(result));
426
- assert.strictEqual(result.status, "success");
427
- });
428
- it("should return issues from get_milestone_issue", async () => {
429
- const result = await callTool("get_milestone_issue", { project_id: TEST_PROJECT_ID, milestone_id: TEST_MILESTONE_ID }, env());
430
- assert.ok(Array.isArray(result));
431
- assert.strictEqual(result[0].title, "Issue one");
432
- });
433
- it("should return merge requests from get_milestone_merge_requests", async () => {
434
- const result = await callTool("get_milestone_merge_requests", { project_id: TEST_PROJECT_ID, milestone_id: TEST_MILESTONE_ID }, env());
435
- assert.ok(Array.isArray(result));
436
- assert.strictEqual(result[0].title, "MR one");
437
- });
438
- it("should promote a milestone with promote_milestone", async () => {
439
- const result = await callTool("promote_milestone", { project_id: TEST_PROJECT_ID, milestone_id: TEST_MILESTONE_ID }, env());
440
- assert.ok(isRecord(result));
441
- assert.strictEqual(result.group_id, TEST_GROUP_ID);
442
- });
443
- it("should return events from get_milestone_burndown_events", async () => {
444
- const result = await callTool("get_milestone_burndown_events", { project_id: TEST_PROJECT_ID, milestone_id: TEST_MILESTONE_ID }, env());
445
- assert.ok(Array.isArray(result));
446
- assert.strictEqual(result[0].action, "created");
447
- });
448
- it("should return group milestones from list_group_milestones", async () => {
449
- const result = await callTool("list_group_milestones", { group_id: TEST_GROUP_ID }, env());
450
- assert.ok(Array.isArray(result));
451
- assert.strictEqual(result[0].group_id, TEST_GROUP_ID);
452
- });
453
- it("should return a group milestone from get_group_milestone", async () => {
454
- const result = await callTool("get_group_milestone", { group_id: TEST_GROUP_ID, milestone_id: TEST_MILESTONE_ID }, env());
455
- assert.ok(isRecord(result));
456
- assert.strictEqual(result.group_id, TEST_GROUP_ID);
457
- });
458
- it("should create a group milestone with create_group_milestone", async () => {
459
- const result = await callTool("create_group_milestone", { group_id: TEST_GROUP_ID, title: "v1" }, env());
460
- assert.ok(isRecord(result));
461
- assert.strictEqual(result.title, "v1");
462
- });
463
- it("should edit a group milestone with edit_group_milestone", async () => {
464
- const result = await callTool("edit_group_milestone", {
465
- group_id: TEST_GROUP_ID,
466
- milestone_id: TEST_MILESTONE_ID,
467
- title: "v1-group-edited",
468
- }, env());
469
- assert.ok(isRecord(result));
470
- assert.strictEqual(result.title, "v1-group-edited");
471
- });
472
- it("should delete a group milestone with delete_group_milestone", async () => {
473
- const result = await callTool("delete_group_milestone", { group_id: TEST_GROUP_ID, milestone_id: TEST_MILESTONE_ID }, env());
474
- assert.ok(isRecord(result));
475
- assert.strictEqual(result.status, "success");
476
- });
477
- it("should return issues from get_group_milestone_issue", async () => {
478
- const result = await callTool("get_group_milestone_issue", { group_id: TEST_GROUP_ID, milestone_id: TEST_MILESTONE_ID }, env());
479
- assert.ok(Array.isArray(result));
480
- assert.strictEqual(result[0].title, "Issue one");
481
- });
482
- it("should return merge requests from get_group_milestone_merge_requests", async () => {
483
- const result = await callTool("get_group_milestone_merge_requests", { group_id: TEST_GROUP_ID, milestone_id: TEST_MILESTONE_ID }, env());
484
- assert.ok(Array.isArray(result));
485
- assert.strictEqual(result[0].title, "MR one");
486
- });
487
- it("should return events from get_group_milestone_burndown_events", async () => {
488
- const result = await callTool("get_group_milestone_burndown_events", { group_id: TEST_GROUP_ID, milestone_id: TEST_MILESTONE_ID }, env());
489
- assert.ok(Array.isArray(result));
490
- assert.strictEqual(result[0].action, "created");
491
- });
492
- it("should return releases from list_releases", async () => {
493
- const result = await callTool("list_releases", { project_id: TEST_PROJECT_ID }, env());
494
- assert.ok(Array.isArray(result));
495
- assert.strictEqual(result[0].tag_name, TEST_TAG_NAME);
496
- });
497
- it("should return a release from get_release", async () => {
498
- const result = await callTool("get_release", { project_id: TEST_PROJECT_ID, tag_name: TEST_TAG_NAME }, env());
499
- assert.ok(isRecord(result));
500
- assert.strictEqual(result.tag_name, TEST_TAG_NAME);
501
- });
502
- it("should create a release with create_release", async () => {
503
- const result = await callTool("create_release", { project_id: TEST_PROJECT_ID, tag_name: TEST_TAG_NAME }, env());
504
- assert.ok(isRecord(result));
505
- assert.strictEqual(result.tag_name, TEST_TAG_NAME);
506
- });
507
- it("should update a release with update_release", async () => {
508
- const result = await callTool("update_release", {
509
- project_id: TEST_PROJECT_ID,
510
- tag_name: TEST_TAG_NAME,
511
- description: "updated notes",
512
- }, env());
513
- assert.ok(isRecord(result));
514
- assert.strictEqual(result.description, "updated notes");
515
- });
516
- it("should delete a release with delete_release", async () => {
517
- const result = await callTool("delete_release", { project_id: TEST_PROJECT_ID, tag_name: TEST_TAG_NAME }, env());
518
- assert.ok(isRecord(result));
519
- assert.strictEqual(result.status, "success");
520
- });
521
- it("should create evidence with create_release_evidence", async () => {
522
- const result = await callTool("create_release_evidence", { project_id: TEST_PROJECT_ID, tag_name: TEST_TAG_NAME }, env());
523
- assert.ok(isRecord(result));
524
- assert.strictEqual(result.status, "success");
525
- });
526
- it("should download an asset with download_release_asset", async () => {
527
- const result = await callTool("download_release_asset", {
528
- project_id: TEST_PROJECT_ID,
529
- tag_name: TEST_TAG_NAME,
530
- direct_asset_path: TEST_ASSET_PATH,
531
- }, env());
532
- assert.strictEqual(result, "asset-bytes");
533
- });
534
- });
535
- });
@@ -1,145 +0,0 @@
1
- import { describe, test, before, after } from "node:test";
2
- import assert from "node:assert";
3
- import { spawn } from "child_process";
4
- import { MockGitLabServer, findMockServerPort } from "./utils/mock-gitlab-server.js";
5
- const MOCK_TOKEN = "glpat-mock-token-12345";
6
- const TEST_PROJECT_ID = "123";
7
- const MOCK_BLAME = [
8
- {
9
- lines: ["line one", ""],
10
- commit: {
11
- id: "1111111111111111111111111111111111111111",
12
- message: "feat: initial commit",
13
- authored_date: "2024-01-01T00:00:00.000Z",
14
- author_name: "Alice",
15
- author_email: "alice@example.com",
16
- },
17
- },
18
- {
19
- lines: ["line three"],
20
- commit: {
21
- id: "2222222222222222222222222222222222222222",
22
- message: "feat: add second change",
23
- authored_date: "2024-02-02T00:00:00.000Z",
24
- author_name: "Bob",
25
- author_email: "bob@example.com",
26
- },
27
- },
28
- ];
29
- async function callGetFileBlame(args, env) {
30
- return new Promise((resolve, reject) => {
31
- const proc = spawn("node", ["build/index.js"], {
32
- stdio: ["pipe", "pipe", "pipe"],
33
- env: {
34
- ...process.env,
35
- ...env,
36
- GITLAB_READ_ONLY_MODE: "true",
37
- },
38
- });
39
- let output = "";
40
- let errorOutput = "";
41
- proc.stdout?.on("data", (d) => (output += d));
42
- proc.stderr?.on("data", (d) => (errorOutput += d));
43
- proc.on("close", (code) => {
44
- if (code !== 0)
45
- return reject(new Error(`Process exited with code ${code}: ${errorOutput}`));
46
- const line = output.split("\n").find((l) => l.startsWith("{"));
47
- if (!line)
48
- return reject(new Error("No JSON output found"));
49
- try {
50
- const response = JSON.parse(line);
51
- if (response.error)
52
- return reject(response.error);
53
- const content = response.result?.content?.[0]?.text;
54
- if (content)
55
- return resolve(JSON.parse(content));
56
- resolve(response.result);
57
- }
58
- catch (e) {
59
- reject(e);
60
- }
61
- });
62
- proc.stdin?.end(JSON.stringify({
63
- jsonrpc: "2.0",
64
- id: 1,
65
- method: "tools/call",
66
- params: { name: "get_file_blame", arguments: args },
67
- }) + "\n");
68
- });
69
- }
70
- describe("get_file_blame", () => {
71
- let mockGitLab;
72
- let mockGitLabUrl;
73
- let lastQuery = {};
74
- before(async () => {
75
- const mockPort = await findMockServerPort();
76
- mockGitLab = new MockGitLabServer({
77
- port: mockPort,
78
- validTokens: [MOCK_TOKEN],
79
- });
80
- mockGitLab.addMockHandler("get", `/projects/${TEST_PROJECT_ID}/repository/files/src%2Fexample.txt/blame`, (req, res) => {
81
- lastQuery = req.query;
82
- res.json(MOCK_BLAME);
83
- });
84
- await mockGitLab.start();
85
- mockGitLabUrl = mockGitLab.getUrl();
86
- });
87
- after(async () => {
88
- await mockGitLab.stop();
89
- });
90
- test("returns blame entries for a file at ref", async () => {
91
- const blame = await callGetFileBlame({
92
- project_id: TEST_PROJECT_ID,
93
- file_path: "src/example.txt",
94
- ref: "main",
95
- }, {
96
- GITLAB_API_URL: `${mockGitLabUrl}/api/v4`,
97
- GITLAB_PERSONAL_ACCESS_TOKEN: MOCK_TOKEN,
98
- });
99
- assert.ok(Array.isArray(blame), "Response should be an array");
100
- assert.strictEqual(blame.length, 2, "Two blame entries expected");
101
- assert.strictEqual(blame[1].commit.id, "2222222222222222222222222222222222222222", "second entry commit id matches");
102
- assert.deepStrictEqual(blame[1].lines, ["line three"]);
103
- assert.strictEqual(lastQuery.ref, "main", "ref propagated to GitLab API");
104
- assert.ok(!("range[start]" in lastQuery) && !("range[end]" in lastQuery), "no range params when omitted");
105
- });
106
- test("passes range[start]/range[end] when both set", async () => {
107
- await callGetFileBlame({
108
- project_id: TEST_PROJECT_ID,
109
- file_path: "src/example.txt",
110
- ref: "main",
111
- range_start: 10,
112
- range_end: 20,
113
- }, {
114
- GITLAB_API_URL: `${mockGitLabUrl}/api/v4`,
115
- GITLAB_PERSONAL_ACCESS_TOKEN: MOCK_TOKEN,
116
- });
117
- assert.strictEqual(lastQuery["range[start]"], "10");
118
- assert.strictEqual(lastQuery["range[end]"], "20");
119
- });
120
- test("rejects partial range (range_start only) at schema layer", async () => {
121
- await assert.rejects(() => callGetFileBlame({
122
- project_id: TEST_PROJECT_ID,
123
- file_path: "src/example.txt",
124
- ref: "main",
125
- range_start: 10,
126
- }, {
127
- GITLAB_API_URL: `${mockGitLabUrl}/api/v4`,
128
- GITLAB_PERSONAL_ACCESS_TOKEN: MOCK_TOKEN,
129
- }), (e) => typeof e?.message === "string" &&
130
- e.message.includes("range_start and range_end must be provided together"));
131
- });
132
- test("rejects inverted range (start > end) at schema layer", async () => {
133
- await assert.rejects(() => callGetFileBlame({
134
- project_id: TEST_PROJECT_ID,
135
- file_path: "src/example.txt",
136
- ref: "main",
137
- range_start: 20,
138
- range_end: 10,
139
- }, {
140
- GITLAB_API_URL: `${mockGitLabUrl}/api/v4`,
141
- GITLAB_PERSONAL_ACCESS_TOKEN: MOCK_TOKEN,
142
- }), (e) => typeof e?.message === "string" &&
143
- e.message.includes("range_start must be less than or equal to range_end"));
144
- });
145
- });