@wanadev/mcp-gitlab 1.0.5 → 1.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/dist/client.d.ts +5 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +331 -171
- package/dist/client.js.map +1 -1
- package/dist/graphql.d.ts +56 -0
- package/dist/graphql.d.ts.map +1 -0
- package/dist/graphql.js +615 -0
- package/dist/graphql.js.map +1 -0
- package/dist/index.js +93 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12,39 +12,111 @@ import { registerIssueTools } from "./tools/issues.js";
|
|
|
12
12
|
import { registerMilestoneTools } from "./tools/milestones.js";
|
|
13
13
|
import { registerMergeRequestTools } from "./tools/merge_requests.js";
|
|
14
14
|
import { registerUtilTools } from "./tools/utils.js";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
const SETUP_MESSAGE = `GITLAB_TOKEN is not set. The GitLab MCP server needs a Personal Access Token to connect.
|
|
16
|
+
|
|
17
|
+
Setup steps:
|
|
18
|
+
1. Go to GitLab > Settings > Access Tokens
|
|
19
|
+
2. Create a token with the "api" scope
|
|
20
|
+
3. Set it as an environment variable:
|
|
21
|
+
- Linux/macOS: export GITLAB_TOKEN=glpat-xxxx (add to ~/.bashrc or ~/.zshrc)
|
|
22
|
+
- Windows: set GITLAB_TOKEN=glpat-xxxx (or use System Environment Variables)
|
|
23
|
+
4. Restart Claude Code or Claude Desktop
|
|
24
|
+
|
|
25
|
+
Tell the user these steps in their language. Be friendly and concise.`;
|
|
25
26
|
async function main() {
|
|
26
|
-
const token =
|
|
27
|
+
const token = process.env["GITLAB_TOKEN"] ?? "";
|
|
27
28
|
const baseUrl = process.env["GITLAB_BASE_URL"] ?? "https://gitlab.com";
|
|
28
29
|
const readOnly = process.env["GITLAB_READ_ONLY"] === "true";
|
|
29
|
-
const client = new GitLabClient({ baseUrl, token, readOnly });
|
|
30
30
|
const server = new McpServer({
|
|
31
31
|
name: pkg.name,
|
|
32
32
|
version: pkg.version,
|
|
33
33
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
if (!token) {
|
|
35
|
+
// No token: register a single setup tool that guides the user
|
|
36
|
+
console.error("@wanadev/mcp-gitlab: GITLAB_TOKEN not set — starting in setup mode");
|
|
37
|
+
server.registerTool("gitlab_setup", {
|
|
38
|
+
description: "GitLab MCP is not configured yet. Call this tool to show the user how to set up their GitLab token.",
|
|
39
|
+
inputSchema: {},
|
|
40
|
+
annotations: { readOnlyHint: true },
|
|
41
|
+
}, async () => {
|
|
42
|
+
return { content: [{ type: "text", text: SETUP_MESSAGE }] };
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Validate base URL
|
|
47
|
+
try {
|
|
48
|
+
new URL(baseUrl);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
console.error(`@wanadev/mcp-gitlab: invalid GITLAB_BASE_URL "${baseUrl}"`);
|
|
52
|
+
server.registerTool("gitlab_setup", {
|
|
53
|
+
description: "GitLab MCP has an invalid GITLAB_BASE_URL. Call this tool to help the user fix it.",
|
|
54
|
+
inputSchema: {},
|
|
55
|
+
annotations: { readOnlyHint: true },
|
|
56
|
+
}, async () => {
|
|
57
|
+
return { content: [{ type: "text", text: `GITLAB_BASE_URL is invalid: "${baseUrl}". It must be a valid URL (e.g. https://gitlab.com or https://gitlab.mycompany.com). Tell the user to fix it in their language and restart.` }] };
|
|
58
|
+
});
|
|
59
|
+
const transport = new StdioServerTransport();
|
|
60
|
+
await server.connect(transport);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
// Token + URL present: validate connection then register tools
|
|
64
|
+
const client = new GitLabClient({ baseUrl, token, readOnly });
|
|
65
|
+
// Test the connection at startup and detect access level
|
|
66
|
+
try {
|
|
67
|
+
const user = await client.getCurrentUser();
|
|
68
|
+
const mode = readOnly ? "read-only (forced by GITLAB_READ_ONLY=true)" : "read-write";
|
|
69
|
+
console.error(`@wanadev/mcp-gitlab: connected as @${user.username} on ${baseUrl} [${mode}]`);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
const msg = error.message;
|
|
73
|
+
if (msg.includes("401")) {
|
|
74
|
+
console.error("@wanadev/mcp-gitlab: GITLAB_TOKEN is invalid or expired. Tools will register but all calls will fail.");
|
|
75
|
+
}
|
|
76
|
+
else if (msg.includes("403")) {
|
|
77
|
+
console.error("@wanadev/mcp-gitlab: GITLAB_TOKEN has insufficient permissions. Make sure it has the 'api' scope.");
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
console.error(`@wanadev/mcp-gitlab: connection check failed — ${msg}`);
|
|
81
|
+
console.error("Tools will still register but API calls may fail. Check your GITLAB_TOKEN and GITLAB_BASE_URL.");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
registerEpicTools(server, client);
|
|
85
|
+
registerIssueTools(server, client);
|
|
86
|
+
registerMilestoneTools(server, client);
|
|
87
|
+
registerMergeRequestTools(server, client);
|
|
88
|
+
registerUtilTools(server, client);
|
|
89
|
+
}
|
|
39
90
|
const transport = new StdioServerTransport();
|
|
40
91
|
await server.connect(transport);
|
|
41
|
-
console.error(
|
|
42
|
-
if (
|
|
43
|
-
console.error("
|
|
92
|
+
console.error(`@wanadev/mcp-gitlab v${pkg.version} started (stdio)`);
|
|
93
|
+
if (!token) {
|
|
94
|
+
console.error("Setup mode — run gitlab_setup for configuration help");
|
|
95
|
+
}
|
|
96
|
+
else if (readOnly) {
|
|
97
|
+
console.error("Read-only mode active (GITLAB_READ_ONLY=true)");
|
|
98
|
+
}
|
|
99
|
+
// Non-blocking update check
|
|
100
|
+
checkForUpdate(pkg.name, pkg.version).catch(() => { });
|
|
101
|
+
}
|
|
102
|
+
async function checkForUpdate(name, currentVersion) {
|
|
103
|
+
try {
|
|
104
|
+
const res = await fetch(`https://registry.npmjs.org/${name}/latest`, {
|
|
105
|
+
signal: AbortSignal.timeout(3_000),
|
|
106
|
+
});
|
|
107
|
+
if (!res.ok)
|
|
108
|
+
return;
|
|
109
|
+
const data = (await res.json());
|
|
110
|
+
if (data.version && data.version !== currentVersion) {
|
|
111
|
+
console.error(`@wanadev/mcp-gitlab: update available ${currentVersion} → ${data.version} (npx @wanadev/mcp-gitlab@latest)`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// Silently ignore — not critical
|
|
44
116
|
}
|
|
45
117
|
}
|
|
46
118
|
main().catch((error) => {
|
|
47
|
-
console.error("
|
|
119
|
+
console.error("Fatal error:", error);
|
|
48
120
|
process.exit(1);
|
|
49
121
|
});
|
|
50
122
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAsC,CAAC;AAC5H,OAAO,EAAE,YAAY,EAAE,MAA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