issue-scribe-mcp 1.1.0 → 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/README.md +114 -0
- package/README_EN.md +114 -0
- package/dist/index.js +555 -0
- package/package.json +1 -1
- package/src/index.ts +611 -0
package/dist/index.js
CHANGED
|
@@ -129,6 +129,54 @@ const GetPRFilesSchema = z.object({
|
|
|
129
129
|
repo: z.string(),
|
|
130
130
|
pull_number: z.number(),
|
|
131
131
|
});
|
|
132
|
+
const CreateLabelSchema = z.object({
|
|
133
|
+
owner: z.string(),
|
|
134
|
+
repo: z.string(),
|
|
135
|
+
name: z.string(),
|
|
136
|
+
color: z.string(), // hex color without '#'
|
|
137
|
+
description: z.string().optional(),
|
|
138
|
+
});
|
|
139
|
+
const UpdateLabelSchema = z.object({
|
|
140
|
+
owner: z.string(),
|
|
141
|
+
repo: z.string(),
|
|
142
|
+
name: z.string(), // current label name
|
|
143
|
+
new_name: z.string().optional(),
|
|
144
|
+
color: z.string().optional(), // hex color without '#'
|
|
145
|
+
description: z.string().optional(),
|
|
146
|
+
});
|
|
147
|
+
const DeleteLabelSchema = z.object({
|
|
148
|
+
owner: z.string(),
|
|
149
|
+
repo: z.string(),
|
|
150
|
+
name: z.string(),
|
|
151
|
+
});
|
|
152
|
+
const ListLabelsSchema = z.object({
|
|
153
|
+
owner: z.string(),
|
|
154
|
+
repo: z.string(),
|
|
155
|
+
per_page: z.number().max(100).optional(),
|
|
156
|
+
});
|
|
157
|
+
const ListBranchesSchema = z.object({
|
|
158
|
+
owner: z.string(),
|
|
159
|
+
repo: z.string(),
|
|
160
|
+
protected: z.boolean().optional(),
|
|
161
|
+
per_page: z.number().max(100).optional(),
|
|
162
|
+
});
|
|
163
|
+
const CreateBranchSchema = z.object({
|
|
164
|
+
owner: z.string(),
|
|
165
|
+
repo: z.string(),
|
|
166
|
+
branch: z.string(), // new branch name
|
|
167
|
+
ref: z.string(), // source branch or commit SHA (e.g., "main" or full ref "refs/heads/main")
|
|
168
|
+
});
|
|
169
|
+
const DeleteBranchSchema = z.object({
|
|
170
|
+
owner: z.string(),
|
|
171
|
+
repo: z.string(),
|
|
172
|
+
branch: z.string(), // branch name to delete
|
|
173
|
+
});
|
|
174
|
+
const CompareBranchesSchema = z.object({
|
|
175
|
+
owner: z.string(),
|
|
176
|
+
repo: z.string(),
|
|
177
|
+
base: z.string(), // base branch
|
|
178
|
+
head: z.string(), // head branch to compare
|
|
179
|
+
});
|
|
132
180
|
const server = new Server({
|
|
133
181
|
name: "issue-scribe-mcp",
|
|
134
182
|
version: "1.0.0",
|
|
@@ -370,6 +418,118 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
370
418
|
required: ["owner", "repo", "pull_number"],
|
|
371
419
|
},
|
|
372
420
|
},
|
|
421
|
+
{
|
|
422
|
+
name: "github_create_label",
|
|
423
|
+
description: "Create a new label in the repository",
|
|
424
|
+
inputSchema: {
|
|
425
|
+
type: "object",
|
|
426
|
+
properties: {
|
|
427
|
+
owner: { type: "string", description: "Repository owner" },
|
|
428
|
+
repo: { type: "string", description: "Repository name" },
|
|
429
|
+
name: { type: "string", description: "Label name" },
|
|
430
|
+
color: { type: "string", description: "Hex color code without '#' (e.g., 'FF0000' for red)" },
|
|
431
|
+
description: { type: "string", description: "Label description (optional)" },
|
|
432
|
+
},
|
|
433
|
+
required: ["owner", "repo", "name", "color"],
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
name: "github_update_label",
|
|
438
|
+
description: "Update an existing label (name, color, or description)",
|
|
439
|
+
inputSchema: {
|
|
440
|
+
type: "object",
|
|
441
|
+
properties: {
|
|
442
|
+
owner: { type: "string", description: "Repository owner" },
|
|
443
|
+
repo: { type: "string", description: "Repository name" },
|
|
444
|
+
name: { type: "string", description: "Current label name to update" },
|
|
445
|
+
new_name: { type: "string", description: "New label name (optional)" },
|
|
446
|
+
color: { type: "string", description: "New hex color code without '#' (optional)" },
|
|
447
|
+
description: { type: "string", description: "New description (optional)" },
|
|
448
|
+
},
|
|
449
|
+
required: ["owner", "repo", "name"],
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
name: "github_delete_label",
|
|
454
|
+
description: "Delete a label from the repository",
|
|
455
|
+
inputSchema: {
|
|
456
|
+
type: "object",
|
|
457
|
+
properties: {
|
|
458
|
+
owner: { type: "string", description: "Repository owner" },
|
|
459
|
+
repo: { type: "string", description: "Repository name" },
|
|
460
|
+
name: { type: "string", description: "Label name to delete" },
|
|
461
|
+
},
|
|
462
|
+
required: ["owner", "repo", "name"],
|
|
463
|
+
},
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
name: "github_list_labels",
|
|
467
|
+
description: "List all labels in the repository",
|
|
468
|
+
inputSchema: {
|
|
469
|
+
type: "object",
|
|
470
|
+
properties: {
|
|
471
|
+
owner: { type: "string", description: "Repository owner" },
|
|
472
|
+
repo: { type: "string", description: "Repository name" },
|
|
473
|
+
per_page: { type: "number", description: "Results per page, max 100 (optional, default: 30)" },
|
|
474
|
+
},
|
|
475
|
+
required: ["owner", "repo"],
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
name: "github_list_branches",
|
|
480
|
+
description: "List all branches in the repository",
|
|
481
|
+
inputSchema: {
|
|
482
|
+
type: "object",
|
|
483
|
+
properties: {
|
|
484
|
+
owner: { type: "string", description: "Repository owner" },
|
|
485
|
+
repo: { type: "string", description: "Repository name" },
|
|
486
|
+
protected: { type: "boolean", description: "Filter by protected status (optional)" },
|
|
487
|
+
per_page: { type: "number", description: "Results per page, max 100 (optional, default: 30)" },
|
|
488
|
+
},
|
|
489
|
+
required: ["owner", "repo"],
|
|
490
|
+
},
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
name: "github_create_branch",
|
|
494
|
+
description: "Create a new branch from an existing branch or commit",
|
|
495
|
+
inputSchema: {
|
|
496
|
+
type: "object",
|
|
497
|
+
properties: {
|
|
498
|
+
owner: { type: "string", description: "Repository owner" },
|
|
499
|
+
repo: { type: "string", description: "Repository name" },
|
|
500
|
+
branch: { type: "string", description: "New branch name" },
|
|
501
|
+
ref: { type: "string", description: "Source branch name or commit SHA (e.g., 'main' or 'abc123')" },
|
|
502
|
+
},
|
|
503
|
+
required: ["owner", "repo", "branch", "ref"],
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
name: "github_delete_branch",
|
|
508
|
+
description: "Delete a branch from the repository",
|
|
509
|
+
inputSchema: {
|
|
510
|
+
type: "object",
|
|
511
|
+
properties: {
|
|
512
|
+
owner: { type: "string", description: "Repository owner" },
|
|
513
|
+
repo: { type: "string", description: "Repository name" },
|
|
514
|
+
branch: { type: "string", description: "Branch name to delete" },
|
|
515
|
+
},
|
|
516
|
+
required: ["owner", "repo", "branch"],
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
name: "github_compare_branches",
|
|
521
|
+
description: "Compare two branches and show the differences",
|
|
522
|
+
inputSchema: {
|
|
523
|
+
type: "object",
|
|
524
|
+
properties: {
|
|
525
|
+
owner: { type: "string", description: "Repository owner" },
|
|
526
|
+
repo: { type: "string", description: "Repository name" },
|
|
527
|
+
base: { type: "string", description: "Base branch name" },
|
|
528
|
+
head: { type: "string", description: "Head branch name to compare" },
|
|
529
|
+
},
|
|
530
|
+
required: ["owner", "repo", "base", "head"],
|
|
531
|
+
},
|
|
532
|
+
},
|
|
373
533
|
],
|
|
374
534
|
};
|
|
375
535
|
});
|
|
@@ -1146,6 +1306,401 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1146
1306
|
};
|
|
1147
1307
|
}
|
|
1148
1308
|
}
|
|
1309
|
+
if (name === "github_create_label") {
|
|
1310
|
+
try {
|
|
1311
|
+
const { owner, repo, name: labelName, color, description } = CreateLabelSchema.parse(args);
|
|
1312
|
+
const label = await octokit.rest.issues.createLabel({
|
|
1313
|
+
owner,
|
|
1314
|
+
repo,
|
|
1315
|
+
name: labelName,
|
|
1316
|
+
color,
|
|
1317
|
+
description,
|
|
1318
|
+
});
|
|
1319
|
+
return {
|
|
1320
|
+
content: [
|
|
1321
|
+
{
|
|
1322
|
+
type: "text",
|
|
1323
|
+
text: JSON.stringify({
|
|
1324
|
+
success: true,
|
|
1325
|
+
label: {
|
|
1326
|
+
name: label.data.name,
|
|
1327
|
+
color: label.data.color,
|
|
1328
|
+
description: label.data.description,
|
|
1329
|
+
url: label.data.url,
|
|
1330
|
+
},
|
|
1331
|
+
message: `Label "${labelName}" created successfully`,
|
|
1332
|
+
}, null, 2),
|
|
1333
|
+
},
|
|
1334
|
+
],
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
catch (error) {
|
|
1338
|
+
const labelName = args && typeof args === 'object' && 'name' in args ? args.name : 'unknown';
|
|
1339
|
+
const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
|
|
1340
|
+
const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
|
|
1341
|
+
return {
|
|
1342
|
+
content: [
|
|
1343
|
+
{
|
|
1344
|
+
type: "text",
|
|
1345
|
+
text: JSON.stringify({
|
|
1346
|
+
error: error.message,
|
|
1347
|
+
status: error.status,
|
|
1348
|
+
detail: `Failed to create label "${labelName}" in ${owner}/${repo}`,
|
|
1349
|
+
}, null, 2),
|
|
1350
|
+
},
|
|
1351
|
+
],
|
|
1352
|
+
isError: true,
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
if (name === "github_update_label") {
|
|
1357
|
+
try {
|
|
1358
|
+
const { owner, repo, name: currentName, new_name, color, description } = UpdateLabelSchema.parse(args);
|
|
1359
|
+
const label = await octokit.rest.issues.updateLabel({
|
|
1360
|
+
owner,
|
|
1361
|
+
repo,
|
|
1362
|
+
name: currentName,
|
|
1363
|
+
new_name,
|
|
1364
|
+
color,
|
|
1365
|
+
description,
|
|
1366
|
+
});
|
|
1367
|
+
return {
|
|
1368
|
+
content: [
|
|
1369
|
+
{
|
|
1370
|
+
type: "text",
|
|
1371
|
+
text: JSON.stringify({
|
|
1372
|
+
success: true,
|
|
1373
|
+
label: {
|
|
1374
|
+
name: label.data.name,
|
|
1375
|
+
color: label.data.color,
|
|
1376
|
+
description: label.data.description,
|
|
1377
|
+
url: label.data.url,
|
|
1378
|
+
},
|
|
1379
|
+
message: `Label "${currentName}" updated successfully`,
|
|
1380
|
+
}, null, 2),
|
|
1381
|
+
},
|
|
1382
|
+
],
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
catch (error) {
|
|
1386
|
+
const labelName = args && typeof args === 'object' && 'name' in args ? args.name : 'unknown';
|
|
1387
|
+
const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
|
|
1388
|
+
const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
|
|
1389
|
+
return {
|
|
1390
|
+
content: [
|
|
1391
|
+
{
|
|
1392
|
+
type: "text",
|
|
1393
|
+
text: JSON.stringify({
|
|
1394
|
+
error: error.message,
|
|
1395
|
+
status: error.status,
|
|
1396
|
+
detail: `Failed to update label "${labelName}" in ${owner}/${repo}`,
|
|
1397
|
+
}, null, 2),
|
|
1398
|
+
},
|
|
1399
|
+
],
|
|
1400
|
+
isError: true,
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
if (name === "github_delete_label") {
|
|
1405
|
+
try {
|
|
1406
|
+
const { owner, repo, name: labelName } = DeleteLabelSchema.parse(args);
|
|
1407
|
+
await octokit.rest.issues.deleteLabel({
|
|
1408
|
+
owner,
|
|
1409
|
+
repo,
|
|
1410
|
+
name: labelName,
|
|
1411
|
+
});
|
|
1412
|
+
return {
|
|
1413
|
+
content: [
|
|
1414
|
+
{
|
|
1415
|
+
type: "text",
|
|
1416
|
+
text: JSON.stringify({
|
|
1417
|
+
success: true,
|
|
1418
|
+
message: `Label "${labelName}" deleted successfully from ${owner}/${repo}`,
|
|
1419
|
+
}, null, 2),
|
|
1420
|
+
},
|
|
1421
|
+
],
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
catch (error) {
|
|
1425
|
+
const labelName = args && typeof args === 'object' && 'name' in args ? args.name : 'unknown';
|
|
1426
|
+
const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
|
|
1427
|
+
const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
|
|
1428
|
+
return {
|
|
1429
|
+
content: [
|
|
1430
|
+
{
|
|
1431
|
+
type: "text",
|
|
1432
|
+
text: JSON.stringify({
|
|
1433
|
+
error: error.message,
|
|
1434
|
+
status: error.status,
|
|
1435
|
+
detail: `Failed to delete label "${labelName}" from ${owner}/${repo}`,
|
|
1436
|
+
}, null, 2),
|
|
1437
|
+
},
|
|
1438
|
+
],
|
|
1439
|
+
isError: true,
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
if (name === "github_list_labels") {
|
|
1444
|
+
try {
|
|
1445
|
+
const { owner, repo, per_page } = ListLabelsSchema.parse(args);
|
|
1446
|
+
const labels = await octokit.rest.issues.listLabelsForRepo({
|
|
1447
|
+
owner,
|
|
1448
|
+
repo,
|
|
1449
|
+
per_page,
|
|
1450
|
+
});
|
|
1451
|
+
return {
|
|
1452
|
+
content: [
|
|
1453
|
+
{
|
|
1454
|
+
type: "text",
|
|
1455
|
+
text: JSON.stringify({
|
|
1456
|
+
success: true,
|
|
1457
|
+
count: labels.data.length,
|
|
1458
|
+
labels: labels.data.map((label) => ({
|
|
1459
|
+
name: label.name,
|
|
1460
|
+
color: label.color,
|
|
1461
|
+
description: label.description,
|
|
1462
|
+
url: label.url,
|
|
1463
|
+
})),
|
|
1464
|
+
}, null, 2),
|
|
1465
|
+
},
|
|
1466
|
+
],
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1469
|
+
catch (error) {
|
|
1470
|
+
const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
|
|
1471
|
+
const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
|
|
1472
|
+
return {
|
|
1473
|
+
content: [
|
|
1474
|
+
{
|
|
1475
|
+
type: "text",
|
|
1476
|
+
text: JSON.stringify({
|
|
1477
|
+
error: error.message,
|
|
1478
|
+
status: error.status,
|
|
1479
|
+
detail: `Failed to list labels for ${owner}/${repo}`,
|
|
1480
|
+
}, null, 2),
|
|
1481
|
+
},
|
|
1482
|
+
],
|
|
1483
|
+
isError: true,
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
if (name === "github_list_branches") {
|
|
1488
|
+
try {
|
|
1489
|
+
const { owner, repo, protected: isProtected, per_page } = ListBranchesSchema.parse(args);
|
|
1490
|
+
const branches = await octokit.rest.repos.listBranches({
|
|
1491
|
+
owner,
|
|
1492
|
+
repo,
|
|
1493
|
+
protected: isProtected,
|
|
1494
|
+
per_page,
|
|
1495
|
+
});
|
|
1496
|
+
return {
|
|
1497
|
+
content: [
|
|
1498
|
+
{
|
|
1499
|
+
type: "text",
|
|
1500
|
+
text: JSON.stringify({
|
|
1501
|
+
success: true,
|
|
1502
|
+
count: branches.data.length,
|
|
1503
|
+
branches: branches.data.map((branch) => ({
|
|
1504
|
+
name: branch.name,
|
|
1505
|
+
commit: {
|
|
1506
|
+
sha: branch.commit.sha,
|
|
1507
|
+
url: branch.commit.url,
|
|
1508
|
+
},
|
|
1509
|
+
protected: branch.protected,
|
|
1510
|
+
})),
|
|
1511
|
+
}, null, 2),
|
|
1512
|
+
},
|
|
1513
|
+
],
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
catch (error) {
|
|
1517
|
+
const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
|
|
1518
|
+
const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
|
|
1519
|
+
return {
|
|
1520
|
+
content: [
|
|
1521
|
+
{
|
|
1522
|
+
type: "text",
|
|
1523
|
+
text: JSON.stringify({
|
|
1524
|
+
error: error.message,
|
|
1525
|
+
status: error.status,
|
|
1526
|
+
detail: `Failed to list branches for ${owner}/${repo}`,
|
|
1527
|
+
}, null, 2),
|
|
1528
|
+
},
|
|
1529
|
+
],
|
|
1530
|
+
isError: true,
|
|
1531
|
+
};
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
if (name === "github_create_branch") {
|
|
1535
|
+
try {
|
|
1536
|
+
const { owner, repo, branch, ref } = CreateBranchSchema.parse(args);
|
|
1537
|
+
// Get the SHA of the source ref
|
|
1538
|
+
let sha;
|
|
1539
|
+
try {
|
|
1540
|
+
// Try to get ref as a branch first
|
|
1541
|
+
const refData = await octokit.rest.git.getRef({
|
|
1542
|
+
owner,
|
|
1543
|
+
repo,
|
|
1544
|
+
ref: `heads/${ref}`,
|
|
1545
|
+
});
|
|
1546
|
+
sha = refData.data.object.sha;
|
|
1547
|
+
}
|
|
1548
|
+
catch {
|
|
1549
|
+
// If not a branch, try as a commit SHA
|
|
1550
|
+
const commit = await octokit.rest.git.getCommit({
|
|
1551
|
+
owner,
|
|
1552
|
+
repo,
|
|
1553
|
+
commit_sha: ref,
|
|
1554
|
+
});
|
|
1555
|
+
sha = commit.data.sha;
|
|
1556
|
+
}
|
|
1557
|
+
// Create the new branch
|
|
1558
|
+
const newBranch = await octokit.rest.git.createRef({
|
|
1559
|
+
owner,
|
|
1560
|
+
repo,
|
|
1561
|
+
ref: `refs/heads/${branch}`,
|
|
1562
|
+
sha,
|
|
1563
|
+
});
|
|
1564
|
+
return {
|
|
1565
|
+
content: [
|
|
1566
|
+
{
|
|
1567
|
+
type: "text",
|
|
1568
|
+
text: JSON.stringify({
|
|
1569
|
+
success: true,
|
|
1570
|
+
branch: {
|
|
1571
|
+
name: branch,
|
|
1572
|
+
ref: newBranch.data.ref,
|
|
1573
|
+
sha: newBranch.data.object.sha,
|
|
1574
|
+
url: newBranch.data.url,
|
|
1575
|
+
},
|
|
1576
|
+
message: `Branch "${branch}" created successfully from "${ref}"`,
|
|
1577
|
+
}, null, 2),
|
|
1578
|
+
},
|
|
1579
|
+
],
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1582
|
+
catch (error) {
|
|
1583
|
+
const branchName = args && typeof args === 'object' && 'branch' in args ? args.branch : 'unknown';
|
|
1584
|
+
const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
|
|
1585
|
+
const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
|
|
1586
|
+
return {
|
|
1587
|
+
content: [
|
|
1588
|
+
{
|
|
1589
|
+
type: "text",
|
|
1590
|
+
text: JSON.stringify({
|
|
1591
|
+
error: error.message,
|
|
1592
|
+
status: error.status,
|
|
1593
|
+
detail: `Failed to create branch "${branchName}" in ${owner}/${repo}`,
|
|
1594
|
+
}, null, 2),
|
|
1595
|
+
},
|
|
1596
|
+
],
|
|
1597
|
+
isError: true,
|
|
1598
|
+
};
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
if (name === "github_delete_branch") {
|
|
1602
|
+
try {
|
|
1603
|
+
const { owner, repo, branch } = DeleteBranchSchema.parse(args);
|
|
1604
|
+
await octokit.rest.git.deleteRef({
|
|
1605
|
+
owner,
|
|
1606
|
+
repo,
|
|
1607
|
+
ref: `heads/${branch}`,
|
|
1608
|
+
});
|
|
1609
|
+
return {
|
|
1610
|
+
content: [
|
|
1611
|
+
{
|
|
1612
|
+
type: "text",
|
|
1613
|
+
text: JSON.stringify({
|
|
1614
|
+
success: true,
|
|
1615
|
+
message: `Branch "${branch}" deleted successfully from ${owner}/${repo}`,
|
|
1616
|
+
}, null, 2),
|
|
1617
|
+
},
|
|
1618
|
+
],
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
catch (error) {
|
|
1622
|
+
const branchName = args && typeof args === 'object' && 'branch' in args ? args.branch : 'unknown';
|
|
1623
|
+
const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
|
|
1624
|
+
const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
|
|
1625
|
+
return {
|
|
1626
|
+
content: [
|
|
1627
|
+
{
|
|
1628
|
+
type: "text",
|
|
1629
|
+
text: JSON.stringify({
|
|
1630
|
+
error: error.message,
|
|
1631
|
+
status: error.status,
|
|
1632
|
+
detail: `Failed to delete branch "${branchName}" from ${owner}/${repo}`,
|
|
1633
|
+
}, null, 2),
|
|
1634
|
+
},
|
|
1635
|
+
],
|
|
1636
|
+
isError: true,
|
|
1637
|
+
};
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
if (name === "github_compare_branches") {
|
|
1641
|
+
try {
|
|
1642
|
+
const { owner, repo, base, head } = CompareBranchesSchema.parse(args);
|
|
1643
|
+
const comparison = await octokit.rest.repos.compareCommits({
|
|
1644
|
+
owner,
|
|
1645
|
+
repo,
|
|
1646
|
+
base,
|
|
1647
|
+
head,
|
|
1648
|
+
});
|
|
1649
|
+
return {
|
|
1650
|
+
content: [
|
|
1651
|
+
{
|
|
1652
|
+
type: "text",
|
|
1653
|
+
text: JSON.stringify({
|
|
1654
|
+
success: true,
|
|
1655
|
+
comparison: {
|
|
1656
|
+
status: comparison.data.status,
|
|
1657
|
+
ahead_by: comparison.data.ahead_by,
|
|
1658
|
+
behind_by: comparison.data.behind_by,
|
|
1659
|
+
total_commits: comparison.data.total_commits,
|
|
1660
|
+
base_commit: {
|
|
1661
|
+
sha: comparison.data.base_commit.sha,
|
|
1662
|
+
message: comparison.data.base_commit.commit.message,
|
|
1663
|
+
},
|
|
1664
|
+
commits: comparison.data.commits.map((commit) => ({
|
|
1665
|
+
sha: commit.sha,
|
|
1666
|
+
message: commit.commit.message,
|
|
1667
|
+
author: commit.commit.author?.name,
|
|
1668
|
+
date: commit.commit.author?.date,
|
|
1669
|
+
})),
|
|
1670
|
+
files: comparison.data.files?.map((file) => ({
|
|
1671
|
+
filename: file.filename,
|
|
1672
|
+
status: file.status,
|
|
1673
|
+
additions: file.additions,
|
|
1674
|
+
deletions: file.deletions,
|
|
1675
|
+
changes: file.changes,
|
|
1676
|
+
})),
|
|
1677
|
+
},
|
|
1678
|
+
message: `Comparing ${base}...${head}: ${comparison.data.ahead_by} commits ahead, ${comparison.data.behind_by} commits behind`,
|
|
1679
|
+
}, null, 2),
|
|
1680
|
+
},
|
|
1681
|
+
],
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
catch (error) {
|
|
1685
|
+
const base = args && typeof args === 'object' && 'base' in args ? args.base : 'unknown';
|
|
1686
|
+
const head = args && typeof args === 'object' && 'head' in args ? args.head : 'unknown';
|
|
1687
|
+
const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
|
|
1688
|
+
const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
|
|
1689
|
+
return {
|
|
1690
|
+
content: [
|
|
1691
|
+
{
|
|
1692
|
+
type: "text",
|
|
1693
|
+
text: JSON.stringify({
|
|
1694
|
+
error: error.message,
|
|
1695
|
+
status: error.status,
|
|
1696
|
+
detail: `Failed to compare branches ${base}...${head} in ${owner}/${repo}`,
|
|
1697
|
+
}, null, 2),
|
|
1698
|
+
},
|
|
1699
|
+
],
|
|
1700
|
+
isError: true,
|
|
1701
|
+
};
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1149
1704
|
throw new Error(`Unknown tool: ${name}`);
|
|
1150
1705
|
});
|
|
1151
1706
|
async function main() {
|