@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 CHANGED
@@ -1,3 +1,7 @@
1
+ <p align="center">
2
+ <img src="assets/logo.png" alt="GitLab MCP" width="160">
3
+ </p>
4
+
1
5
  # GitLab MCP Server
2
6
 
3
7
  [![npm](https://img.shields.io/npm/v/@zereight/mcp-gitlab.svg)](https://www.npmjs.com/package/@zereight/mcp-gitlab)
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ <p align="center">
2
+ <img src="assets/logo.png" alt="GitLab MCP" width="160">
3
+ </p>
4
+
1
5
  # GitLab MCP Server
2
6
 
3
7
  [![GitHub stars](https://badgen.net/github/stars/zereight/gitlab-mcp?icon=github&label=Star)](https://github.com/zereight/gitlab-mcp)
package/README.pt-BR.md CHANGED
@@ -1,3 +1,7 @@
1
+ <p align="center">
2
+ <img src="assets/logo.png" alt="GitLab MCP" width="160">
3
+ </p>
4
+
1
5
  # GitLab MCP Server
2
6
 
3
7
  [![npm](https://img.shields.io/npm/v/@zereight/mcp-gitlab.svg)](https://www.npmjs.com/package/@zereight/mcp-gitlab)
package/README.zh-CN.md CHANGED
@@ -1,3 +1,7 @@
1
+ <p align="center">
2
+ <img src="assets/logo.png" alt="GitLab MCP" width="160">
3
+ </p>
4
+
1
5
  # GitLab MCP Server
2
6
 
3
7
  [![npm](https://img.shields.io/npm/v/@zereight/mcp-gitlab.svg)](https://www.npmjs.com/package/@zereight/mcp-gitlab)
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
- const start = args.findIndex(arg => !arg.startsWith("-") && SCRIPT_PATH_PATTERN.test(arg));
244
- if (start >= 0) {
245
- return args.slice(start + 1);
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
- cli: buildToolReplayCommand(input.toolName, input.args),
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
- const SIMPLE_SHELL_TOKEN = /^[A-Za-z0-9._:/=+-]+$/;
4
- const SECRET_ARGUMENT_NAMES = new Set([
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
- export function buildToolReplayCommand(toolName, args) {
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
- parts.push(`--${snakeToKebab(key)}`, shellToken(String(value)));
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", shellToken(JSON.stringify(nested)));
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 shellToken(value) {
49
- if (SIMPLE_SHELL_TOKEN.test(value)) {
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 JSON.stringify(value);
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.232",
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": [