@zereight/mcp-gitlab 2.3.12-next.162 → 2.3.12-next.163
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/config.js +2 -0
- package/build/index.js +2 -2
- package/build/utils/version-check.js +23 -167
- package/package.json +1 -1
package/build/config.js
CHANGED
|
@@ -62,6 +62,8 @@ export const USE_MILESTONE = USE_MILESTONE_RAW === "true";
|
|
|
62
62
|
export const USE_PIPELINE_RAW = getConfig("use-pipeline", "USE_PIPELINE");
|
|
63
63
|
export const USE_PIPELINE = USE_PIPELINE_RAW === "true";
|
|
64
64
|
export const GITLAB_DISABLE_VERSION_CHECK = getConfig("disable-version-check", "GITLAB_DISABLE_VERSION_CHECK") === "true";
|
|
65
|
+
/** https registry the startup version check queries instead of registry.npmjs.org. */
|
|
66
|
+
export const GITLAB_VERSION_CHECK_REGISTRY = process.env.GITLAB_VERSION_CHECK_REGISTRY;
|
|
65
67
|
// ---------------------------------------------------------------------------
|
|
66
68
|
// Tool filtering
|
|
67
69
|
// ---------------------------------------------------------------------------
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { cliArgs, getConfig, ENABLE_DYNAMIC_API_URL, ENABLE_DYNAMIC_PROJECT_SCOPE, ENABLE_STRICT_PROJECT_SCOPE, GITLAB_AUTH_COOKIE_PATH, GITLAB_ALLOW_UNAUTHENTICATED_TOOL_DISCOVERY, GITLAB_CA_CERT_PATH, GITLAB_JOB_TOKEN, GITLAB_MCP_OAUTH, GITLAB_MCP_REQUEST_BODY_LIMIT, GITLAB_OAUTH_APP_ID, GITLAB_OAUTH_SCOPES, GITLAB_OAUTH_CALLBACK_PROXY, GITLAB_OAUTH_ALLOWED_REDIRECT_URIS_RAW, GITLAB_PERSONAL_ACCESS_TOKEN, GITLAB_POOL_MAX_SIZE, GITLAB_DISABLE_VERSION_CHECK, GITLAB_MASKING_ENABLED, GITLAB_MASKING_CONFIG, GITLAB_MASKING_POLICY_FILE, GITLAB_MASKING_WORKSPACE_DIR, GITLAB_PERMISSION_MODE, GITLAB_TOOLSETS_RAW, GITLAB_TOOLS_RAW, HOST, HTTP_PROXY, HTTPS_PROXY, IS_OLD, MCP_SERVER_URL, NODE_TLS_REJECT_UNAUTHORIZED, NO_PROXY, OAUTH_DISABLE_REFRESH_TOKEN, OAUTH_STATELESS_CLIENT_TTL_SECONDS, OAUTH_STATELESS_MODE, OAUTH_STATELESS_PENDING_TTL_SECONDS, OAUTH_STATELESS_SESSION_TTL_SECONDS, OAUTH_STATELESS_STORED_TTL_SECONDS, PORT, REMOTE_AUTHORIZATION, SESSION_TIMEOUT_SECONDS, SSE, STREAMABLE_HTTP, MCP_TRUST_PROXY, USE_GITLAB_WIKI, USE_MILESTONE, USE_OAUTH, USE_PIPELINE, GITLAB_TOOL_POLICY_APPROVE_RAW, GITLAB_TOOL_POLICY_HIDDEN_RAW, GITLAB_OAUTH_ALLOWED_GROUPS, GITLAB_MCP_COMPACT_RESULTS, GITLAB_MCP_COMPACT_RESULT_CHARS, GITLAB_MCP_COMPACT_TOOL_NAMES, GITLAB_TOOL_PROFILE, GITLAB_DOWNLOAD_DIR, buildDeprecatedEnvInput, } from "./config.js";
|
|
2
|
+
import { cliArgs, getConfig, ENABLE_DYNAMIC_API_URL, ENABLE_DYNAMIC_PROJECT_SCOPE, ENABLE_STRICT_PROJECT_SCOPE, GITLAB_AUTH_COOKIE_PATH, GITLAB_ALLOW_UNAUTHENTICATED_TOOL_DISCOVERY, GITLAB_CA_CERT_PATH, GITLAB_JOB_TOKEN, GITLAB_MCP_OAUTH, GITLAB_MCP_REQUEST_BODY_LIMIT, GITLAB_OAUTH_APP_ID, GITLAB_OAUTH_SCOPES, GITLAB_OAUTH_CALLBACK_PROXY, GITLAB_OAUTH_ALLOWED_REDIRECT_URIS_RAW, GITLAB_PERSONAL_ACCESS_TOKEN, GITLAB_POOL_MAX_SIZE, GITLAB_DISABLE_VERSION_CHECK, GITLAB_VERSION_CHECK_REGISTRY, GITLAB_MASKING_ENABLED, GITLAB_MASKING_CONFIG, GITLAB_MASKING_POLICY_FILE, GITLAB_MASKING_WORKSPACE_DIR, GITLAB_PERMISSION_MODE, GITLAB_TOOLSETS_RAW, GITLAB_TOOLS_RAW, HOST, HTTP_PROXY, HTTPS_PROXY, IS_OLD, MCP_SERVER_URL, NODE_TLS_REJECT_UNAUTHORIZED, NO_PROXY, OAUTH_DISABLE_REFRESH_TOKEN, OAUTH_STATELESS_CLIENT_TTL_SECONDS, OAUTH_STATELESS_MODE, OAUTH_STATELESS_PENDING_TTL_SECONDS, OAUTH_STATELESS_SESSION_TTL_SECONDS, OAUTH_STATELESS_STORED_TTL_SECONDS, PORT, REMOTE_AUTHORIZATION, SESSION_TIMEOUT_SECONDS, SSE, STREAMABLE_HTTP, MCP_TRUST_PROXY, USE_GITLAB_WIKI, USE_MILESTONE, USE_OAUTH, USE_PIPELINE, GITLAB_TOOL_POLICY_APPROVE_RAW, GITLAB_TOOL_POLICY_HIDDEN_RAW, GITLAB_OAUTH_ALLOWED_GROUPS, GITLAB_MCP_COMPACT_RESULTS, GITLAB_MCP_COMPACT_RESULT_CHARS, GITLAB_MCP_COMPACT_TOOL_NAMES, GITLAB_TOOL_PROFILE, GITLAB_DOWNLOAD_DIR, buildDeprecatedEnvInput, } from "./config.js";
|
|
3
3
|
import { getDeprecatedEnvWarnings } from "./deprecated-env.js";
|
|
4
4
|
/** True when the server is running in remote/network mode (SSE or StreamableHTTP transport). */
|
|
5
5
|
const IS_REMOTE = SSE || STREAMABLE_HTTP;
|
|
@@ -13006,7 +13006,7 @@ async function runServer() {
|
|
|
13006
13006
|
await initializeServerByTransportMode(transportMode);
|
|
13007
13007
|
if (!GITLAB_DISABLE_VERSION_CHECK) {
|
|
13008
13008
|
// Fire-and-forget: logs to stderr only, never blocks or fails startup.
|
|
13009
|
-
void checkForNewVersion(SERVER_VERSION).then(latestVersion => {
|
|
13009
|
+
void checkForNewVersion(SERVER_VERSION, undefined, GITLAB_VERSION_CHECK_REGISTRY).then(latestVersion => {
|
|
13010
13010
|
if (latestVersion) {
|
|
13011
13011
|
logger.warn(`A newer version of @zereight/mcp-gitlab is available: v${latestVersion} (current: v${SERVER_VERSION}). ` +
|
|
13012
13012
|
`Upgrade with \`brew upgrade zereight-mcp-gitlab\`, \`npx -y @zereight/mcp-gitlab@latest\`, or \`npm install -g @zereight/mcp-gitlab\`. ` +
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { promisify } from "node:util";
|
|
6
|
-
const execFileAsync = promisify(execFile);
|
|
7
1
|
const DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org";
|
|
8
2
|
const PACKAGE_LATEST_PATH = "@zereight/mcp-gitlab/latest";
|
|
9
3
|
const RELEASE_VERSION_PATTERN = /^\d+\.\d+\.\d+$/;
|
|
10
|
-
const AUTH_TOKEN_KEY_PATTERN = /^\/\/[-A-Za-z0-9.]+(?::\d+)?(?:\/[-A-Za-z0-9._]+)*\/:_authToken$/;
|
|
11
|
-
const NPMRC_ENV_PATTERN = /\$\{([A-Za-z_]\w*)\}/g;
|
|
12
4
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* string like "?tenant=a" would
|
|
17
|
-
* request reaching the intended
|
|
5
|
+
* An operator-set registry (`GITLAB_VERSION_CHECK_REGISTRY`) is only used when
|
|
6
|
+
* it parses as an https URL with a hostname and no userinfo. A query or
|
|
7
|
+
* fragment is rejected too: the package path is appended to this value with
|
|
8
|
+
* plain string concatenation below, so a query string like "?tenant=a" would
|
|
9
|
+
* swallow the appended path instead of the request reaching the intended
|
|
10
|
+
* endpoint.
|
|
18
11
|
*/
|
|
19
12
|
function isUsableRegistryUrl(registry) {
|
|
20
13
|
try {
|
|
21
14
|
const parsed = new URL(registry);
|
|
22
|
-
return ((
|
|
15
|
+
return (!/[?#]/.test(registry) &&
|
|
16
|
+
parsed.protocol === "https:" &&
|
|
23
17
|
parsed.hostname !== "" &&
|
|
18
|
+
parsed.username === "" &&
|
|
19
|
+
parsed.password === "" &&
|
|
24
20
|
parsed.search === "" &&
|
|
25
21
|
parsed.hash === "");
|
|
26
22
|
}
|
|
@@ -28,141 +24,6 @@ function isUsableRegistryUrl(registry) {
|
|
|
28
24
|
return false;
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
|
-
/** Runs `npm config get <key>` and returns the trimmed value, or null if unavailable/unset. */
|
|
32
|
-
async function npmConfigGet(key) {
|
|
33
|
-
try {
|
|
34
|
-
// On Windows "npm" resolves to npm.cmd, which execFile can't launch
|
|
35
|
-
// directly — route through cmd.exe instead. Command and args are fixed
|
|
36
|
-
// literals (only `key` varies, and only with our own constant inputs), so
|
|
37
|
-
// this doesn't open a shell-injection surface.
|
|
38
|
-
const isWindows = process.platform === "win32";
|
|
39
|
-
const { stdout } = await execFileAsync(isWindows ? "cmd.exe" : "npm", isWindows ? ["/d", "/s", "/c", "npm", "config", "get", key] : ["config", "get", key], { timeout: 5000, windowsHide: true });
|
|
40
|
-
const value = stdout.trim().replace(/\/$/, "");
|
|
41
|
-
return value && value !== "undefined" ? value : null;
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Resolves the npm registry to use, honoring `.npmrc` / `npm_config_registry`.
|
|
49
|
-
* Package-scoped config (`@zereight:registry`) takes precedence, matching how
|
|
50
|
-
* npm itself resolves the registry for a scoped package like this one.
|
|
51
|
-
*/
|
|
52
|
-
async function resolveConfiguredRegistry() {
|
|
53
|
-
const scoped = await npmConfigGet("@zereight:registry");
|
|
54
|
-
if (scoped)
|
|
55
|
-
return scoped;
|
|
56
|
-
const unscoped = await npmConfigGet("registry");
|
|
57
|
-
if (unscoped)
|
|
58
|
-
return unscoped;
|
|
59
|
-
return DEFAULT_NPM_REGISTRY;
|
|
60
|
-
}
|
|
61
|
-
function authTokenConfigKeys(registry) {
|
|
62
|
-
if (!isUsableRegistryUrl(registry))
|
|
63
|
-
return [];
|
|
64
|
-
const parsed = new URL(registry);
|
|
65
|
-
if (parsed.protocol !== "https:")
|
|
66
|
-
return [];
|
|
67
|
-
const keys = [];
|
|
68
|
-
let path = parsed.pathname.replace(/\/$/, "");
|
|
69
|
-
while (true) {
|
|
70
|
-
const key = `//${parsed.host}${path}/:_authToken`;
|
|
71
|
-
if (AUTH_TOKEN_KEY_PATTERN.test(key))
|
|
72
|
-
keys.push(key);
|
|
73
|
-
if (path === "")
|
|
74
|
-
break;
|
|
75
|
-
const slash = path.lastIndexOf("/");
|
|
76
|
-
path = slash <= 0 ? "" : path.slice(0, slash);
|
|
77
|
-
}
|
|
78
|
-
return keys;
|
|
79
|
-
}
|
|
80
|
-
async function npmrcCandidatePaths() {
|
|
81
|
-
const paths = [];
|
|
82
|
-
const configuredGlobal = process.env.NPM_CONFIG_GLOBALCONFIG;
|
|
83
|
-
const globalconfig = configuredGlobal || (await npmConfigGet("globalconfig"));
|
|
84
|
-
if (globalconfig)
|
|
85
|
-
paths.push(globalconfig);
|
|
86
|
-
paths.push(process.env.NPM_CONFIG_USERCONFIG ?? join(homedir(), ".npmrc"));
|
|
87
|
-
paths.push(join(process.cwd(), ".npmrc"));
|
|
88
|
-
return paths;
|
|
89
|
-
}
|
|
90
|
-
function unquoteNpmrcValue(value) {
|
|
91
|
-
if (value.length >= 2) {
|
|
92
|
-
const start = value[0];
|
|
93
|
-
const end = value[value.length - 1];
|
|
94
|
-
if ((start === '"' && end === '"') || (start === "'" && end === "'")) {
|
|
95
|
-
return value.slice(1, -1);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return value;
|
|
99
|
-
}
|
|
100
|
-
function expandNpmrcEnv(value) {
|
|
101
|
-
return value.replace(NPMRC_ENV_PATTERN, (_match, name) => process.env[name] ?? "");
|
|
102
|
-
}
|
|
103
|
-
function parseNpmrc(content) {
|
|
104
|
-
const entries = new Map();
|
|
105
|
-
for (const rawLine of content.split(/\r?\n/)) {
|
|
106
|
-
const line = rawLine.trim();
|
|
107
|
-
if (!line || line.startsWith("#") || line.startsWith(";"))
|
|
108
|
-
continue;
|
|
109
|
-
const separator = line.indexOf("=");
|
|
110
|
-
if (separator <= 0)
|
|
111
|
-
continue;
|
|
112
|
-
const key = line.slice(0, separator).trim();
|
|
113
|
-
const value = expandNpmrcEnv(unquoteNpmrcValue(line.slice(separator + 1).trim()));
|
|
114
|
-
entries.set(key, value);
|
|
115
|
-
}
|
|
116
|
-
return entries;
|
|
117
|
-
}
|
|
118
|
-
async function readNpmrcFile(path) {
|
|
119
|
-
try {
|
|
120
|
-
return parseNpmrc(await readFile(path, "utf8"));
|
|
121
|
-
}
|
|
122
|
-
catch {
|
|
123
|
-
return new Map();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Reads `//host[:port][/path]/:_authToken` from npmrc files, then walks up
|
|
128
|
-
* parent paths to `//host/:_authToken`, matching npm-registry-fetch.
|
|
129
|
-
* `npm config get` refuses to print protected auth keys, so this parses the
|
|
130
|
-
* files npm itself would consult instead of asking the CLI.
|
|
131
|
-
*/
|
|
132
|
-
async function resolveRegistryAuthToken(registry) {
|
|
133
|
-
const keys = authTokenConfigKeys(registry);
|
|
134
|
-
if (keys.length === 0)
|
|
135
|
-
return null;
|
|
136
|
-
const merged = new Map();
|
|
137
|
-
for (const path of await npmrcCandidatePaths()) {
|
|
138
|
-
const entries = await readNpmrcFile(path);
|
|
139
|
-
for (const [entryKey, value] of entries)
|
|
140
|
-
merged.set(entryKey, value);
|
|
141
|
-
}
|
|
142
|
-
for (const key of keys) {
|
|
143
|
-
const token = merged.get(key);
|
|
144
|
-
if (token)
|
|
145
|
-
return token;
|
|
146
|
-
}
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
149
|
-
function requestIsUnderRegistry(registry, requestUrl) {
|
|
150
|
-
try {
|
|
151
|
-
const parsedRegistry = new URL(registry);
|
|
152
|
-
const parsedRequest = new URL(requestUrl);
|
|
153
|
-
if (parsedRegistry.protocol !== "https:" || parsedRequest.protocol !== "https:")
|
|
154
|
-
return false;
|
|
155
|
-
if (parsedRegistry.origin !== parsedRequest.origin)
|
|
156
|
-
return false;
|
|
157
|
-
const basePath = parsedRegistry.pathname.replace(/\/$/, "");
|
|
158
|
-
if (basePath === "")
|
|
159
|
-
return true;
|
|
160
|
-
return parsedRequest.pathname === basePath || parsedRequest.pathname.startsWith(`${basePath}/`);
|
|
161
|
-
}
|
|
162
|
-
catch {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
27
|
function readVersionField(data) {
|
|
167
28
|
if (typeof data !== "object" || data === null)
|
|
168
29
|
return null;
|
|
@@ -183,24 +44,19 @@ export function isNewerVersion(candidate, current) {
|
|
|
183
44
|
}
|
|
184
45
|
return false;
|
|
185
46
|
}
|
|
186
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Looks up the latest published version anonymously: no `.npmrc`, npm config,
|
|
49
|
+
* or credentials are consulted. `registry` replaces the public registry only
|
|
50
|
+
* when it is a usable https URL.
|
|
51
|
+
*/
|
|
52
|
+
export async function fetchLatestVersion(fetchFn = fetch, timeoutMs = 3000, registry) {
|
|
187
53
|
try {
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
const headers = { accept: "application/json" };
|
|
192
|
-
const init = {
|
|
54
|
+
const configured = registry?.trim().replace(/\/$/, "");
|
|
55
|
+
const base = configured && isUsableRegistryUrl(configured) ? configured : DEFAULT_NPM_REGISTRY;
|
|
56
|
+
const response = await fetchFn(`${base}/${PACKAGE_LATEST_PATH}`, {
|
|
193
57
|
signal: AbortSignal.timeout(timeoutMs),
|
|
194
|
-
headers,
|
|
195
|
-
};
|
|
196
|
-
const token = await resolveRegistryAuthToken(registry).catch(() => null);
|
|
197
|
-
if (token && requestIsUnderRegistry(registry, registryLatestUrl)) {
|
|
198
|
-
headers.authorization = `Bearer ${token}`;
|
|
199
|
-
// Never follow redirects with a token attached — fetch would otherwise
|
|
200
|
-
// forward Authorization to a different origin.
|
|
201
|
-
init.redirect = "error";
|
|
202
|
-
}
|
|
203
|
-
const response = await fetchFn(registryLatestUrl, init);
|
|
58
|
+
headers: { accept: "application/json" },
|
|
59
|
+
});
|
|
204
60
|
if (!response.ok)
|
|
205
61
|
return null;
|
|
206
62
|
return readVersionField(await response.json());
|
|
@@ -212,10 +68,10 @@ export async function fetchLatestVersion(fetchFn = fetch, timeoutMs = 3000, reso
|
|
|
212
68
|
}
|
|
213
69
|
}
|
|
214
70
|
/** Returns the latest published version when it is newer than `currentVersion`, otherwise null. */
|
|
215
|
-
export async function checkForNewVersion(currentVersion, fetchFn = fetch) {
|
|
71
|
+
export async function checkForNewVersion(currentVersion, fetchFn = fetch, registry) {
|
|
216
72
|
if (!RELEASE_VERSION_PATTERN.test(currentVersion))
|
|
217
73
|
return null;
|
|
218
|
-
const latest = await fetchLatestVersion(fetchFn);
|
|
74
|
+
const latest = await fetchLatestVersion(fetchFn, 3000, registry);
|
|
219
75
|
if (!latest || !RELEASE_VERSION_PATTERN.test(latest))
|
|
220
76
|
return null;
|
|
221
77
|
return isNewerVersion(latest, currentVersion) ? latest : null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zereight/mcp-gitlab",
|
|
3
|
-
"version": "2.3.12-next.
|
|
3
|
+
"version": "2.3.12-next.163",
|
|
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": [
|