@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.
- package/README.ko.md +9 -5
- package/README.md +15 -11
- package/README.pt-BR.md +9 -5
- package/README.zh-CN.md +9 -5
- package/build/config.js +12 -4
- package/build/deprecated-env.js +63 -0
- package/build/index.js +430 -200
- package/build/oauth-device-flow.js +80 -0
- package/build/oauth.js +135 -18
- package/build/schemas.js +1 -1
- package/build/server/remote-http-stack.js +39 -0
- package/build/tools/discover-activation.js +38 -0
- package/build/tools/exposed-tools.js +35 -0
- package/build/tools/listed-tools.js +76 -0
- package/build/tools/registry.js +232 -63
- package/build/tools/tool-descriptions.js +3 -3
- package/build/tools/tool-profile.js +66 -0
- package/build/utils/compact-tool-allowlist.js +14 -0
- package/build/utils/logger.js +34 -12
- package/package.json +3 -3
- package/build/scripts/check-skill-sync.js +0 -143
- package/build/scripts/generate-server-card.js +0 -39
- package/build/scripts/generate-tool-coverage.js +0 -58
- package/build/scripts/generate-tool-docs.js +0 -430
- package/build/scripts/tool-coverage/coverage.js +0 -341
- package/build/scripts/tool-coverage/coverage.test.js +0 -142
- package/build/test/callback-proxy-tests.js +0 -321
- package/build/test/cli/args.test.js +0 -175
- package/build/test/cli/boolean-flags.test.js +0 -106
- package/build/test/cli/compact-mcp-result.test.js +0 -93
- package/build/test/cli/credentials.test.js +0 -153
- package/build/test/cli/exposure.test.js +0 -104
- package/build/test/cli/load-config-snapshot.js +0 -5
- package/build/test/cli/output.test.js +0 -74
- package/build/test/cli/replay-command.test.js +0 -37
- package/build/test/cli/router.test.js +0 -183
- package/build/test/client-pool-test.js +0 -109
- package/build/test/clients/client.js +0 -34
- package/build/test/clients/custom-header-client.js +0 -122
- package/build/test/clients/sse-client.js +0 -95
- package/build/test/clients/stdio-client.js +0 -113
- package/build/test/clients/streamable-http-client.js +0 -95
- package/build/test/config-allowed-groups.test.js +0 -97
- package/build/test/create-commit-actions.test.js +0 -102
- package/build/test/draft-note-schema.test.js +0 -44
- package/build/test/dynamic-api-url-allowlist.test.js +0 -121
- package/build/test/dynamic-api-url-test.js +0 -304
- package/build/test/dynamic-routing-tests.js +0 -495
- package/build/test/get-merge-request-discussion-schema.test.js +0 -30
- package/build/test/gitlab-api-tool-errors.test.js +0 -112
- package/build/test/gitlab-artifact-entry-schema.test.js +0 -44
- package/build/test/gitlab-diff-schema.test.js +0 -36
- package/build/test/gitlab-pipeline-schedule-schema.test.js +0 -32
- package/build/test/gitlab-tag-schema.test.js +0 -51
- package/build/test/group-milestone-schema.test.js +0 -45
- package/build/test/mcp-oauth-tests.js +0 -905
- package/build/test/mcp-server-name.test.js +0 -87
- package/build/test/merge-merge-request-schema.test.js +0 -75
- package/build/test/multi-server-test.js +0 -190
- package/build/test/no-proxy-integration-test.js +0 -183
- package/build/test/no-proxy-test.js +0 -149
- package/build/test/nullable-gitlab-response-fields.test.js +0 -37
- package/build/test/nullish-tool-arguments-schema.test.js +0 -118
- package/build/test/oauth-device-flow-tests.js +0 -450
- package/build/test/oauth-download-url.test.js +0 -157
- package/build/test/oauth-startup.test.js +0 -204
- package/build/test/oauth-tests.js +0 -428
- package/build/test/path-segment-encoding.test.js +0 -98
- package/build/test/remote-auth-simple-test.js +0 -277
- package/build/test/remote-auth-tests.js +0 -314
- package/build/test/response-masking.test.js +0 -445
- package/build/test/schema-tests.js +0 -1679
- package/build/test/server/metrics.test.js +0 -47
- package/build/test/server/request-helpers.test.js +0 -48
- package/build/test/server/version.test.js +0 -13
- package/build/test/sse-auth-guard.test.js +0 -96
- package/build/test/sse-session-limits.test.js +0 -273
- package/build/test/stateless/callback-proxy.test.js +0 -510
- package/build/test/stateless/client-id.test.js +0 -177
- package/build/test/stateless/codec.test.js +0 -328
- package/build/test/stateless/config-ttl.test.js +0 -149
- package/build/test/stateless/consumed-proxy-code-cache.test.js +0 -150
- package/build/test/stateless/session-id-integration.test.js +0 -675
- package/build/test/stateless/session-id.test.js +0 -157
- package/build/test/streamable-http-concurrent-session.test.js +0 -171
- package/build/test/streamable-http-dns-rebinding.test.js +0 -185
- package/build/test/streamable-http-sse-stream.test.js +0 -350
- package/build/test/streamable-http-static-token-auth.test.js +0 -157
- package/build/test/streamable-http-unauthenticated-discovery.test.js +0 -207
- package/build/test/test-all-transport-server.js +0 -255
- package/build/test/test-auth-retry.js +0 -195
- package/build/test/test-blank-filters.js +0 -156
- package/build/test/test-ci-catalog.js +0 -177
- package/build/test/test-ci-lint.js +0 -191
- package/build/test/test-ci-variables.js +0 -309
- package/build/test/test-create-repository.js +0 -120
- package/build/test/test-dependency-proxy.js +0 -195
- package/build/test/test-deployment-tools.js +0 -463
- package/build/test/test-download-attachment.js +0 -190
- package/build/test/test-dynamic-project-scope.js +0 -524
- package/build/test/test-empty-toolsets.js +0 -535
- package/build/test/test-get-file-blame.js +0 -145
- package/build/test/test-get-file-contents.js +0 -128
- package/build/test/test-geteffectiveprojectid.js +0 -804
- package/build/test/test-health-check.js +0 -115
- package/build/test/test-issue-description-patch.js +0 -256
- package/build/test/test-job-artifacts.js +0 -275
- package/build/test/test-json-schema.js +0 -166
- package/build/test/test-list-group-members.js +0 -150
- package/build/test/test-list-group-merge-requests.js +0 -165
- package/build/test/test-list-issues.js +0 -170
- package/build/test/test-list-merge-requests.js +0 -201
- package/build/test/test-list-milestones.js +0 -145
- package/build/test/test-list-project-members.js +0 -132
- package/build/test/test-merge-request-approval-state-tools.js +0 -213
- package/build/test/test-merge-request-approvals.js +0 -187
- package/build/test/test-merge-request-pipelines.js +0 -106
- package/build/test/test-mr-diffs-filter.js +0 -132
- package/build/test/test-mr-file-diffs.js +0 -251
- package/build/test/test-oauth-proxy-rate-limit.js +0 -133
- package/build/test/test-orbit.js +0 -155
- package/build/test/test-permission-mode.js +0 -424
- package/build/test/test-pipeline-schedules.js +0 -484
- package/build/test/test-protected-branches.js +0 -174
- package/build/test/test-remote-downloads.js +0 -510
- package/build/test/test-search-code.js +0 -275
- package/build/test/test-snippets.js +0 -735
- package/build/test/test-tags.js +0 -220
- package/build/test/test-todos.js +0 -195
- package/build/test/test-token-optimizations.js +0 -691
- package/build/test/test-toolset-filtering.js +0 -499
- package/build/test/test-update-issue-slim.js +0 -141
- package/build/test/test-update-project.js +0 -112
- package/build/test/test-upload-markdown.js +0 -206
- package/build/test/test-vulnerabilities.js +0 -399
- package/build/test/test-webhooks.js +0 -218
- package/build/test/tool-description-quality.test.js +0 -50
- package/build/test/utils/bulk-publish-options.test.js +0 -32
- package/build/test/utils/download-token.test.js +0 -35
- package/build/test/utils/forwarded-public-base-url.test.js +0 -46
- package/build/test/utils/gitlab-instance-version.test.js +0 -32
- package/build/test/utils/gitlab-version-gate.test.js +0 -74
- package/build/test/utils/graphql-query.test.js +0 -168
- package/build/test/utils/helpers-path.test.js +0 -104
- package/build/test/utils/jmespath-tool-result.test.js +0 -91
- package/build/test/utils/masking.test.js +0 -384
- package/build/test/utils/merge-request-position.test.js +0 -57
- package/build/test/utils/mock-gitlab-server.js +0 -614
- package/build/test/utils/proxy-client-ip.test.js +0 -28
- package/build/test/utils/redact-sensitive.test.js +0 -32
- package/build/test/utils/safe-redirect-fetch.test.js +0 -463
- package/build/test/utils/server-launcher.js +0 -231
- package/build/test/utils/tool-args.test.js +0 -210
- package/build/test/utils/url.test.js +0 -141
- package/build/test/utils/version-check.test.js +0 -239
- package/build/test/utils/wiki-title.test.js +0 -21
- package/build/test-note.js +0 -54
- package/build/test-resolve-issue-note.js +0 -127
package/build/test/test-tags.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { after, before, describe, test } 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-tags";
|
|
6
|
-
const TEST_PROJECT_ID = "123";
|
|
7
|
-
const TEST_TAG_NAME = "v1.0.0";
|
|
8
|
-
function buildTag(overrides = {}) {
|
|
9
|
-
return {
|
|
10
|
-
name: TEST_TAG_NAME,
|
|
11
|
-
message: "Annotated release tag",
|
|
12
|
-
target: "abc123def4567890",
|
|
13
|
-
commit: {
|
|
14
|
-
id: "abc123def4567890",
|
|
15
|
-
short_id: "abc123de",
|
|
16
|
-
title: "Release v1.0.0",
|
|
17
|
-
created_at: "2026-03-13T10:00:00.000Z",
|
|
18
|
-
parent_ids: ["1111111111111111"],
|
|
19
|
-
message: "Release v1.0.0",
|
|
20
|
-
author_name: "Test User",
|
|
21
|
-
author_email: "test@example.com",
|
|
22
|
-
authored_date: "2026-03-13T09:55:00.000Z",
|
|
23
|
-
committer_name: "Test User",
|
|
24
|
-
committer_email: "test@example.com",
|
|
25
|
-
committed_date: "2026-03-13T10:00:00.000Z",
|
|
26
|
-
},
|
|
27
|
-
release: {
|
|
28
|
-
tag_name: TEST_TAG_NAME,
|
|
29
|
-
description: "Release notes",
|
|
30
|
-
},
|
|
31
|
-
protected: false,
|
|
32
|
-
created_at: "2026-03-13T10:00:00.000Z",
|
|
33
|
-
...overrides,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
async function callTool(toolName, args, env) {
|
|
37
|
-
return new Promise((resolve, reject) => {
|
|
38
|
-
const proc = spawn("node", ["build/index.js"], {
|
|
39
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
40
|
-
env: {
|
|
41
|
-
...process.env,
|
|
42
|
-
...env,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
let output = "";
|
|
46
|
-
let errorOutput = "";
|
|
47
|
-
proc.stdout?.on("data", (d) => (output += d));
|
|
48
|
-
proc.stderr?.on("data", (d) => (errorOutput += d));
|
|
49
|
-
proc.on("close", code => {
|
|
50
|
-
if (code !== 0) {
|
|
51
|
-
return reject(new Error(`Process exited with code ${code}: ${errorOutput}`));
|
|
52
|
-
}
|
|
53
|
-
const line = output.split("\n").find(l => l.startsWith("{"));
|
|
54
|
-
if (!line) {
|
|
55
|
-
return reject(new Error("No JSON output found"));
|
|
56
|
-
}
|
|
57
|
-
try {
|
|
58
|
-
const response = JSON.parse(line);
|
|
59
|
-
if (response.error) {
|
|
60
|
-
reject(response.error);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const content = response.result?.content?.[0]?.text;
|
|
64
|
-
if (!content) {
|
|
65
|
-
resolve(response.result);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
resolve(JSON.parse(content));
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
resolve(content);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
reject(error);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
proc.stdin?.end(JSON.stringify({
|
|
80
|
-
jsonrpc: "2.0",
|
|
81
|
-
id: 1,
|
|
82
|
-
method: "tools/call",
|
|
83
|
-
params: { name: toolName, arguments: args },
|
|
84
|
-
}) + "\n");
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
describe("tag tools", () => {
|
|
88
|
-
let mockGitLab;
|
|
89
|
-
let mockGitLabUrl;
|
|
90
|
-
before(async () => {
|
|
91
|
-
const mockPort = await findMockServerPort();
|
|
92
|
-
mockGitLab = new MockGitLabServer({
|
|
93
|
-
port: mockPort,
|
|
94
|
-
validTokens: [MOCK_TOKEN],
|
|
95
|
-
});
|
|
96
|
-
mockGitLab.addMockHandler("get", `/projects/${TEST_PROJECT_ID}/repository/tags`, (req, res) => {
|
|
97
|
-
assert.strictEqual(req.query.search, "^v");
|
|
98
|
-
assert.strictEqual(req.query.order_by, "version");
|
|
99
|
-
assert.strictEqual(req.query.sort, "desc");
|
|
100
|
-
assert.strictEqual(req.query.page, "2");
|
|
101
|
-
assert.strictEqual(req.query.per_page, "10");
|
|
102
|
-
res.json([buildTag()]);
|
|
103
|
-
});
|
|
104
|
-
mockGitLab.addMockHandler("get", `/projects/${TEST_PROJECT_ID}/repository/tags/${encodeURIComponent(TEST_TAG_NAME)}`, (_req, res) => {
|
|
105
|
-
res.json(buildTag());
|
|
106
|
-
});
|
|
107
|
-
mockGitLab.addMockHandler("post", `/projects/${TEST_PROJECT_ID}/repository/tags`, (req, res) => {
|
|
108
|
-
if (req.body.tag_name === "v-no-release") {
|
|
109
|
-
const tag = buildTag({ name: "v-no-release", message: null });
|
|
110
|
-
res.json(Object.fromEntries(Object.entries(tag).filter(([key]) => key !== "release")));
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
assert.deepStrictEqual(req.body, {
|
|
114
|
-
tag_name: TEST_TAG_NAME,
|
|
115
|
-
ref: "main",
|
|
116
|
-
message: "Release tag",
|
|
117
|
-
});
|
|
118
|
-
res.json(buildTag({ created_at: null }));
|
|
119
|
-
});
|
|
120
|
-
mockGitLab.addMockHandler("delete", `/projects/${TEST_PROJECT_ID}/repository/tags/${encodeURIComponent(TEST_TAG_NAME)}`, (_req, res) => {
|
|
121
|
-
res.status(204).send();
|
|
122
|
-
});
|
|
123
|
-
mockGitLab.addMockHandler("get", `/projects/${TEST_PROJECT_ID}/repository/tags/${encodeURIComponent(TEST_TAG_NAME)}/signature`, (_req, res) => {
|
|
124
|
-
res.json({
|
|
125
|
-
signature_type: "X509",
|
|
126
|
-
verification_status: "unverified",
|
|
127
|
-
x509_certificate: {
|
|
128
|
-
id: 1,
|
|
129
|
-
subject: "CN=Test User,O=Example",
|
|
130
|
-
subject_key_identifier: "A1725E379E7B25B2",
|
|
131
|
-
email: null,
|
|
132
|
-
serial_number: 123456789,
|
|
133
|
-
certificate_status: "good",
|
|
134
|
-
x509_issuer: {
|
|
135
|
-
id: 1,
|
|
136
|
-
subject: "CN=Example CA,O=Example",
|
|
137
|
-
subject_key_identifier: "C6411E6F5B9E2CFD",
|
|
138
|
-
crl_url: null,
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
await mockGitLab.start();
|
|
144
|
-
mockGitLabUrl = mockGitLab.getUrl();
|
|
145
|
-
});
|
|
146
|
-
after(async () => {
|
|
147
|
-
await mockGitLab.stop();
|
|
148
|
-
});
|
|
149
|
-
const env = () => ({
|
|
150
|
-
GITLAB_API_URL: `${mockGitLabUrl}/api/v4`,
|
|
151
|
-
GITLAB_PERSONAL_ACCESS_TOKEN: MOCK_TOKEN,
|
|
152
|
-
GITLAB_TOOLSETS: "tags",
|
|
153
|
-
});
|
|
154
|
-
test("list_tags returns parsed tags with query filters", async () => {
|
|
155
|
-
const result = await callTool("list_tags", {
|
|
156
|
-
project_id: TEST_PROJECT_ID,
|
|
157
|
-
search: "^v",
|
|
158
|
-
order_by: "version",
|
|
159
|
-
sort: "desc",
|
|
160
|
-
page: 2,
|
|
161
|
-
per_page: 10,
|
|
162
|
-
}, env());
|
|
163
|
-
assert.ok(Array.isArray(result));
|
|
164
|
-
assert.strictEqual(result.length, 1);
|
|
165
|
-
assert.strictEqual(result[0].name, TEST_TAG_NAME);
|
|
166
|
-
});
|
|
167
|
-
test("get_tag returns a single tag", async () => {
|
|
168
|
-
const result = await callTool("get_tag", { project_id: TEST_PROJECT_ID, tag_name: TEST_TAG_NAME }, env());
|
|
169
|
-
assert.strictEqual(result.name, TEST_TAG_NAME);
|
|
170
|
-
assert.strictEqual(result.commit.short_id, "abc123de");
|
|
171
|
-
});
|
|
172
|
-
test("create_tag posts the expected payload", async () => {
|
|
173
|
-
const result = await callTool("create_tag", {
|
|
174
|
-
project_id: TEST_PROJECT_ID,
|
|
175
|
-
tag_name: TEST_TAG_NAME,
|
|
176
|
-
ref: "main",
|
|
177
|
-
message: "Release tag",
|
|
178
|
-
}, env());
|
|
179
|
-
assert.strictEqual(result.name, TEST_TAG_NAME);
|
|
180
|
-
assert.strictEqual(result.release.description, "Release notes");
|
|
181
|
-
assert.strictEqual(result.created_at, null);
|
|
182
|
-
});
|
|
183
|
-
test("create_tag succeeds when GitLab omits the release field", async () => {
|
|
184
|
-
const result = await callTool("create_tag", {
|
|
185
|
-
project_id: TEST_PROJECT_ID,
|
|
186
|
-
tag_name: "v-no-release",
|
|
187
|
-
ref: "main",
|
|
188
|
-
}, env());
|
|
189
|
-
assert.strictEqual(result.name, "v-no-release");
|
|
190
|
-
assert.strictEqual(result.release, undefined);
|
|
191
|
-
});
|
|
192
|
-
test("delete_tag returns a success payload", async () => {
|
|
193
|
-
const result = await callTool("delete_tag", { project_id: TEST_PROJECT_ID, tag_name: TEST_TAG_NAME }, env());
|
|
194
|
-
assert.deepStrictEqual(result, {
|
|
195
|
-
status: "success",
|
|
196
|
-
message: `Tag '${TEST_TAG_NAME}' deleted successfully`,
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
test("get_tag_signature returns signature data", async () => {
|
|
200
|
-
const result = await callTool("get_tag_signature", { project_id: TEST_PROJECT_ID, tag_name: TEST_TAG_NAME }, env());
|
|
201
|
-
assert.deepStrictEqual(result, {
|
|
202
|
-
signature_type: "X509",
|
|
203
|
-
verification_status: "unverified",
|
|
204
|
-
x509_certificate: {
|
|
205
|
-
id: 1,
|
|
206
|
-
subject: "CN=Test User,O=Example",
|
|
207
|
-
subject_key_identifier: "A1725E379E7B25B2",
|
|
208
|
-
email: null,
|
|
209
|
-
serial_number: 123456789,
|
|
210
|
-
certificate_status: "good",
|
|
211
|
-
x509_issuer: {
|
|
212
|
-
id: 1,
|
|
213
|
-
subject: "CN=Example CA,O=Example",
|
|
214
|
-
subject_key_identifier: "C6411E6F5B9E2CFD",
|
|
215
|
-
crl_url: null,
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
});
|
package/build/test/test-todos.js
DELETED
|
@@ -1,195 +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-todos-test-token";
|
|
6
|
-
async function callTool(toolName, args, env) {
|
|
7
|
-
return new Promise((resolve, reject) => {
|
|
8
|
-
const proc = spawn("node", ["build/index.js"], {
|
|
9
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
10
|
-
env: {
|
|
11
|
-
...process.env,
|
|
12
|
-
...env,
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
let output = "";
|
|
16
|
-
let errorOutput = "";
|
|
17
|
-
proc.stdout?.on("data", (d) => (output += d));
|
|
18
|
-
proc.stderr?.on("data", (d) => (errorOutput += d));
|
|
19
|
-
proc.on("close", code => {
|
|
20
|
-
if (code !== 0) {
|
|
21
|
-
return reject(new Error(`Process exited with code ${code}: ${errorOutput}`));
|
|
22
|
-
}
|
|
23
|
-
const line = output.split("\n").find(l => l.startsWith("{"));
|
|
24
|
-
if (!line)
|
|
25
|
-
return reject(new Error("No JSON output found"));
|
|
26
|
-
try {
|
|
27
|
-
const response = JSON.parse(line);
|
|
28
|
-
if (response.error) {
|
|
29
|
-
reject(response.error);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
const content = response.result?.content?.[0]?.text;
|
|
33
|
-
resolve(content ? JSON.parse(content) : response.result);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
reject(e);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
proc.stdin?.end(JSON.stringify({
|
|
41
|
-
jsonrpc: "2.0",
|
|
42
|
-
id: 1,
|
|
43
|
-
method: "tools/call",
|
|
44
|
-
params: args === undefined ? { name: toolName } : { name: toolName, arguments: args },
|
|
45
|
-
}) + "\n");
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
async function listToolNames(env) {
|
|
49
|
-
return new Promise((resolve, reject) => {
|
|
50
|
-
const proc = spawn("node", ["build/index.js"], {
|
|
51
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
52
|
-
env: {
|
|
53
|
-
...process.env,
|
|
54
|
-
...env,
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
let output = "";
|
|
58
|
-
let errorOutput = "";
|
|
59
|
-
proc.stdout?.on("data", (d) => (output += d));
|
|
60
|
-
proc.stderr?.on("data", (d) => (errorOutput += d));
|
|
61
|
-
proc.on("close", code => {
|
|
62
|
-
if (code !== 0) {
|
|
63
|
-
return reject(new Error(`Process exited with code ${code}: ${errorOutput}`));
|
|
64
|
-
}
|
|
65
|
-
const line = output.split("\n").find(l => l.startsWith("{"));
|
|
66
|
-
if (!line)
|
|
67
|
-
return reject(new Error("No JSON output found"));
|
|
68
|
-
try {
|
|
69
|
-
const response = JSON.parse(line);
|
|
70
|
-
if (response.error) {
|
|
71
|
-
reject(response.error);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
resolve(response.result.tools.map((tool) => tool.name));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch (e) {
|
|
78
|
-
reject(e);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
proc.stdin?.end(JSON.stringify({
|
|
82
|
-
jsonrpc: "2.0",
|
|
83
|
-
id: 1,
|
|
84
|
-
method: "tools/list",
|
|
85
|
-
params: {},
|
|
86
|
-
}) + "\n");
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
function todoFixture(id, state = "pending") {
|
|
90
|
-
return {
|
|
91
|
-
id,
|
|
92
|
-
project: { id: 123, path_with_namespace: "group/project" },
|
|
93
|
-
author: { id: 1, username: "root" },
|
|
94
|
-
action_name: "marked",
|
|
95
|
-
target_type: "MergeRequest",
|
|
96
|
-
target: { id: 34, iid: 7, project_id: 123, title: "Review this MR" },
|
|
97
|
-
target_url: "https://gitlab.example.com/group/project/-/merge_requests/7",
|
|
98
|
-
body: "Review this MR",
|
|
99
|
-
state,
|
|
100
|
-
created_at: "2026-01-01T00:00:00.000Z",
|
|
101
|
-
updated_at: "2026-01-01T00:00:00.000Z",
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
describe("GitLab todos tools", () => {
|
|
105
|
-
let mockGitLab;
|
|
106
|
-
let mockGitLabUrl;
|
|
107
|
-
before(async () => {
|
|
108
|
-
const mockPort = await findMockServerPort();
|
|
109
|
-
mockGitLab = new MockGitLabServer({
|
|
110
|
-
port: mockPort,
|
|
111
|
-
validTokens: [MOCK_TOKEN],
|
|
112
|
-
});
|
|
113
|
-
mockGitLab.addMockHandler("get", "/todos", (req, res) => {
|
|
114
|
-
assert.strictEqual(req.query.state, "pending");
|
|
115
|
-
assert.strictEqual(req.query.action, "assigned");
|
|
116
|
-
assert.strictEqual(req.query.project_id, "123");
|
|
117
|
-
assert.strictEqual(req.query.page, "2");
|
|
118
|
-
assert.strictEqual(req.query.per_page, "5");
|
|
119
|
-
res.json([todoFixture(102)]);
|
|
120
|
-
});
|
|
121
|
-
mockGitLab.addMockHandler("post", "/todos/102/mark_as_done", (req, res) => {
|
|
122
|
-
res.json(todoFixture(102, "done"));
|
|
123
|
-
});
|
|
124
|
-
mockGitLab.addMockHandler("post", "/todos/mark_as_done", (req, res) => {
|
|
125
|
-
res.status(204).send();
|
|
126
|
-
});
|
|
127
|
-
await mockGitLab.start();
|
|
128
|
-
mockGitLabUrl = mockGitLab.getUrl();
|
|
129
|
-
});
|
|
130
|
-
after(async () => {
|
|
131
|
-
await mockGitLab.stop();
|
|
132
|
-
});
|
|
133
|
-
test("list_todos sends filters and returns todos", async () => {
|
|
134
|
-
const result = await callTool("list_todos", {
|
|
135
|
-
state: "pending",
|
|
136
|
-
action: "assigned",
|
|
137
|
-
project_id: 123,
|
|
138
|
-
page: 2,
|
|
139
|
-
per_page: 5,
|
|
140
|
-
}, {
|
|
141
|
-
GITLAB_API_URL: `${mockGitLabUrl}/api/v4`,
|
|
142
|
-
GITLAB_PERSONAL_ACCESS_TOKEN: MOCK_TOKEN,
|
|
143
|
-
});
|
|
144
|
-
assert.ok(Array.isArray(result));
|
|
145
|
-
assert.strictEqual(result[0].id, 102);
|
|
146
|
-
assert.strictEqual(result[0].state, "pending");
|
|
147
|
-
});
|
|
148
|
-
test("mark_todo_done marks one todo done", async () => {
|
|
149
|
-
const result = await callTool("mark_todo_done", { id: 102 }, {
|
|
150
|
-
GITLAB_API_URL: `${mockGitLabUrl}/api/v4`,
|
|
151
|
-
GITLAB_PERSONAL_ACCESS_TOKEN: MOCK_TOKEN,
|
|
152
|
-
});
|
|
153
|
-
assert.strictEqual(result.id, 102);
|
|
154
|
-
assert.strictEqual(result.state, "done");
|
|
155
|
-
});
|
|
156
|
-
test("mark_all_todos_done reports success", async () => {
|
|
157
|
-
const result = await callTool("mark_all_todos_done", {}, {
|
|
158
|
-
GITLAB_API_URL: `${mockGitLabUrl}/api/v4`,
|
|
159
|
-
GITLAB_PERSONAL_ACCESS_TOKEN: MOCK_TOKEN,
|
|
160
|
-
});
|
|
161
|
-
assert.deepStrictEqual(result, {
|
|
162
|
-
status: "success",
|
|
163
|
-
message: "All pending to-do items marked as done",
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
test("mark_all_todos_done accepts omitted arguments", async () => {
|
|
167
|
-
const result = await callTool("mark_all_todos_done", undefined, {
|
|
168
|
-
GITLAB_API_URL: `${mockGitLabUrl}/api/v4`,
|
|
169
|
-
GITLAB_PERSONAL_ACCESS_TOKEN: MOCK_TOKEN,
|
|
170
|
-
});
|
|
171
|
-
assert.deepStrictEqual(result, {
|
|
172
|
-
status: "success",
|
|
173
|
-
message: "All pending to-do items marked as done",
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
test("todo tools are visible in the default issues toolset", async () => {
|
|
177
|
-
const tools = await listToolNames({
|
|
178
|
-
GITLAB_API_URL: `${mockGitLabUrl}/api/v4`,
|
|
179
|
-
GITLAB_PERSONAL_ACCESS_TOKEN: MOCK_TOKEN,
|
|
180
|
-
});
|
|
181
|
-
assert.ok(tools.includes("list_todos"));
|
|
182
|
-
assert.ok(tools.includes("mark_todo_done"));
|
|
183
|
-
assert.ok(tools.includes("mark_all_todos_done"));
|
|
184
|
-
});
|
|
185
|
-
test("read-only mode keeps list_todos and hides todo mutations", async () => {
|
|
186
|
-
const tools = await listToolNames({
|
|
187
|
-
GITLAB_API_URL: `${mockGitLabUrl}/api/v4`,
|
|
188
|
-
GITLAB_PERSONAL_ACCESS_TOKEN: MOCK_TOKEN,
|
|
189
|
-
GITLAB_READ_ONLY_MODE: "true",
|
|
190
|
-
});
|
|
191
|
-
assert.ok(tools.includes("list_todos"));
|
|
192
|
-
assert.ok(!tools.includes("mark_todo_done"));
|
|
193
|
-
assert.ok(!tools.includes("mark_all_todos_done"));
|
|
194
|
-
});
|
|
195
|
-
});
|