@zereight/mcp-gitlab 2.3.27-next.232 → 2.3.27-next.233
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 +4 -0
- package/README.md +4 -0
- package/README.pt-BR.md +4 -0
- package/README.zh-CN.md +4 -0
- package/build/cli/args.js +5 -3
- package/build/cli/compact-mcp-result.js +3 -1
- package/build/cli/replay-command.js +40 -9
- package/build/index.js +1 -0
- package/package.json +1 -1
package/README.ko.md
CHANGED
package/README.md
CHANGED
package/README.pt-BR.md
CHANGED
package/README.zh-CN.md
CHANGED
package/build/cli/args.js
CHANGED
|
@@ -240,9 +240,11 @@ export function isCliOutputMode(value) {
|
|
|
240
240
|
}
|
|
241
241
|
function userArgv(argv) {
|
|
242
242
|
const args = argv.slice(2);
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
243
|
+
// Only the first positional can be the script a runner passes in. A later
|
|
244
|
+
// value such as `src/app.ts` is a tool argument, not a script path.
|
|
245
|
+
const first = args.findIndex(arg => !arg.startsWith("-"));
|
|
246
|
+
if (first >= 0 && SCRIPT_PATH_PATTERN.test(args[first])) {
|
|
247
|
+
return args.slice(first + 1);
|
|
246
248
|
}
|
|
247
249
|
return args;
|
|
248
250
|
}
|
|
@@ -24,12 +24,14 @@ export function compactMcpToolResult(input) {
|
|
|
24
24
|
if (text.length <= input.maxChars) {
|
|
25
25
|
return toolResultRecord(input.result);
|
|
26
26
|
}
|
|
27
|
+
const cli = buildToolReplayCommand(input.toolName, input.args, input.inputSchema);
|
|
27
28
|
const compact = {
|
|
28
29
|
compact: true,
|
|
29
30
|
tool: input.toolName,
|
|
30
31
|
original_chars: text.length,
|
|
31
32
|
...buildPreview(text),
|
|
32
|
-
|
|
33
|
+
// No safe replay line exists for these arguments: the preview stays, without `cli`.
|
|
34
|
+
...(cli === undefined ? {} : { cli }),
|
|
33
35
|
};
|
|
34
36
|
return {
|
|
35
37
|
content: [{ type: "text", text: JSON.stringify(compact) }],
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { snakeToKebab } from "./args.js";
|
|
1
|
+
import { readObjectSchema, snakeToKebab } from "./args.js";
|
|
2
2
|
const BINARY = "zereight-mcp-gitlab";
|
|
3
|
-
|
|
4
|
-
const
|
|
3
|
+
// Words that POSIX sh passes through unchanged. Anything else is single-quoted.
|
|
4
|
+
const SIMPLE_SHELL_WORD = /^[A-Za-z0-9._:/=+-]+$/;
|
|
5
|
+
const TOOL_NAME = /^[a-z][a-z0-9_]*$/;
|
|
6
|
+
const ARGUMENT_NAME = /^[a-z][a-z0-9_]*$/;
|
|
7
|
+
const LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
8
|
+
export const SECRET_ARGUMENT_NAMES = new Set([
|
|
5
9
|
"token",
|
|
6
10
|
"job_token",
|
|
7
11
|
"private_token",
|
|
@@ -12,7 +16,18 @@ const SECRET_ARGUMENT_NAMES = new Set([
|
|
|
12
16
|
"signing_token",
|
|
13
17
|
"authorization",
|
|
14
18
|
]);
|
|
15
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Builds the `zereight-mcp-gitlab tool ...` line for a compacted reply, or returns
|
|
21
|
+
* undefined when no safe line exists. Every token is either a plain word or
|
|
22
|
+
* single-quoted, so the line is inert when a shell runs it. Only keys that the
|
|
23
|
+
* tool's input schema declares become flags; the CLI reads any other flag from
|
|
24
|
+
* the same argv, and names such as `api_url` would then change its configuration.
|
|
25
|
+
*/
|
|
26
|
+
export function buildToolReplayCommand(toolName, args, inputSchema) {
|
|
27
|
+
if (!TOOL_NAME.test(toolName)) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
const declared = new Set(Object.keys(readObjectSchema(inputSchema).properties ?? {}));
|
|
16
31
|
const parts = [BINARY, "tool", toolName];
|
|
17
32
|
const nested = {};
|
|
18
33
|
if (args !== undefined) {
|
|
@@ -24,15 +39,23 @@ export function buildToolReplayCommand(toolName, args) {
|
|
|
24
39
|
if (value === undefined) {
|
|
25
40
|
continue;
|
|
26
41
|
}
|
|
42
|
+
if (!ARGUMENT_NAME.test(key) || !declared.has(key)) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
27
45
|
if (isScalarReplayValue(value)) {
|
|
28
|
-
|
|
46
|
+
const text = String(value);
|
|
47
|
+
// argv cannot carry a NUL byte, and a lone surrogate does not survive UTF-8.
|
|
48
|
+
if (text.includes("\0") || LONE_SURROGATE.test(text)) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
parts.push(...flagTokens(snakeToKebab(key), text));
|
|
29
52
|
continue;
|
|
30
53
|
}
|
|
31
54
|
nested[key] = value;
|
|
32
55
|
}
|
|
33
56
|
}
|
|
34
57
|
if (Object.keys(nested).length > 0) {
|
|
35
|
-
parts.push("--args-json",
|
|
58
|
+
parts.push("--args-json", shellWord(JSON.stringify(nested)));
|
|
36
59
|
}
|
|
37
60
|
return parts.join(" ");
|
|
38
61
|
}
|
|
@@ -45,9 +68,17 @@ function shouldOmitReplayArgument(name) {
|
|
|
45
68
|
function isScalarReplayValue(value) {
|
|
46
69
|
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
47
70
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
71
|
+
function flagTokens(flag, value) {
|
|
72
|
+
// The CLI reads `--flag -x` as a missing value, so a value that starts with a
|
|
73
|
+
// dash goes in the `--flag=value` form, which it parses as one token.
|
|
74
|
+
if (value.startsWith("-")) {
|
|
75
|
+
return [`--${flag}=${shellWord(value)}`];
|
|
76
|
+
}
|
|
77
|
+
return [`--${flag}`, shellWord(value)];
|
|
78
|
+
}
|
|
79
|
+
function shellWord(value) {
|
|
80
|
+
if (SIMPLE_SHELL_WORD.test(value)) {
|
|
50
81
|
return value;
|
|
51
82
|
}
|
|
52
|
-
return
|
|
83
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
53
84
|
}
|
package/build/index.js
CHANGED
|
@@ -274,6 +274,7 @@ function createServer() {
|
|
|
274
274
|
maxChars: GITLAB_MCP_COMPACT_RESULT_CHARS,
|
|
275
275
|
toolName,
|
|
276
276
|
args: readOwnRecord(request.params.arguments),
|
|
277
|
+
inputSchema: allTools.find(tool => tool.name === toolName)?.inputSchema,
|
|
277
278
|
});
|
|
278
279
|
};
|
|
279
280
|
const logError = (error) => {
|
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.233",
|
|
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": [
|