opencode-gitlab-plugin 2.8.2 → 3.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/CHANGELOG.md +22 -0
- package/README.md +45 -3
- package/dist/index.d.ts +36 -4
- package/dist/index.js +125 -31
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.cjs +369 -22
- package/dist/mcp-server.cjs.map +1 -1
- package/package.json +2 -1
package/dist/mcp-server.cjs
CHANGED
|
@@ -34199,6 +34199,372 @@ Examples:
|
|
|
34199
34199
|
})
|
|
34200
34200
|
};
|
|
34201
34201
|
|
|
34202
|
+
// src/tools/orbit.ts
|
|
34203
|
+
var z18 = tool.schema;
|
|
34204
|
+
var orbitTools = {
|
|
34205
|
+
gitlab_orbit_status: tool({
|
|
34206
|
+
description: `Check GitLab Orbit Knowledge Graph API availability and health.
|
|
34207
|
+
|
|
34208
|
+
Returns the status of the Orbit API for the connected GitLab instance.
|
|
34209
|
+
Orbit is GitLab's Knowledge Graph API that provides rich SDLC graph data.
|
|
34210
|
+
|
|
34211
|
+
Note: Orbit is only available on Premium/Ultimate tiers and requires the feature flag to be enabled.
|
|
34212
|
+
If unavailable, returns an error with suggestions for REST API alternatives.`,
|
|
34213
|
+
args: {},
|
|
34214
|
+
execute: async (_args, _ctx) => {
|
|
34215
|
+
const client = getGitLabClient();
|
|
34216
|
+
try {
|
|
34217
|
+
const status = await client.fetch("GET", "/orbit/status");
|
|
34218
|
+
return JSON.stringify(
|
|
34219
|
+
{
|
|
34220
|
+
...status,
|
|
34221
|
+
available: true,
|
|
34222
|
+
message: "Orbit Knowledge Graph API is available"
|
|
34223
|
+
},
|
|
34224
|
+
null,
|
|
34225
|
+
2
|
|
34226
|
+
);
|
|
34227
|
+
} catch (error45) {
|
|
34228
|
+
const errorMessage = error45 instanceof Error ? error45.message : String(error45);
|
|
34229
|
+
if (errorMessage.includes("404") || errorMessage.includes("not found")) {
|
|
34230
|
+
return JSON.stringify(
|
|
34231
|
+
{
|
|
34232
|
+
available: false,
|
|
34233
|
+
error: "Orbit API not available",
|
|
34234
|
+
reason: "The Orbit Knowledge Graph API is not enabled on this GitLab instance. Orbit requires GitLab Premium/Ultimate tier and the feature flag to be enabled.",
|
|
34235
|
+
alternatives: [
|
|
34236
|
+
"Use REST API endpoints for MRs, issues, pipelines",
|
|
34237
|
+
"Use GraphQL API for complex queries",
|
|
34238
|
+
"Use gitlab_search for finding related entities"
|
|
34239
|
+
]
|
|
34240
|
+
},
|
|
34241
|
+
null,
|
|
34242
|
+
2
|
|
34243
|
+
);
|
|
34244
|
+
}
|
|
34245
|
+
if (errorMessage.includes("403") || errorMessage.includes("forbidden")) {
|
|
34246
|
+
return JSON.stringify(
|
|
34247
|
+
{
|
|
34248
|
+
available: false,
|
|
34249
|
+
error: "Orbit API access forbidden",
|
|
34250
|
+
reason: "Your access token does not have permission to use the Orbit API. This may require specific scopes or Premium/Ultimate tier.",
|
|
34251
|
+
alternatives: [
|
|
34252
|
+
"Check token scopes include api or read_api",
|
|
34253
|
+
"Verify your GitLab tier supports Orbit",
|
|
34254
|
+
"Use REST/GraphQL APIs as fallback"
|
|
34255
|
+
]
|
|
34256
|
+
},
|
|
34257
|
+
null,
|
|
34258
|
+
2
|
|
34259
|
+
);
|
|
34260
|
+
}
|
|
34261
|
+
if (errorMessage.includes("502")) {
|
|
34262
|
+
return JSON.stringify(
|
|
34263
|
+
{
|
|
34264
|
+
available: false,
|
|
34265
|
+
error: "Orbit API temporarily unavailable",
|
|
34266
|
+
reason: "The Orbit API returned a 502 error. This may be temporary.",
|
|
34267
|
+
suggestion: "Try again later or use REST/GraphQL APIs as fallback."
|
|
34268
|
+
},
|
|
34269
|
+
null,
|
|
34270
|
+
2
|
|
34271
|
+
);
|
|
34272
|
+
}
|
|
34273
|
+
return JSON.stringify(
|
|
34274
|
+
{
|
|
34275
|
+
available: false,
|
|
34276
|
+
error: "Orbit API error",
|
|
34277
|
+
message: errorMessage,
|
|
34278
|
+
alternatives: ["Use REST/GraphQL APIs as fallback"]
|
|
34279
|
+
},
|
|
34280
|
+
null,
|
|
34281
|
+
2
|
|
34282
|
+
);
|
|
34283
|
+
}
|
|
34284
|
+
}
|
|
34285
|
+
}),
|
|
34286
|
+
gitlab_orbit_schema: tool({
|
|
34287
|
+
description: `Get the Orbit Knowledge Graph schema.
|
|
34288
|
+
|
|
34289
|
+
Returns the available node types, relationship types, and their properties.
|
|
34290
|
+
Use this to understand what entities and relationships can be queried.
|
|
34291
|
+
|
|
34292
|
+
Node type domains include:
|
|
34293
|
+
- Core: Project, Group, User
|
|
34294
|
+
- Source Code: File, Definition, Commit
|
|
34295
|
+
- Code Review: MergeRequest, Diff, Review
|
|
34296
|
+
- CI/CD: Pipeline, Job, Deployment
|
|
34297
|
+
- Planning: WorkItem (issues, epics, tasks)
|
|
34298
|
+
- Security: Vulnerability
|
|
34299
|
+
|
|
34300
|
+
Note: Requires Orbit API to be available (Premium/Ultimate tier).`,
|
|
34301
|
+
args: {},
|
|
34302
|
+
execute: async (_args, _ctx) => {
|
|
34303
|
+
const client = getGitLabClient();
|
|
34304
|
+
try {
|
|
34305
|
+
const schema = await client.fetch("GET", "/orbit/schema");
|
|
34306
|
+
return JSON.stringify(schema, null, 2);
|
|
34307
|
+
} catch (error45) {
|
|
34308
|
+
const errorMessage = error45 instanceof Error ? error45.message : String(error45);
|
|
34309
|
+
if (errorMessage.includes("404") || errorMessage.includes("not found")) {
|
|
34310
|
+
return JSON.stringify(
|
|
34311
|
+
{
|
|
34312
|
+
error: "Orbit API not available",
|
|
34313
|
+
suggestion: "Use gitlab_orbit_status to check API availability"
|
|
34314
|
+
},
|
|
34315
|
+
null,
|
|
34316
|
+
2
|
|
34317
|
+
);
|
|
34318
|
+
}
|
|
34319
|
+
if (errorMessage.includes("502")) {
|
|
34320
|
+
return JSON.stringify(
|
|
34321
|
+
{
|
|
34322
|
+
error: "Orbit API temporarily unavailable",
|
|
34323
|
+
suggestion: "The Orbit API returned a 502 error. This may be temporary - try again later."
|
|
34324
|
+
},
|
|
34325
|
+
null,
|
|
34326
|
+
2
|
|
34327
|
+
);
|
|
34328
|
+
}
|
|
34329
|
+
throw error45;
|
|
34330
|
+
}
|
|
34331
|
+
}
|
|
34332
|
+
}),
|
|
34333
|
+
gitlab_orbit_query: tool({
|
|
34334
|
+
description: `Execute a query against the Orbit Knowledge Graph.
|
|
34335
|
+
|
|
34336
|
+
Query types:
|
|
34337
|
+
- traversal: Walk the graph from a starting node
|
|
34338
|
+
- neighbors: Get immediate neighbors of a node
|
|
34339
|
+
|
|
34340
|
+
IMPORTANT: The query format uses variable names for node references.
|
|
34341
|
+
- "id" in node definition is a VARIABLE NAME (alias), not the actual entity ID
|
|
34342
|
+
- Actual IDs go in "filters" with {"field": {"op": "eq", "value": X}} format
|
|
34343
|
+
|
|
34344
|
+
Example neighbors query to get a project's connections:
|
|
34345
|
+
{
|
|
34346
|
+
"query_type": "neighbors",
|
|
34347
|
+
"node": {
|
|
34348
|
+
"entity": "Project",
|
|
34349
|
+
"id": "p",
|
|
34350
|
+
"filters": {"id": {"op": "eq", "value": 278964}}
|
|
34351
|
+
},
|
|
34352
|
+
"neighbors": {"node": "p", "direction": "incoming"},
|
|
34353
|
+
"aggregations": [],
|
|
34354
|
+
"path": {"type": "shortest", "from": "p", "to": "p", "max_depth": 1}
|
|
34355
|
+
}
|
|
34356
|
+
|
|
34357
|
+
Example traversal query:
|
|
34358
|
+
{
|
|
34359
|
+
"query_type": "traversal",
|
|
34360
|
+
"node": {
|
|
34361
|
+
"entity": "MergeRequest",
|
|
34362
|
+
"id": "mr",
|
|
34363
|
+
"filters": {"id": {"op": "eq", "value": 377844873}}
|
|
34364
|
+
},
|
|
34365
|
+
"neighbors": {"node": "mr", "direction": "both"},
|
|
34366
|
+
"aggregations": [],
|
|
34367
|
+
"path": {"type": "shortest", "from": "mr", "to": "mr", "max_depth": 1}
|
|
34368
|
+
}
|
|
34369
|
+
|
|
34370
|
+
Note: Use gitlab_get_merge_request to get the internal ID from an IID.
|
|
34371
|
+
Returns nodes array and edges array with relationship types.`,
|
|
34372
|
+
args: {
|
|
34373
|
+
// Using a JSON string rather than a structured zod schema because the Orbit query
|
|
34374
|
+
// format is still evolving. This allows flexibility as the API changes without
|
|
34375
|
+
// requiring schema updates for each iteration.
|
|
34376
|
+
query: z18.string().describe(
|
|
34377
|
+
"JSON string containing the full query object. Must include query_type, node, neighbors, aggregations, and path fields. See description for format details."
|
|
34378
|
+
),
|
|
34379
|
+
limit: z18.number().optional().describe("Maximum number of results (default: 30)")
|
|
34380
|
+
},
|
|
34381
|
+
execute: async (args, _ctx) => {
|
|
34382
|
+
const client = getGitLabClient();
|
|
34383
|
+
let queryObj;
|
|
34384
|
+
try {
|
|
34385
|
+
queryObj = JSON.parse(args.query);
|
|
34386
|
+
} catch {
|
|
34387
|
+
return JSON.stringify(
|
|
34388
|
+
{
|
|
34389
|
+
error: "Invalid JSON in query parameter",
|
|
34390
|
+
suggestion: "Ensure the query parameter is valid JSON"
|
|
34391
|
+
},
|
|
34392
|
+
null,
|
|
34393
|
+
2
|
|
34394
|
+
);
|
|
34395
|
+
}
|
|
34396
|
+
const requestBody = {
|
|
34397
|
+
query: queryObj
|
|
34398
|
+
};
|
|
34399
|
+
if (args.limit) {
|
|
34400
|
+
requestBody.limit = args.limit;
|
|
34401
|
+
}
|
|
34402
|
+
try {
|
|
34403
|
+
const result = await client.fetch("POST", "/orbit/query", requestBody);
|
|
34404
|
+
if (result.code) {
|
|
34405
|
+
return JSON.stringify(
|
|
34406
|
+
{
|
|
34407
|
+
error: "Query compilation error",
|
|
34408
|
+
code: result.code,
|
|
34409
|
+
message: result.message,
|
|
34410
|
+
suggestion: 'Check query structure. Node "id" is a variable name, actual IDs go in filters.'
|
|
34411
|
+
},
|
|
34412
|
+
null,
|
|
34413
|
+
2
|
|
34414
|
+
);
|
|
34415
|
+
}
|
|
34416
|
+
return JSON.stringify(result, null, 2);
|
|
34417
|
+
} catch (error45) {
|
|
34418
|
+
const errorMessage = error45 instanceof Error ? error45.message : String(error45);
|
|
34419
|
+
if (errorMessage.includes("404") || errorMessage.includes("not found")) {
|
|
34420
|
+
return JSON.stringify(
|
|
34421
|
+
{
|
|
34422
|
+
error: "Orbit API not available",
|
|
34423
|
+
suggestion: "Use gitlab_orbit_status to check API availability"
|
|
34424
|
+
},
|
|
34425
|
+
null,
|
|
34426
|
+
2
|
|
34427
|
+
);
|
|
34428
|
+
}
|
|
34429
|
+
if (errorMessage.includes("502")) {
|
|
34430
|
+
return JSON.stringify(
|
|
34431
|
+
{
|
|
34432
|
+
error: "Orbit query failed",
|
|
34433
|
+
message: "The Orbit API returned a 502 error. This is a known issue with some entity types (e.g., source_code domain).",
|
|
34434
|
+
suggestion: "Try a different entity type or use REST/GraphQL APIs as fallback."
|
|
34435
|
+
},
|
|
34436
|
+
null,
|
|
34437
|
+
2
|
|
34438
|
+
);
|
|
34439
|
+
}
|
|
34440
|
+
throw error45;
|
|
34441
|
+
}
|
|
34442
|
+
}
|
|
34443
|
+
}),
|
|
34444
|
+
gitlab_orbit_neighbors: tool({
|
|
34445
|
+
description: `Get immediate neighbors of a node in the Orbit Knowledge Graph.
|
|
34446
|
+
|
|
34447
|
+
This is a simplified wrapper that builds the query for you.
|
|
34448
|
+
Returns nodes directly connected to the specified node.
|
|
34449
|
+
|
|
34450
|
+
Common use cases:
|
|
34451
|
+
- Get all connections to a project (users, groups, pipelines, MRs)
|
|
34452
|
+
- Get pipelines for an MR
|
|
34453
|
+
- Get files changed in a commit
|
|
34454
|
+
- Get deployments from a pipeline
|
|
34455
|
+
|
|
34456
|
+
Note: Use GitLab internal numeric IDs (not IIDs).
|
|
34457
|
+
Example: For MR !123 in gitlab-org/gitlab, first get the internal ID via gitlab_get_merge_request,
|
|
34458
|
+
then use that ID (e.g., 377844873).`,
|
|
34459
|
+
args: {
|
|
34460
|
+
entity_type: z18.string().describe(
|
|
34461
|
+
"Type of the entity (e.g., Project, MergeRequest, User, Pipeline, Commit, WorkItem, Group)"
|
|
34462
|
+
),
|
|
34463
|
+
entity_id: z18.number().describe(
|
|
34464
|
+
"GitLab internal numeric ID (not IID). Get this from REST/GraphQL API responses."
|
|
34465
|
+
),
|
|
34466
|
+
direction: z18.enum(["incoming", "outgoing", "both"]).optional().describe("Direction of relationships to traverse (default: both)"),
|
|
34467
|
+
limit: z18.number().optional().describe("Maximum number of neighbors to return (default: 30)")
|
|
34468
|
+
},
|
|
34469
|
+
execute: async (args, _ctx) => {
|
|
34470
|
+
const client = getGitLabClient();
|
|
34471
|
+
const direction = args.direction || "both";
|
|
34472
|
+
const queryObj = {
|
|
34473
|
+
query_type: "neighbors",
|
|
34474
|
+
node: {
|
|
34475
|
+
entity: args.entity_type,
|
|
34476
|
+
id: "n",
|
|
34477
|
+
filters: {
|
|
34478
|
+
id: { op: "eq", value: args.entity_id }
|
|
34479
|
+
}
|
|
34480
|
+
},
|
|
34481
|
+
neighbors: {
|
|
34482
|
+
node: "n",
|
|
34483
|
+
direction
|
|
34484
|
+
},
|
|
34485
|
+
aggregations: [],
|
|
34486
|
+
path: { type: "shortest", from: "n", to: "n", max_depth: 1 }
|
|
34487
|
+
};
|
|
34488
|
+
const requestBody = {
|
|
34489
|
+
query: queryObj
|
|
34490
|
+
};
|
|
34491
|
+
if (args.limit) {
|
|
34492
|
+
requestBody.limit = args.limit;
|
|
34493
|
+
}
|
|
34494
|
+
try {
|
|
34495
|
+
const result = await client.fetch("POST", "/orbit/query", requestBody);
|
|
34496
|
+
if (result.code) {
|
|
34497
|
+
return JSON.stringify(
|
|
34498
|
+
{
|
|
34499
|
+
error: "Query error",
|
|
34500
|
+
code: result.code,
|
|
34501
|
+
message: result.message,
|
|
34502
|
+
entity_type: args.entity_type,
|
|
34503
|
+
entity_id: args.entity_id
|
|
34504
|
+
},
|
|
34505
|
+
null,
|
|
34506
|
+
2
|
|
34507
|
+
);
|
|
34508
|
+
}
|
|
34509
|
+
return JSON.stringify(result, null, 2);
|
|
34510
|
+
} catch (error45) {
|
|
34511
|
+
const errorMessage = error45 instanceof Error ? error45.message : String(error45);
|
|
34512
|
+
if (errorMessage.includes("404") || errorMessage.includes("not found")) {
|
|
34513
|
+
return JSON.stringify(
|
|
34514
|
+
{
|
|
34515
|
+
error: "Orbit API not available",
|
|
34516
|
+
entity_type: args.entity_type,
|
|
34517
|
+
entity_id: args.entity_id,
|
|
34518
|
+
suggestion: "Use gitlab_orbit_status to check API availability"
|
|
34519
|
+
},
|
|
34520
|
+
null,
|
|
34521
|
+
2
|
|
34522
|
+
);
|
|
34523
|
+
}
|
|
34524
|
+
if (errorMessage.includes("502")) {
|
|
34525
|
+
return JSON.stringify(
|
|
34526
|
+
{
|
|
34527
|
+
error: "Orbit query failed",
|
|
34528
|
+
entity_type: args.entity_type,
|
|
34529
|
+
entity_id: args.entity_id,
|
|
34530
|
+
message: "The Orbit API returned a 502 error. This is a known issue with some entity types.",
|
|
34531
|
+
suggestion: "Try a different entity type or use REST/GraphQL APIs as fallback."
|
|
34532
|
+
},
|
|
34533
|
+
null,
|
|
34534
|
+
2
|
|
34535
|
+
);
|
|
34536
|
+
}
|
|
34537
|
+
throw error45;
|
|
34538
|
+
}
|
|
34539
|
+
}
|
|
34540
|
+
})
|
|
34541
|
+
};
|
|
34542
|
+
|
|
34543
|
+
// src/tools/index.ts
|
|
34544
|
+
var mcpTools = {
|
|
34545
|
+
...mergeRequestTools,
|
|
34546
|
+
...issueTools,
|
|
34547
|
+
...epicTools,
|
|
34548
|
+
...pipelineTools,
|
|
34549
|
+
...repositoryTools,
|
|
34550
|
+
...searchTools,
|
|
34551
|
+
...projectTools,
|
|
34552
|
+
...userTools,
|
|
34553
|
+
...securityTools,
|
|
34554
|
+
...todoTools,
|
|
34555
|
+
...wikiTools,
|
|
34556
|
+
...workItemTools,
|
|
34557
|
+
...discussionsUnifiedTools,
|
|
34558
|
+
...notesUnifiedTools,
|
|
34559
|
+
...gitTools,
|
|
34560
|
+
...auditTools,
|
|
34561
|
+
...awardEmojiTools
|
|
34562
|
+
};
|
|
34563
|
+
var allTools = {
|
|
34564
|
+
...mcpTools,
|
|
34565
|
+
...orbitTools
|
|
34566
|
+
};
|
|
34567
|
+
|
|
34202
34568
|
// src/mcp-adapter.ts
|
|
34203
34569
|
function adaptToolsToMcp(server, tools) {
|
|
34204
34570
|
for (const [name, def] of Object.entries(tools)) {
|
|
@@ -34224,31 +34590,12 @@ async function main() {
|
|
|
34224
34590
|
`);
|
|
34225
34591
|
process.exit(1);
|
|
34226
34592
|
}
|
|
34227
|
-
const
|
|
34228
|
-
...mergeRequestTools,
|
|
34229
|
-
...issueTools,
|
|
34230
|
-
...epicTools,
|
|
34231
|
-
...pipelineTools,
|
|
34232
|
-
...repositoryTools,
|
|
34233
|
-
...searchTools,
|
|
34234
|
-
...projectTools,
|
|
34235
|
-
...userTools,
|
|
34236
|
-
...securityTools,
|
|
34237
|
-
...todoTools,
|
|
34238
|
-
...wikiTools,
|
|
34239
|
-
...workItemTools,
|
|
34240
|
-
...discussionsUnifiedTools,
|
|
34241
|
-
...notesUnifiedTools,
|
|
34242
|
-
...gitTools,
|
|
34243
|
-
...auditTools,
|
|
34244
|
-
...awardEmojiTools
|
|
34245
|
-
};
|
|
34246
|
-
const version2 = true ? "2.8.2" : "0.0.0";
|
|
34593
|
+
const version2 = true ? "3.0.0" : "0.0.0";
|
|
34247
34594
|
const server = new McpServer({ name: "gitlab", version: version2 });
|
|
34248
|
-
adaptToolsToMcp(server,
|
|
34595
|
+
adaptToolsToMcp(server, mcpTools);
|
|
34249
34596
|
const transport = new StdioServerTransport();
|
|
34250
34597
|
await server.connect(transport);
|
|
34251
|
-
const toolCount = Object.keys(
|
|
34598
|
+
const toolCount = Object.keys(mcpTools).length;
|
|
34252
34599
|
process.stderr.write(`gitlab MCP: serving ${toolCount} tools via stdio
|
|
34253
34600
|
`);
|
|
34254
34601
|
process.on("SIGINT", async () => {
|