@zereight/mcp-gitlab 2.3.15-next.174 → 2.3.15-next.175
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/index.js
CHANGED
|
@@ -95,6 +95,7 @@ import { getForwardedPublicBaseUrl, getForwardedRequestHost, } from "./utils/for
|
|
|
95
95
|
import { registerDownloadProxy } from "./downloads/proxy.js";
|
|
96
96
|
import { createDownloadToken } from "./utils/download-token.js";
|
|
97
97
|
import { loadRemoteHttpStack } from "./server/remote-http-stack.js";
|
|
98
|
+
import { createHttpErrorHandler } from "./server/http-error-handler.js";
|
|
98
99
|
import { determineTransportMode, TransportMode } from "./server/transport-mode.js";
|
|
99
100
|
import { formatPrometheusMetrics } from "./server/metrics.js";
|
|
100
101
|
import { SERVER_VERSION } from "./server/version.js";
|
|
@@ -11568,6 +11569,7 @@ async function startSSEServer() {
|
|
|
11568
11569
|
uptime: process.uptime(),
|
|
11569
11570
|
});
|
|
11570
11571
|
});
|
|
11572
|
+
app.use(createHttpErrorHandler(logger));
|
|
11571
11573
|
const httpServer = app.listen(Number(PORT), HOST, () => {
|
|
11572
11574
|
logger.info("GitLab MCP Server running with SSE transport");
|
|
11573
11575
|
logger.info(`${colorGreen}Endpoint: http://${HOST}:${PORT}/sse${colorReset}`);
|
|
@@ -12891,6 +12893,7 @@ async function startStreamableHTTPServer() {
|
|
|
12891
12893
|
message: "Method Not Allowed. Use GET, POST, or DELETE to communicate with the MCP server.",
|
|
12892
12894
|
});
|
|
12893
12895
|
});
|
|
12896
|
+
app.use(createHttpErrorHandler(logger));
|
|
12894
12897
|
// Start server
|
|
12895
12898
|
const httpServer = app.listen(Number(PORT), HOST, () => {
|
|
12896
12899
|
logger.info(`GitLab MCP Server running with Streamable HTTP transport`);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { STATUS_CODES } from "node:http";
|
|
2
|
+
const JSON_RPC_PARSE_ERROR_CODE = -32700;
|
|
3
|
+
const JSON_RPC_PARSE_ERROR_BODY = {
|
|
4
|
+
jsonrpc: "2.0",
|
|
5
|
+
error: {
|
|
6
|
+
code: JSON_RPC_PARSE_ERROR_CODE,
|
|
7
|
+
message: "Parse error",
|
|
8
|
+
},
|
|
9
|
+
id: null,
|
|
10
|
+
};
|
|
11
|
+
const BODY_PARSER_JSON_PARSE_TYPE = "entity.parse.failed";
|
|
12
|
+
const CLIENT_ERROR_MIN_STATUS = 400;
|
|
13
|
+
const SERVER_ERROR_MIN_STATUS = 500;
|
|
14
|
+
const MAX_HTTP_STATUS = 599;
|
|
15
|
+
function isObject(value) {
|
|
16
|
+
return typeof value === "object" && value !== null;
|
|
17
|
+
}
|
|
18
|
+
function readErrorType(error) {
|
|
19
|
+
if (isObject(error) && typeof error.type === "string" && error.type.length > 0) {
|
|
20
|
+
return error.type;
|
|
21
|
+
}
|
|
22
|
+
if (error instanceof Error && error.name.length > 0) {
|
|
23
|
+
return error.name;
|
|
24
|
+
}
|
|
25
|
+
return "Error";
|
|
26
|
+
}
|
|
27
|
+
function readHttpStatus(error) {
|
|
28
|
+
if (!isObject(error)) {
|
|
29
|
+
return SERVER_ERROR_MIN_STATUS;
|
|
30
|
+
}
|
|
31
|
+
for (const key of ["status", "statusCode"]) {
|
|
32
|
+
const value = error[key];
|
|
33
|
+
if (typeof value === "number" &&
|
|
34
|
+
Number.isInteger(value) &&
|
|
35
|
+
value >= CLIENT_ERROR_MIN_STATUS &&
|
|
36
|
+
value <= MAX_HTTP_STATUS) {
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return SERVER_ERROR_MIN_STATUS;
|
|
41
|
+
}
|
|
42
|
+
function isJsonParseError(error) {
|
|
43
|
+
return isObject(error) && error.type === BODY_PARSER_JSON_PARSE_TYPE;
|
|
44
|
+
}
|
|
45
|
+
function clientErrorPhrase(status) {
|
|
46
|
+
const phrase = STATUS_CODES[status];
|
|
47
|
+
return typeof phrase === "string" ? phrase : "Request Error";
|
|
48
|
+
}
|
|
49
|
+
function responseBodyForError(error, status) {
|
|
50
|
+
if (isJsonParseError(error)) {
|
|
51
|
+
return JSON_RPC_PARSE_ERROR_BODY;
|
|
52
|
+
}
|
|
53
|
+
if (status >= SERVER_ERROR_MIN_STATUS) {
|
|
54
|
+
return { error: "Internal server error" };
|
|
55
|
+
}
|
|
56
|
+
return { error: clientErrorPhrase(status) };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Express 5.3's default handler logs `console.error(err)`. body-parser's JSON
|
|
60
|
+
* SyntaxError carries the raw request on `err.body`, so that path prints
|
|
61
|
+
* credentials that pino redaction never sees. `stdSerializers.err` would copy
|
|
62
|
+
* the same field. Log type/status only, and never `next(err)`.
|
|
63
|
+
*/
|
|
64
|
+
export function createHttpErrorHandler(logger) {
|
|
65
|
+
return function httpErrorHandler(err, req, res, _next) {
|
|
66
|
+
const type = readErrorType(err);
|
|
67
|
+
const status = readHttpStatus(err);
|
|
68
|
+
const fields = { type, status };
|
|
69
|
+
if (typeof req.method === "string") {
|
|
70
|
+
fields.method = req.method;
|
|
71
|
+
}
|
|
72
|
+
if (typeof req.path === "string") {
|
|
73
|
+
fields.path = req.path;
|
|
74
|
+
}
|
|
75
|
+
if (status >= SERVER_ERROR_MIN_STATUS) {
|
|
76
|
+
logger.error(fields, "HTTP request error");
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
logger.warn(fields, "HTTP request error");
|
|
80
|
+
}
|
|
81
|
+
if (res.headersSent) {
|
|
82
|
+
if (!res.writableEnded) {
|
|
83
|
+
res.end();
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
res.status(isJsonParseError(err) ? 400 : status).json(responseBodyForError(err, status));
|
|
88
|
+
};
|
|
89
|
+
}
|
package/build/utils/logger.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { pino } from "pino";
|
|
2
|
+
import { pino, destination, stdSerializers, } from "pino";
|
|
3
3
|
import { redactUrlSecretsInError, redactUrlSecretsInLogLine } from "./redact-url.js";
|
|
4
4
|
const require = createRequire(import.meta.url);
|
|
5
5
|
const REDACT_PATHS = [
|
|
@@ -60,7 +60,7 @@ function loadPrettifier() {
|
|
|
60
60
|
return prettyModule.prettyFactory({ colorize: true, levelFirst: true });
|
|
61
61
|
}
|
|
62
62
|
function createAsyncStderr() {
|
|
63
|
-
return
|
|
63
|
+
return destination({
|
|
64
64
|
dest: STDERR_FD,
|
|
65
65
|
sync: false,
|
|
66
66
|
minLength: ASYNC_LOG_MIN_LENGTH,
|
|
@@ -123,7 +123,7 @@ export function flushBufferedLogs(logger) {
|
|
|
123
123
|
* that the line redaction cannot recognize.
|
|
124
124
|
*/
|
|
125
125
|
export function serializeLoggedError(error) {
|
|
126
|
-
return
|
|
126
|
+
return stdSerializers.err(redactUrlSecretsInError(error));
|
|
127
127
|
}
|
|
128
128
|
// Keys whose error pino or pino-pretty prints even though no serializer runs on it.
|
|
129
129
|
const LOGGED_ERROR_KEYS = ["err", "error"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zereight/mcp-gitlab",
|
|
3
|
-
"version": "2.3.15-next.
|
|
3
|
+
"version": "2.3.15-next.175",
|
|
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": [
|