@zereight/mcp-gitlab 2.3.27-next.233 → 2.3.27-next.234
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/build/schemas.js +11 -9
- package/build/utils/helpers.js +47 -12
- package/package.json +1 -1
package/build/schemas.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { EXCLUDED_FILE_PATTERN_MAX_COUNT, EXCLUDED_FILE_PATTERN_MAX_LENGTH, } from "./utils/helpers.js";
|
|
2
3
|
import { omitIncompleteMergeRequestPosition } from "./utils/merge-request-position.js";
|
|
3
4
|
// Helper: coerce a JSON-stringified array to an actual array.
|
|
4
5
|
// LLMs sometimes send '["a", "b"]' (string) instead of ["a", "b"] (array).
|
|
@@ -2242,16 +2243,19 @@ export const GitLabBranchSchema = z.object({
|
|
|
2242
2243
|
default: z.boolean(),
|
|
2243
2244
|
web_url: z.string().optional(),
|
|
2244
2245
|
});
|
|
2246
|
+
const excludedFilePatternsSchema = z
|
|
2247
|
+
.array(z.string().max(EXCLUDED_FILE_PATTERN_MAX_LENGTH))
|
|
2248
|
+
.max(EXCLUDED_FILE_PATTERN_MAX_COUNT);
|
|
2249
|
+
const EXCLUDED_DIFF_PATTERNS_DESCRIPTION = 'Array of regex patterns to exclude files from the diff results. Each pattern is an RE2 regular expression that matches file paths to ignore. RE2 runs in linear time but does not support lookahead, lookbehind, or backreferences. At most 50 patterns of at most 200 characters each. Examples: ["^vendor/", "^test/mocks/", "\\.spec\\.ts$", "package-lock\\.json"]';
|
|
2245
2250
|
export const GetBranchDiffsSchema = ProjectParamsSchema.extend({
|
|
2246
2251
|
from: z.string().describe("The base branch or commit SHA to compare from"),
|
|
2247
2252
|
to: z.string().describe("The target branch or commit SHA to compare to"),
|
|
2248
2253
|
straight: coerceBooleanString
|
|
2249
2254
|
.optional()
|
|
2250
2255
|
.describe("Comparison method: false for '...' (default), true for '--'"),
|
|
2251
|
-
excluded_file_patterns:
|
|
2252
|
-
.array(z.string())
|
|
2256
|
+
excluded_file_patterns: excludedFilePatternsSchema
|
|
2253
2257
|
.optional()
|
|
2254
|
-
.describe(
|
|
2258
|
+
.describe(EXCLUDED_DIFF_PATTERNS_DESCRIPTION),
|
|
2255
2259
|
});
|
|
2256
2260
|
const flexibleBooleanOptional = z.preprocess(val => {
|
|
2257
2261
|
if (typeof val !== "string")
|
|
@@ -2425,10 +2429,9 @@ export const ListMergeRequestPipelinesSchema = ProjectParamsSchema.extend({
|
|
|
2425
2429
|
}).merge(PaginationOptionsSchema);
|
|
2426
2430
|
export const GetMergeRequestDiffsSchema = MergeRequestParamsSchema.extend({
|
|
2427
2431
|
view: z.enum(["inline", "parallel"]).optional().describe("Diff view type"),
|
|
2428
|
-
excluded_file_patterns:
|
|
2429
|
-
.array(z.string())
|
|
2432
|
+
excluded_file_patterns: excludedFilePatternsSchema
|
|
2430
2433
|
.optional()
|
|
2431
|
-
.describe(
|
|
2434
|
+
.describe(EXCLUDED_DIFF_PATTERNS_DESCRIPTION),
|
|
2432
2435
|
});
|
|
2433
2436
|
export const ListMergeRequestDiffsSchema = MergeRequestParamsSchema.extend({
|
|
2434
2437
|
page: z.coerce.number().optional().describe("Page number for pagination (default: 1)"),
|
|
@@ -2441,10 +2444,9 @@ export const ListMergeRequestDiffsSchema = MergeRequestParamsSchema.extend({
|
|
|
2441
2444
|
.describe("Present diffs in the unified diff format. Default is false. Introduced in GitLab 16.5."),
|
|
2442
2445
|
});
|
|
2443
2446
|
export const ListMergeRequestChangedFilesSchema = MergeRequestParamsSchema.extend({
|
|
2444
|
-
excluded_file_patterns:
|
|
2445
|
-
.array(z.string())
|
|
2447
|
+
excluded_file_patterns: excludedFilePatternsSchema
|
|
2446
2448
|
.optional()
|
|
2447
|
-
.describe('Array of regex patterns to exclude files. Examples: ["^vendor/", "\\.pb\\.go$"]'),
|
|
2449
|
+
.describe('Array of regex patterns to exclude files. Each pattern is an RE2 regular expression (linear time; no lookahead, lookbehind, or backreferences). At most 50 patterns of at most 200 characters each. Examples: ["^vendor/", "\\.pb\\.go$"]'),
|
|
2448
2450
|
});
|
|
2449
2451
|
export const GetMergeRequestFileDiffSchema = MergeRequestParamsSchema.extend({
|
|
2450
2452
|
file_paths: z
|
package/build/utils/helpers.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { RE2JS } from "re2js";
|
|
4
|
+
/**
|
|
5
|
+
* Limits on excluded_file_patterns. The tool schemas reject input over these
|
|
6
|
+
* limits, and filterDiffsByPatterns ignores anything over them.
|
|
7
|
+
*/
|
|
8
|
+
export const EXCLUDED_FILE_PATTERN_MAX_LENGTH = 200;
|
|
9
|
+
export const EXCLUDED_FILE_PATTERN_MAX_COUNT = 50;
|
|
10
|
+
// Matching cost per character grows with the compiled program. A counted
|
|
11
|
+
// repeat such as .{1000} repeated many times produces a large program.
|
|
12
|
+
export const EXCLUDED_FILE_PATTERN_MAX_PROGRAM_SIZE = 1000;
|
|
3
13
|
/**
|
|
4
14
|
* Reject absolute paths and directory-traversal sequences for user-supplied
|
|
5
15
|
* local filesystem paths (e.g. local_path / file_path tool arguments).
|
|
@@ -289,27 +299,52 @@ export function summarizeWebhookEvents(events) {
|
|
|
289
299
|
execution_duration: event.execution_duration,
|
|
290
300
|
}));
|
|
291
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Compile excluded_file_patterns with RE2, which matches in time linear in the
|
|
304
|
+
* path length. A pattern RE2 cannot compile (lookaround, backreferences, or
|
|
305
|
+
* \uXXXX escapes, for example) is skipped with a warning, so it excludes no files.
|
|
306
|
+
*/
|
|
307
|
+
function compileExcludedFilePatterns(patterns) {
|
|
308
|
+
if (patterns.length > EXCLUDED_FILE_PATTERN_MAX_COUNT) {
|
|
309
|
+
console.warn(`Excluded file patterns after the first ${EXCLUDED_FILE_PATTERN_MAX_COUNT} ignored (${patterns.length} given).`);
|
|
310
|
+
}
|
|
311
|
+
const compiled = [];
|
|
312
|
+
for (const pattern of patterns.slice(0, EXCLUDED_FILE_PATTERN_MAX_COUNT)) {
|
|
313
|
+
if (pattern.length > EXCLUDED_FILE_PATTERN_MAX_LENGTH) {
|
|
314
|
+
console.warn(`Excluded file pattern ignored: ${pattern.length} characters exceeds ${EXCLUDED_FILE_PATTERN_MAX_LENGTH}.`);
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
let regex;
|
|
318
|
+
try {
|
|
319
|
+
regex = RE2JS.compile(pattern);
|
|
320
|
+
}
|
|
321
|
+
catch {
|
|
322
|
+
console.warn(`Invalid regex pattern ignored: ${pattern} (RE2 rejects lookaround, backreferences, and \\uXXXX escapes)`);
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
const programSize = regex.programSize();
|
|
326
|
+
if (programSize > EXCLUDED_FILE_PATTERN_MAX_PROGRAM_SIZE) {
|
|
327
|
+
console.warn(`Excluded file pattern ignored: compiled size ${programSize} exceeds ${EXCLUDED_FILE_PATTERN_MAX_PROGRAM_SIZE}: ${pattern}`);
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
compiled.push(regex);
|
|
331
|
+
}
|
|
332
|
+
return compiled;
|
|
333
|
+
}
|
|
292
334
|
/**
|
|
293
335
|
* Filter MR diffs by excluding files matching regex patterns.
|
|
294
336
|
*
|
|
337
|
+
* Patterns use RE2 syntax (see compileExcludedFilePatterns), so matching cannot
|
|
338
|
+
* backtrack catastrophically on a long path.
|
|
339
|
+
*
|
|
295
340
|
* @param diffs - Array of diff objects with new_path property
|
|
296
|
-
* @param excludedFilePatterns - Array of regex patterns to exclude
|
|
341
|
+
* @param excludedFilePatterns - Array of RE2 regex patterns to exclude
|
|
297
342
|
* @returns Filtered array of diffs
|
|
298
343
|
*/
|
|
299
344
|
export function filterDiffsByPatterns(diffs, excludedFilePatterns) {
|
|
300
345
|
if (!excludedFilePatterns?.length)
|
|
301
346
|
return diffs;
|
|
302
|
-
const regexPatterns = excludedFilePatterns
|
|
303
|
-
.map(pattern => {
|
|
304
|
-
try {
|
|
305
|
-
return new RegExp(pattern);
|
|
306
|
-
}
|
|
307
|
-
catch {
|
|
308
|
-
console.warn(`Invalid regex pattern ignored: ${pattern}`);
|
|
309
|
-
return null;
|
|
310
|
-
}
|
|
311
|
-
})
|
|
312
|
-
.filter((regex) => regex !== null);
|
|
347
|
+
const regexPatterns = compileExcludedFilePatterns(excludedFilePatterns);
|
|
313
348
|
if (regexPatterns.length === 0)
|
|
314
349
|
return diffs;
|
|
315
350
|
const matchesAnyPattern = (path) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zereight/mcp-gitlab",
|
|
3
|
-
"version": "2.3.27-next.
|
|
3
|
+
"version": "2.3.27-next.234",
|
|
4
4
|
"mcpName": "io.github.zereight/gitlab-mcp",
|
|
5
5
|
"description": "GitLab MCP server for projects, merge requests, issues, pipelines, wiki, releases, and more",
|
|
6
6
|
"keywords": [
|