@zereight/mcp-gitlab 2.1.70 → 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.
- package/README.ko.md +3 -1
- package/README.md +6 -2
- package/README.pt-BR.md +1 -1
- package/README.zh-CN.md +3 -1
- package/build/config.js +12 -4
- package/build/deprecated-env.js +47 -0
- package/build/index.js +369 -184
- 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 +226 -57
- 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
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { after, before, describe, test } from "node:test";
|
|
3
|
-
import { Buffer } from "node:buffer";
|
|
4
|
-
import { CustomHeaderClient } from "./clients/custom-header-client.js";
|
|
5
|
-
import { cleanupServers, findAvailablePort, HOST, launchServer, TransportMode, } from "./utils/server-launcher.js";
|
|
6
|
-
import { findMockServerPort, MockGitLabServer } from "./utils/mock-gitlab-server.js";
|
|
7
|
-
const MOCK_TOKEN = "glpat-get-file-contents-test-token";
|
|
8
|
-
const TEST_PROJECT_ID = "123";
|
|
9
|
-
describe("get_file_contents", { timeout: 20_000 }, () => {
|
|
10
|
-
let mockGitLab;
|
|
11
|
-
let server;
|
|
12
|
-
let mcpUrl;
|
|
13
|
-
before(async () => {
|
|
14
|
-
const binaryContent = Buffer.from([
|
|
15
|
-
0x25, 0x50, 0x44, 0x46, 0x2d, 0x31, 0x2e, 0x37, 0x0a, 0xc7, 0xff, 0xd8, 0x00,
|
|
16
|
-
]).toString("base64");
|
|
17
|
-
const mockPort = await findMockServerPort();
|
|
18
|
-
mockGitLab = new MockGitLabServer({
|
|
19
|
-
port: mockPort,
|
|
20
|
-
validTokens: [MOCK_TOKEN],
|
|
21
|
-
});
|
|
22
|
-
mockGitLab.addMockHandler("get", `/projects/${TEST_PROJECT_ID}/repository/files/sample.pdf`, (_req, res) => {
|
|
23
|
-
res.json({
|
|
24
|
-
file_name: "sample.pdf",
|
|
25
|
-
file_path: "sample.pdf",
|
|
26
|
-
encoding: "base64",
|
|
27
|
-
content: binaryContent,
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
mockGitLab.addMockHandler("get", `/projects/${TEST_PROJECT_ID}/repository/files/README.md`, (_req, res) => {
|
|
31
|
-
res.json({
|
|
32
|
-
file_name: "README.md",
|
|
33
|
-
file_path: "README.md",
|
|
34
|
-
encoding: "base64",
|
|
35
|
-
content: Buffer.from("Hello, 世界\n", "utf8").toString("base64"),
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
mockGitLab.addMockHandler("get", `/projects/${TEST_PROJECT_ID}/repository/files/empty.txt`, (_req, res) => {
|
|
39
|
-
res.json({
|
|
40
|
-
file_name: "empty.txt",
|
|
41
|
-
file_path: "empty.txt",
|
|
42
|
-
encoding: "base64",
|
|
43
|
-
content: "",
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
await mockGitLab.start();
|
|
47
|
-
const port = await findAvailablePort(3480);
|
|
48
|
-
server = await launchServer({
|
|
49
|
-
mode: TransportMode.STREAMABLE_HTTP,
|
|
50
|
-
port,
|
|
51
|
-
timeout: 10_000,
|
|
52
|
-
env: {
|
|
53
|
-
STREAMABLE_HTTP: "true",
|
|
54
|
-
REMOTE_AUTHORIZATION: "true",
|
|
55
|
-
GITLAB_API_URL: `${mockGitLab.getUrl()}/api/v4`,
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
mcpUrl = `http://${HOST}:${port}/mcp`;
|
|
59
|
-
});
|
|
60
|
-
after(async () => {
|
|
61
|
-
cleanupServers([server]);
|
|
62
|
-
if (mockGitLab)
|
|
63
|
-
await mockGitLab.stop();
|
|
64
|
-
});
|
|
65
|
-
test("preserves non-UTF-8 file content as base64", async () => {
|
|
66
|
-
const expectedContent = Buffer.from([
|
|
67
|
-
0x25, 0x50, 0x44, 0x46, 0x2d, 0x31, 0x2e, 0x37, 0x0a, 0xc7, 0xff, 0xd8, 0x00,
|
|
68
|
-
]).toString("base64");
|
|
69
|
-
const client = new CustomHeaderClient({ Authorization: `Bearer ${MOCK_TOKEN}` });
|
|
70
|
-
await client.connect(mcpUrl);
|
|
71
|
-
try {
|
|
72
|
-
const result = await Promise.race([
|
|
73
|
-
client.callTool("get_file_contents", {
|
|
74
|
-
project_id: TEST_PROJECT_ID,
|
|
75
|
-
file_path: "sample.pdf",
|
|
76
|
-
ref: "main",
|
|
77
|
-
}),
|
|
78
|
-
new Promise((_, reject) => {
|
|
79
|
-
const timer = setTimeout(() => reject(new Error("get_file_contents timed out")), 5_000);
|
|
80
|
-
timer.unref();
|
|
81
|
-
}),
|
|
82
|
-
]);
|
|
83
|
-
const responseText = result.content?.[0]?.type === "text" ? result.content[0].text : "";
|
|
84
|
-
const file = JSON.parse(responseText);
|
|
85
|
-
assert.strictEqual(file.content, expectedContent);
|
|
86
|
-
assert.strictEqual(file.encoding, "base64");
|
|
87
|
-
}
|
|
88
|
-
finally {
|
|
89
|
-
await client.disconnect();
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
test("decodes valid UTF-8 file content", async () => {
|
|
93
|
-
const client = new CustomHeaderClient({ Authorization: `Bearer ${MOCK_TOKEN}` });
|
|
94
|
-
await client.connect(mcpUrl);
|
|
95
|
-
try {
|
|
96
|
-
const result = await client.callTool("get_file_contents", {
|
|
97
|
-
project_id: TEST_PROJECT_ID,
|
|
98
|
-
file_path: "README.md",
|
|
99
|
-
ref: "main",
|
|
100
|
-
});
|
|
101
|
-
const responseText = result.content?.[0]?.type === "text" ? result.content[0].text : "";
|
|
102
|
-
const file = JSON.parse(responseText);
|
|
103
|
-
assert.strictEqual(file.content, "Hello, 世界\n");
|
|
104
|
-
assert.strictEqual(file.encoding, "utf8");
|
|
105
|
-
}
|
|
106
|
-
finally {
|
|
107
|
-
await client.disconnect();
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
test("decodes empty file content as UTF-8", async () => {
|
|
111
|
-
const client = new CustomHeaderClient({ Authorization: `Bearer ${MOCK_TOKEN}` });
|
|
112
|
-
await client.connect(mcpUrl);
|
|
113
|
-
try {
|
|
114
|
-
const result = await client.callTool("get_file_contents", {
|
|
115
|
-
project_id: TEST_PROJECT_ID,
|
|
116
|
-
file_path: "empty.txt",
|
|
117
|
-
ref: "main",
|
|
118
|
-
});
|
|
119
|
-
const responseText = result.content?.[0]?.type === "text" ? result.content[0].text : "";
|
|
120
|
-
const file = JSON.parse(responseText);
|
|
121
|
-
assert.strictEqual(file.content, "");
|
|
122
|
-
assert.strictEqual(file.encoding, "utf8");
|
|
123
|
-
}
|
|
124
|
-
finally {
|
|
125
|
-
await client.disconnect();
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
});
|