@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.
- package/README.ko.md +10 -4
- package/README.md +238 -233
- package/README.pt-BR.md +4 -4
- package/README.zh-CN.md +6 -4
- package/build/config.js +12 -4
- package/build/deprecated-env.js +47 -0
- package/build/index.js +456 -237
- 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/build/utils/url.js +15 -0
- 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/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-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-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 -812
- 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 -482
- 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 -128
- 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,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom Header MCP Client for Testing Remote Authorization
|
|
3
|
-
* Extends StreamableHTTPTestClient to support custom headers
|
|
4
|
-
*/
|
|
5
|
-
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
6
|
-
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
7
|
-
/**
|
|
8
|
-
* MCP client with support for custom HTTP headers
|
|
9
|
-
* Useful for testing remote authorization scenarios
|
|
10
|
-
*/
|
|
11
|
-
export class CustomHeaderClient {
|
|
12
|
-
client;
|
|
13
|
-
transport = null;
|
|
14
|
-
customHeaders;
|
|
15
|
-
timeout;
|
|
16
|
-
constructor(options = {}) {
|
|
17
|
-
// Support both old signature (headers only) and new options object
|
|
18
|
-
if ('headers' in options || 'timeout' in options || 'clientName' in options) {
|
|
19
|
-
const opts = options;
|
|
20
|
-
this.customHeaders = opts.headers || {};
|
|
21
|
-
this.timeout = opts.timeout || 30000;
|
|
22
|
-
this.client = new Client({
|
|
23
|
-
name: opts.clientName || "test-client-with-headers",
|
|
24
|
-
version: opts.clientVersion || "1.0.0"
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
// Backward compatible: treat options as headers record
|
|
29
|
-
this.customHeaders = options;
|
|
30
|
-
this.timeout = 30000;
|
|
31
|
-
this.client = new Client({ name: "test-client-with-headers", version: "1.0.0" });
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Connect to MCP server with custom headers
|
|
36
|
-
*/
|
|
37
|
-
async connect(url) {
|
|
38
|
-
if (this.transport) {
|
|
39
|
-
throw new Error('Client is already connected');
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
this.transport = new StreamableHTTPClientTransport(new URL(url), {
|
|
43
|
-
requestInit: {
|
|
44
|
-
headers: this.customHeaders
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
await this.client.connect(this.transport);
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
this.transport = null;
|
|
51
|
-
throw new Error(`Failed to connect: ${error instanceof Error ? error.message : String(error)}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Disconnect from server
|
|
56
|
-
*/
|
|
57
|
-
async disconnect() {
|
|
58
|
-
if (this.transport) {
|
|
59
|
-
try {
|
|
60
|
-
await this.transport.close();
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
// Silently ignore disconnect errors in tests
|
|
64
|
-
// In production, you'd want proper logging
|
|
65
|
-
}
|
|
66
|
-
finally {
|
|
67
|
-
this.transport = null;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Get session ID from transport (useful for testing)
|
|
73
|
-
*/
|
|
74
|
-
getSessionId() {
|
|
75
|
-
return this.transport?.sessionId;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Update custom headers (creates new connection if already connected)
|
|
79
|
-
*/
|
|
80
|
-
setHeaders(headers) {
|
|
81
|
-
if (this.transport) {
|
|
82
|
-
throw new Error('Cannot update headers while connected. Disconnect first.');
|
|
83
|
-
}
|
|
84
|
-
this.customHeaders = headers;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* List available tools from server
|
|
88
|
-
*/
|
|
89
|
-
async listTools() {
|
|
90
|
-
if (!this.transport) {
|
|
91
|
-
throw new Error('Client is not connected');
|
|
92
|
-
}
|
|
93
|
-
try {
|
|
94
|
-
const response = await this.client.listTools();
|
|
95
|
-
return response;
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
throw new Error(`Failed to list tools: ${error instanceof Error ? error.message : String(error)}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Call a tool on the server
|
|
103
|
-
*/
|
|
104
|
-
async callTool(name, arguments_ = {}) {
|
|
105
|
-
if (!this.transport) {
|
|
106
|
-
throw new Error('Client is not connected');
|
|
107
|
-
}
|
|
108
|
-
try {
|
|
109
|
-
const response = await this.client.callTool({ name, arguments: arguments_ });
|
|
110
|
-
return response;
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
throw new Error(`Failed to call tool '${name}': ${error instanceof Error ? error.message : String(error)}`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Get client connection status
|
|
118
|
-
*/
|
|
119
|
-
get isConnected() {
|
|
120
|
-
return this.transport !== null;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SSE MCP Client for testing
|
|
3
|
-
*/
|
|
4
|
-
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
5
|
-
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
6
|
-
import { MCPConnectionError, MCPToolCallError } from "./client.js";
|
|
7
|
-
export class SSETestClient {
|
|
8
|
-
client;
|
|
9
|
-
transport = null;
|
|
10
|
-
constructor() {
|
|
11
|
-
this.client = new Client({ name: "test-client", version: "1.0.0" });
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Connect to MCP server via SSE
|
|
15
|
-
*/
|
|
16
|
-
async connect(url) {
|
|
17
|
-
if (this.transport) {
|
|
18
|
-
throw new MCPConnectionError('Client is already connected');
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
this.transport = new SSEClientTransport(new URL(url));
|
|
22
|
-
await this.client.connect(this.transport);
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
this.transport = null;
|
|
26
|
-
throw new MCPConnectionError(`Failed to connect to SSE server: ${error instanceof Error ? error.message : String(error)}`, error instanceof Error ? error : undefined);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Disconnect from server
|
|
31
|
-
*/
|
|
32
|
-
async disconnect() {
|
|
33
|
-
if (this.transport) {
|
|
34
|
-
try {
|
|
35
|
-
await this.transport.close();
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
// Log but don't throw on disconnect errors
|
|
39
|
-
console.warn('Warning during disconnect:', error);
|
|
40
|
-
}
|
|
41
|
-
finally {
|
|
42
|
-
this.transport = null;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* List available tools from server
|
|
48
|
-
*/
|
|
49
|
-
async listTools() {
|
|
50
|
-
if (!this.transport) {
|
|
51
|
-
throw new MCPConnectionError('Client is not connected');
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
const response = await this.client.listTools();
|
|
55
|
-
return response;
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
throw new MCPToolCallError(`Failed to list tools: ${error instanceof Error ? error.message : String(error)}`, 'listTools', error instanceof Error ? error : undefined);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Call a tool on the server
|
|
63
|
-
*/
|
|
64
|
-
async callTool(name, arguments_ = {}) {
|
|
65
|
-
if (!this.transport) {
|
|
66
|
-
throw new MCPConnectionError('Client is not connected');
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
const response = await this.client.callTool({ name, arguments: arguments_ });
|
|
70
|
-
// Ensure the response conforms to CallToolResult interface
|
|
71
|
-
return response;
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
throw new MCPToolCallError(`Failed to call tool '${name}': ${error instanceof Error ? error.message : String(error)}`, name, error instanceof Error ? error : undefined);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Test connection by listing tools
|
|
79
|
-
*/
|
|
80
|
-
async testConnection() {
|
|
81
|
-
try {
|
|
82
|
-
const tools = await this.listTools();
|
|
83
|
-
return Array.isArray(tools.tools) && tools.tools.length > 0;
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Get client connection status
|
|
91
|
-
*/
|
|
92
|
-
get isConnected() {
|
|
93
|
-
return this.transport !== null;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stdio MCP Client for testing
|
|
3
|
-
*/
|
|
4
|
-
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
5
|
-
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
6
|
-
import { MCPConnectionError, MCPToolCallError } from "./client.js";
|
|
7
|
-
export class StdioTestClient {
|
|
8
|
-
client;
|
|
9
|
-
transport = null;
|
|
10
|
-
constructor() {
|
|
11
|
-
this.client = new Client({ name: "test-client", version: "1.0.0" });
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Connect to MCP server via stdio
|
|
15
|
-
*/
|
|
16
|
-
async connect(serverPath, env) {
|
|
17
|
-
if (this.transport) {
|
|
18
|
-
throw new MCPConnectionError('Client is already connected');
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
const command = process.execPath;
|
|
22
|
-
const args = [serverPath];
|
|
23
|
-
// Prepare environment variables for the server process
|
|
24
|
-
const serverEnv = {};
|
|
25
|
-
// Copy process.env, filtering out undefined values
|
|
26
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
27
|
-
if (value !== undefined) {
|
|
28
|
-
serverEnv[key] = value;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
// Add custom environment variables
|
|
32
|
-
if (env) {
|
|
33
|
-
Object.assign(serverEnv, env);
|
|
34
|
-
}
|
|
35
|
-
this.transport = new StdioClientTransport({
|
|
36
|
-
command,
|
|
37
|
-
args,
|
|
38
|
-
env: serverEnv
|
|
39
|
-
});
|
|
40
|
-
await this.client.connect(this.transport);
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
this.transport = null;
|
|
44
|
-
throw new MCPConnectionError(`Failed to connect to stdio server: ${error instanceof Error ? error.message : String(error)}`, error instanceof Error ? error : undefined);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Disconnect from server
|
|
49
|
-
*/
|
|
50
|
-
async disconnect() {
|
|
51
|
-
if (this.transport) {
|
|
52
|
-
try {
|
|
53
|
-
await this.transport.close();
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
// Log but don't throw on disconnect errors
|
|
57
|
-
console.warn('Warning during disconnect:', error);
|
|
58
|
-
}
|
|
59
|
-
finally {
|
|
60
|
-
this.transport = null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* List available tools from server
|
|
66
|
-
*/
|
|
67
|
-
async listTools() {
|
|
68
|
-
if (!this.transport) {
|
|
69
|
-
throw new MCPConnectionError('Client is not connected');
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
const response = await this.client.listTools();
|
|
73
|
-
return response;
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
throw new MCPToolCallError(`Failed to list tools: ${error instanceof Error ? error.message : String(error)}`, 'listTools', error instanceof Error ? error : undefined);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Call a tool on the server
|
|
81
|
-
*/
|
|
82
|
-
async callTool(name, arguments_ = {}) {
|
|
83
|
-
if (!this.transport) {
|
|
84
|
-
throw new MCPConnectionError('Client is not connected');
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
const response = await this.client.callTool({ name, arguments: arguments_ });
|
|
88
|
-
// Ensure the response conforms to CallToolResult interface
|
|
89
|
-
return response;
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
throw new MCPToolCallError(`Failed to call tool '${name}': ${error instanceof Error ? error.message : String(error)}`, name, error instanceof Error ? error : undefined);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Test connection by listing tools
|
|
97
|
-
*/
|
|
98
|
-
async testConnection() {
|
|
99
|
-
try {
|
|
100
|
-
const tools = await this.listTools();
|
|
101
|
-
return Array.isArray(tools.tools) && tools.tools.length > 0;
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Get client connection status
|
|
109
|
-
*/
|
|
110
|
-
get isConnected() {
|
|
111
|
-
return this.transport !== null;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Streamable HTTP MCP Client for testing
|
|
3
|
-
*/
|
|
4
|
-
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
5
|
-
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
6
|
-
import { MCPConnectionError, MCPToolCallError } from "./client.js";
|
|
7
|
-
export class StreamableHTTPTestClient {
|
|
8
|
-
client;
|
|
9
|
-
transport = null;
|
|
10
|
-
constructor() {
|
|
11
|
-
this.client = new Client({ name: "test-client", version: "1.0.0" });
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Connect to MCP server via Streamable HTTP
|
|
15
|
-
*/
|
|
16
|
-
async connect(url) {
|
|
17
|
-
if (this.transport) {
|
|
18
|
-
throw new MCPConnectionError('Client is already connected');
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
this.transport = new StreamableHTTPClientTransport(new URL(url));
|
|
22
|
-
await this.client.connect(this.transport);
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
this.transport = null;
|
|
26
|
-
throw new MCPConnectionError(`Failed to connect to Streamable HTTP server: ${error instanceof Error ? error.message : String(error)}`, error instanceof Error ? error : undefined);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Disconnect from server
|
|
31
|
-
*/
|
|
32
|
-
async disconnect() {
|
|
33
|
-
if (this.transport) {
|
|
34
|
-
try {
|
|
35
|
-
await this.transport.close();
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
// Log but don't throw on disconnect errors
|
|
39
|
-
console.warn('Warning during disconnect:', error);
|
|
40
|
-
}
|
|
41
|
-
finally {
|
|
42
|
-
this.transport = null;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* List available tools from server
|
|
48
|
-
*/
|
|
49
|
-
async listTools() {
|
|
50
|
-
if (!this.transport) {
|
|
51
|
-
throw new MCPConnectionError('Client is not connected');
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
const response = await this.client.listTools();
|
|
55
|
-
return response;
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
throw new MCPToolCallError(`Failed to list tools: ${error instanceof Error ? error.message : String(error)}`, 'listTools', error instanceof Error ? error : undefined);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Call a tool on the server
|
|
63
|
-
*/
|
|
64
|
-
async callTool(name, arguments_ = {}) {
|
|
65
|
-
if (!this.transport) {
|
|
66
|
-
throw new MCPConnectionError('Client is not connected');
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
const response = await this.client.callTool({ name, arguments: arguments_ });
|
|
70
|
-
// Ensure the response conforms to CallToolResult interface
|
|
71
|
-
return response;
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
throw new MCPToolCallError(`Failed to call tool '${name}': ${error instanceof Error ? error.message : String(error)}`, name, error instanceof Error ? error : undefined);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Test connection by listing tools
|
|
79
|
-
*/
|
|
80
|
-
async testConnection() {
|
|
81
|
-
try {
|
|
82
|
-
const tools = await this.listTools();
|
|
83
|
-
return Array.isArray(tools.tools) && tools.tools.length > 0;
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Get client connection status
|
|
91
|
-
*/
|
|
92
|
-
get isConnected() {
|
|
93
|
-
return this.transport !== null;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for GITLAB_OAUTH_ALLOWED_GROUPS config resolution.
|
|
3
|
-
*
|
|
4
|
-
* Verifies that:
|
|
5
|
-
* - The new GITLAB_OAUTH_ALLOWED_GROUPS env var is preferred when set.
|
|
6
|
-
* - The deprecated GITLAB_ALLOWED_GROUPS is accepted as a fallback and
|
|
7
|
-
* sets the deprecation flag so callers can emit a warning.
|
|
8
|
-
* - When both are set, the new var wins and GITLAB_ALLOWED_GROUPS_RAW remains
|
|
9
|
-
* set, so callers can emit a "set but ignored" warning.
|
|
10
|
-
*
|
|
11
|
-
* config.ts reads process.env at module load, so each scenario runs in a
|
|
12
|
-
* fresh child process — same pattern as test/stateless/config-ttl.test.ts.
|
|
13
|
-
*/
|
|
14
|
-
import assert from "node:assert/strict";
|
|
15
|
-
import { execFileSync } from "node:child_process";
|
|
16
|
-
import * as path from "node:path";
|
|
17
|
-
import * as url from "node:url";
|
|
18
|
-
import { describe, test } from "node:test";
|
|
19
|
-
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
20
|
-
const CONFIG_PATH = path.resolve(__dirname, "../config.ts");
|
|
21
|
-
function loadConfig(env) {
|
|
22
|
-
const script = `
|
|
23
|
-
import(${JSON.stringify(url.pathToFileURL(CONFIG_PATH).href)}).then((m) => {
|
|
24
|
-
const out = {
|
|
25
|
-
GITLAB_OAUTH_ALLOWED_GROUPS: m.GITLAB_OAUTH_ALLOWED_GROUPS ?? null,
|
|
26
|
-
GITLAB_OAUTH_ALLOWED_GROUPS_RAW: m.GITLAB_OAUTH_ALLOWED_GROUPS_RAW ?? null,
|
|
27
|
-
GITLAB_ALLOWED_GROUPS_RAW: m.GITLAB_ALLOWED_GROUPS_RAW ?? null,
|
|
28
|
-
};
|
|
29
|
-
process.stdout.write(JSON.stringify(out));
|
|
30
|
-
}).catch((err) => {
|
|
31
|
-
process.stderr.write(String(err && err.stack || err));
|
|
32
|
-
process.exit(2);
|
|
33
|
-
});
|
|
34
|
-
`;
|
|
35
|
-
const childEnv = {
|
|
36
|
-
...process.env,
|
|
37
|
-
};
|
|
38
|
-
delete childEnv.GITLAB_OAUTH_ALLOWED_GROUPS;
|
|
39
|
-
delete childEnv.GITLAB_ALLOWED_GROUPS;
|
|
40
|
-
for (const [k, v] of Object.entries(env)) {
|
|
41
|
-
if (v === undefined) {
|
|
42
|
-
delete childEnv[k];
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
childEnv[k] = v;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const stdout = execFileSync(process.execPath, ["--import", "tsx/esm", "--input-type=module", "--eval", script], { env: childEnv, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
49
|
-
return JSON.parse(stdout);
|
|
50
|
-
}
|
|
51
|
-
describe("config.ts — GITLAB_OAUTH_ALLOWED_GROUPS resolution", () => {
|
|
52
|
-
test("neither var set — resolved value and raws are null", () => {
|
|
53
|
-
const cfg = loadConfig({});
|
|
54
|
-
assert.equal(cfg.GITLAB_OAUTH_ALLOWED_GROUPS, null);
|
|
55
|
-
assert.equal(cfg.GITLAB_OAUTH_ALLOWED_GROUPS_RAW, null);
|
|
56
|
-
assert.equal(cfg.GITLAB_ALLOWED_GROUPS_RAW, null);
|
|
57
|
-
});
|
|
58
|
-
test("only new var set — resolved correctly, deprecated raw is null", () => {
|
|
59
|
-
const cfg = loadConfig({ GITLAB_OAUTH_ALLOWED_GROUPS: "my-org" });
|
|
60
|
-
assert.deepEqual(cfg.GITLAB_OAUTH_ALLOWED_GROUPS, ["my-org"]);
|
|
61
|
-
assert.equal(cfg.GITLAB_OAUTH_ALLOWED_GROUPS_RAW, "my-org");
|
|
62
|
-
assert.equal(cfg.GITLAB_ALLOWED_GROUPS_RAW, null);
|
|
63
|
-
});
|
|
64
|
-
test("only deprecated var set — resolved via fallback, deprecated raw is set", () => {
|
|
65
|
-
const cfg = loadConfig({ GITLAB_ALLOWED_GROUPS: "my-org" });
|
|
66
|
-
assert.deepEqual(cfg.GITLAB_OAUTH_ALLOWED_GROUPS, ["my-org"]);
|
|
67
|
-
assert.equal(cfg.GITLAB_ALLOWED_GROUPS_RAW, "my-org");
|
|
68
|
-
assert.equal(cfg.GITLAB_OAUTH_ALLOWED_GROUPS_RAW, null);
|
|
69
|
-
});
|
|
70
|
-
test("both vars set — new var wins, both raws are set (triggers 'set but ignored' warning)", () => {
|
|
71
|
-
const cfg = loadConfig({
|
|
72
|
-
GITLAB_OAUTH_ALLOWED_GROUPS: "new-org",
|
|
73
|
-
GITLAB_ALLOWED_GROUPS: "old-org",
|
|
74
|
-
});
|
|
75
|
-
assert.deepEqual(cfg.GITLAB_OAUTH_ALLOWED_GROUPS, ["new-org"]);
|
|
76
|
-
assert.equal(cfg.GITLAB_OAUTH_ALLOWED_GROUPS_RAW, "new-org");
|
|
77
|
-
assert.equal(cfg.GITLAB_ALLOWED_GROUPS_RAW, "old-org");
|
|
78
|
-
});
|
|
79
|
-
test("comma-separated values are split and trimmed", () => {
|
|
80
|
-
const cfg = loadConfig({
|
|
81
|
-
GITLAB_OAUTH_ALLOWED_GROUPS: "my-org/team-a , my-org/team-b , my-org",
|
|
82
|
-
});
|
|
83
|
-
assert.deepEqual(cfg.GITLAB_OAUTH_ALLOWED_GROUPS, [
|
|
84
|
-
"my-org/team-a",
|
|
85
|
-
"my-org/team-b",
|
|
86
|
-
"my-org",
|
|
87
|
-
]);
|
|
88
|
-
});
|
|
89
|
-
test("empty string resolves to null", () => {
|
|
90
|
-
const cfg = loadConfig({ GITLAB_OAUTH_ALLOWED_GROUPS: "" });
|
|
91
|
-
assert.equal(cfg.GITLAB_OAUTH_ALLOWED_GROUPS, null);
|
|
92
|
-
});
|
|
93
|
-
test("whitespace-only entries are filtered out", () => {
|
|
94
|
-
const cfg = loadConfig({ GITLAB_OAUTH_ALLOWED_GROUPS: " , , " });
|
|
95
|
-
assert.equal(cfg.GITLAB_OAUTH_ALLOWED_GROUPS, null);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import { FileOperationSchema } from "../schemas.js";
|
|
4
|
-
import { fileOperationsIncludeDeleteOrMove, toGitLabCommitActions, } from "../utils/gitlab-commit-actions.js";
|
|
5
|
-
function firstAction(actions) {
|
|
6
|
-
const entry = actions[0];
|
|
7
|
-
if (!entry) {
|
|
8
|
-
throw new Error("expected at least one commit action");
|
|
9
|
-
}
|
|
10
|
-
return entry;
|
|
11
|
-
}
|
|
12
|
-
describe("When mapping file operations to GitLab commit actions", () => {
|
|
13
|
-
describe("with a plain text file and no per-file encoding", () => {
|
|
14
|
-
it("should default the action to create", () => {
|
|
15
|
-
const entry = firstAction(toGitLabCommitActions([{ path: "a.txt", content: "hi" }], "text"));
|
|
16
|
-
assert.equal(entry.action, "create");
|
|
17
|
-
});
|
|
18
|
-
it("should keep the content unchanged when the global encoding is text", () => {
|
|
19
|
-
const entry = firstAction(toGitLabCommitActions([{ path: "a.txt", content: "hi" }], "text"));
|
|
20
|
-
assert.equal(entry.content, "hi");
|
|
21
|
-
});
|
|
22
|
-
it("should set encoding to the global text value", () => {
|
|
23
|
-
const entry = firstAction(toGitLabCommitActions([{ path: "a.txt", content: "hi" }], "text"));
|
|
24
|
-
assert.equal(entry.encoding, "text");
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe("with a plain text file and global base64 encoding", () => {
|
|
28
|
-
it("should base64-encode the content", () => {
|
|
29
|
-
const entry = firstAction(toGitLabCommitActions([{ path: "a.txt", content: "hi" }], "base64"));
|
|
30
|
-
assert.equal(entry.content, Buffer.from("hi").toString("base64"));
|
|
31
|
-
});
|
|
32
|
-
it("should set encoding to base64", () => {
|
|
33
|
-
const entry = firstAction(toGitLabCommitActions([{ path: "a.txt", content: "hi" }], "base64"));
|
|
34
|
-
assert.equal(entry.encoding, "base64");
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
describe("with an explicit per-file encoding", () => {
|
|
38
|
-
it("should pass text content through when encoding is text even if global is base64", () => {
|
|
39
|
-
const entry = firstAction(toGitLabCommitActions([{ path: "a.txt", content: "hi", encoding: "text" }], "base64"));
|
|
40
|
-
assert.equal(entry.content, "hi");
|
|
41
|
-
});
|
|
42
|
-
it("should keep the explicit text encoding on the payload", () => {
|
|
43
|
-
const entry = firstAction(toGitLabCommitActions([{ path: "a.txt", content: "hi", encoding: "text" }], "base64"));
|
|
44
|
-
assert.equal(entry.encoding, "text");
|
|
45
|
-
});
|
|
46
|
-
it("should pass base64 content through without encoding it again", () => {
|
|
47
|
-
const entry = firstAction(toGitLabCommitActions([{ path: "logo.png", content: "aGk=", encoding: "base64" }], "text"));
|
|
48
|
-
assert.equal(entry.content, "aGk=");
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
describe("with action delete", () => {
|
|
52
|
-
it("should omit content from the payload", () => {
|
|
53
|
-
const entry = firstAction(toGitLabCommitActions([{ path: "a.txt", action: "delete" }], "text"));
|
|
54
|
-
assert.equal("content" in entry, false);
|
|
55
|
-
});
|
|
56
|
-
it("should omit encoding from the payload", () => {
|
|
57
|
-
const entry = firstAction(toGitLabCommitActions([{ path: "a.txt", action: "delete" }], "text"));
|
|
58
|
-
assert.equal("encoding" in entry, false);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
describe("with action move", () => {
|
|
62
|
-
it("should omit content when the move has no new content", () => {
|
|
63
|
-
const entry = firstAction(toGitLabCommitActions([{ path: "b.txt", action: "move", previous_path: "a.txt" }], "text"));
|
|
64
|
-
assert.equal("content" in entry, false);
|
|
65
|
-
});
|
|
66
|
-
it("should include previous_path", () => {
|
|
67
|
-
const entry = firstAction(toGitLabCommitActions([{ path: "b.txt", action: "move", previous_path: "a.txt" }], "text"));
|
|
68
|
-
assert.equal(entry.previous_path, "a.txt");
|
|
69
|
-
});
|
|
70
|
-
it("should include content when a move supplies replacement content", () => {
|
|
71
|
-
const entry = firstAction(toGitLabCommitActions([{ path: "b.txt", action: "move", previous_path: "a.txt", content: "new" }], "text"));
|
|
72
|
-
assert.equal(entry.content, "new");
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
describe("with create or update missing content", () => {
|
|
76
|
-
it("should reject a create without content before sending an empty file", () => {
|
|
77
|
-
assert.throws(() => toGitLabCommitActions([{ path: "a.txt" }], "text"), /content is required when action is 'create'/);
|
|
78
|
-
});
|
|
79
|
-
it("should reject the FileOperation schema for create without content", () => {
|
|
80
|
-
const parsed = FileOperationSchema.safeParse({ path: "a.txt" });
|
|
81
|
-
assert.equal(parsed.success, false);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
describe("When checking push_files actions against modify mode", () => {
|
|
86
|
-
describe("with delete or move entries", () => {
|
|
87
|
-
it("should treat delete as blocked", () => {
|
|
88
|
-
assert.equal(fileOperationsIncludeDeleteOrMove([{ action: "delete" }]), true);
|
|
89
|
-
});
|
|
90
|
-
it("should treat move as blocked", () => {
|
|
91
|
-
assert.equal(fileOperationsIncludeDeleteOrMove([{ action: "move" }]), true);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
describe("with create or update entries", () => {
|
|
95
|
-
it("should allow omitted action", () => {
|
|
96
|
-
assert.equal(fileOperationsIncludeDeleteOrMove([{}]), false);
|
|
97
|
-
});
|
|
98
|
-
it("should allow update", () => {
|
|
99
|
-
assert.equal(fileOperationsIncludeDeleteOrMove([{ action: "update" }]), false);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { test } from "node:test";
|
|
3
|
-
import { GitLabDraftNoteSchema } from "../schemas.js";
|
|
4
|
-
test("draft note schema keeps Draft Notes API fields and drops fake timestamps", () => {
|
|
5
|
-
const parsed = GitLabDraftNoteSchema.parse({
|
|
6
|
-
id: 42,
|
|
7
|
-
author_id: 7,
|
|
8
|
-
note: "looks wrong on this line",
|
|
9
|
-
line_code: "a1b2c3d4e5f6_12_17",
|
|
10
|
-
merge_request_id: 99,
|
|
11
|
-
commit_id: "abc123",
|
|
12
|
-
discussion_id: null,
|
|
13
|
-
position: { new_path: "src/app.ts", new_line: 17 },
|
|
14
|
-
resolve_discussion: false,
|
|
15
|
-
// Notes-API leftovers that Draft Notes API never returns — must be stripped
|
|
16
|
-
created_at: "2024-01-01T00:00:00Z",
|
|
17
|
-
updated_at: "2024-01-02T00:00:00Z",
|
|
18
|
-
});
|
|
19
|
-
assert.equal(parsed.id, "42");
|
|
20
|
-
assert.equal(parsed.author_id, 7);
|
|
21
|
-
assert.equal(parsed.body, "looks wrong on this line");
|
|
22
|
-
assert.equal(parsed.line_code, "a1b2c3d4e5f6_12_17");
|
|
23
|
-
assert.equal(parsed.merge_request_id, 99);
|
|
24
|
-
assert.equal(parsed.commit_id, "abc123");
|
|
25
|
-
assert.equal(parsed.discussion_id, null);
|
|
26
|
-
assert.equal(parsed.resolve_discussion, false);
|
|
27
|
-
assert.equal("created_at" in parsed, false);
|
|
28
|
-
assert.equal("updated_at" in parsed, false);
|
|
29
|
-
});
|
|
30
|
-
test("draft note schema preserves null line_code for unresolved positions", () => {
|
|
31
|
-
const parsed = GitLabDraftNoteSchema.parse({
|
|
32
|
-
id: "43",
|
|
33
|
-
author_id: 7,
|
|
34
|
-
note: "orphan draft",
|
|
35
|
-
line_code: null,
|
|
36
|
-
merge_request_id: 99,
|
|
37
|
-
commit_id: null,
|
|
38
|
-
discussion_id: null,
|
|
39
|
-
position: null,
|
|
40
|
-
resolve_discussion: false,
|
|
41
|
-
});
|
|
42
|
-
assert.equal(parsed.line_code, null);
|
|
43
|
-
assert.equal(parsed.commit_id, null);
|
|
44
|
-
});
|