@structured-world/gitlab-mcp 12.0.3 → 13.0.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/README.md +45 -3
- package/README.md.in +43 -1
- package/dist/src/cli/plugin/build.d.ts +4 -1
- package/dist/src/cli/plugin/build.js +53 -10
- package/dist/src/cli/plugin/build.js.map +1 -1
- package/dist/src/cli/plugin/runtime.d.ts +1 -0
- package/dist/src/cli/plugin/runtime.js +79 -0
- package/dist/src/cli/plugin/runtime.js.map +1 -0
- package/dist/src/cli-utils.d.ts +0 -2
- package/dist/src/cli-utils.js +1 -5
- package/dist/src/cli-utils.js.map +1 -1
- package/dist/src/entities/context/output-schema.d.ts +13 -0
- package/dist/src/entities/context/output-schema.js +9 -0
- package/dist/src/entities/context/output-schema.js.map +1 -1
- package/dist/src/entities/context/types.d.ts +8 -0
- package/dist/src/entities/context/whoami.js +87 -9
- package/dist/src/entities/context/whoami.js.map +1 -1
- package/dist/src/entities/core/schema-readonly.d.ts +1 -1
- package/dist/src/entities/pipelines/artifact-path.d.ts +4 -0
- package/dist/src/entities/pipelines/artifact-path.js +41 -0
- package/dist/src/entities/pipelines/artifact-path.js.map +1 -0
- package/dist/src/entities/pipelines/artifact-window.d.ts +18 -0
- package/dist/src/entities/pipelines/artifact-window.js +187 -0
- package/dist/src/entities/pipelines/artifact-window.js.map +1 -0
- package/dist/src/entities/pipelines/artifact.d.ts +26 -0
- package/dist/src/entities/pipelines/artifact.js +148 -0
- package/dist/src/entities/pipelines/artifact.js.map +1 -0
- package/dist/src/entities/pipelines/registry.js +4 -1
- package/dist/src/entities/pipelines/registry.js.map +1 -1
- package/dist/src/entities/pipelines/schema-readonly.d.ts +7 -0
- package/dist/src/entities/pipelines/schema-readonly.js +37 -0
- package/dist/src/entities/pipelines/schema-readonly.js.map +1 -1
- package/dist/src/entities/refs/protection.d.ts +15 -0
- package/dist/src/entities/refs/protection.js +124 -0
- package/dist/src/entities/refs/protection.js.map +1 -0
- package/dist/src/entities/refs/registry.js +10 -8
- package/dist/src/entities/refs/registry.js.map +1 -1
- package/dist/src/entities/refs/schema.d.ts +11 -11
- package/dist/src/entities/refs/schema.js +22 -67
- package/dist/src/entities/refs/schema.js.map +1 -1
- package/dist/src/entities/search/registry.js +73 -40
- package/dist/src/entities/search/registry.js.map +1 -1
- package/dist/src/entities/search/schema-readonly.js +6 -2
- package/dist/src/entities/search/schema-readonly.js.map +1 -1
- package/dist/src/entities/wiki/registry.js +3 -0
- package/dist/src/entities/wiki/registry.js.map +1 -1
- package/dist/src/entities/wiki/schema.js +4 -1
- package/dist/src/entities/wiki/schema.js.map +1 -1
- package/dist/src/handlers.js +53 -31
- package/dist/src/handlers.js.map +1 -1
- package/dist/src/main.js +0 -4
- package/dist/src/main.js.map +1 -1
- package/dist/src/mcp-server-context.d.ts +2 -1
- package/dist/src/mcp-server-context.js +7 -3
- package/dist/src/mcp-server-context.js.map +1 -1
- package/dist/src/plugin/authorization.d.ts +46 -0
- package/dist/src/plugin/authorization.js +235 -0
- package/dist/src/plugin/authorization.js.map +1 -0
- package/dist/src/plugin/connection-store.d.ts +59 -0
- package/dist/src/plugin/connection-store.js +171 -0
- package/dist/src/plugin/connection-store.js.map +1 -0
- package/dist/src/plugin/connections.d.ts +48 -0
- package/dist/src/plugin/connections.js +469 -0
- package/dist/src/plugin/connections.js.map +1 -0
- package/dist/src/plugin/core.d.ts +1 -0
- package/dist/src/plugin/core.js +11 -0
- package/dist/src/plugin/core.js.map +1 -0
- package/dist/src/plugin/main.d.ts +2 -0
- package/dist/src/plugin/main.js +38 -0
- package/dist/src/plugin/main.js.map +1 -0
- package/dist/src/plugin/panel.d.ts +12 -0
- package/dist/src/plugin/panel.js +38 -0
- package/dist/src/plugin/panel.js.map +1 -0
- package/dist/src/plugin/refresh-guard.d.ts +9 -0
- package/dist/src/plugin/refresh-guard.js +59 -0
- package/dist/src/plugin/refresh-guard.js.map +1 -0
- package/dist/src/plugin/server.d.ts +4 -0
- package/dist/src/plugin/server.js +280 -0
- package/dist/src/plugin/server.js.map +1 -0
- package/dist/src/server.d.ts +1 -0
- package/dist/src/server.js +1 -0
- package/dist/src/server.js.map +1 -1
- package/dist/src/utils/error-handler.d.ts +14 -1
- package/dist/src/utils/error-handler.js +5 -1
- package/dist/src/utils/error-handler.js.map +1 -1
- package/dist/src/utils/fetch.d.ts +3 -0
- package/dist/src/utils/fetch.js +82 -27
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/gitlab-api.d.ts +6 -0
- package/dist/src/utils/gitlab-api.js +20 -2
- package/dist/src/utils/gitlab-api.js.map +1 -1
- package/dist/src/utils/retry-after.d.ts +1 -0
- package/dist/src/utils/retry-after.js +55 -0
- package/dist/src/utils/retry-after.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +9 -3
- package/skills/gitlab-ci/SKILL.md +2 -2
- package/skills/gitlab-setup/SKILL.md +7 -0
- package/dist/src/cli/plugin/command.d.ts +0 -4
- package/dist/src/cli/plugin/command.js +0 -89
- package/dist/src/cli/plugin/command.js.map +0 -1
- package/dist/src/cli/plugin/index.d.ts +0 -5
- package/dist/src/cli/plugin/index.js +0 -15
- package/dist/src/cli/plugin/index.js.map +0 -1
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Connections = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/client/index.js");
|
|
6
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/client/stdio.js");
|
|
7
|
+
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
8
|
+
const auth_js_1 = require("@modelcontextprotocol/sdk/client/auth.js");
|
|
9
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
10
|
+
const protocol_js_1 = require("@modelcontextprotocol/sdk/shared/protocol.js");
|
|
11
|
+
const authorization_1 = require("./authorization");
|
|
12
|
+
const connection_store_1 = require("./connection-store");
|
|
13
|
+
function connectionFailure(error, stage) {
|
|
14
|
+
const text = error instanceof Error
|
|
15
|
+
? `${error.message} ${String(error.cause?.code ?? '')}`
|
|
16
|
+
: '';
|
|
17
|
+
let reason = 'Check the address, credentials and server availability.';
|
|
18
|
+
if (/401|unauthorized|authentication/i.test(text))
|
|
19
|
+
reason = 'Authentication was rejected. Check the token or reconnect to sign in.';
|
|
20
|
+
else if (/403|forbidden|scope/i.test(text))
|
|
21
|
+
reason = 'The account lacks permission. Check its GitLab token scopes.';
|
|
22
|
+
else if (/ENOTFOUND|EAI_AGAIN/i.test(text))
|
|
23
|
+
reason = 'The address could not be resolved. Check the hostname and network.';
|
|
24
|
+
else if (/certificate|CERT_|TLS|SSL/i.test(text))
|
|
25
|
+
reason =
|
|
26
|
+
'The TLS certificate could not be verified. Check the certificate chain and configured CA.';
|
|
27
|
+
else if (/ECONNREFUSED|ECONNRESET|unreachable|timed out|timeout/i.test(text))
|
|
28
|
+
reason = 'The server is unreachable or did not answer. Check the address and network.';
|
|
29
|
+
return `Connection failed during ${stage ?? 'setup'}. ${reason} The previous connection is unchanged.`;
|
|
30
|
+
}
|
|
31
|
+
function localTransport(connection, core) {
|
|
32
|
+
const env = {
|
|
33
|
+
GITLAB_API_URL: connection.url,
|
|
34
|
+
GITLAB_TOKEN: connection.token,
|
|
35
|
+
LOG_JSON: 'true',
|
|
36
|
+
};
|
|
37
|
+
if (connection.initTimeoutMs !== undefined)
|
|
38
|
+
env.GITLAB_INIT_TIMEOUT_MS = String(connection.initTimeoutMs);
|
|
39
|
+
for (const name of [
|
|
40
|
+
'HOME',
|
|
41
|
+
'USERPROFILE',
|
|
42
|
+
'PATH',
|
|
43
|
+
'SystemRoot',
|
|
44
|
+
'TEMP',
|
|
45
|
+
'TMP',
|
|
46
|
+
'LANG',
|
|
47
|
+
'SSL_CERT_FILE',
|
|
48
|
+
'NODE_EXTRA_CA_CERTS',
|
|
49
|
+
'GITLAB_CA_CERT_PATH',
|
|
50
|
+
'HTTP_PROXY',
|
|
51
|
+
'HTTPS_PROXY',
|
|
52
|
+
'NO_PROXY',
|
|
53
|
+
'http_proxy',
|
|
54
|
+
'https_proxy',
|
|
55
|
+
'no_proxy',
|
|
56
|
+
]) {
|
|
57
|
+
const value = process.env[name];
|
|
58
|
+
if (value !== undefined)
|
|
59
|
+
env[name] = value;
|
|
60
|
+
}
|
|
61
|
+
return new stdio_js_1.StdioClientTransport({
|
|
62
|
+
command: process.execPath,
|
|
63
|
+
args: [core, 'stdio'],
|
|
64
|
+
env,
|
|
65
|
+
cwd: (0, node_path_1.join)(core, '..', '..', '..'),
|
|
66
|
+
stderr: 'ignore',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
class Connections {
|
|
70
|
+
store;
|
|
71
|
+
core;
|
|
72
|
+
active;
|
|
73
|
+
pending;
|
|
74
|
+
epoch = 0;
|
|
75
|
+
opening;
|
|
76
|
+
restoring;
|
|
77
|
+
failedSnapshot;
|
|
78
|
+
watcher;
|
|
79
|
+
closing = false;
|
|
80
|
+
phase = 'unconfigured';
|
|
81
|
+
message;
|
|
82
|
+
identity;
|
|
83
|
+
capabilities = {};
|
|
84
|
+
wire = () => { };
|
|
85
|
+
changed = () => { };
|
|
86
|
+
constructor(store, core = (0, node_path_1.join)(__dirname, 'core.js')) {
|
|
87
|
+
this.store = store;
|
|
88
|
+
this.core = core;
|
|
89
|
+
this.watcher = store.watchChanges(() => {
|
|
90
|
+
if (this.closing)
|
|
91
|
+
return;
|
|
92
|
+
void this.refresh().catch(() => {
|
|
93
|
+
this.phase = 'failed';
|
|
94
|
+
this.message = {
|
|
95
|
+
revision: null,
|
|
96
|
+
text: 'Could not read the saved connection. Reopen connection settings.',
|
|
97
|
+
};
|
|
98
|
+
this.changed();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
async refresh() {
|
|
103
|
+
const revision = this.store.revision();
|
|
104
|
+
if (this.pending && this.pending.snapshot.revision !== revision)
|
|
105
|
+
await this.cancel();
|
|
106
|
+
if (this.closing)
|
|
107
|
+
return;
|
|
108
|
+
await this.ready();
|
|
109
|
+
}
|
|
110
|
+
status() {
|
|
111
|
+
const saved = this.selection();
|
|
112
|
+
const active = this.active?.snapshot.revision === saved.revision;
|
|
113
|
+
const message = this.phase !== 'connecting' &&
|
|
114
|
+
(this.message?.revision === null || this.message?.revision === saved.revision)
|
|
115
|
+
? this.message.text
|
|
116
|
+
: undefined;
|
|
117
|
+
let state = this.phase;
|
|
118
|
+
if (state === 'failed' && !message) {
|
|
119
|
+
if (active)
|
|
120
|
+
state = 'connected';
|
|
121
|
+
else if (saved.connection)
|
|
122
|
+
state = 'connecting';
|
|
123
|
+
else
|
|
124
|
+
state = 'unconfigured';
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
revision: saved.revision,
|
|
128
|
+
state: saved.error ? 'failed' : state,
|
|
129
|
+
mode: saved.connection?.mode ?? null,
|
|
130
|
+
url: saved.connection?.url ?? null,
|
|
131
|
+
authentication: saved.connection?.mode === 'remote' ? saved.connection.authentication : null,
|
|
132
|
+
initTimeoutMs: saved.connection?.mode === 'local' ? (saved.connection.initTimeoutMs ?? null) : null,
|
|
133
|
+
identity: !saved.error && active ? (this.identity ?? null) : null,
|
|
134
|
+
message: saved.error ?? message ?? null,
|
|
135
|
+
authorizationUrl: this.pending?.authorization?.authorizationUrl ?? null,
|
|
136
|
+
proposedTarget: this.pending
|
|
137
|
+
? {
|
|
138
|
+
mode: this.pending.snapshot.connection?.mode,
|
|
139
|
+
url: this.pending.snapshot.connection?.url,
|
|
140
|
+
}
|
|
141
|
+
: null,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
failed(saved) {
|
|
145
|
+
return (this.failedSnapshot?.revision === saved.revision &&
|
|
146
|
+
JSON.stringify(this.failedSnapshot.connection) === JSON.stringify(saved.connection));
|
|
147
|
+
}
|
|
148
|
+
selection() {
|
|
149
|
+
try {
|
|
150
|
+
return this.store.read();
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
if (!(error instanceof connection_store_1.InvalidSavedConnection))
|
|
154
|
+
throw error;
|
|
155
|
+
return { revision: error.revision, connection: null, error: error.message };
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
async ready() {
|
|
159
|
+
if (this.closing)
|
|
160
|
+
return undefined;
|
|
161
|
+
const saved = this.selection();
|
|
162
|
+
if (saved.error) {
|
|
163
|
+
if (this.failedSnapshot?.revision !== saved.revision || this.active) {
|
|
164
|
+
await this.dispose(this.active);
|
|
165
|
+
this.active = undefined;
|
|
166
|
+
this.identity = undefined;
|
|
167
|
+
this.phase = 'failed';
|
|
168
|
+
this.message = { revision: saved.revision, text: saved.error };
|
|
169
|
+
this.failedSnapshot = saved;
|
|
170
|
+
this.changed();
|
|
171
|
+
}
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
if (!saved.connection && !this.active)
|
|
175
|
+
return undefined;
|
|
176
|
+
if (this.active?.snapshot.revision === saved.revision) {
|
|
177
|
+
if (this.active.authorization && saved.connection?.authorization)
|
|
178
|
+
this.active.authorization.data = saved.connection.authorization;
|
|
179
|
+
this.active.snapshot = saved;
|
|
180
|
+
return this.active;
|
|
181
|
+
}
|
|
182
|
+
if (this.failed(saved))
|
|
183
|
+
return undefined;
|
|
184
|
+
this.opening ??= this.restore(saved).finally(() => {
|
|
185
|
+
this.opening = undefined;
|
|
186
|
+
});
|
|
187
|
+
await this.opening;
|
|
188
|
+
if (this.closing)
|
|
189
|
+
return undefined;
|
|
190
|
+
const current = this.selection();
|
|
191
|
+
if (this.active?.snapshot.revision !== current.revision &&
|
|
192
|
+
!this.failed(current) &&
|
|
193
|
+
current.connection)
|
|
194
|
+
return this.ready();
|
|
195
|
+
return this.active;
|
|
196
|
+
}
|
|
197
|
+
async restore(saved) {
|
|
198
|
+
const epoch = this.epoch;
|
|
199
|
+
const previous = this.active;
|
|
200
|
+
await this.dispose(previous);
|
|
201
|
+
if (this.closing || epoch !== this.epoch || this.active !== previous)
|
|
202
|
+
return;
|
|
203
|
+
this.active = undefined;
|
|
204
|
+
this.identity = undefined;
|
|
205
|
+
if (!saved.connection) {
|
|
206
|
+
this.phase = 'unconfigured';
|
|
207
|
+
this.changed();
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
let backend;
|
|
211
|
+
try {
|
|
212
|
+
backend = await this.make(saved, false);
|
|
213
|
+
this.restoring = backend;
|
|
214
|
+
if (this.closing || epoch !== this.epoch) {
|
|
215
|
+
await this.dispose(backend);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
await this.qualify(backend);
|
|
219
|
+
if (epoch !== this.epoch || this.store.read().revision !== backend.snapshot.revision) {
|
|
220
|
+
await this.dispose(backend);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
this.active = backend;
|
|
224
|
+
this.identity = backend.identity;
|
|
225
|
+
this.phase = 'connected';
|
|
226
|
+
this.message = undefined;
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
await this.dispose(backend);
|
|
230
|
+
if (epoch !== this.epoch || this.closing)
|
|
231
|
+
return;
|
|
232
|
+
this.phase = 'failed';
|
|
233
|
+
const current = this.selection();
|
|
234
|
+
this.failedSnapshot = current.revision === saved.revision ? current : saved;
|
|
235
|
+
this.message = { revision: saved.revision, text: connectionFailure(error, backend?.stage) };
|
|
236
|
+
}
|
|
237
|
+
finally {
|
|
238
|
+
if (this.restoring === backend)
|
|
239
|
+
this.restoring = undefined;
|
|
240
|
+
}
|
|
241
|
+
this.changed();
|
|
242
|
+
}
|
|
243
|
+
async connect(input, expected) {
|
|
244
|
+
const connection = connection_store_1.ConnectionInput.parse(input);
|
|
245
|
+
if (connection.mode === 'remote' && connection.authentication === 'bearer' && !connection.token)
|
|
246
|
+
throw new Error('Enter the bearer token.');
|
|
247
|
+
if (this.store.revision() !== expected)
|
|
248
|
+
throw new Error('The connection changed. Open settings again.');
|
|
249
|
+
const epoch = ++this.epoch;
|
|
250
|
+
const pending = this.pending;
|
|
251
|
+
this.pending = undefined;
|
|
252
|
+
await this.dispose(pending);
|
|
253
|
+
this.phase = 'connecting';
|
|
254
|
+
let backend;
|
|
255
|
+
try {
|
|
256
|
+
backend = await this.make({ revision: expected, connection }, true);
|
|
257
|
+
if (epoch !== this.epoch) {
|
|
258
|
+
await this.dispose(backend);
|
|
259
|
+
return this.status();
|
|
260
|
+
}
|
|
261
|
+
this.pending = backend;
|
|
262
|
+
await this.qualify(backend);
|
|
263
|
+
await this.accept(backend, epoch);
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
if (error instanceof auth_js_1.UnauthorizedError && backend?.authorization?.authorizationUrl)
|
|
267
|
+
return this.status();
|
|
268
|
+
await this.dispose(backend);
|
|
269
|
+
if (epoch === this.epoch) {
|
|
270
|
+
this.pending = undefined;
|
|
271
|
+
this.phase = 'failed';
|
|
272
|
+
this.message = { revision: expected, text: connectionFailure(error, backend?.stage) };
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return this.status();
|
|
276
|
+
}
|
|
277
|
+
authorization(connection, interactive, getBackend) {
|
|
278
|
+
const data = interactive ? { redirectUrl: '' } : connection.authorization;
|
|
279
|
+
if (!data)
|
|
280
|
+
throw new Error('Reconnect to sign in.');
|
|
281
|
+
const selected = () => !interactive || this.active === getBackend();
|
|
282
|
+
const authorization = new authorization_1.ConnectionAuthorization(data, (patch) => {
|
|
283
|
+
connection.authorization = authorization.data;
|
|
284
|
+
if (!selected())
|
|
285
|
+
return;
|
|
286
|
+
const backend = getBackend();
|
|
287
|
+
const committed = this.store.updateAuthorization(backend.snapshot.revision, patch);
|
|
288
|
+
backend.snapshot.connection = { ...connection, authorization: committed };
|
|
289
|
+
return committed;
|
|
290
|
+
}, {
|
|
291
|
+
current: () => {
|
|
292
|
+
if (!selected())
|
|
293
|
+
return undefined;
|
|
294
|
+
return this.store.readAuthorization(getBackend().snapshot.revision);
|
|
295
|
+
},
|
|
296
|
+
lockPath: this.store.refreshLockPath,
|
|
297
|
+
});
|
|
298
|
+
connection.authorization = data;
|
|
299
|
+
authorization.onFailure = () => {
|
|
300
|
+
if (this.pending !== getBackend())
|
|
301
|
+
return;
|
|
302
|
+
const failedEpoch = this.epoch + 1;
|
|
303
|
+
void this.cancel().then(() => {
|
|
304
|
+
if (this.epoch !== failedEpoch || this.closing)
|
|
305
|
+
return;
|
|
306
|
+
this.phase = 'failed';
|
|
307
|
+
this.message = {
|
|
308
|
+
revision: getBackend().snapshot.revision,
|
|
309
|
+
text: 'Sign-in was cancelled, denied or expired. Try again.',
|
|
310
|
+
};
|
|
311
|
+
this.changed();
|
|
312
|
+
});
|
|
313
|
+
};
|
|
314
|
+
return authorization;
|
|
315
|
+
}
|
|
316
|
+
async make(snapshot, interactive) {
|
|
317
|
+
const connection = snapshot.connection;
|
|
318
|
+
if (!connection)
|
|
319
|
+
throw new Error('No connection is selected.');
|
|
320
|
+
const client = new index_js_1.Client({ name: 'gitlab-mcp-plugin', version: '1.0.0' }, { capabilities: this.capabilities });
|
|
321
|
+
let backend;
|
|
322
|
+
let transport;
|
|
323
|
+
let provider;
|
|
324
|
+
if (connection.mode === 'local') {
|
|
325
|
+
transport = localTransport(connection, this.core);
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
if (connection.authentication === 'oauth')
|
|
329
|
+
provider = this.authorization(connection, interactive, () => backend);
|
|
330
|
+
transport = new streamableHttp_js_1.StreamableHTTPClientTransport(new URL(connection.url), {
|
|
331
|
+
authProvider: provider,
|
|
332
|
+
fetch: provider?.fetch,
|
|
333
|
+
...(connection.authentication === 'bearer'
|
|
334
|
+
? { requestInit: { headers: { Authorization: `Bearer ${connection.token}` } } }
|
|
335
|
+
: {}),
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
backend = { client, snapshot, transport, authorization: provider };
|
|
339
|
+
try {
|
|
340
|
+
this.wire(backend);
|
|
341
|
+
this.wireAuthorization(backend, connection.url);
|
|
342
|
+
if (interactive && provider)
|
|
343
|
+
await provider.listen();
|
|
344
|
+
return backend;
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
await this.dispose(backend);
|
|
348
|
+
throw error;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
wireAuthorization(backend, url) {
|
|
352
|
+
if (!backend.authorization)
|
|
353
|
+
return;
|
|
354
|
+
backend.authorization.onCode = async (code) => {
|
|
355
|
+
if (this.pending !== backend)
|
|
356
|
+
return;
|
|
357
|
+
const epoch = this.epoch;
|
|
358
|
+
try {
|
|
359
|
+
await backend.transport.finishAuth(code);
|
|
360
|
+
backend.transport = new streamableHttp_js_1.StreamableHTTPClientTransport(new URL(url), {
|
|
361
|
+
authProvider: backend.authorization,
|
|
362
|
+
fetch: backend.authorization?.fetch,
|
|
363
|
+
});
|
|
364
|
+
await this.qualify(backend);
|
|
365
|
+
await this.accept(backend, epoch);
|
|
366
|
+
}
|
|
367
|
+
catch {
|
|
368
|
+
backend.authorization?.onFailure?.();
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
async qualify(backend) {
|
|
373
|
+
const signal = AbortSignal.timeout(protocol_js_1.DEFAULT_REQUEST_TIMEOUT_MSEC);
|
|
374
|
+
backend.stage = 'initialization';
|
|
375
|
+
await backend.client.connect(backend.transport, { signal });
|
|
376
|
+
backend.stage = 'tool discovery';
|
|
377
|
+
let cursor;
|
|
378
|
+
for (;;) {
|
|
379
|
+
const page = await backend.client.listTools({ cursor }, { signal });
|
|
380
|
+
if (page.tools.some((tool) => tool.name === 'get_profile'))
|
|
381
|
+
break;
|
|
382
|
+
if (page.nextCursor === undefined)
|
|
383
|
+
throw new Error('This endpoint is not a supported GitLab MCP server.');
|
|
384
|
+
cursor = page.nextCursor;
|
|
385
|
+
}
|
|
386
|
+
backend.stage = 'account verification';
|
|
387
|
+
const profile = await backend.client.request({ method: 'tools/call', params: { name: 'get_profile', arguments: {} } }, types_js_1.ResultSchema, { signal });
|
|
388
|
+
if (profile.isError) {
|
|
389
|
+
if (JSON.stringify(profile).includes('CONNECTION_FAILED'))
|
|
390
|
+
throw new Error('Backend initialization failed or timed out.');
|
|
391
|
+
const challenge = JSON.stringify(profile._meta?.['mcp/www_authenticate']);
|
|
392
|
+
if (challenge?.includes('invalid_token'))
|
|
393
|
+
throw new Error('GitLab authentication was rejected.');
|
|
394
|
+
if (challenge?.includes('insufficient_scope'))
|
|
395
|
+
throw new Error('GitLab token scope is insufficient.');
|
|
396
|
+
throw new Error('The backend could not verify the GitLab account.');
|
|
397
|
+
}
|
|
398
|
+
const identity = profile.structuredContent;
|
|
399
|
+
if (typeof identity !== 'object' ||
|
|
400
|
+
identity === null ||
|
|
401
|
+
!('id' in identity) ||
|
|
402
|
+
typeof identity.id !== 'string' ||
|
|
403
|
+
identity.id.length === 0)
|
|
404
|
+
throw new Error('The server did not identify the connected account.');
|
|
405
|
+
backend.identity = identity;
|
|
406
|
+
}
|
|
407
|
+
async accept(backend, epoch) {
|
|
408
|
+
if (this.pending !== backend || epoch !== this.epoch) {
|
|
409
|
+
await this.dispose(backend);
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
backend.snapshot = this.store.commit(backend.snapshot.revision, backend.snapshot.connection);
|
|
413
|
+
const previous = this.active;
|
|
414
|
+
this.active = backend;
|
|
415
|
+
this.identity = backend.identity;
|
|
416
|
+
this.failedSnapshot = undefined;
|
|
417
|
+
this.pending = undefined;
|
|
418
|
+
backend.authorization?.close();
|
|
419
|
+
this.phase = 'connected';
|
|
420
|
+
this.message = undefined;
|
|
421
|
+
this.changed();
|
|
422
|
+
await this.dispose(previous);
|
|
423
|
+
}
|
|
424
|
+
async cancel() {
|
|
425
|
+
this.epoch++;
|
|
426
|
+
const pending = this.pending;
|
|
427
|
+
this.pending = undefined;
|
|
428
|
+
await this.dispose(pending);
|
|
429
|
+
const saved = this.selection();
|
|
430
|
+
if (this.active?.snapshot.revision === saved.revision)
|
|
431
|
+
this.phase = 'connected';
|
|
432
|
+
else if (this.failed(saved))
|
|
433
|
+
this.phase = 'failed';
|
|
434
|
+
else
|
|
435
|
+
this.phase = saved.connection ? 'connecting' : 'unconfigured';
|
|
436
|
+
if (this.phase !== 'failed')
|
|
437
|
+
this.message = undefined;
|
|
438
|
+
}
|
|
439
|
+
async disconnect(expected) {
|
|
440
|
+
this.store.commit(expected, null);
|
|
441
|
+
await this.cancel();
|
|
442
|
+
const active = this.active;
|
|
443
|
+
this.active = undefined;
|
|
444
|
+
this.identity = undefined;
|
|
445
|
+
this.phase = 'unconfigured';
|
|
446
|
+
this.message = undefined;
|
|
447
|
+
this.changed();
|
|
448
|
+
await this.dispose(active);
|
|
449
|
+
}
|
|
450
|
+
async close() {
|
|
451
|
+
if (this.closing)
|
|
452
|
+
return;
|
|
453
|
+
this.closing = true;
|
|
454
|
+
this.watcher.close();
|
|
455
|
+
await this.cancel();
|
|
456
|
+
await this.dispose(this.restoring);
|
|
457
|
+
await this.opening;
|
|
458
|
+
await this.dispose(this.active);
|
|
459
|
+
this.active = undefined;
|
|
460
|
+
this.store.close();
|
|
461
|
+
}
|
|
462
|
+
async dispose(backend) {
|
|
463
|
+
await backend?.authorization?.dispose();
|
|
464
|
+
if (backend)
|
|
465
|
+
await backend.client.close();
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
exports.Connections = Connections;
|
|
469
|
+
//# sourceMappingURL=connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../../src/plugin/connections.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAEjC,wEAAmE;AACnE,wEAAiF;AACjF,0FAAmG;AACnG,sEAA6E;AAC7E,iEAA2F;AAE3F,8EAA4F;AAC5F,mDAA0D;AAC1D,yDAM4B;AAW5B,SAAS,iBAAiB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
const server_1 = require("../server");
|
|
4
|
+
process.stdin.once('end', () => {
|
|
5
|
+
void (0, server_1.gracefulShutdown)('stdin closed').catch(() => process.exit(1));
|
|
6
|
+
});
|
|
7
|
+
void (0, server_1.startServer)().catch(() => {
|
|
8
|
+
console.error('The local GitLab core could not start.');
|
|
9
|
+
process.exit(1);
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/plugin/core.ts"],"names":[],"mappings":";;AAAA,sCAA0D;AAG1D,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE;IAC7B,KAAK,IAAA,yBAAgB,EAAC,cAAc,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC,CAAC;AACH,KAAK,IAAA,oBAAW,GAAE,CAAC,KAAK,CAAC,GAAG,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;IACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
5
|
+
const connection_store_1 = require("./connection-store");
|
|
6
|
+
const connections_1 = require("./connections");
|
|
7
|
+
const server_1 = require("./server");
|
|
8
|
+
async function main() {
|
|
9
|
+
const dir = process.argv[2];
|
|
10
|
+
if (!dir || dir.includes('${'))
|
|
11
|
+
throw new Error('The host must provide the plugin data directory.');
|
|
12
|
+
const connections = new connections_1.Connections(new connection_store_1.ConnectionStore(dir));
|
|
13
|
+
const server = (0, server_1.createPluginServer)(connections);
|
|
14
|
+
let closing = false;
|
|
15
|
+
const close = async () => {
|
|
16
|
+
if (closing)
|
|
17
|
+
return;
|
|
18
|
+
closing = true;
|
|
19
|
+
await connections.close();
|
|
20
|
+
await server.close();
|
|
21
|
+
};
|
|
22
|
+
server.onclose = () => {
|
|
23
|
+
void close();
|
|
24
|
+
};
|
|
25
|
+
process.stdin.once('end', () => {
|
|
26
|
+
void close();
|
|
27
|
+
});
|
|
28
|
+
for (const signal of ['SIGINT', 'SIGTERM'])
|
|
29
|
+
process.once(signal, () => {
|
|
30
|
+
void close();
|
|
31
|
+
});
|
|
32
|
+
await server.connect(new stdio_js_1.StdioServerTransport());
|
|
33
|
+
}
|
|
34
|
+
void main().catch(() => {
|
|
35
|
+
console.error('GitLab plugin could not start. Check Node.js 24+ and the plugin data directory.');
|
|
36
|
+
process.exitCode = 1;
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../src/plugin/main.ts"],"names":[],"mappings":";;;AAEA,wEAAiF;AACjF,yDAAqD;AACrD,+CAA4C;AAC5C,qCAA8C;AAE9C,KAAK,UAAU,IAAI;IACjB,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,MAAM,WAAW,GAAG,IAAI,yBAAW,CAAC,IAAI,kCAAe,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,IAAA,2BAAkB,EAAC,WAAW,CAAC,CAAC;IAC/C,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,MAAM,KAAK,GAAG,KAAK,IAAmB,EAAE;QACtC,IAAI,OAAO;YAAE,OAAO;QACpB,OAAO,GAAG,IAAI,CAAC;QACf,MAAM,WAAW,CAAC,KAAK,EAAE,CAAC;QAC1B,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC,CAAC;IACF,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE;QACpB,KAAK,KAAK,EAAE,CAAC;IACf,CAAC,CAAC;IACF,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE;QAC7B,KAAK,KAAK,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;IACH,KAAK,MAAM,MAAM,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAU;QACjD,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;YACxB,KAAK,KAAK,EAAE,CAAC;QACf,CAAC,CAAC,CAAC;IACL,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,+BAAoB,EAAE,CAAC,CAAC;AACnD,CAAC;AACD,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,iFAAiF,CAAC,CAAC;IACjG,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const CONNECTION_PANEL_URI = "ui://gitlab-mcp-local/connection.html";
|
|
2
|
+
export declare const CONNECTION_PANEL_META: {
|
|
3
|
+
ui: {
|
|
4
|
+
csp: {
|
|
5
|
+
connectDomains: never[];
|
|
6
|
+
resourceDomains: never[];
|
|
7
|
+
frameDomains: never[];
|
|
8
|
+
};
|
|
9
|
+
prefersBorder: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare function connectionPanel(): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONNECTION_PANEL_META = exports.CONNECTION_PANEL_URI = void 0;
|
|
4
|
+
exports.connectionPanel = connectionPanel;
|
|
5
|
+
exports.CONNECTION_PANEL_URI = 'ui://gitlab-mcp-local/connection.html';
|
|
6
|
+
exports.CONNECTION_PANEL_META = {
|
|
7
|
+
ui: { csp: { connectDomains: [], resourceDomains: [], frameDomains: [] }, prefersBorder: true },
|
|
8
|
+
};
|
|
9
|
+
function connectionPanel() {
|
|
10
|
+
return String.raw `<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
11
|
+
<style>
|
|
12
|
+
:root{color-scheme:light dark;font:14px/1.5 var(--font-sans,system-ui);background:var(--color-background-primary,Canvas);color:var(--color-text-primary,CanvasText)}
|
|
13
|
+
*{box-sizing:border-box}body{margin:0;padding:24px;max-width:660px}h1{font-size:23px;margin:0}p{color:var(--color-text-secondary,GrayText)}
|
|
14
|
+
label{display:block;margin:18px 0 5px;font-weight:600}input,select,button{font:inherit;border:1px solid var(--color-border-primary,GrayText);border-radius:8px;padding:10px;background:var(--color-background-secondary,Canvas);color:inherit}input,select{width:100%}button{cursor:pointer}button:disabled{opacity:.5;cursor:wait}.actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:22px}.primary{background:#6b4fbb;color:white;border-color:#6b4fbb}:focus-visible{outline:3px solid #b197fc;outline-offset:2px}#status{padding:12px;border:1px solid var(--color-border-primary,GrayText);border-radius:10px;margin:20px 0;white-space:pre-wrap}small{color:var(--color-text-secondary,GrayText)}[hidden]{display:none!important}
|
|
15
|
+
</style><h1>Your GitLab connection</h1><p>Choose where GitLab runs. Change this later without reinstalling the plugin.</p>
|
|
16
|
+
<div id="status" role="status" aria-live="polite">Loading connection...</div>
|
|
17
|
+
<form id="form"><label for="mode">Connect to</label><select id="mode"><option value="local">GitLab instance, run MCP locally</option><option value="remote">Existing GitLab MCP server</option></select>
|
|
18
|
+
<label for="url" id="address-label">GitLab address</label><input id="url" type="url" required placeholder="https://gitlab.example.com" autocomplete="url"><small id="hint">The core server starts automatically. GitLab 16.0 or later.</small>
|
|
19
|
+
<div id="remote-auth" hidden><label for="authentication">Authentication</label><select id="authentication"><option value="oauth">Browser sign-in (OAuth)</option><option value="bearer">Bearer token</option><option value="none">No authentication</option></select></div>
|
|
20
|
+
<div id="secret"><label for="token" id="token-label">GitLab personal access token</label><input id="token" type="password" autocomplete="off" spellcheck="false"><small>Stored privately on this computer. Never paste credentials into the chat.</small></div>
|
|
21
|
+
<details id="advanced"><summary>Local connection options</summary><label for="init-timeout">Initialization budget (milliseconds)</label><input id="init-timeout" type="number" min="1000" max="45000" step="1000" placeholder="Core default: 5000"><small>For slow instances, increase the initial discovery budget. Maximum 45000 leaves time for the host to receive the result.</small></details>
|
|
22
|
+
<div class="actions"><button class="primary" type="submit">Verify and save</button><button type="button" id="reconnect">Reconnect saved connection</button><button type="button" id="cancel">Cancel setup</button><button type="button" id="disconnect">Disconnect</button><button type="button" id="refresh">Refresh status</button><button type="button" id="authorize" hidden>Continue browser sign-in</button></div></form>
|
|
23
|
+
<script>
|
|
24
|
+
(()=>{'use strict';const el=id=>document.getElementById(id);let next=0,revision=0,authorizationUrl=null,loaded=false;const pending=new Map();
|
|
25
|
+
function request(method,params){return new Promise((resolve,reject)=>{const id=++next;const timer=setTimeout(()=>{pending.delete(id);reject(Error('The host did not answer. Refresh status before retrying.'));},60000);pending.set(id,{resolve,reject,timer});window.parent.postMessage({jsonrpc:'2.0',id,method,params},'*');});}
|
|
26
|
+
function applyContext(context){if(!context)return;if(context.theme==='dark'||context.theme==='light')document.documentElement.style.colorScheme=context.theme;const variables=context.styles&&context.styles.variables;if(variables)for(const [name,value] of Object.entries(variables))if(name.startsWith('--')&&typeof value==='string')document.documentElement.style.setProperty(name,value);}
|
|
27
|
+
window.addEventListener('message',event=>{if(event.source!==window.parent)return;const m=event.data;if(!m||m.jsonrpc!=='2.0')return;const p=pending.get(m.id);if(p){clearTimeout(p.timer);pending.delete(m.id);m.error?p.reject(Error(m.error.message)):p.resolve(m.result);}if(m.method==='ui/notifications/host-context-changed')applyContext(m.params);if(m.method==='ui/resource-teardown'&&m.id!==undefined){window.parent.postMessage({jsonrpc:'2.0',id:m.id,result:{}},'*');}});
|
|
28
|
+
async function call(action,extra={}){const r=await request('tools/call',{name:'gitlab_plugin_connection',arguments:{action,revision,...extra}});if(r.isError)throw Error('Could not change the connection. Refresh status and try again.');return r.structuredContent;}
|
|
29
|
+
function render(s){revision=s.revision;authorizationUrl=s.authorizationUrl;el('authorize').hidden=!authorizationUrl;if(!loaded&&s.url&&s.mode){el('mode').value=s.mode;el('url').value=s.url;if(s.authentication)el('authentication').value=s.authentication;if(s.initTimeoutMs)el('init-timeout').value=String(s.initTimeoutMs);fields();}loaded=true;el('status').textContent=[s.state,s.mode==='local'?'Local GitLab':s.mode==='remote'?'Existing MCP server':null,s.url,s.proposedTarget?'Connecting to '+s.proposedTarget.url:null,s.message,s.identity?JSON.stringify(s.identity,null,2):null].filter(Boolean).join('\n');}
|
|
30
|
+
function fields(){const local=el('mode').value==='local';el('advanced').hidden=!local;el('remote-auth').hidden=local;el('secret').hidden=!local&&el('authentication').value!=='bearer';el('address-label').textContent=local?'GitLab address':'MCP endpoint';el('token-label').textContent=local?'GitLab personal access token':'MCP bearer token';el('hint').textContent=local?'GitLab 16.0 or later. Use a token with the permissions you need.':'Use the server endpoint, usually ending in /mcp. Browser sign-in requires OAuth on that server.';}
|
|
31
|
+
async function run(action,extra){try{render(await call(action,extra));}catch(e){el('status').textContent=e.message;}}
|
|
32
|
+
el('mode').onchange=fields;el('authentication').onchange=fields;el('form').onsubmit=async event=>{event.preventDefault();const input={mode:el('mode').value,url:el('url').value};if(input.mode==='remote')input.authentication=el('authentication').value;if(input.mode==='local'&&el('init-timeout').value!=='')input.initTimeoutMs=Number(el('init-timeout').value);if(!el('secret').hidden)input.token=el('token').value;el('token').value='';await run('connect',{connection:input});};
|
|
33
|
+
for(const action of ['reconnect','cancel','disconnect','refresh'])el(action).onclick=()=>run(action==='refresh'?'status':action);
|
|
34
|
+
el('authorize').onclick=()=>{if(authorizationUrl)request('ui/open-link',{url:authorizationUrl}).catch(e=>{el('status').textContent=e.message;});};
|
|
35
|
+
request('ui/initialize',{protocolVersion:'2026-01-26',appInfo:{name:'GitLab connection',version:'1.0.0'},appCapabilities:{}}).then(result=>{applyContext(result.hostContext);window.parent.postMessage({jsonrpc:'2.0',method:'ui/notifications/initialized',params:{}},'*');return run('status');}).catch(e=>{el('status').textContent=e.message;});fields();})();
|
|
36
|
+
</script></html>`;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panel.js","sourceRoot":"","sources":["../../../src/plugin/panel.ts"],"names":[],"mappings":";;;AAMA,0CA4BC;AAlCY,QAAA,oBAAoB,GAAG,uCAAuC,CAAC;AAC/D,QAAA,qBAAqB,GAAG;IACnC,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE;CAChG,CAAC;AAGF,SAAgB,eAAe;IAC7B,OAAO,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BF,CAAC;AAClB,CAAC"}
|