@jmrp.io/gitlab-mcp-server 3.0.0 → 3.2.0
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/LICENSE +21 -0
- package/README.md +5 -3
- package/THIRD_PARTY_NOTICES +7584 -0
- package/cli.js +87 -16
- package/package.json +10 -8
package/cli.js
CHANGED
|
@@ -2,17 +2,54 @@
|
|
|
2
2
|
// cli.js resolves the prebuilt gitlab-mcp-server binary for the current
|
|
3
3
|
// platform and hands control to it. The binary ships inside a per-platform
|
|
4
4
|
// optional dependency (see the package's optionalDependencies); npm installs
|
|
5
|
-
// only the one whose os/cpu match, and this launcher
|
|
5
|
+
// only the one whose os/cpu match, and this launcher runs it.
|
|
6
6
|
//
|
|
7
7
|
// It is a thin shim on purpose. The server speaks MCP over stdio, so stdio is
|
|
8
8
|
// inherited untouched; argv is forwarded verbatim; the child's exit code and
|
|
9
9
|
// terminating signal are mirrored so `npx` callers and process supervisors see
|
|
10
10
|
// the real outcome.
|
|
11
|
+
//
|
|
12
|
+
// The one thing a shim cannot leave to the operating system is stopping the
|
|
13
|
+
// server. A client or a supervisor signals the process it started, which is
|
|
14
|
+
// this launcher, or npm under npx, and a signal sent to one process never
|
|
15
|
+
// reaches its children. So the launcher waits for the server in the event loop
|
|
16
|
+
// rather than blocking in spawnSync, where no handler of its own could run,
|
|
17
|
+
// and on POSIX:
|
|
18
|
+
//
|
|
19
|
+
// - SIGTERM, SIGINT and SIGHUP are passed on to the server, which then runs
|
|
20
|
+
// its own shutdown (and in HTTP mode its drain) instead of being orphaned;
|
|
21
|
+
// - under npm (npx, or an npm script) it also watches its parent. A signal
|
|
22
|
+
// sent to npx stops at npm's shell: npm passes it to the `sh -c` it runs
|
|
23
|
+
// this launcher through, the shell dies, and the launcher is reparented
|
|
24
|
+
// without ever being signalled. Its parent changing is how it learns that,
|
|
25
|
+
// and it then sends the server SIGTERM. Started any other way, the parent
|
|
26
|
+
// is the client or a shell, and a server deliberately left running after
|
|
27
|
+
// it (an HTTP server put in the background) is not stopped.
|
|
28
|
+
//
|
|
29
|
+
// On Windows neither applies, and the launcher does what it always did. There
|
|
30
|
+
// are no POSIX signals there: Ctrl+C and closing the console reach every
|
|
31
|
+
// process attached to the console, the server included, which shuts down on
|
|
32
|
+
// its own, whereas child.kill would end it outright before it could; and a
|
|
33
|
+
// process whose parent exits keeps that parent's id, so there is no change to
|
|
34
|
+
// watch.
|
|
11
35
|
"use strict";
|
|
12
36
|
|
|
13
|
-
const {
|
|
37
|
+
const { spawn } = require("node:child_process");
|
|
38
|
+
const { writeSync } = require("node:fs");
|
|
14
39
|
const os = require("node:os");
|
|
15
40
|
|
|
41
|
+
// The signals passed on to the server, which decides what each does: SIGTERM
|
|
42
|
+
// and SIGINT start its shutdown, and SIGHUP ends it as it would end the binary
|
|
43
|
+
// run directly. A Ctrl+C in a terminal already reaches the server through the
|
|
44
|
+
// process group, so it sees that SIGINT twice; its handler starts the shutdown
|
|
45
|
+
// on the first and ignores the rest.
|
|
46
|
+
const FORWARDED = process.platform === "win32" ? [] : ["SIGTERM", "SIGINT", "SIGHUP"];
|
|
47
|
+
|
|
48
|
+
// How often the parent is checked under npm. A second is the longest the
|
|
49
|
+
// server outlives npm's shell, and the check costs nothing: the timer is
|
|
50
|
+
// unref'd, so it never keeps the launcher alive by itself.
|
|
51
|
+
const PARENT_POLL_MS = 1000;
|
|
52
|
+
|
|
16
53
|
// platformKey maps Node's platform/arch names to the per-platform package
|
|
17
54
|
// suffix. The suffixes follow Node's vocabulary (win32, x64), not Go's
|
|
18
55
|
// (windows, amd64); the release generator translates when it builds each
|
|
@@ -84,22 +121,56 @@ if (!binary) {
|
|
|
84
121
|
|
|
85
122
|
const env = { ...process.env };
|
|
86
123
|
|
|
87
|
-
|
|
124
|
+
// The handlers are installed before the server starts, so a signal that
|
|
125
|
+
// arrives while it is starting is passed on rather than ending the launcher
|
|
126
|
+
// with the server left behind. Node runs a handler on a later turn of the
|
|
127
|
+
// event loop, by which time `child` is set.
|
|
128
|
+
let child = null;
|
|
129
|
+
for (const signal of FORWARDED) {
|
|
130
|
+
process.on(signal, () => child.kill(signal));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
child = spawn(binary, process.argv.slice(2), {
|
|
88
134
|
stdio: "inherit",
|
|
89
135
|
env,
|
|
90
136
|
});
|
|
91
137
|
|
|
92
|
-
|
|
93
|
-
|
|
138
|
+
// npm sets npm_lifecycle_event for whatever it runs, npx included ("npx"),
|
|
139
|
+
// and runs it through a shell whose death is the only sign the launcher gets
|
|
140
|
+
// that npm was told to stop. The parent is read once, now, and polled.
|
|
141
|
+
if (FORWARDED.length > 0 && process.env.npm_lifecycle_event) {
|
|
142
|
+
const parent = process.ppid;
|
|
143
|
+
const watch = setInterval(() => {
|
|
144
|
+
if (process.ppid === parent) return;
|
|
145
|
+
clearInterval(watch);
|
|
146
|
+
child.kill("SIGTERM");
|
|
147
|
+
}, PARENT_POLL_MS);
|
|
148
|
+
watch.unref();
|
|
94
149
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
150
|
+
|
|
151
|
+
child.on("error", (err) => {
|
|
152
|
+
// Emitted when the binary could not be started, and, rarely, when a signal
|
|
153
|
+
// could not be delivered to it. Only the first ends the launcher here: a
|
|
154
|
+
// server that is running still ends with an "exit" event, mirrored below.
|
|
155
|
+
if (child.pid === undefined) fail(`failed to start the binary: ${err.message}`);
|
|
156
|
+
// Written to the descriptor directly: process.stderr would switch the pipe
|
|
157
|
+
// the server shares into non-blocking mode under its feet.
|
|
158
|
+
writeSync(2, `gitlab-mcp-server: ${err.message}\n`);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
child.on("exit", (code, signal) => {
|
|
162
|
+
// A child killed by a signal reports null status and a signal name. Re-raise
|
|
163
|
+
// it so the launcher dies the same way rather than masking a SIGINT as exit
|
|
164
|
+
// 0. The handler that would pass it on goes first, or the launcher would
|
|
165
|
+
// catch its own signal and send it to a server that is already gone.
|
|
166
|
+
if (signal) {
|
|
167
|
+
process.removeAllListeners(signal);
|
|
168
|
+
process.kill(process.pid, signal);
|
|
169
|
+
// If the re-raise did not terminate us (signal ignored, or no default
|
|
170
|
+
// disposition), exit with the conventional 128+signal code so the caller
|
|
171
|
+
// still sees the child's terminating signal rather than a bare failure.
|
|
172
|
+
const signum = os.constants.signals[signal];
|
|
173
|
+
process.exit(signum ? 128 + signum : 1);
|
|
174
|
+
}
|
|
175
|
+
process.exit(code === null ? 1 : code);
|
|
176
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jmrp.io/gitlab-mcp-server",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"mcpName": "io.github.jmrplens/gitlab-mcp-server",
|
|
5
5
|
"description": "Model Context Protocol (MCP) server exposing GitLab REST v4 and GraphQL as tools for AI assistants. Runs as a local binary over stdio or HTTP.",
|
|
6
6
|
"keywords": [
|
|
@@ -29,15 +29,17 @@
|
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"cli.js",
|
|
32
|
-
"README.md"
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"THIRD_PARTY_NOTICES"
|
|
33
35
|
],
|
|
34
36
|
"optionalDependencies": {
|
|
35
|
-
"@jmrp.io/gitlab-mcp-server-linux-x64": "3.
|
|
36
|
-
"@jmrp.io/gitlab-mcp-server-linux-arm64": "3.
|
|
37
|
-
"@jmrp.io/gitlab-mcp-server-darwin-x64": "3.
|
|
38
|
-
"@jmrp.io/gitlab-mcp-server-darwin-arm64": "3.
|
|
39
|
-
"@jmrp.io/gitlab-mcp-server-win32-x64": "3.
|
|
40
|
-
"@jmrp.io/gitlab-mcp-server-win32-arm64": "3.
|
|
37
|
+
"@jmrp.io/gitlab-mcp-server-linux-x64": "3.2.0",
|
|
38
|
+
"@jmrp.io/gitlab-mcp-server-linux-arm64": "3.2.0",
|
|
39
|
+
"@jmrp.io/gitlab-mcp-server-darwin-x64": "3.2.0",
|
|
40
|
+
"@jmrp.io/gitlab-mcp-server-darwin-arm64": "3.2.0",
|
|
41
|
+
"@jmrp.io/gitlab-mcp-server-win32-x64": "3.2.0",
|
|
42
|
+
"@jmrp.io/gitlab-mcp-server-win32-arm64": "3.2.0"
|
|
41
43
|
},
|
|
42
44
|
"engines": {
|
|
43
45
|
"node": ">=18"
|