@zereight/mcp-gitlab 2.1.70 → 2.2.1

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 (158) hide show
  1. package/README.ko.md +9 -5
  2. package/README.md +15 -11
  3. package/README.pt-BR.md +9 -5
  4. package/README.zh-CN.md +9 -5
  5. package/build/config.js +12 -4
  6. package/build/deprecated-env.js +63 -0
  7. package/build/index.js +430 -200
  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 +232 -63
  16. package/build/tools/tool-descriptions.js +3 -3
  17. package/build/tools/tool-profile.js +66 -0
  18. package/build/utils/compact-tool-allowlist.js +14 -0
  19. package/build/utils/logger.js +34 -12
  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/credentials.test.js +0 -153
  32. package/build/test/cli/exposure.test.js +0 -104
  33. package/build/test/cli/load-config-snapshot.js +0 -5
  34. package/build/test/cli/output.test.js +0 -74
  35. package/build/test/cli/replay-command.test.js +0 -37
  36. package/build/test/cli/router.test.js +0 -183
  37. package/build/test/client-pool-test.js +0 -109
  38. package/build/test/clients/client.js +0 -34
  39. package/build/test/clients/custom-header-client.js +0 -122
  40. package/build/test/clients/sse-client.js +0 -95
  41. package/build/test/clients/stdio-client.js +0 -113
  42. package/build/test/clients/streamable-http-client.js +0 -95
  43. package/build/test/config-allowed-groups.test.js +0 -97
  44. package/build/test/create-commit-actions.test.js +0 -102
  45. package/build/test/draft-note-schema.test.js +0 -44
  46. package/build/test/dynamic-api-url-allowlist.test.js +0 -121
  47. package/build/test/dynamic-api-url-test.js +0 -304
  48. package/build/test/dynamic-routing-tests.js +0 -495
  49. package/build/test/get-merge-request-discussion-schema.test.js +0 -30
  50. package/build/test/gitlab-api-tool-errors.test.js +0 -112
  51. package/build/test/gitlab-artifact-entry-schema.test.js +0 -44
  52. package/build/test/gitlab-diff-schema.test.js +0 -36
  53. package/build/test/gitlab-pipeline-schedule-schema.test.js +0 -32
  54. package/build/test/gitlab-tag-schema.test.js +0 -51
  55. package/build/test/group-milestone-schema.test.js +0 -45
  56. package/build/test/mcp-oauth-tests.js +0 -905
  57. package/build/test/mcp-server-name.test.js +0 -87
  58. package/build/test/merge-merge-request-schema.test.js +0 -75
  59. package/build/test/multi-server-test.js +0 -190
  60. package/build/test/no-proxy-integration-test.js +0 -183
  61. package/build/test/no-proxy-test.js +0 -149
  62. package/build/test/nullable-gitlab-response-fields.test.js +0 -37
  63. package/build/test/nullish-tool-arguments-schema.test.js +0 -118
  64. package/build/test/oauth-device-flow-tests.js +0 -450
  65. package/build/test/oauth-download-url.test.js +0 -157
  66. package/build/test/oauth-startup.test.js +0 -204
  67. package/build/test/oauth-tests.js +0 -428
  68. package/build/test/path-segment-encoding.test.js +0 -98
  69. package/build/test/remote-auth-simple-test.js +0 -277
  70. package/build/test/remote-auth-tests.js +0 -314
  71. package/build/test/response-masking.test.js +0 -445
  72. package/build/test/schema-tests.js +0 -1679
  73. package/build/test/server/metrics.test.js +0 -47
  74. package/build/test/server/request-helpers.test.js +0 -48
  75. package/build/test/server/version.test.js +0 -13
  76. package/build/test/sse-auth-guard.test.js +0 -96
  77. package/build/test/sse-session-limits.test.js +0 -273
  78. package/build/test/stateless/callback-proxy.test.js +0 -510
  79. package/build/test/stateless/client-id.test.js +0 -177
  80. package/build/test/stateless/codec.test.js +0 -328
  81. package/build/test/stateless/config-ttl.test.js +0 -149
  82. package/build/test/stateless/consumed-proxy-code-cache.test.js +0 -150
  83. package/build/test/stateless/session-id-integration.test.js +0 -675
  84. package/build/test/stateless/session-id.test.js +0 -157
  85. package/build/test/streamable-http-concurrent-session.test.js +0 -171
  86. package/build/test/streamable-http-dns-rebinding.test.js +0 -185
  87. package/build/test/streamable-http-sse-stream.test.js +0 -350
  88. package/build/test/streamable-http-static-token-auth.test.js +0 -157
  89. package/build/test/streamable-http-unauthenticated-discovery.test.js +0 -207
  90. package/build/test/test-all-transport-server.js +0 -255
  91. package/build/test/test-auth-retry.js +0 -195
  92. package/build/test/test-blank-filters.js +0 -156
  93. package/build/test/test-ci-catalog.js +0 -177
  94. package/build/test/test-ci-lint.js +0 -191
  95. package/build/test/test-ci-variables.js +0 -309
  96. package/build/test/test-create-repository.js +0 -120
  97. package/build/test/test-dependency-proxy.js +0 -195
  98. package/build/test/test-deployment-tools.js +0 -463
  99. package/build/test/test-download-attachment.js +0 -190
  100. package/build/test/test-dynamic-project-scope.js +0 -524
  101. package/build/test/test-empty-toolsets.js +0 -535
  102. package/build/test/test-get-file-blame.js +0 -145
  103. package/build/test/test-get-file-contents.js +0 -128
  104. package/build/test/test-geteffectiveprojectid.js +0 -804
  105. package/build/test/test-health-check.js +0 -115
  106. package/build/test/test-issue-description-patch.js +0 -256
  107. package/build/test/test-job-artifacts.js +0 -275
  108. package/build/test/test-json-schema.js +0 -166
  109. package/build/test/test-list-group-members.js +0 -150
  110. package/build/test/test-list-group-merge-requests.js +0 -165
  111. package/build/test/test-list-issues.js +0 -170
  112. package/build/test/test-list-merge-requests.js +0 -201
  113. package/build/test/test-list-milestones.js +0 -145
  114. package/build/test/test-list-project-members.js +0 -132
  115. package/build/test/test-merge-request-approval-state-tools.js +0 -213
  116. package/build/test/test-merge-request-approvals.js +0 -187
  117. package/build/test/test-merge-request-pipelines.js +0 -106
  118. package/build/test/test-mr-diffs-filter.js +0 -132
  119. package/build/test/test-mr-file-diffs.js +0 -251
  120. package/build/test/test-oauth-proxy-rate-limit.js +0 -133
  121. package/build/test/test-orbit.js +0 -155
  122. package/build/test/test-permission-mode.js +0 -424
  123. package/build/test/test-pipeline-schedules.js +0 -484
  124. package/build/test/test-protected-branches.js +0 -174
  125. package/build/test/test-remote-downloads.js +0 -510
  126. package/build/test/test-search-code.js +0 -275
  127. package/build/test/test-snippets.js +0 -735
  128. package/build/test/test-tags.js +0 -220
  129. package/build/test/test-todos.js +0 -195
  130. package/build/test/test-token-optimizations.js +0 -691
  131. package/build/test/test-toolset-filtering.js +0 -499
  132. package/build/test/test-update-issue-slim.js +0 -141
  133. package/build/test/test-update-project.js +0 -112
  134. package/build/test/test-upload-markdown.js +0 -206
  135. package/build/test/test-vulnerabilities.js +0 -399
  136. package/build/test/test-webhooks.js +0 -218
  137. package/build/test/tool-description-quality.test.js +0 -50
  138. package/build/test/utils/bulk-publish-options.test.js +0 -32
  139. package/build/test/utils/download-token.test.js +0 -35
  140. package/build/test/utils/forwarded-public-base-url.test.js +0 -46
  141. package/build/test/utils/gitlab-instance-version.test.js +0 -32
  142. package/build/test/utils/gitlab-version-gate.test.js +0 -74
  143. package/build/test/utils/graphql-query.test.js +0 -168
  144. package/build/test/utils/helpers-path.test.js +0 -104
  145. package/build/test/utils/jmespath-tool-result.test.js +0 -91
  146. package/build/test/utils/masking.test.js +0 -384
  147. package/build/test/utils/merge-request-position.test.js +0 -57
  148. package/build/test/utils/mock-gitlab-server.js +0 -614
  149. package/build/test/utils/proxy-client-ip.test.js +0 -28
  150. package/build/test/utils/redact-sensitive.test.js +0 -32
  151. package/build/test/utils/safe-redirect-fetch.test.js +0 -463
  152. package/build/test/utils/server-launcher.js +0 -231
  153. package/build/test/utils/tool-args.test.js +0 -210
  154. package/build/test/utils/url.test.js +0 -141
  155. package/build/test/utils/version-check.test.js +0 -239
  156. package/build/test/utils/wiki-title.test.js +0 -21
  157. package/build/test-note.js +0 -54
  158. package/build/test-resolve-issue-note.js +0 -127
@@ -1,314 +0,0 @@
1
- /**
2
- * Remote Authorization Tests
3
- * Tests for per-session HTTP header-based authorization
4
- */
5
- import { describe, test, after, before } from 'node:test';
6
- import assert from 'node:assert';
7
- import { launchServer, findAvailablePort, cleanupServers, TransportMode, checkHealthEndpoint, HOST } from './utils/server-launcher.js';
8
- console.log('🔐 Remote Authorization Tests');
9
- console.log('');
10
- // Configuration check
11
- const GITLAB_API_URL = process.env.GITLAB_API_URL || "https://gitlab.com";
12
- const GITLAB_TOKEN = process.env.GITLAB_TOKEN_TEST || process.env.GITLAB_TOKEN;
13
- const TEST_PROJECT_ID = process.env.TEST_PROJECT_ID;
14
- console.log('🔧 Test Configuration:');
15
- console.log(` GitLab URL: ${GITLAB_API_URL}`);
16
- console.log(` Token: ${GITLAB_TOKEN ? '✅ Provided' : '❌ Missing'}`);
17
- console.log(` Project ID: ${TEST_PROJECT_ID || '❌ Missing'}`);
18
- // Validate required configuration
19
- if (!GITLAB_TOKEN) {
20
- console.error('❌ Error: GITLAB_TOKEN_TEST or GITLAB_TOKEN environment variable is required for testing');
21
- console.error(' Set one of these variables to your GitLab API token');
22
- process.exit(1);
23
- }
24
- if (!TEST_PROJECT_ID) {
25
- console.error('❌ Error: TEST_PROJECT_ID environment variable is required for testing');
26
- console.error(' Set this variable to a valid GitLab project ID (e.g., "123" or "group/project")');
27
- process.exit(1);
28
- }
29
- console.log('✅ Configuration validated');
30
- console.log('');
31
- let servers = [];
32
- // Cleanup function for all tests
33
- const cleanup = () => {
34
- cleanupServers(servers);
35
- servers = [];
36
- };
37
- // Handle process termination
38
- process.on('SIGINT', cleanup);
39
- process.on('SIGTERM', cleanup);
40
- process.on('exit', cleanup);
41
- /**
42
- * Helper to send MCP request with custom headers
43
- */
44
- async function sendMCPRequest(url, method, headers = {}) {
45
- const response = await fetch(url, {
46
- method: 'POST',
47
- headers: {
48
- 'Content-Type': 'application/json',
49
- ...headers,
50
- },
51
- body: JSON.stringify(method),
52
- });
53
- if (!response.ok) {
54
- const text = await response.text();
55
- throw new Error(`HTTP ${response.status}: ${text}`);
56
- }
57
- return response.json();
58
- }
59
- describe('Remote Authorization - Streamable HTTP with Authorization header', () => {
60
- let server;
61
- let port;
62
- let mcpUrl;
63
- before(async () => {
64
- port = await findAvailablePort();
65
- server = await launchServer({
66
- mode: TransportMode.STREAMABLE_HTTP,
67
- port,
68
- timeout: 3000,
69
- env: {
70
- STREAMABLE_HTTP: 'true',
71
- REMOTE_AUTHORIZATION: 'true',
72
- GITLAB_API_URL: `${GITLAB_API_URL}/api/v4`,
73
- GITLAB_PROJECT_ID: TEST_PROJECT_ID,
74
- GITLAB_READ_ONLY_MODE: 'true',
75
- // Explicitly no GITLAB_PERSONAL_ACCESS_TOKEN
76
- }
77
- });
78
- servers.push(server);
79
- mcpUrl = `http://${HOST}:${port}/mcp`;
80
- // Verify server started successfully
81
- assert.ok(server.process.pid !== undefined, 'Server process should have PID');
82
- // Verify health check
83
- if (server.port) {
84
- const health = await checkHealthEndpoint(server.port);
85
- assert.strictEqual(health.status, 'healthy', 'Health status should be healthy');
86
- }
87
- console.log('Server started with remote authorization enabled');
88
- });
89
- after(async () => {
90
- cleanup();
91
- console.log('Server stopped');
92
- });
93
- test('should reject request without Authorization header', async () => {
94
- const initRequest = {
95
- jsonrpc: '2.0',
96
- id: 1,
97
- method: 'initialize',
98
- params: {
99
- protocolVersion: '2024-11-05',
100
- capabilities: {},
101
- clientInfo: { name: 'test-client', version: '1.0.0' }
102
- }
103
- };
104
- try {
105
- await sendMCPRequest(mcpUrl, initRequest, {
106
- 'mcp-session-id': 'test-session-no-auth'
107
- });
108
- assert.fail('Should have rejected request without auth header');
109
- }
110
- catch (error) {
111
- assert.ok(error instanceof Error);
112
- assert.ok(error.message.includes('401'), 'Should get 401 Unauthorized');
113
- }
114
- });
115
- test('should accept request with Authorization Bearer header', async () => {
116
- const sessionId = `test-session-bearer-${Date.now()}`;
117
- const initRequest = {
118
- jsonrpc: '2.0',
119
- id: 1,
120
- method: 'initialize',
121
- params: {
122
- protocolVersion: '2024-11-05',
123
- capabilities: {},
124
- clientInfo: { name: 'test-client', version: '1.0.0' }
125
- }
126
- };
127
- const response = await sendMCPRequest(mcpUrl, initRequest, {
128
- 'mcp-session-id': sessionId,
129
- 'authorization': `Bearer ${GITLAB_TOKEN}`
130
- });
131
- assert.ok(response, 'Should get response');
132
- assert.ok(response.result, 'Should have result');
133
- assert.strictEqual(response.result.protocolVersion, '2024-11-05', 'Protocol version should match');
134
- });
135
- test('should reuse auth from first request in subsequent requests', async () => {
136
- const sessionId = `test-session-reuse-${Date.now()}`;
137
- // First request with auth
138
- const initRequest = {
139
- jsonrpc: '2.0',
140
- id: 1,
141
- method: 'initialize',
142
- params: {
143
- protocolVersion: '2024-11-05',
144
- capabilities: {},
145
- clientInfo: { name: 'test-client', version: '1.0.0' }
146
- }
147
- };
148
- const initResponse = await sendMCPRequest(mcpUrl, initRequest, {
149
- 'mcp-session-id': sessionId,
150
- 'authorization': `Bearer ${GITLAB_TOKEN}`
151
- });
152
- assert.ok(initResponse.result, 'Init should succeed');
153
- // Second request without auth header (should reuse)
154
- const listToolsRequest = {
155
- jsonrpc: '2.0',
156
- id: 2,
157
- method: 'tools/list',
158
- params: {}
159
- };
160
- const listResponse = await sendMCPRequest(mcpUrl, listToolsRequest, {
161
- 'mcp-session-id': sessionId
162
- // No authorization header
163
- });
164
- assert.ok(listResponse.result, 'List tools should succeed with reused auth');
165
- assert.ok(Array.isArray(listResponse.result.tools), 'Should return tools array');
166
- assert.ok(listResponse.result.tools.length > 0, 'Should have at least one tool');
167
- });
168
- test('should call tool with Bearer token', async () => {
169
- const sessionId = `test-session-tool-${Date.now()}`;
170
- // Initialize
171
- const initRequest = {
172
- jsonrpc: '2.0',
173
- id: 1,
174
- method: 'initialize',
175
- params: {
176
- protocolVersion: '2024-11-05',
177
- capabilities: {},
178
- clientInfo: { name: 'test-client', version: '1.0.0' }
179
- }
180
- };
181
- await sendMCPRequest(mcpUrl, initRequest, {
182
- 'mcp-session-id': sessionId,
183
- 'authorization': `Bearer ${GITLAB_TOKEN}`
184
- });
185
- // Call tool
186
- const callToolRequest = {
187
- jsonrpc: '2.0',
188
- id: 2,
189
- method: 'tools/call',
190
- params: {
191
- name: 'get_project',
192
- arguments: {
193
- project_id: TEST_PROJECT_ID
194
- }
195
- }
196
- };
197
- const toolResponse = await sendMCPRequest(mcpUrl, callToolRequest, {
198
- 'mcp-session-id': sessionId
199
- });
200
- assert.ok(toolResponse.result, 'Tool call should succeed');
201
- assert.ok(toolResponse.result.content, 'Should have content');
202
- assert.ok(Array.isArray(toolResponse.result.content), 'Content should be array');
203
- assert.ok(toolResponse.result.content.length > 0, 'Should have content items');
204
- const projectData = JSON.parse(toolResponse.result.content[0].text);
205
- assert.ok(projectData.id, 'Should have project id');
206
- assert.ok(projectData.name, 'Should have project name');
207
- });
208
- });
209
- describe('Remote Authorization - Streamable HTTP with Private-Token header', () => {
210
- let server;
211
- let port;
212
- let mcpUrl;
213
- before(async () => {
214
- port = await findAvailablePort();
215
- server = await launchServer({
216
- mode: TransportMode.STREAMABLE_HTTP,
217
- port,
218
- timeout: 3000,
219
- env: {
220
- STREAMABLE_HTTP: 'true',
221
- REMOTE_AUTHORIZATION: 'true',
222
- GITLAB_API_URL: `${GITLAB_API_URL}/api/v4`,
223
- GITLAB_PROJECT_ID: TEST_PROJECT_ID,
224
- GITLAB_READ_ONLY_MODE: 'true',
225
- }
226
- });
227
- servers.push(server);
228
- mcpUrl = `http://${HOST}:${port}/mcp`;
229
- console.log('Server started for Private-Token tests');
230
- });
231
- after(async () => {
232
- cleanup();
233
- console.log('Server stopped');
234
- });
235
- test('should accept request with Private-Token header', async () => {
236
- const sessionId = `test-session-private-${Date.now()}`;
237
- const initRequest = {
238
- jsonrpc: '2.0',
239
- id: 1,
240
- method: 'initialize',
241
- params: {
242
- protocolVersion: '2024-11-05',
243
- capabilities: {},
244
- clientInfo: { name: 'test-client', version: '1.0.0' }
245
- }
246
- };
247
- const response = await sendMCPRequest(mcpUrl, initRequest, {
248
- 'mcp-session-id': sessionId,
249
- 'private-token': GITLAB_TOKEN
250
- });
251
- assert.ok(response.result, 'Should succeed with Private-Token');
252
- assert.strictEqual(response.result.protocolVersion, '2024-11-05', 'Protocol version should match');
253
- });
254
- test('should call tool with Private-Token', async () => {
255
- const sessionId = `test-session-private-tool-${Date.now()}`;
256
- // Initialize
257
- const initRequest = {
258
- jsonrpc: '2.0',
259
- id: 1,
260
- method: 'initialize',
261
- params: {
262
- protocolVersion: '2024-11-05',
263
- capabilities: {},
264
- clientInfo: { name: 'test-client', version: '1.0.0' }
265
- }
266
- };
267
- await sendMCPRequest(mcpUrl, initRequest, {
268
- 'mcp-session-id': sessionId,
269
- 'private-token': GITLAB_TOKEN
270
- });
271
- // Call tool
272
- const callToolRequest = {
273
- jsonrpc: '2.0',
274
- id: 2,
275
- method: 'tools/call',
276
- params: {
277
- name: 'list_merge_requests',
278
- arguments: {
279
- project_id: TEST_PROJECT_ID
280
- }
281
- }
282
- };
283
- const toolResponse = await sendMCPRequest(mcpUrl, callToolRequest, {
284
- 'mcp-session-id': sessionId
285
- });
286
- assert.ok(toolResponse.result, 'Tool call should succeed with Private-Token');
287
- assert.ok(toolResponse.result.content, 'Should have content');
288
- });
289
- });
290
- describe('Remote Authorization - SSE mode should be disabled', () => {
291
- test('should fail to start with SSE and REMOTE_AUTHORIZATION', async () => {
292
- const port = await findAvailablePort();
293
- try {
294
- const server = await launchServer({
295
- mode: TransportMode.SSE,
296
- port,
297
- timeout: 3000,
298
- env: {
299
- SSE: 'true',
300
- REMOTE_AUTHORIZATION: 'true',
301
- GITLAB_API_URL: `${GITLAB_API_URL}/api/v4`,
302
- }
303
- });
304
- // If we get here, the server started when it shouldn't have
305
- servers.push(server);
306
- assert.fail('Server should not start with SSE and REMOTE_AUTHORIZATION=true');
307
- }
308
- catch (error) {
309
- // Expected: server should fail to start
310
- assert.ok(error instanceof Error, 'Should throw an error');
311
- console.log('✅ Server correctly rejected SSE mode with remote authorization');
312
- }
313
- });
314
- });