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/src/index.ts CHANGED
@@ -153,6 +153,62 @@ const GetPRFilesSchema = z.object({
153
153
  pull_number: z.number(),
154
154
  });
155
155
 
156
+ const CreateLabelSchema = z.object({
157
+ owner: z.string(),
158
+ repo: z.string(),
159
+ name: z.string(),
160
+ color: z.string(), // hex color without '#'
161
+ description: z.string().optional(),
162
+ });
163
+
164
+ const UpdateLabelSchema = z.object({
165
+ owner: z.string(),
166
+ repo: z.string(),
167
+ name: z.string(), // current label name
168
+ new_name: z.string().optional(),
169
+ color: z.string().optional(), // hex color without '#'
170
+ description: z.string().optional(),
171
+ });
172
+
173
+ const DeleteLabelSchema = z.object({
174
+ owner: z.string(),
175
+ repo: z.string(),
176
+ name: z.string(),
177
+ });
178
+
179
+ const ListLabelsSchema = z.object({
180
+ owner: z.string(),
181
+ repo: z.string(),
182
+ per_page: z.number().max(100).optional(),
183
+ });
184
+
185
+ const ListBranchesSchema = z.object({
186
+ owner: z.string(),
187
+ repo: z.string(),
188
+ protected: z.boolean().optional(),
189
+ per_page: z.number().max(100).optional(),
190
+ });
191
+
192
+ const CreateBranchSchema = z.object({
193
+ owner: z.string(),
194
+ repo: z.string(),
195
+ branch: z.string(), // new branch name
196
+ ref: z.string(), // source branch or commit SHA (e.g., "main" or full ref "refs/heads/main")
197
+ });
198
+
199
+ const DeleteBranchSchema = z.object({
200
+ owner: z.string(),
201
+ repo: z.string(),
202
+ branch: z.string(), // branch name to delete
203
+ });
204
+
205
+ const CompareBranchesSchema = z.object({
206
+ owner: z.string(),
207
+ repo: z.string(),
208
+ base: z.string(), // base branch
209
+ head: z.string(), // head branch to compare
210
+ });
211
+
156
212
  const server = new Server(
157
213
  {
158
214
  name: "issue-scribe-mcp",
@@ -398,6 +454,118 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
398
454
  required: ["owner", "repo", "pull_number"],
399
455
  },
400
456
  },
457
+ {
458
+ name: "github_create_label",
459
+ description: "Create a new label in the repository",
460
+ inputSchema: {
461
+ type: "object",
462
+ properties: {
463
+ owner: { type: "string", description: "Repository owner" },
464
+ repo: { type: "string", description: "Repository name" },
465
+ name: { type: "string", description: "Label name" },
466
+ color: { type: "string", description: "Hex color code without '#' (e.g., 'FF0000' for red)" },
467
+ description: { type: "string", description: "Label description (optional)" },
468
+ },
469
+ required: ["owner", "repo", "name", "color"],
470
+ },
471
+ },
472
+ {
473
+ name: "github_update_label",
474
+ description: "Update an existing label (name, color, or description)",
475
+ inputSchema: {
476
+ type: "object",
477
+ properties: {
478
+ owner: { type: "string", description: "Repository owner" },
479
+ repo: { type: "string", description: "Repository name" },
480
+ name: { type: "string", description: "Current label name to update" },
481
+ new_name: { type: "string", description: "New label name (optional)" },
482
+ color: { type: "string", description: "New hex color code without '#' (optional)" },
483
+ description: { type: "string", description: "New description (optional)" },
484
+ },
485
+ required: ["owner", "repo", "name"],
486
+ },
487
+ },
488
+ {
489
+ name: "github_delete_label",
490
+ description: "Delete a label from the repository",
491
+ inputSchema: {
492
+ type: "object",
493
+ properties: {
494
+ owner: { type: "string", description: "Repository owner" },
495
+ repo: { type: "string", description: "Repository name" },
496
+ name: { type: "string", description: "Label name to delete" },
497
+ },
498
+ required: ["owner", "repo", "name"],
499
+ },
500
+ },
501
+ {
502
+ name: "github_list_labels",
503
+ description: "List all labels in the repository",
504
+ inputSchema: {
505
+ type: "object",
506
+ properties: {
507
+ owner: { type: "string", description: "Repository owner" },
508
+ repo: { type: "string", description: "Repository name" },
509
+ per_page: { type: "number", description: "Results per page, max 100 (optional, default: 30)" },
510
+ },
511
+ required: ["owner", "repo"],
512
+ },
513
+ },
514
+ {
515
+ name: "github_list_branches",
516
+ description: "List all branches in the repository",
517
+ inputSchema: {
518
+ type: "object",
519
+ properties: {
520
+ owner: { type: "string", description: "Repository owner" },
521
+ repo: { type: "string", description: "Repository name" },
522
+ protected: { type: "boolean", description: "Filter by protected status (optional)" },
523
+ per_page: { type: "number", description: "Results per page, max 100 (optional, default: 30)" },
524
+ },
525
+ required: ["owner", "repo"],
526
+ },
527
+ },
528
+ {
529
+ name: "github_create_branch",
530
+ description: "Create a new branch from an existing branch or commit",
531
+ inputSchema: {
532
+ type: "object",
533
+ properties: {
534
+ owner: { type: "string", description: "Repository owner" },
535
+ repo: { type: "string", description: "Repository name" },
536
+ branch: { type: "string", description: "New branch name" },
537
+ ref: { type: "string", description: "Source branch name or commit SHA (e.g., 'main' or 'abc123')" },
538
+ },
539
+ required: ["owner", "repo", "branch", "ref"],
540
+ },
541
+ },
542
+ {
543
+ name: "github_delete_branch",
544
+ description: "Delete a branch from the repository",
545
+ inputSchema: {
546
+ type: "object",
547
+ properties: {
548
+ owner: { type: "string", description: "Repository owner" },
549
+ repo: { type: "string", description: "Repository name" },
550
+ branch: { type: "string", description: "Branch name to delete" },
551
+ },
552
+ required: ["owner", "repo", "branch"],
553
+ },
554
+ },
555
+ {
556
+ name: "github_compare_branches",
557
+ description: "Compare two branches and show the differences",
558
+ inputSchema: {
559
+ type: "object",
560
+ properties: {
561
+ owner: { type: "string", description: "Repository owner" },
562
+ repo: { type: "string", description: "Repository name" },
563
+ base: { type: "string", description: "Base branch name" },
564
+ head: { type: "string", description: "Head branch name to compare" },
565
+ },
566
+ required: ["owner", "repo", "base", "head"],
567
+ },
568
+ },
401
569
  ],
402
570
  };
403
571
  });
@@ -1278,6 +1446,449 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1278
1446
  }
1279
1447
  }
1280
1448
 
1449
+ if (name === "github_create_label") {
1450
+ try {
1451
+ const { owner, repo, name: labelName, color, description } = CreateLabelSchema.parse(args);
1452
+
1453
+ const label = await octokit.rest.issues.createLabel({
1454
+ owner,
1455
+ repo,
1456
+ name: labelName,
1457
+ color,
1458
+ description,
1459
+ });
1460
+
1461
+ return {
1462
+ content: [
1463
+ {
1464
+ type: "text",
1465
+ text: JSON.stringify(
1466
+ {
1467
+ success: true,
1468
+ label: {
1469
+ name: label.data.name,
1470
+ color: label.data.color,
1471
+ description: label.data.description,
1472
+ url: label.data.url,
1473
+ },
1474
+ message: `Label "${labelName}" created successfully`,
1475
+ },
1476
+ null,
1477
+ 2
1478
+ ),
1479
+ },
1480
+ ],
1481
+ };
1482
+ } catch (error: any) {
1483
+ const labelName = args && typeof args === 'object' && 'name' in args ? args.name : 'unknown';
1484
+ const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
1485
+ const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
1486
+ return {
1487
+ content: [
1488
+ {
1489
+ type: "text",
1490
+ text: JSON.stringify({
1491
+ error: error.message,
1492
+ status: error.status,
1493
+ detail: `Failed to create label "${labelName}" in ${owner}/${repo}`,
1494
+ }, null, 2),
1495
+ },
1496
+ ],
1497
+ isError: true,
1498
+ };
1499
+ }
1500
+ }
1501
+
1502
+ if (name === "github_update_label") {
1503
+ try {
1504
+ const { owner, repo, name: currentName, new_name, color, description } = UpdateLabelSchema.parse(args);
1505
+
1506
+ const label = await octokit.rest.issues.updateLabel({
1507
+ owner,
1508
+ repo,
1509
+ name: currentName,
1510
+ new_name,
1511
+ color,
1512
+ description,
1513
+ });
1514
+
1515
+ return {
1516
+ content: [
1517
+ {
1518
+ type: "text",
1519
+ text: JSON.stringify(
1520
+ {
1521
+ success: true,
1522
+ label: {
1523
+ name: label.data.name,
1524
+ color: label.data.color,
1525
+ description: label.data.description,
1526
+ url: label.data.url,
1527
+ },
1528
+ message: `Label "${currentName}" updated successfully`,
1529
+ },
1530
+ null,
1531
+ 2
1532
+ ),
1533
+ },
1534
+ ],
1535
+ };
1536
+ } catch (error: any) {
1537
+ const labelName = args && typeof args === 'object' && 'name' in args ? args.name : 'unknown';
1538
+ const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
1539
+ const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
1540
+ return {
1541
+ content: [
1542
+ {
1543
+ type: "text",
1544
+ text: JSON.stringify({
1545
+ error: error.message,
1546
+ status: error.status,
1547
+ detail: `Failed to update label "${labelName}" in ${owner}/${repo}`,
1548
+ }, null, 2),
1549
+ },
1550
+ ],
1551
+ isError: true,
1552
+ };
1553
+ }
1554
+ }
1555
+
1556
+ if (name === "github_delete_label") {
1557
+ try {
1558
+ const { owner, repo, name: labelName } = DeleteLabelSchema.parse(args);
1559
+
1560
+ await octokit.rest.issues.deleteLabel({
1561
+ owner,
1562
+ repo,
1563
+ name: labelName,
1564
+ });
1565
+
1566
+ return {
1567
+ content: [
1568
+ {
1569
+ type: "text",
1570
+ text: JSON.stringify(
1571
+ {
1572
+ success: true,
1573
+ message: `Label "${labelName}" deleted successfully from ${owner}/${repo}`,
1574
+ },
1575
+ null,
1576
+ 2
1577
+ ),
1578
+ },
1579
+ ],
1580
+ };
1581
+ } catch (error: any) {
1582
+ const labelName = args && typeof args === 'object' && 'name' in args ? args.name : 'unknown';
1583
+ const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
1584
+ const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
1585
+ return {
1586
+ content: [
1587
+ {
1588
+ type: "text",
1589
+ text: JSON.stringify({
1590
+ error: error.message,
1591
+ status: error.status,
1592
+ detail: `Failed to delete label "${labelName}" from ${owner}/${repo}`,
1593
+ }, null, 2),
1594
+ },
1595
+ ],
1596
+ isError: true,
1597
+ };
1598
+ }
1599
+ }
1600
+
1601
+ if (name === "github_list_labels") {
1602
+ try {
1603
+ const { owner, repo, per_page } = ListLabelsSchema.parse(args);
1604
+
1605
+ const labels = await octokit.rest.issues.listLabelsForRepo({
1606
+ owner,
1607
+ repo,
1608
+ per_page,
1609
+ });
1610
+
1611
+ return {
1612
+ content: [
1613
+ {
1614
+ type: "text",
1615
+ text: JSON.stringify(
1616
+ {
1617
+ success: true,
1618
+ count: labels.data.length,
1619
+ labels: labels.data.map((label) => ({
1620
+ name: label.name,
1621
+ color: label.color,
1622
+ description: label.description,
1623
+ url: label.url,
1624
+ })),
1625
+ },
1626
+ null,
1627
+ 2
1628
+ ),
1629
+ },
1630
+ ],
1631
+ };
1632
+ } catch (error: any) {
1633
+ const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
1634
+ const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
1635
+ return {
1636
+ content: [
1637
+ {
1638
+ type: "text",
1639
+ text: JSON.stringify({
1640
+ error: error.message,
1641
+ status: error.status,
1642
+ detail: `Failed to list labels for ${owner}/${repo}`,
1643
+ }, null, 2),
1644
+ },
1645
+ ],
1646
+ isError: true,
1647
+ };
1648
+ }
1649
+ }
1650
+
1651
+ if (name === "github_list_branches") {
1652
+ try {
1653
+ const { owner, repo, protected: isProtected, per_page } = ListBranchesSchema.parse(args);
1654
+
1655
+ const branches = await octokit.rest.repos.listBranches({
1656
+ owner,
1657
+ repo,
1658
+ protected: isProtected,
1659
+ per_page,
1660
+ });
1661
+
1662
+ return {
1663
+ content: [
1664
+ {
1665
+ type: "text",
1666
+ text: JSON.stringify(
1667
+ {
1668
+ success: true,
1669
+ count: branches.data.length,
1670
+ branches: branches.data.map((branch) => ({
1671
+ name: branch.name,
1672
+ commit: {
1673
+ sha: branch.commit.sha,
1674
+ url: branch.commit.url,
1675
+ },
1676
+ protected: branch.protected,
1677
+ })),
1678
+ },
1679
+ null,
1680
+ 2
1681
+ ),
1682
+ },
1683
+ ],
1684
+ };
1685
+ } catch (error: any) {
1686
+ const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
1687
+ const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
1688
+ return {
1689
+ content: [
1690
+ {
1691
+ type: "text",
1692
+ text: JSON.stringify({
1693
+ error: error.message,
1694
+ status: error.status,
1695
+ detail: `Failed to list branches for ${owner}/${repo}`,
1696
+ }, null, 2),
1697
+ },
1698
+ ],
1699
+ isError: true,
1700
+ };
1701
+ }
1702
+ }
1703
+
1704
+ if (name === "github_create_branch") {
1705
+ try {
1706
+ const { owner, repo, branch, ref } = CreateBranchSchema.parse(args);
1707
+
1708
+ // Get the SHA of the source ref
1709
+ let sha: string;
1710
+ try {
1711
+ // Try to get ref as a branch first
1712
+ const refData = await octokit.rest.git.getRef({
1713
+ owner,
1714
+ repo,
1715
+ ref: `heads/${ref}`,
1716
+ });
1717
+ sha = refData.data.object.sha;
1718
+ } catch {
1719
+ // If not a branch, try as a commit SHA
1720
+ const commit = await octokit.rest.git.getCommit({
1721
+ owner,
1722
+ repo,
1723
+ commit_sha: ref,
1724
+ });
1725
+ sha = commit.data.sha;
1726
+ }
1727
+
1728
+ // Create the new branch
1729
+ const newBranch = await octokit.rest.git.createRef({
1730
+ owner,
1731
+ repo,
1732
+ ref: `refs/heads/${branch}`,
1733
+ sha,
1734
+ });
1735
+
1736
+ return {
1737
+ content: [
1738
+ {
1739
+ type: "text",
1740
+ text: JSON.stringify(
1741
+ {
1742
+ success: true,
1743
+ branch: {
1744
+ name: branch,
1745
+ ref: newBranch.data.ref,
1746
+ sha: newBranch.data.object.sha,
1747
+ url: newBranch.data.url,
1748
+ },
1749
+ message: `Branch "${branch}" created successfully from "${ref}"`,
1750
+ },
1751
+ null,
1752
+ 2
1753
+ ),
1754
+ },
1755
+ ],
1756
+ };
1757
+ } catch (error: any) {
1758
+ const branchName = args && typeof args === 'object' && 'branch' in args ? args.branch : 'unknown';
1759
+ const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
1760
+ const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
1761
+ return {
1762
+ content: [
1763
+ {
1764
+ type: "text",
1765
+ text: JSON.stringify({
1766
+ error: error.message,
1767
+ status: error.status,
1768
+ detail: `Failed to create branch "${branchName}" in ${owner}/${repo}`,
1769
+ }, null, 2),
1770
+ },
1771
+ ],
1772
+ isError: true,
1773
+ };
1774
+ }
1775
+ }
1776
+
1777
+ if (name === "github_delete_branch") {
1778
+ try {
1779
+ const { owner, repo, branch } = DeleteBranchSchema.parse(args);
1780
+
1781
+ await octokit.rest.git.deleteRef({
1782
+ owner,
1783
+ repo,
1784
+ ref: `heads/${branch}`,
1785
+ });
1786
+
1787
+ return {
1788
+ content: [
1789
+ {
1790
+ type: "text",
1791
+ text: JSON.stringify(
1792
+ {
1793
+ success: true,
1794
+ message: `Branch "${branch}" deleted successfully from ${owner}/${repo}`,
1795
+ },
1796
+ null,
1797
+ 2
1798
+ ),
1799
+ },
1800
+ ],
1801
+ };
1802
+ } catch (error: any) {
1803
+ const branchName = args && typeof args === 'object' && 'branch' in args ? args.branch : 'unknown';
1804
+ const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
1805
+ const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
1806
+ return {
1807
+ content: [
1808
+ {
1809
+ type: "text",
1810
+ text: JSON.stringify({
1811
+ error: error.message,
1812
+ status: error.status,
1813
+ detail: `Failed to delete branch "${branchName}" from ${owner}/${repo}`,
1814
+ }, null, 2),
1815
+ },
1816
+ ],
1817
+ isError: true,
1818
+ };
1819
+ }
1820
+ }
1821
+
1822
+ if (name === "github_compare_branches") {
1823
+ try {
1824
+ const { owner, repo, base, head } = CompareBranchesSchema.parse(args);
1825
+
1826
+ const comparison = await octokit.rest.repos.compareCommits({
1827
+ owner,
1828
+ repo,
1829
+ base,
1830
+ head,
1831
+ });
1832
+
1833
+ return {
1834
+ content: [
1835
+ {
1836
+ type: "text",
1837
+ text: JSON.stringify(
1838
+ {
1839
+ success: true,
1840
+ comparison: {
1841
+ status: comparison.data.status,
1842
+ ahead_by: comparison.data.ahead_by,
1843
+ behind_by: comparison.data.behind_by,
1844
+ total_commits: comparison.data.total_commits,
1845
+ base_commit: {
1846
+ sha: comparison.data.base_commit.sha,
1847
+ message: comparison.data.base_commit.commit.message,
1848
+ },
1849
+ commits: comparison.data.commits.map((commit) => ({
1850
+ sha: commit.sha,
1851
+ message: commit.commit.message,
1852
+ author: commit.commit.author?.name,
1853
+ date: commit.commit.author?.date,
1854
+ })),
1855
+ files: comparison.data.files?.map((file) => ({
1856
+ filename: file.filename,
1857
+ status: file.status,
1858
+ additions: file.additions,
1859
+ deletions: file.deletions,
1860
+ changes: file.changes,
1861
+ })),
1862
+ },
1863
+ message: `Comparing ${base}...${head}: ${comparison.data.ahead_by} commits ahead, ${comparison.data.behind_by} commits behind`,
1864
+ },
1865
+ null,
1866
+ 2
1867
+ ),
1868
+ },
1869
+ ],
1870
+ };
1871
+ } catch (error: any) {
1872
+ const base = args && typeof args === 'object' && 'base' in args ? args.base : 'unknown';
1873
+ const head = args && typeof args === 'object' && 'head' in args ? args.head : 'unknown';
1874
+ const owner = args && typeof args === 'object' && 'owner' in args ? args.owner : 'unknown';
1875
+ const repo = args && typeof args === 'object' && 'repo' in args ? args.repo : 'unknown';
1876
+ return {
1877
+ content: [
1878
+ {
1879
+ type: "text",
1880
+ text: JSON.stringify({
1881
+ error: error.message,
1882
+ status: error.status,
1883
+ detail: `Failed to compare branches ${base}...${head} in ${owner}/${repo}`,
1884
+ }, null, 2),
1885
+ },
1886
+ ],
1887
+ isError: true,
1888
+ };
1889
+ }
1890
+ }
1891
+
1281
1892
  throw new Error(`Unknown tool: ${name}`);
1282
1893
  });
1283
1894