@zereight/mcp-gitlab 2.3.29 → 2.3.30-next.254
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 +1 -1
- package/README.md +1 -1
- package/README.pt-BR.md +1 -1
- package/README.zh-CN.md +1 -1
- package/build/cli/compact-mcp-result.js +4 -4
- package/build/cli/replay-command.js +54 -18
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -317,7 +317,7 @@ CLI 인자는 환경 변수보다 우선합니다.
|
|
|
317
317
|
|
|
318
318
|
`zereight-mcp-gitlab auth`는 MCP 서버 플래그가 아니라 서브커맨드입니다. GitLab device flow를 실행한 뒤 종료합니다. [CLI 인자](./docs/getting-started/cli-arguments.md#auth)를 참고하세요.
|
|
319
319
|
|
|
320
|
-
같은 바이너리는 `gh` 스타일 GitLab CLI이기도 합니다 (`tool <name>` 또는 `mr list` 같은 curated 명령). **MCP 등록은 필요 없습니다** — PAT를 설정하거나, `auth`를 실행한 뒤 `GITLAB_USE_OAUTH=true`를 설정하면 됩니다: [MCP 없이 CLI 사용하기](./docs/getting-started/cli-without-mcp.md). `setup --cursor` / `setup --claude`는 클라이언트 설정을 출력하고, `doctor`는 토큰·API URL·toolset·버전을 점검합니다. 전체 페이로드는 터미널에서 이 CLI로 읽습니다. MCP 응답은 대화에 남습니다. `GITLAB_MCP_COMPACT_RESULTS=true`(또는 `--compact-results`)를 켜면 큰 도구 응답이 미리보기와 CLI 명령으로 바뀝니다. Human CLI 자체는 compact 되지 않습니다. permission mode, toolsets, denied-tools regex, tool-policy는 MCP와 같습니다. destructive 도구와 `GITLAB_TOOL_POLICY_APPROVE` 도구는 `--yes`가 필요합니다. [Human CLI](./docs/getting-started/cli-arguments.md#human-cli)를 참고하세요.
|
|
320
|
+
같은 바이너리는 `gh` 스타일 GitLab CLI이기도 합니다 (`tool <name>` 또는 `mr list` 같은 curated 명령). **MCP 등록은 필요 없습니다** — PAT를 설정하거나, `auth`를 실행한 뒤 `GITLAB_USE_OAUTH=true`를 설정하면 됩니다: [MCP 없이 CLI 사용하기](./docs/getting-started/cli-without-mcp.md). `setup --cursor` / `setup --claude`는 클라이언트 설정을 출력하고, `doctor`는 토큰·API URL·toolset·버전을 점검합니다. 전체 페이로드는 터미널에서 이 CLI로 읽습니다. MCP 응답은 대화에 남습니다. `GITLAB_MCP_COMPACT_RESULTS=true`(또는 `--compact-results`)를 켜면 큰 도구 응답이 미리보기와 CLI 명령으로 바뀝니다. 모든 값이 POSIX 셸, cmd.exe, PowerShell 어디서나 셸에 안전할 때만 응답에 `cli` 명령이 들어가고, 그렇지 않으면 셸 없이 실행할 argv 배열 `cli_argv`가 들어갑니다. Human CLI 자체는 compact 되지 않습니다. permission mode, toolsets, denied-tools regex, tool-policy는 MCP와 같습니다. destructive 도구와 `GITLAB_TOOL_POLICY_APPROVE` 도구는 `--yes`가 필요합니다. [Human CLI](./docs/getting-started/cli-arguments.md#human-cli)를 참고하세요.
|
|
321
321
|
|
|
322
322
|
> **세밀한 도구 필터링:** `GITLAB_PERMISSION_MODE=modify`로 생성/수정은 허용하고 모든 삭제 도구와
|
|
323
323
|
> 파괴적인 중단(teardown) 도구(`cancel_pipeline`, `cancel_pipeline_job`, `stop_environment`,
|
package/README.md
CHANGED
|
@@ -322,7 +322,7 @@ CLI arguments take precedence over environment variables.
|
|
|
322
322
|
|
|
323
323
|
`zereight-mcp-gitlab auth` is a subcommand (not an MCP server flag). It runs GitLab device flow and exits. See [CLI Arguments](./docs/getting-started/cli-arguments.md#auth).
|
|
324
324
|
|
|
325
|
-
The same binary is also a `gh`-style GitLab CLI (`tool <name>` or curated forms such as `mr list`). **No MCP registration is needed** — set a PAT, or run `auth` and set `GITLAB_USE_OAUTH=true`: see [CLI without MCP](./docs/getting-started/cli-without-mcp.md). `setup --cursor` / `setup --claude` prints client config; `doctor` checks token, API URL, toolsets, and version. Use it for the full payload in a terminal. MCP replies stay in the chat unless you set `GITLAB_MCP_COMPACT_RESULTS=true` (or `--compact-results`), which replaces oversized tool replies with a preview and a CLI command. Human CLI is never compacted. Same permission mode, toolsets, denied-tools regex, and tool-policy filters. Destructive tools and `GITLAB_TOOL_POLICY_APPROVE` tools need `--yes`. See [Human CLI](./docs/getting-started/cli-arguments.md#human-cli).
|
|
325
|
+
The same binary is also a `gh`-style GitLab CLI (`tool <name>` or curated forms such as `mr list`). **No MCP registration is needed** — set a PAT, or run `auth` and set `GITLAB_USE_OAUTH=true`: see [CLI without MCP](./docs/getting-started/cli-without-mcp.md). `setup --cursor` / `setup --claude` prints client config; `doctor` checks token, API URL, toolsets, and version. Use it for the full payload in a terminal. MCP replies stay in the chat unless you set `GITLAB_MCP_COMPACT_RESULTS=true` (or `--compact-results`), which replaces oversized tool replies with a preview and a CLI command. The reply carries a `cli` command only when every value is shell-safe on POSIX shells, cmd.exe, and PowerShell; otherwise it carries `cli_argv` (an argv array) to run without a shell. Human CLI is never compacted. Same permission mode, toolsets, denied-tools regex, and tool-policy filters. Destructive tools and `GITLAB_TOOL_POLICY_APPROVE` tools need `--yes`. See [Human CLI](./docs/getting-started/cli-arguments.md#human-cli).
|
|
326
326
|
|
|
327
327
|
> **Fine-grained tool filtering:** use `GITLAB_PERMISSION_MODE=modify` to allow create/update while
|
|
328
328
|
> blocking every delete tool and the destructive teardown tools (`cancel_pipeline`,
|
package/README.pt-BR.md
CHANGED
|
@@ -317,7 +317,7 @@ Os argumentos de CLI têm precedência sobre as variáveis de ambiente.
|
|
|
317
317
|
|
|
318
318
|
`zereight-mcp-gitlab auth` é um subcomando, não uma flag do servidor MCP. Ele executa o device flow do GitLab e encerra. Veja [Argumentos de CLI](./docs/getting-started/cli-arguments.md#auth).
|
|
319
319
|
|
|
320
|
-
O mesmo binário também é uma CLI do GitLab no estilo `gh` (`tool <name>` ou formas curadas como `mr list`). **Não é necessário registrar o MCP** — defina um PAT, ou execute `auth` e defina `GITLAB_USE_OAUTH=true`: veja [CLI sem MCP](./docs/getting-started/cli-without-mcp.md). `setup --cursor` / `setup --claude` imprime a configuração do cliente; `doctor` verifica token, URL da API, toolsets e versão. Use-o para ver a carga completa no terminal. As respostas do MCP permanecem no chat, a menos que você defina `GITLAB_MCP_COMPACT_RESULTS=true` (ou `--compact-results`), o que substitui respostas grandes de ferramentas por uma prévia e um comando CLI. A CLI humana nunca é compactada. Os mesmos filtros de permission mode, toolsets, denied-tools regex e tool-policy se aplicam. Ferramentas destrutivas e ferramentas com `GITLAB_TOOL_POLICY_APPROVE` exigem `--yes`. Consulte [CLI Humana](./docs/getting-started/cli-arguments.md#human-cli).
|
|
320
|
+
O mesmo binário também é uma CLI do GitLab no estilo `gh` (`tool <name>` ou formas curadas como `mr list`). **Não é necessário registrar o MCP** — defina um PAT, ou execute `auth` e defina `GITLAB_USE_OAUTH=true`: veja [CLI sem MCP](./docs/getting-started/cli-without-mcp.md). `setup --cursor` / `setup --claude` imprime a configuração do cliente; `doctor` verifica token, URL da API, toolsets e versão. Use-o para ver a carga completa no terminal. As respostas do MCP permanecem no chat, a menos que você defina `GITLAB_MCP_COMPACT_RESULTS=true` (ou `--compact-results`), o que substitui respostas grandes de ferramentas por uma prévia e um comando CLI. A resposta só traz um comando `cli` quando todos os valores são seguros para shell em shells POSIX, cmd.exe e PowerShell; caso contrário, traz `cli_argv` (um array argv) para executar sem shell. A CLI humana nunca é compactada. Os mesmos filtros de permission mode, toolsets, denied-tools regex e tool-policy se aplicam. Ferramentas destrutivas e ferramentas com `GITLAB_TOOL_POLICY_APPROVE` exigem `--yes`. Consulte [CLI Humana](./docs/getting-started/cli-arguments.md#human-cli).
|
|
321
321
|
|
|
322
322
|
> **Filtragem granular de ferramentas:** use `GITLAB_PERMISSION_MODE=modify` para permitir criação/atualização enquanto
|
|
323
323
|
> bloqueia todas as ferramentas de exclusão e as ferramentas destrutivas de teardown (`cancel_pipeline`,
|
package/README.zh-CN.md
CHANGED
|
@@ -317,7 +317,7 @@ CLI 参数优先于环境变量。
|
|
|
317
317
|
|
|
318
318
|
`zereight-mcp-gitlab auth` 是子命令,不是 MCP 服务器参数。它运行 GitLab device flow 后退出。参见 [CLI 参数](./docs/getting-started/cli-arguments.md#auth)。
|
|
319
319
|
|
|
320
|
-
同一二进制也是 `gh` 风格的 GitLab CLI(`tool <name>`,或 `mr list` 这类 curated 命令)。**无需注册 MCP**——设置 PAT,或运行 `auth` 后设置 `GITLAB_USE_OAUTH=true`:参见 [无需 MCP 使用 CLI](./docs/getting-started/cli-without-mcp.md)。`setup --cursor` / `setup --claude` 会打印客户端配置;`doctor` 检查 token、API URL、toolset 和版本。完整结果在终端用 CLI 查看。MCP 回复仍进入对话。设置 `GITLAB_MCP_COMPACT_RESULTS=true`(或 `--compact-results`)后,过大的工具回复会变成预览加上 CLI
|
|
320
|
+
同一二进制也是 `gh` 风格的 GitLab CLI(`tool <name>`,或 `mr list` 这类 curated 命令)。**无需注册 MCP**——设置 PAT,或运行 `auth` 后设置 `GITLAB_USE_OAUTH=true`:参见 [无需 MCP 使用 CLI](./docs/getting-started/cli-without-mcp.md)。`setup --cursor` / `setup --claude` 会打印客户端配置;`doctor` 检查 token、API URL、toolset 和版本。完整结果在终端用 CLI 查看。MCP 回复仍进入对话。设置 `GITLAB_MCP_COMPACT_RESULTS=true`(或 `--compact-results`)后,过大的工具回复会变成预览加上 CLI 命令。仅当每个值在 POSIX shell、cmd.exe 和 PowerShell 中都是 shell 安全的,回复才带 `cli` 命令;否则带 `cli_argv`(argv 数组),不经 shell 直接运行。Human CLI 本身不会被 compact。permission mode、toolsets、denied-tools regex 和 tool-policy 与 MCP 相同。破坏性工具以及 `GITLAB_TOOL_POLICY_APPROVE` 工具需要 `--yes`。参见 [Human CLI](./docs/getting-started/cli-arguments.md#human-cli)。
|
|
321
321
|
|
|
322
322
|
> **细粒度工具过滤:**使用 `GITLAB_PERMISSION_MODE=modify` 允许创建/更新,同时阻止所有删除工具以及
|
|
323
323
|
> 破坏性的拆除(teardown)工具(`cancel_pipeline`、`cancel_pipeline_job`、`stop_environment`、
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { omitInvalidStructuredContent } from "../utils/structured-content.js";
|
|
2
|
-
import {
|
|
2
|
+
import { buildToolReplay } from "./replay-command.js";
|
|
3
3
|
const PREVIEW_ARRAY_ITEMS = 5;
|
|
4
4
|
const PREVIEW_TEXT_CHARS = 1500;
|
|
5
5
|
const PREVIEW_JSON_CHARS = 2000;
|
|
@@ -24,14 +24,14 @@ export function compactMcpToolResult(input) {
|
|
|
24
24
|
if (text.length <= input.maxChars) {
|
|
25
25
|
return toolResultRecord(input.result);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const replay = buildToolReplay(input.toolName, input.args, input.inputSchema);
|
|
28
28
|
const compact = {
|
|
29
29
|
compact: true,
|
|
30
30
|
tool: input.toolName,
|
|
31
31
|
original_chars: text.length,
|
|
32
32
|
...buildPreview(text),
|
|
33
|
-
//
|
|
34
|
-
...
|
|
33
|
+
// `cli` or `cli_argv`; neither when the arguments cannot be replayed, and the preview stays.
|
|
34
|
+
...replay,
|
|
35
35
|
};
|
|
36
36
|
return {
|
|
37
37
|
content: [{ type: "text", text: JSON.stringify(compact) }],
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { readObjectSchema, snakeToKebab } from "./args.js";
|
|
2
2
|
const BINARY = "zereight-mcp-gitlab";
|
|
3
|
-
//
|
|
4
|
-
|
|
3
|
+
// The `cli` line must give the same argv in POSIX sh, cmd.exe (including the .cmd
|
|
4
|
+
// shim npm installs on Windows) and PowerShell, and they do not agree on quoting:
|
|
5
|
+
// cmd and PowerShell do not read single quotes as POSIX does, cmd expands `%` and
|
|
6
|
+
// `!` even inside double quotes, and PowerShell reads `$`, backticks, and Unicode
|
|
7
|
+
// quote and dash look-alikes. So no value is escaped. A token goes in the line bare
|
|
8
|
+
// or in double quotes, made only of characters none of the three treat specially;
|
|
9
|
+
// for any other value the reply carries the argv (`cli_argv`) instead.
|
|
10
|
+
const BARE_WORD = /^[A-Za-z0-9._:/=+-]+$/;
|
|
11
|
+
const DOUBLE_QUOTED_WORD = /^[A-Za-z0-9 ._:/=+,-]+$/;
|
|
12
|
+
const PORTABLE_LINE = /^[A-Za-z0-9 ._:/=+,"-]+$/;
|
|
5
13
|
const TOOL_NAME = /^[a-z][a-z0-9_]*$/;
|
|
6
14
|
const ARGUMENT_NAME = /^[a-z][a-z0-9_]*$/;
|
|
7
15
|
const LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
@@ -17,18 +25,28 @@ export const SECRET_ARGUMENT_NAMES = new Set([
|
|
|
17
25
|
"authorization",
|
|
18
26
|
]);
|
|
19
27
|
/**
|
|
20
|
-
* Builds the `zereight-mcp-gitlab tool ...`
|
|
21
|
-
* undefined when
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* the same argv, and names such as `api_url` would then change its configuration.
|
|
28
|
+
* Builds the `zereight-mcp-gitlab tool ...` replay for a compacted reply, or returns
|
|
29
|
+
* undefined when the arguments cannot be replayed. Only keys that the tool's input
|
|
30
|
+
* schema declares become flags; the CLI reads any other flag from the same argv, and
|
|
31
|
+
* names such as `api_url` would then change its configuration.
|
|
25
32
|
*/
|
|
26
|
-
export function
|
|
33
|
+
export function buildToolReplay(toolName, args, inputSchema) {
|
|
34
|
+
const words = buildReplayWords(toolName, args, inputSchema);
|
|
35
|
+
if (words === undefined) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
const cli = portableCommand(words);
|
|
39
|
+
if (cli !== undefined) {
|
|
40
|
+
return { cli };
|
|
41
|
+
}
|
|
42
|
+
return { cli_argv: words.map(word => word.prefix + word.value) };
|
|
43
|
+
}
|
|
44
|
+
function buildReplayWords(toolName, args, inputSchema) {
|
|
27
45
|
if (!TOOL_NAME.test(toolName)) {
|
|
28
46
|
return undefined;
|
|
29
47
|
}
|
|
30
48
|
const declared = new Set(Object.keys(readObjectSchema(inputSchema).properties ?? {}));
|
|
31
|
-
const
|
|
49
|
+
const words = [BINARY, "tool", toolName].map(plainWord);
|
|
32
50
|
const nested = {};
|
|
33
51
|
if (args !== undefined) {
|
|
34
52
|
for (const key of Object.keys(args)) {
|
|
@@ -48,16 +66,16 @@ export function buildToolReplayCommand(toolName, args, inputSchema) {
|
|
|
48
66
|
if (text.includes("\0") || LONE_SURROGATE.test(text)) {
|
|
49
67
|
return undefined;
|
|
50
68
|
}
|
|
51
|
-
|
|
69
|
+
words.push(...flagWords(snakeToKebab(key), text));
|
|
52
70
|
continue;
|
|
53
71
|
}
|
|
54
72
|
nested[key] = value;
|
|
55
73
|
}
|
|
56
74
|
}
|
|
57
75
|
if (Object.keys(nested).length > 0) {
|
|
58
|
-
|
|
76
|
+
words.push(plainWord("--args-json"), plainWord(JSON.stringify(nested)));
|
|
59
77
|
}
|
|
60
|
-
return
|
|
78
|
+
return words;
|
|
61
79
|
}
|
|
62
80
|
function shouldOmitReplayArgument(name) {
|
|
63
81
|
if (name.startsWith("_")) {
|
|
@@ -68,17 +86,35 @@ function shouldOmitReplayArgument(name) {
|
|
|
68
86
|
function isScalarReplayValue(value) {
|
|
69
87
|
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
70
88
|
}
|
|
71
|
-
function
|
|
89
|
+
function plainWord(value) {
|
|
90
|
+
return { prefix: "", value };
|
|
91
|
+
}
|
|
92
|
+
function flagWords(flag, value) {
|
|
72
93
|
// The CLI reads `--flag -x` as a missing value, so a value that starts with a
|
|
73
94
|
// dash goes in the `--flag=value` form, which it parses as one token.
|
|
74
95
|
if (value.startsWith("-")) {
|
|
75
|
-
return [`--${flag}
|
|
96
|
+
return [{ prefix: `--${flag}=`, value }];
|
|
76
97
|
}
|
|
77
|
-
return [`--${flag}
|
|
98
|
+
return [plainWord(`--${flag}`), plainWord(value)];
|
|
78
99
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
100
|
+
function portableCommand(words) {
|
|
101
|
+
const tokens = [];
|
|
102
|
+
for (const word of words) {
|
|
103
|
+
const text = portableWord(word.value);
|
|
104
|
+
if (text === undefined) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
tokens.push(word.prefix + text);
|
|
108
|
+
}
|
|
109
|
+
const line = tokens.join(" ");
|
|
110
|
+
return PORTABLE_LINE.test(line) ? line : undefined;
|
|
111
|
+
}
|
|
112
|
+
function portableWord(value) {
|
|
113
|
+
if (BARE_WORD.test(value)) {
|
|
81
114
|
return value;
|
|
82
115
|
}
|
|
83
|
-
|
|
116
|
+
if (DOUBLE_QUOTED_WORD.test(value)) {
|
|
117
|
+
return `"${value}"`;
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
84
120
|
}
|
package/package.json
CHANGED