@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,275 +0,0 @@
1
- /**
2
- * Search Code Tools Test Suite
3
- *
4
- * Tests search_code, search_project_code, and search_group_code tools
5
- * using the mock GitLab server and streamable HTTP transport.
6
- */
7
- import { describe, test, after, before } from "node:test";
8
- import assert from "node:assert";
9
- import { launchServer, findAvailablePort, cleanupServers, TransportMode, HOST, } from "./utils/server-launcher.js";
10
- import { MockGitLabServer, findMockServerPort, } from "./utils/mock-gitlab-server.js";
11
- import { CustomHeaderClient } from "./clients/custom-header-client.js";
12
- const MOCK_TOKEN = "glpat-search-test-token";
13
- // Port bases that don't conflict with other test suites
14
- const MOCK_PORT_BASE = 9300;
15
- const MCP_PORT_BASE = 3300;
16
- let portCounter = 0;
17
- async function nextMcpPort() {
18
- return findAvailablePort(MCP_PORT_BASE + portCounter++ * 10);
19
- }
20
- async function launchMcpServer(mockGitLabUrl, mcpPort, extraEnv = {}) {
21
- return launchServer({
22
- mode: TransportMode.STREAMABLE_HTTP,
23
- port: mcpPort,
24
- timeout: 10000,
25
- env: {
26
- STREAMABLE_HTTP: "true",
27
- REMOTE_AUTHORIZATION: "true",
28
- GITLAB_API_URL: `${mockGitLabUrl}/api/v4`,
29
- ...extraEnv,
30
- },
31
- });
32
- }
33
- async function getToolNames(mcpUrl) {
34
- const client = new CustomHeaderClient({
35
- authorization: `Bearer ${MOCK_TOKEN}`,
36
- });
37
- await client.connect(mcpUrl);
38
- const result = await client.listTools();
39
- await client.disconnect();
40
- return result.tools.map((t) => t.name);
41
- }
42
- async function callTool(mcpUrl, toolName, args = {}) {
43
- const client = new CustomHeaderClient({
44
- authorization: `Bearer ${MOCK_TOKEN}`,
45
- });
46
- await client.connect(mcpUrl);
47
- const result = await client.callTool(toolName, args);
48
- await client.disconnect();
49
- // Parse the tool result content
50
- const content = result?.content?.[0]?.text;
51
- if (content) {
52
- return JSON.parse(content);
53
- }
54
- return result;
55
- }
56
- // --- Tests ---
57
- let mockGitLab;
58
- let mockGitLabUrl;
59
- describe("Search Code Tools", () => {
60
- before(async () => {
61
- const mockPort = await findMockServerPort();
62
- mockGitLab = new MockGitLabServer({
63
- port: mockPort,
64
- validTokens: [MOCK_TOKEN],
65
- });
66
- await mockGitLab.start();
67
- mockGitLabUrl = mockGitLab.getUrl();
68
- console.log(`Mock GitLab: ${mockGitLabUrl}`);
69
- });
70
- after(async () => {
71
- if (mockGitLab)
72
- await mockGitLab.stop();
73
- });
74
- // ---- 1. search toolset exposes exactly 4 tools ----
75
- describe("search toolset exposes exactly 4 tools", () => {
76
- let server;
77
- let tools;
78
- before(async () => {
79
- const port = await nextMcpPort();
80
- server = await launchMcpServer(mockGitLabUrl, port, {
81
- GITLAB_TOOLSETS: "search",
82
- });
83
- tools = await getToolNames(`http://${HOST}:${port}/mcp`);
84
- });
85
- after(() => cleanupServers([server]));
86
- test("returns exactly 4 tools", () => {
87
- assert.strictEqual(tools.length, 4, `Expected 4 tools but got ${tools.length}: ${tools.join(", ")}`);
88
- });
89
- test("includes search_code", () => {
90
- assert.ok(tools.includes("search_code"), "Expected search_code to be present");
91
- });
92
- test("includes search_project_code", () => {
93
- assert.ok(tools.includes("search_project_code"), "Expected search_project_code to be present");
94
- });
95
- test("includes search_group_code", () => {
96
- assert.ok(tools.includes("search_group_code"), "Expected search_group_code to be present");
97
- });
98
- test("includes discover_tools", () => {
99
- assert.ok(tools.includes("discover_tools"), "Expected discover_tools to be present");
100
- });
101
- });
102
- // ---- 2. search_code returns blob results ----
103
- describe("search_code returns blob results", () => {
104
- let server;
105
- let mcpUrl;
106
- before(async () => {
107
- const port = await nextMcpPort();
108
- server = await launchMcpServer(mockGitLabUrl, port, {
109
- GITLAB_TOOLSETS: "search",
110
- });
111
- mcpUrl = `http://${HOST}:${port}/mcp`;
112
- });
113
- after(() => cleanupServers([server]));
114
- test("returns array with blob fields", async () => {
115
- const result = await callTool(mcpUrl, "search_code", { search: "searchResult" });
116
- assert.ok(Array.isArray(result), "Response should be an array");
117
- assert.ok(result.length > 0, "Response should have at least one result");
118
- const first = result[0];
119
- assert.ok("filename" in first, "Result should have filename field");
120
- assert.ok("path" in first, "Result should have path field");
121
- assert.ok("startline" in first, "Result should have startline field");
122
- });
123
- test("result has correct filename", async () => {
124
- const result = await callTool(mcpUrl, "search_code", { search: "searchResult" });
125
- assert.strictEqual(result[0].filename, "index.ts");
126
- });
127
- test("result has correct path", async () => {
128
- const result = await callTool(mcpUrl, "search_code", { search: "searchResult" });
129
- assert.strictEqual(result[0].path, "src/index.ts");
130
- });
131
- test("result has correct startline", async () => {
132
- const result = await callTool(mcpUrl, "search_code", { search: "searchResult" });
133
- assert.strictEqual(result[0].startline, 42);
134
- });
135
- });
136
- // ---- 3. search_project_code returns blob results for project ----
137
- describe("search_project_code returns blob results for project", () => {
138
- let server;
139
- let mcpUrl;
140
- before(async () => {
141
- const port = await nextMcpPort();
142
- server = await launchMcpServer(mockGitLabUrl, port, {
143
- GITLAB_TOOLSETS: "search",
144
- });
145
- mcpUrl = `http://${HOST}:${port}/mcp`;
146
- });
147
- after(() => cleanupServers([server]));
148
- test("returns array with project_id", async () => {
149
- const result = await callTool(mcpUrl, "search_project_code", {
150
- project_id: "123",
151
- search: "searchResult",
152
- });
153
- assert.ok(Array.isArray(result), "Response should be an array");
154
- assert.ok(result.length > 0, "Response should have at least one result");
155
- });
156
- test("result includes the correct project_id", async () => {
157
- const result = await callTool(mcpUrl, "search_project_code", {
158
- project_id: "123",
159
- search: "searchResult",
160
- });
161
- assert.strictEqual(String(result[0].project_id), "123", "project_id should match requested project");
162
- });
163
- });
164
- // ---- 3b. search_project_code handles URL-encoded namespaced paths ----
165
- describe("search_project_code handles URL-encoded namespaced paths", () => {
166
- let server;
167
- let mcpUrl;
168
- before(async () => {
169
- const port = await nextMcpPort();
170
- server = await launchMcpServer(mockGitLabUrl, port, {
171
- GITLAB_TOOLSETS: "search",
172
- });
173
- mcpUrl = `http://${HOST}:${port}/mcp`;
174
- });
175
- after(() => cleanupServers([server]));
176
- test("URL-encoded project path is not double-encoded", async () => {
177
- // Pass a URL-encoded namespaced path (e.g. "my-group%2Fmy-project")
178
- // The mock echoes back req.params.id (which Express decodes from the URL).
179
- // Correct: decode → "my-group/my-project" → encode → "my-group%2Fmy-project" → Express decodes to "my-group/my-project"
180
- // Double-encoded: encode "my-group%2Fmy-project" → "my-group%252Fmy-project" → Express decodes to "my-group%2Fmy-project"
181
- const result = await callTool(mcpUrl, "search_project_code", {
182
- project_id: "my-group%2Fmy-project",
183
- search: "searchResult",
184
- });
185
- assert.ok(Array.isArray(result), "Response should be an array");
186
- assert.ok(result.length > 0, "Response should have at least one result");
187
- assert.strictEqual(result[0].project_id, "my-group/my-project", "project_id should be decoded (not double-encoded as 'my-group%2Fmy-project')");
188
- });
189
- test("plain numeric project_id still works", async () => {
190
- const result = await callTool(mcpUrl, "search_project_code", {
191
- project_id: "123",
192
- search: "searchResult",
193
- });
194
- assert.strictEqual(result[0].project_id, "123");
195
- });
196
- });
197
- // ---- 4. search_group_code returns blob results for group ----
198
- describe("search_group_code returns blob results for group", () => {
199
- let server;
200
- let mcpUrl;
201
- before(async () => {
202
- const port = await nextMcpPort();
203
- server = await launchMcpServer(mockGitLabUrl, port, {
204
- GITLAB_TOOLSETS: "search",
205
- });
206
- mcpUrl = `http://${HOST}:${port}/mcp`;
207
- });
208
- after(() => cleanupServers([server]));
209
- test("returns array of results", async () => {
210
- const result = await callTool(mcpUrl, "search_group_code", {
211
- group_id: "456",
212
- search: "searchResult",
213
- });
214
- assert.ok(Array.isArray(result), "Response should be an array");
215
- assert.ok(result.length > 0, "Response should have at least one result");
216
- });
217
- test("result has expected blob fields", async () => {
218
- const result = await callTool(mcpUrl, "search_group_code", {
219
- group_id: "456",
220
- search: "searchResult",
221
- });
222
- const first = result[0];
223
- assert.ok("filename" in first, "Result should have filename field");
224
- assert.ok("path" in first, "Result should have path field");
225
- });
226
- });
227
- // ---- 4b. search_group_code handles URL-encoded namespaced paths ----
228
- describe("search_group_code handles URL-encoded namespaced paths", () => {
229
- let server;
230
- let mcpUrl;
231
- before(async () => {
232
- const port = await nextMcpPort();
233
- server = await launchMcpServer(mockGitLabUrl, port, {
234
- GITLAB_TOOLSETS: "search",
235
- });
236
- mcpUrl = `http://${HOST}:${port}/mcp`;
237
- });
238
- after(() => cleanupServers([server]));
239
- test("URL-encoded group path is not double-encoded", async () => {
240
- // The mock echoes back req.params.id in the ref field.
241
- // Correct: decode → "my-org/my-group" → encode → "my-org%2Fmy-group" → Express decodes to "my-org/my-group"
242
- // Double-encoded: encode "my-org%2Fmy-group" → "my-org%252Fmy-group" → Express decodes to "my-org%2Fmy-group"
243
- const result = await callTool(mcpUrl, "search_group_code", {
244
- group_id: "my-org%2Fmy-group",
245
- search: "searchResult",
246
- });
247
- assert.ok(Array.isArray(result), "Response should be an array");
248
- assert.ok(result.length > 0, "Response should have at least one result");
249
- assert.strictEqual(result[0].ref, "my-org/my-group", "ref should contain decoded group path (not double-encoded as 'my-org%2Fmy-group')");
250
- });
251
- });
252
- // ---- 5. search tools are not available without search toolset enabled ----
253
- describe("search tools are not available without search toolset enabled", () => {
254
- let server;
255
- let tools;
256
- before(async () => {
257
- const port = await nextMcpPort();
258
- // Launch without GITLAB_TOOLSETS=search (use a different toolset instead)
259
- server = await launchMcpServer(mockGitLabUrl, port, {
260
- GITLAB_TOOLSETS: "issues",
261
- });
262
- tools = await getToolNames(`http://${HOST}:${port}/mcp`);
263
- });
264
- after(() => cleanupServers([server]));
265
- test("search_code is NOT in tool list", () => {
266
- assert.ok(!tools.includes("search_code"), "search_code should NOT be present without search toolset");
267
- });
268
- test("search_project_code is NOT in tool list", () => {
269
- assert.ok(!tools.includes("search_project_code"), "search_project_code should NOT be present without search toolset");
270
- });
271
- test("search_group_code is NOT in tool list", () => {
272
- assert.ok(!tools.includes("search_group_code"), "search_group_code should NOT be present without search toolset");
273
- });
274
- });
275
- });