@zereight/mcp-gitlab 1.0.60 → 1.0.62
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 +37 -20
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import path from "path";
|
|
|
16
16
|
import express from "express";
|
|
17
17
|
// Add type imports for proxy agents
|
|
18
18
|
import { Agent } from "http";
|
|
19
|
-
import { Agent as HttpsAgent } from
|
|
19
|
+
import { Agent as HttpsAgent } from "https";
|
|
20
20
|
import { URL } from "url";
|
|
21
21
|
import { GitLabForkSchema, GitLabReferenceSchema, GitLabRepositorySchema, GitLabIssueSchema, GitLabMergeRequestSchema, GitLabContentSchema, GitLabCreateUpdateFileResponseSchema, GitLabSearchResponseSchema, GitLabTreeSchema, GitLabCommitSchema, GitLabNamespaceSchema, GitLabNamespaceExistsResponseSchema, GitLabProjectSchema, GitLabUserSchema, GitLabUsersResponseSchema, GetUsersSchema, CreateOrUpdateFileSchema, SearchRepositoriesSchema, CreateRepositorySchema, GetFileContentsSchema, PushFilesSchema, CreateIssueSchema, CreateMergeRequestSchema, ForkRepositorySchema, CreateBranchSchema, GitLabDiffSchema, GetMergeRequestSchema, GetMergeRequestDiffsSchema, UpdateMergeRequestSchema, ListIssuesSchema, GetIssueSchema, UpdateIssueSchema, DeleteIssueSchema, GitLabIssueLinkSchema, GitLabIssueWithLinkDetailsSchema, ListIssueLinksSchema, ListIssueDiscussionsSchema, GetIssueLinkSchema, CreateIssueLinkSchema, DeleteIssueLinkSchema, ListNamespacesSchema, GetNamespaceSchema, VerifyNamespaceSchema, GetProjectSchema, ListProjectsSchema, ListLabelsSchema, GetLabelSchema, CreateLabelSchema, UpdateLabelSchema, DeleteLabelSchema, CreateNoteSchema, CreateMergeRequestThreadSchema, ListGroupProjectsSchema, ListWikiPagesSchema, GetWikiPageSchema, CreateWikiPageSchema, UpdateWikiPageSchema, DeleteWikiPageSchema, GitLabWikiPageSchema, GetRepositoryTreeSchema, GitLabTreeItemSchema, GitLabPipelineSchema, GetPipelineSchema, ListPipelinesSchema, ListPipelineJobsSchema, CreatePipelineSchema, RetryPipelineSchema, CancelPipelineSchema,
|
|
22
22
|
// pipeline job schemas
|
|
@@ -40,7 +40,7 @@ try {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
catch (error) {
|
|
43
|
-
|
|
43
|
+
// Warning: Could not read version from package.json - silently continue
|
|
44
44
|
}
|
|
45
45
|
const server = new Server({
|
|
46
46
|
name: "better-gitlab-mcp-server",
|
|
@@ -51,6 +51,7 @@ const server = new Server({
|
|
|
51
51
|
},
|
|
52
52
|
});
|
|
53
53
|
const GITLAB_PERSONAL_ACCESS_TOKEN = process.env.GITLAB_PERSONAL_ACCESS_TOKEN;
|
|
54
|
+
const IS_OLD = process.env.GITLAB_IS_OLD === "true";
|
|
54
55
|
const GITLAB_READ_ONLY_MODE = process.env.GITLAB_READ_ONLY_MODE === "true";
|
|
55
56
|
const USE_GITLAB_WIKI = process.env.USE_GITLAB_WIKI === "true";
|
|
56
57
|
const USE_MILESTONE = process.env.USE_MILESTONE === "true";
|
|
@@ -62,7 +63,7 @@ const HTTPS_PROXY = process.env.HTTPS_PROXY;
|
|
|
62
63
|
const NODE_TLS_REJECT_UNAUTHORIZED = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
|
|
63
64
|
const GITLAB_CA_CERT_PATH = process.env.GITLAB_CA_CERT_PATH;
|
|
64
65
|
let sslOptions = undefined;
|
|
65
|
-
if (NODE_TLS_REJECT_UNAUTHORIZED ===
|
|
66
|
+
if (NODE_TLS_REJECT_UNAUTHORIZED === "0") {
|
|
66
67
|
sslOptions = { rejectUnauthorized: false };
|
|
67
68
|
}
|
|
68
69
|
else if (GITLAB_CA_CERT_PATH) {
|
|
@@ -94,8 +95,13 @@ httpAgent = httpAgent || new Agent();
|
|
|
94
95
|
const DEFAULT_HEADERS = {
|
|
95
96
|
Accept: "application/json",
|
|
96
97
|
"Content-Type": "application/json",
|
|
97
|
-
Authorization: `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`,
|
|
98
98
|
};
|
|
99
|
+
if (IS_OLD) {
|
|
100
|
+
DEFAULT_HEADERS["Private-Token"] = `${GITLAB_PERSONAL_ACCESS_TOKEN}`;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
DEFAULT_HEADERS["Authorization"] = `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`;
|
|
104
|
+
}
|
|
99
105
|
// Create a default fetch configuration object that includes proxy agents if set
|
|
100
106
|
const DEFAULT_FETCH_CONFIG = {
|
|
101
107
|
headers: DEFAULT_HEADERS,
|
|
@@ -958,12 +964,20 @@ async function listDiscussions(projectId, resourceType, resourceIid, options = {
|
|
|
958
964
|
const discussions = await response.json();
|
|
959
965
|
// Extract pagination headers
|
|
960
966
|
const pagination = {
|
|
961
|
-
x_next_page: response.headers.get("x-next-page")
|
|
967
|
+
x_next_page: response.headers.get("x-next-page")
|
|
968
|
+
? parseInt(response.headers.get("x-next-page"))
|
|
969
|
+
: null,
|
|
962
970
|
x_page: response.headers.get("x-page") ? parseInt(response.headers.get("x-page")) : undefined,
|
|
963
|
-
x_per_page: response.headers.get("x-per-page")
|
|
964
|
-
|
|
971
|
+
x_per_page: response.headers.get("x-per-page")
|
|
972
|
+
? parseInt(response.headers.get("x-per-page"))
|
|
973
|
+
: undefined,
|
|
974
|
+
x_prev_page: response.headers.get("x-prev-page")
|
|
975
|
+
? parseInt(response.headers.get("x-prev-page"))
|
|
976
|
+
: null,
|
|
965
977
|
x_total: response.headers.get("x-total") ? parseInt(response.headers.get("x-total")) : null,
|
|
966
|
-
x_total_pages: response.headers.get("x-total-pages")
|
|
978
|
+
x_total_pages: response.headers.get("x-total-pages")
|
|
979
|
+
? parseInt(response.headers.get("x-total-pages"))
|
|
980
|
+
: null,
|
|
967
981
|
};
|
|
968
982
|
return PaginatedDiscussionsResponseSchema.parse({
|
|
969
983
|
items: discussions,
|
|
@@ -2051,11 +2065,17 @@ async function getRepositoryTree(options) {
|
|
|
2051
2065
|
queryParams.append("page_token", options.page_token);
|
|
2052
2066
|
if (options.pagination)
|
|
2053
2067
|
queryParams.append("pagination", options.pagination);
|
|
2068
|
+
const headers = {
|
|
2069
|
+
"Content-Type": "application/json",
|
|
2070
|
+
};
|
|
2071
|
+
if (IS_OLD) {
|
|
2072
|
+
headers["Private-Token"] = `${GITLAB_PERSONAL_ACCESS_TOKEN}`;
|
|
2073
|
+
}
|
|
2074
|
+
else {
|
|
2075
|
+
headers["Authorization"] = `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`;
|
|
2076
|
+
}
|
|
2054
2077
|
const response = await fetch(`${GITLAB_API_URL}/projects/${encodeURIComponent(options.project_id)}/repository/tree?${queryParams.toString()}`, {
|
|
2055
|
-
headers
|
|
2056
|
-
Authorization: `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`,
|
|
2057
|
-
"Content-Type": "application/json",
|
|
2058
|
-
},
|
|
2078
|
+
headers,
|
|
2059
2079
|
});
|
|
2060
2080
|
if (response.status === 404) {
|
|
2061
2081
|
throw new Error("Repository or path not found");
|
|
@@ -2293,9 +2313,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
2293
2313
|
? tools1
|
|
2294
2314
|
: tools1.filter(tool => !milestoneToolNames.includes(tool.name));
|
|
2295
2315
|
// Toggle pipeline tools by USE_PIPELINE flag
|
|
2296
|
-
let tools = USE_PIPELINE
|
|
2297
|
-
? tools2
|
|
2298
|
-
: tools2.filter(tool => !pipelineToolNames.includes(tool.name));
|
|
2316
|
+
let tools = USE_PIPELINE ? tools2 : tools2.filter(tool => !pipelineToolNames.includes(tool.name));
|
|
2299
2317
|
// <<< START: Gemini 호환성을 위해 $schema 제거 >>>
|
|
2300
2318
|
tools = tools.map(tool => {
|
|
2301
2319
|
// inputSchema가 존재하고 객체인지 확인
|
|
@@ -2989,10 +3007,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
2989
3007
|
*/
|
|
2990
3008
|
async function runServer() {
|
|
2991
3009
|
try {
|
|
2992
|
-
console.error
|
|
2993
|
-
console.error
|
|
2994
|
-
console.error
|
|
2995
|
-
console.error
|
|
3010
|
+
// Server startup banner removed - inappropriate use of console.error for logging
|
|
3011
|
+
// Server version banner removed - inappropriate use of console.error for logging
|
|
3012
|
+
// API URL banner removed - inappropriate use of console.error for logging
|
|
3013
|
+
// Server startup banner removed - inappropriate use of console.error for logging
|
|
2996
3014
|
if (!SSE) {
|
|
2997
3015
|
const transport = new StdioServerTransport();
|
|
2998
3016
|
await server.connect(transport);
|
|
@@ -3023,7 +3041,6 @@ async function runServer() {
|
|
|
3023
3041
|
console.log(`Server is running on port ${PORT}`);
|
|
3024
3042
|
});
|
|
3025
3043
|
}
|
|
3026
|
-
console.error("GitLab MCP Server running on stdio");
|
|
3027
3044
|
}
|
|
3028
3045
|
catch (error) {
|
|
3029
3046
|
console.error("Error initializing server:", error);
|