@zereight/mcp-gitlab 2.0.28 → 2.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -5
- package/build/index.js +974 -65
- package/build/oauth.js +16 -4
- package/build/schemas.js +504 -101
- package/build/test/schema-tests.js +311 -0
- package/build/test/test-deployment-tools.js +366 -0
- package/build/test/test-download-attachment.js +144 -0
- package/build/test/test-job-artifacts.js +194 -0
- package/build/test/test-merge-request-approval-state-tools.js +171 -0
- package/build/test/test-toolset-filtering.js +452 -0
- package/package.json +3 -2
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolset Filtering Test Suite
|
|
3
|
+
*
|
|
4
|
+
* Tests GITLAB_TOOLSETS, GITLAB_TOOLS, and their interaction with
|
|
5
|
+
* legacy flags (USE_GITLAB_WIKI, USE_PIPELINE, USE_MILESTONE),
|
|
6
|
+
* GITLAB_READ_ONLY_MODE, and GITLAB_DENIED_TOOLS_REGEX.
|
|
7
|
+
*/
|
|
8
|
+
import { describe, test, after, before } from "node:test";
|
|
9
|
+
import assert from "node:assert";
|
|
10
|
+
import { launchServer, findAvailablePort, cleanupServers, TransportMode, HOST, } from "./utils/server-launcher.js";
|
|
11
|
+
import { MockGitLabServer, findMockServerPort, } from "./utils/mock-gitlab-server.js";
|
|
12
|
+
import { CustomHeaderClient } from "./clients/custom-header-client.js";
|
|
13
|
+
const MOCK_TOKEN = "glpat-toolset-test-token";
|
|
14
|
+
// Port bases (offset from other test suites to avoid collisions)
|
|
15
|
+
const MOCK_PORT_BASE = 9200;
|
|
16
|
+
const MCP_PORT_BASE = 3200;
|
|
17
|
+
// Known tool counts per toolset (from TOOLSET_DEFINITIONS)
|
|
18
|
+
const TOOLSET_TOOL_COUNTS = {
|
|
19
|
+
merge_requests: 31,
|
|
20
|
+
issues: 14,
|
|
21
|
+
repositories: 7,
|
|
22
|
+
branches: 4,
|
|
23
|
+
projects: 8,
|
|
24
|
+
labels: 5,
|
|
25
|
+
pipelines: 12,
|
|
26
|
+
milestones: 9,
|
|
27
|
+
wiki: 5,
|
|
28
|
+
releases: 7,
|
|
29
|
+
users: 5,
|
|
30
|
+
};
|
|
31
|
+
const DEFAULT_TOOLSETS = [
|
|
32
|
+
"merge_requests",
|
|
33
|
+
"issues",
|
|
34
|
+
"repositories",
|
|
35
|
+
"branches",
|
|
36
|
+
"projects",
|
|
37
|
+
"labels",
|
|
38
|
+
"pipelines",
|
|
39
|
+
"milestones",
|
|
40
|
+
"wiki",
|
|
41
|
+
"releases",
|
|
42
|
+
"users",
|
|
43
|
+
];
|
|
44
|
+
const DEFAULT_TOOL_COUNT = DEFAULT_TOOLSETS.reduce((sum, id) => sum + TOOLSET_TOOL_COUNTS[id], 0);
|
|
45
|
+
const ALL_TOOLSET_TOOL_COUNT = Object.values(TOOLSET_TOOL_COUNTS).reduce((sum, c) => sum + c, 0);
|
|
46
|
+
// Representative tools per toolset for spot-checking
|
|
47
|
+
const TOOLSET_SAMPLE_TOOLS = {
|
|
48
|
+
merge_requests: ["merge_merge_request", "create_merge_request_thread", "list_draft_notes"],
|
|
49
|
+
issues: ["create_issue", "list_issues", "create_note"],
|
|
50
|
+
repositories: ["search_repositories", "get_file_contents", "push_files"],
|
|
51
|
+
branches: ["create_branch", "list_commits"],
|
|
52
|
+
projects: ["get_project", "list_namespaces", "list_group_iterations"],
|
|
53
|
+
labels: ["list_labels", "create_label"],
|
|
54
|
+
pipelines: ["list_pipelines", "create_pipeline", "cancel_pipeline_job"],
|
|
55
|
+
milestones: ["list_milestones", "create_milestone", "get_milestone_burndown_events"],
|
|
56
|
+
wiki: ["list_wiki_pages", "create_wiki_page"],
|
|
57
|
+
releases: ["list_releases", "create_release", "download_release_asset"],
|
|
58
|
+
users: ["get_users", "upload_markdown", "download_attachment"],
|
|
59
|
+
};
|
|
60
|
+
// --- Helpers ---
|
|
61
|
+
async function launchMcpServer(mockGitLabUrl, mcpPort, extraEnv = {}) {
|
|
62
|
+
return launchServer({
|
|
63
|
+
mode: TransportMode.STREAMABLE_HTTP,
|
|
64
|
+
port: mcpPort,
|
|
65
|
+
timeout: 10000,
|
|
66
|
+
env: {
|
|
67
|
+
STREAMABLE_HTTP: "true",
|
|
68
|
+
REMOTE_AUTHORIZATION: "true",
|
|
69
|
+
GITLAB_API_URL: `${mockGitLabUrl}/api/v4`,
|
|
70
|
+
...extraEnv,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async function getToolNames(mcpUrl) {
|
|
75
|
+
const client = new CustomHeaderClient({
|
|
76
|
+
authorization: `Bearer ${MOCK_TOKEN}`,
|
|
77
|
+
});
|
|
78
|
+
await client.connect(mcpUrl);
|
|
79
|
+
const result = await client.listTools();
|
|
80
|
+
await client.disconnect();
|
|
81
|
+
return result.tools.map((t) => t.name);
|
|
82
|
+
}
|
|
83
|
+
function assertContainsAll(actual, expected, label) {
|
|
84
|
+
for (const name of expected) {
|
|
85
|
+
assert.ok(actual.includes(name), `${label}: expected tool "${name}" to be present`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function assertContainsNone(actual, excluded, label) {
|
|
89
|
+
for (const name of excluded) {
|
|
90
|
+
assert.ok(!actual.includes(name), `${label}: expected tool "${name}" to be absent`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// --- Tests ---
|
|
94
|
+
let mockGitLab;
|
|
95
|
+
let mockGitLabUrl;
|
|
96
|
+
let portCounter = 0;
|
|
97
|
+
async function nextMcpPort() {
|
|
98
|
+
return findAvailablePort(MCP_PORT_BASE + portCounter++ * 10);
|
|
99
|
+
}
|
|
100
|
+
describe("Toolset Filtering", () => {
|
|
101
|
+
before(async () => {
|
|
102
|
+
const mockPort = await findMockServerPort(MOCK_PORT_BASE);
|
|
103
|
+
mockGitLab = new MockGitLabServer({
|
|
104
|
+
port: mockPort,
|
|
105
|
+
validTokens: [MOCK_TOKEN],
|
|
106
|
+
});
|
|
107
|
+
await mockGitLab.start();
|
|
108
|
+
mockGitLabUrl = mockGitLab.getUrl();
|
|
109
|
+
console.log(`Mock GitLab: ${mockGitLabUrl}`);
|
|
110
|
+
});
|
|
111
|
+
after(async () => {
|
|
112
|
+
if (mockGitLab)
|
|
113
|
+
await mockGitLab.stop();
|
|
114
|
+
});
|
|
115
|
+
// ---- 1. Default behavior (no GITLAB_TOOLSETS / GITLAB_TOOLS) ----
|
|
116
|
+
describe("defaults (no GITLAB_TOOLSETS)", () => {
|
|
117
|
+
let server;
|
|
118
|
+
let tools;
|
|
119
|
+
before(async () => {
|
|
120
|
+
const port = await nextMcpPort();
|
|
121
|
+
server = await launchMcpServer(mockGitLabUrl, port);
|
|
122
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
123
|
+
});
|
|
124
|
+
after(() => cleanupServers([server]));
|
|
125
|
+
test("returns expected default tool count", () => {
|
|
126
|
+
assert.strictEqual(tools.length, DEFAULT_TOOL_COUNT);
|
|
127
|
+
});
|
|
128
|
+
test("includes tools from every default toolset", () => {
|
|
129
|
+
for (const id of DEFAULT_TOOLSETS) {
|
|
130
|
+
assertContainsAll(tools, TOOLSET_SAMPLE_TOOLS[id], id);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
test("includes all toolsets by default (no non-default toolsets)", () => {
|
|
134
|
+
// All toolsets are now default, so default count equals all toolset count
|
|
135
|
+
assert.strictEqual(tools.length, ALL_TOOLSET_TOOL_COUNT);
|
|
136
|
+
});
|
|
137
|
+
test("excludes execute_graphql (not in any toolset)", () => {
|
|
138
|
+
assertContainsNone(tools, ["execute_graphql"], "unassigned");
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
// ---- 2. Single toolset ----
|
|
142
|
+
describe("GITLAB_TOOLSETS=issues", () => {
|
|
143
|
+
let server;
|
|
144
|
+
let tools;
|
|
145
|
+
before(async () => {
|
|
146
|
+
const port = await nextMcpPort();
|
|
147
|
+
server = await launchMcpServer(mockGitLabUrl, port, {
|
|
148
|
+
GITLAB_TOOLSETS: "issues",
|
|
149
|
+
});
|
|
150
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
151
|
+
});
|
|
152
|
+
after(() => cleanupServers([server]));
|
|
153
|
+
test("returns only issue tools", () => {
|
|
154
|
+
assert.strictEqual(tools.length, TOOLSET_TOOL_COUNTS.issues);
|
|
155
|
+
});
|
|
156
|
+
test("includes issue sample tools", () => {
|
|
157
|
+
assertContainsAll(tools, TOOLSET_SAMPLE_TOOLS.issues, "issues");
|
|
158
|
+
});
|
|
159
|
+
test("excludes merge_requests tools", () => {
|
|
160
|
+
assertContainsNone(tools, TOOLSET_SAMPLE_TOOLS.merge_requests, "merge_requests");
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
// ---- 3. GITLAB_TOOLSETS=all ----
|
|
164
|
+
describe("GITLAB_TOOLSETS=all", () => {
|
|
165
|
+
let server;
|
|
166
|
+
let tools;
|
|
167
|
+
before(async () => {
|
|
168
|
+
const port = await nextMcpPort();
|
|
169
|
+
server = await launchMcpServer(mockGitLabUrl, port, {
|
|
170
|
+
GITLAB_TOOLSETS: "all",
|
|
171
|
+
});
|
|
172
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
173
|
+
});
|
|
174
|
+
after(() => cleanupServers([server]));
|
|
175
|
+
test("returns all toolset tools", () => {
|
|
176
|
+
assert.strictEqual(tools.length, ALL_TOOLSET_TOOL_COUNT);
|
|
177
|
+
});
|
|
178
|
+
test("includes pipelines, milestones, and wiki", () => {
|
|
179
|
+
for (const id of ["pipelines", "milestones", "wiki"]) {
|
|
180
|
+
assertContainsAll(tools, TOOLSET_SAMPLE_TOOLS[id], id);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
test("still excludes execute_graphql", () => {
|
|
184
|
+
assertContainsNone(tools, ["execute_graphql"], "unassigned");
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
// ---- 4. GITLAB_TOOLS (individual tools, additive) ----
|
|
188
|
+
describe("GITLAB_TOOLS=list_pipelines,execute_graphql", () => {
|
|
189
|
+
let server;
|
|
190
|
+
let tools;
|
|
191
|
+
before(async () => {
|
|
192
|
+
const port = await nextMcpPort();
|
|
193
|
+
server = await launchMcpServer(mockGitLabUrl, port, {
|
|
194
|
+
GITLAB_TOOLS: "list_pipelines,execute_graphql",
|
|
195
|
+
});
|
|
196
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
197
|
+
});
|
|
198
|
+
after(() => cleanupServers([server]));
|
|
199
|
+
test("returns default tools plus the two individual tools", () => {
|
|
200
|
+
assert.strictEqual(tools.length, DEFAULT_TOOL_COUNT + 2);
|
|
201
|
+
});
|
|
202
|
+
test("includes the individually added tools", () => {
|
|
203
|
+
assertContainsAll(tools, ["list_pipelines", "execute_graphql"], "individual");
|
|
204
|
+
});
|
|
205
|
+
test("does not include other pipeline tools", () => {
|
|
206
|
+
assertContainsNone(tools, ["create_pipeline", "cancel_pipeline"], "other pipelines");
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
// ---- 5. Toolset + individual tools combined ----
|
|
210
|
+
describe("GITLAB_TOOLSETS=issues + GITLAB_TOOLS=list_pipelines,get_pipeline", () => {
|
|
211
|
+
let server;
|
|
212
|
+
let tools;
|
|
213
|
+
before(async () => {
|
|
214
|
+
const port = await nextMcpPort();
|
|
215
|
+
server = await launchMcpServer(mockGitLabUrl, port, {
|
|
216
|
+
GITLAB_TOOLSETS: "issues",
|
|
217
|
+
GITLAB_TOOLS: "list_pipelines,get_pipeline",
|
|
218
|
+
});
|
|
219
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
220
|
+
});
|
|
221
|
+
after(() => cleanupServers([server]));
|
|
222
|
+
test("returns issue tools + 2 individual pipeline tools", () => {
|
|
223
|
+
assert.strictEqual(tools.length, TOOLSET_TOOL_COUNTS.issues + 2);
|
|
224
|
+
});
|
|
225
|
+
test("includes issue tools and the two pipeline tools", () => {
|
|
226
|
+
assertContainsAll(tools, TOOLSET_SAMPLE_TOOLS.issues, "issues");
|
|
227
|
+
assertContainsAll(tools, ["list_pipelines", "get_pipeline"], "individual");
|
|
228
|
+
});
|
|
229
|
+
test("excludes other pipeline tools", () => {
|
|
230
|
+
assertContainsNone(tools, ["create_pipeline", "cancel_pipeline"], "other pipelines");
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
// ---- 6. Legacy flag USE_PIPELINE as additive override ----
|
|
234
|
+
describe("GITLAB_TOOLSETS=issues + USE_PIPELINE=true", () => {
|
|
235
|
+
let server;
|
|
236
|
+
let tools;
|
|
237
|
+
before(async () => {
|
|
238
|
+
const port = await nextMcpPort();
|
|
239
|
+
server = await launchMcpServer(mockGitLabUrl, port, {
|
|
240
|
+
GITLAB_TOOLSETS: "issues",
|
|
241
|
+
USE_PIPELINE: "true",
|
|
242
|
+
});
|
|
243
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
244
|
+
});
|
|
245
|
+
after(() => cleanupServers([server]));
|
|
246
|
+
test("returns issue tools + all pipeline tools", () => {
|
|
247
|
+
assert.strictEqual(tools.length, TOOLSET_TOOL_COUNTS.issues + TOOLSET_TOOL_COUNTS.pipelines);
|
|
248
|
+
});
|
|
249
|
+
test("includes all pipeline tools via legacy flag", () => {
|
|
250
|
+
assertContainsAll(tools, TOOLSET_SAMPLE_TOOLS.pipelines, "pipelines");
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
// ---- 7. Legacy flag USE_GITLAB_WIKI ----
|
|
254
|
+
describe("USE_GITLAB_WIKI=true (no GITLAB_TOOLSETS)", () => {
|
|
255
|
+
let server;
|
|
256
|
+
let tools;
|
|
257
|
+
before(async () => {
|
|
258
|
+
const port = await nextMcpPort();
|
|
259
|
+
server = await launchMcpServer(mockGitLabUrl, port, {
|
|
260
|
+
USE_GITLAB_WIKI: "true",
|
|
261
|
+
});
|
|
262
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
263
|
+
});
|
|
264
|
+
after(() => cleanupServers([server]));
|
|
265
|
+
test("returns default tools + wiki tools", () => {
|
|
266
|
+
assert.strictEqual(tools.length, DEFAULT_TOOL_COUNT + TOOLSET_TOOL_COUNTS.wiki);
|
|
267
|
+
});
|
|
268
|
+
test("includes wiki tools", () => {
|
|
269
|
+
assertContainsAll(tools, TOOLSET_SAMPLE_TOOLS.wiki, "wiki");
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
// ---- 8. Read-only mode applied after toolset filter ----
|
|
273
|
+
describe("GITLAB_TOOLSETS=issues + GITLAB_READ_ONLY_MODE=true", () => {
|
|
274
|
+
let server;
|
|
275
|
+
let tools;
|
|
276
|
+
// Read-only issue tools (from readOnlyTools set in index.ts)
|
|
277
|
+
const readOnlyIssueTools = [
|
|
278
|
+
"list_issues",
|
|
279
|
+
"my_issues",
|
|
280
|
+
"get_issue",
|
|
281
|
+
"list_issue_links",
|
|
282
|
+
"list_issue_discussions",
|
|
283
|
+
"get_issue_link",
|
|
284
|
+
];
|
|
285
|
+
const writeIssueTools = [
|
|
286
|
+
"create_issue",
|
|
287
|
+
"update_issue",
|
|
288
|
+
"delete_issue",
|
|
289
|
+
"create_issue_note",
|
|
290
|
+
"update_issue_note",
|
|
291
|
+
"create_issue_link",
|
|
292
|
+
"delete_issue_link",
|
|
293
|
+
"create_note",
|
|
294
|
+
];
|
|
295
|
+
before(async () => {
|
|
296
|
+
const port = await nextMcpPort();
|
|
297
|
+
server = await launchMcpServer(mockGitLabUrl, port, {
|
|
298
|
+
GITLAB_TOOLSETS: "issues",
|
|
299
|
+
GITLAB_READ_ONLY_MODE: "true",
|
|
300
|
+
});
|
|
301
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
302
|
+
});
|
|
303
|
+
after(() => cleanupServers([server]));
|
|
304
|
+
test("includes only read-only issue tools", () => {
|
|
305
|
+
assertContainsAll(tools, readOnlyIssueTools, "read-only issues");
|
|
306
|
+
});
|
|
307
|
+
test("excludes write issue tools", () => {
|
|
308
|
+
assertContainsNone(tools, writeIssueTools, "write issues");
|
|
309
|
+
});
|
|
310
|
+
test("returns correct count", () => {
|
|
311
|
+
assert.strictEqual(tools.length, readOnlyIssueTools.length);
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
// ---- 9. GITLAB_DENIED_TOOLS_REGEX applied after toolset filter ----
|
|
315
|
+
describe("GITLAB_TOOLSETS=issues + GITLAB_DENIED_TOOLS_REGEX=^(create_|delete_)", () => {
|
|
316
|
+
let server;
|
|
317
|
+
let tools;
|
|
318
|
+
before(async () => {
|
|
319
|
+
const port = await nextMcpPort();
|
|
320
|
+
server = await launchMcpServer(mockGitLabUrl, port, {
|
|
321
|
+
GITLAB_TOOLSETS: "issues",
|
|
322
|
+
GITLAB_DENIED_TOOLS_REGEX: "^(create_|delete_)",
|
|
323
|
+
});
|
|
324
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
325
|
+
});
|
|
326
|
+
after(() => cleanupServers([server]));
|
|
327
|
+
test("excludes tools matching the denial regex", () => {
|
|
328
|
+
const denied = tools.filter((t) => t.startsWith("create_") || t.startsWith("delete_"));
|
|
329
|
+
assert.strictEqual(denied.length, 0, `Should have no create_/delete_ tools, found: ${denied}`);
|
|
330
|
+
});
|
|
331
|
+
test("keeps non-matching issue tools", () => {
|
|
332
|
+
assertContainsAll(tools, ["list_issues", "my_issues", "get_issue", "update_issue", "update_issue_note"], "non-denied issues");
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
// ---- 10. Full combination: toolset + individual + legacy + read-only ----
|
|
336
|
+
describe("GITLAB_TOOLSETS=issues + GITLAB_TOOLS=list_pipelines + USE_GITLAB_WIKI=true + GITLAB_READ_ONLY_MODE=true", () => {
|
|
337
|
+
let server;
|
|
338
|
+
let tools;
|
|
339
|
+
before(async () => {
|
|
340
|
+
const port = await nextMcpPort();
|
|
341
|
+
server = await launchMcpServer(mockGitLabUrl, port, {
|
|
342
|
+
GITLAB_TOOLSETS: "issues",
|
|
343
|
+
GITLAB_TOOLS: "list_pipelines",
|
|
344
|
+
USE_GITLAB_WIKI: "true",
|
|
345
|
+
GITLAB_READ_ONLY_MODE: "true",
|
|
346
|
+
});
|
|
347
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
348
|
+
});
|
|
349
|
+
after(() => cleanupServers([server]));
|
|
350
|
+
test("includes read-only issue tools", () => {
|
|
351
|
+
assertContainsAll(tools, ["list_issues", "get_issue"], "read-only issues");
|
|
352
|
+
});
|
|
353
|
+
test("includes list_pipelines (read-only individual tool)", () => {
|
|
354
|
+
assertContainsAll(tools, ["list_pipelines"], "individual pipeline");
|
|
355
|
+
});
|
|
356
|
+
test("includes read-only wiki tools from legacy flag", () => {
|
|
357
|
+
assertContainsAll(tools, ["list_wiki_pages", "get_wiki_page"], "read-only wiki");
|
|
358
|
+
});
|
|
359
|
+
test("excludes write tools across all sources", () => {
|
|
360
|
+
assertContainsNone(tools, ["create_issue", "create_pipeline", "create_wiki_page"], "write tools");
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
// ---- 11. Redundant legacy flag (toolset already includes it) ----
|
|
364
|
+
describe("GITLAB_TOOLSETS=pipelines + USE_PIPELINE=true (redundant)", () => {
|
|
365
|
+
let server;
|
|
366
|
+
let tools;
|
|
367
|
+
before(async () => {
|
|
368
|
+
const port = await nextMcpPort();
|
|
369
|
+
server = await launchMcpServer(mockGitLabUrl, port, {
|
|
370
|
+
GITLAB_TOOLSETS: "pipelines",
|
|
371
|
+
USE_PIPELINE: "true",
|
|
372
|
+
});
|
|
373
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
374
|
+
});
|
|
375
|
+
after(() => cleanupServers([server]));
|
|
376
|
+
test("returns exactly pipeline tool count (no duplicates)", () => {
|
|
377
|
+
assert.strictEqual(tools.length, TOOLSET_TOOL_COUNTS.pipelines);
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
// ---- 12. GITLAB_TOOLS with tool already in enabled toolset (no dupes) ----
|
|
381
|
+
describe("GITLAB_TOOLSETS=issues + GITLAB_TOOLS=list_issues (already included)", () => {
|
|
382
|
+
let server;
|
|
383
|
+
let tools;
|
|
384
|
+
before(async () => {
|
|
385
|
+
const port = await nextMcpPort();
|
|
386
|
+
server = await launchMcpServer(mockGitLabUrl, port, {
|
|
387
|
+
GITLAB_TOOLSETS: "issues",
|
|
388
|
+
GITLAB_TOOLS: "list_issues",
|
|
389
|
+
});
|
|
390
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
391
|
+
});
|
|
392
|
+
after(() => cleanupServers([server]));
|
|
393
|
+
test("returns exactly issue tool count (no duplicates)", () => {
|
|
394
|
+
assert.strictEqual(tools.length, TOOLSET_TOOL_COUNTS.issues);
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
// ---- 13. Invalid toolset ID is silently ignored ----
|
|
398
|
+
describe("GITLAB_TOOLSETS=issues,nonexistent_toolset", () => {
|
|
399
|
+
let server;
|
|
400
|
+
let tools;
|
|
401
|
+
before(async () => {
|
|
402
|
+
const port = await nextMcpPort();
|
|
403
|
+
server = await launchMcpServer(mockGitLabUrl, port, {
|
|
404
|
+
GITLAB_TOOLSETS: "issues,nonexistent_toolset",
|
|
405
|
+
});
|
|
406
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
407
|
+
});
|
|
408
|
+
after(() => cleanupServers([server]));
|
|
409
|
+
test("returns only issue tools (invalid toolset ignored)", () => {
|
|
410
|
+
assert.strictEqual(tools.length, TOOLSET_TOOL_COUNTS.issues);
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
// ---- 14. GITLAB_TOOLS case-insensitive matching ----
|
|
414
|
+
describe("GITLAB_TOOLS with mixed-case tool names", () => {
|
|
415
|
+
let server;
|
|
416
|
+
let tools;
|
|
417
|
+
before(async () => {
|
|
418
|
+
const port = await nextMcpPort();
|
|
419
|
+
server = await launchMcpServer(mockGitLabUrl, port, {
|
|
420
|
+
GITLAB_TOOLS: "List_Pipelines,Execute_GraphQL",
|
|
421
|
+
});
|
|
422
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
423
|
+
});
|
|
424
|
+
after(() => cleanupServers([server]));
|
|
425
|
+
test("resolves mixed-case tool names to lowercase equivalents", () => {
|
|
426
|
+
assertContainsAll(tools, ["list_pipelines", "execute_graphql"], "case-insensitive tools");
|
|
427
|
+
});
|
|
428
|
+
test("returns default tools plus the two individual tools", () => {
|
|
429
|
+
assert.strictEqual(tools.length, DEFAULT_TOOL_COUNT + 2);
|
|
430
|
+
});
|
|
431
|
+
});
|
|
432
|
+
// ---- 15. GITLAB_TOOLS with unknown tool names ----
|
|
433
|
+
describe("GITLAB_TOOLS with unknown tool names", () => {
|
|
434
|
+
let server;
|
|
435
|
+
let tools;
|
|
436
|
+
before(async () => {
|
|
437
|
+
const port = await nextMcpPort();
|
|
438
|
+
server = await launchMcpServer(mockGitLabUrl, port, {
|
|
439
|
+
GITLAB_TOOLS: "list_pipelines,nonexistent_tool_xyz",
|
|
440
|
+
});
|
|
441
|
+
tools = await getToolNames(`http://${HOST}:${port}/mcp`);
|
|
442
|
+
});
|
|
443
|
+
after(() => cleanupServers([server]));
|
|
444
|
+
test("server starts normally and returns tools without crashing", () => {
|
|
445
|
+
assert.ok(tools.length > 0, "Should return at least some tools");
|
|
446
|
+
});
|
|
447
|
+
test("includes the valid individual tool but ignores the unknown one", () => {
|
|
448
|
+
assertContainsAll(tools, ["list_pipelines"], "valid individual tool");
|
|
449
|
+
assertContainsNone(tools, ["nonexistent_tool_xyz"], "unknown tool");
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zereight/mcp-gitlab",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.32",
|
|
4
4
|
"description": "MCP server for using the GitLab API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "zereight",
|
|
@@ -29,9 +29,10 @@
|
|
|
29
29
|
"changelog": "auto-changelog -p",
|
|
30
30
|
"test": "npm run test:all",
|
|
31
31
|
"test:all": "npm run build && npm run test:mock && npm run test:live",
|
|
32
|
-
"test:mock": "npx tsx --test test/remote-auth-simple-test.ts && tsx test/oauth-tests.ts && tsx test/test-list-merge-requests.ts && tsx test/test-list-project-members.ts",
|
|
32
|
+
"test:mock": "npx tsx --test test/remote-auth-simple-test.ts && tsx test/oauth-tests.ts && tsx test/test-list-merge-requests.ts && tsx test/test-list-project-members.ts && tsx test/test-download-attachment.ts && tsx --test test/test-job-artifacts.ts && tsx --test test/test-deployment-tools.ts && tsx --test test/test-merge-request-approval-state-tools.ts",
|
|
33
33
|
"test:live": "node test/validate-api.js",
|
|
34
34
|
"test:remote-auth": "npm run build && npx tsx --test test/remote-auth-simple-test.ts",
|
|
35
|
+
"test:schema": "tsx test/schema-tests.ts",
|
|
35
36
|
"test:oauth": "tsx test/oauth-tests.ts",
|
|
36
37
|
"test:list-merge-requests": "npm run build && tsx test/test-list-merge-requests.ts",
|
|
37
38
|
"test:approvals": "npm run build && tsx test/test-merge-request-approvals.ts",
|