@lexmata/bitbucket-mcp 1.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.
@@ -0,0 +1,1698 @@
1
+ import { z } from 'zod';
2
+ import { RepositoriesAPI } from '../api/repositories.js';
3
+ import { PullRequestsAPI } from '../api/pullrequests.js';
4
+ import { BranchesAPI } from '../api/branches.js';
5
+ import { CommitsAPI } from '../api/commits.js';
6
+ import { IssuesAPI } from '../api/issues.js';
7
+ import { PipelinesAPI } from '../api/pipelines.js';
8
+ import { SearchAPI } from '../api/search.js';
9
+ export const toolSchemas = {
10
+ list_repositories: z.object({
11
+ workspace: z.string().describe('The workspace slug'),
12
+ role: z.enum([
13
+ 'owner',
14
+ 'admin',
15
+ 'contributor',
16
+ 'member'
17
+ ]).optional().describe('Filter by role'),
18
+ q: z.string().optional().describe('Query string for filtering'),
19
+ sort: z.string().optional().describe('Sort field (e.g., "-updated_on")'),
20
+ page: z.number().optional().describe('Page number'),
21
+ pagelen: z.number().optional().describe('Results per page (max 100)')
22
+ }),
23
+ get_repository: z.object({
24
+ workspace: z.string().describe('The workspace slug'),
25
+ repo_slug: z.string().describe('The repository slug')
26
+ }),
27
+ create_repository: z.object({
28
+ workspace: z.string().describe('The workspace slug'),
29
+ repo_slug: z.string().describe('The repository slug'),
30
+ name: z.string().optional().describe('Repository name'),
31
+ description: z.string().optional().describe("Repository description"),
32
+ is_private: z.boolean().optional().describe('Whether the repository is private'),
33
+ language: z.string().optional().describe('Primary language'),
34
+ has_issues: z.boolean().optional().describe('Enable issue tracker'),
35
+ has_wiki: z.boolean().optional().describe('Enable wiki'),
36
+ project_key: z.string().optional().describe('Project key to add repo to')
37
+ }),
38
+ delete_repository: z.object({
39
+ workspace: z.string().describe('The workspace slug'),
40
+ repo_slug: z.string().describe('The repository slug')
41
+ }),
42
+ list_repository_forks: z.object({
43
+ workspace: z.string().describe('The workspace slug'),
44
+ repo_slug: z.string().describe('The repository slug'),
45
+ page: z.number().optional().describe('Page number'),
46
+ pagelen: z.number().optional().describe('Results per page')
47
+ }),
48
+ list_pull_requests: z.object({
49
+ workspace: z.string().describe('The workspace slug'),
50
+ repo_slug: z.string().describe('The repository slug'),
51
+ state: z.enum([
52
+ 'OPEN',
53
+ 'MERGED',
54
+ 'DECLINED',
55
+ 'SUPERSEDED'
56
+ ]).optional().describe('Filter by state'),
57
+ page: z.number().optional().describe('Page number'),
58
+ pagelen: z.number().optional().describe('Results per page')
59
+ }),
60
+ get_pull_request: z.object({
61
+ workspace: z.string().describe('The workspace slug'),
62
+ repo_slug: z.string().describe('The repository slug'),
63
+ pr_id: z.number().describe('The pull request ID')
64
+ }),
65
+ create_pull_request: z.object({
66
+ workspace: z.string().describe('The workspace slug'),
67
+ repo_slug: z.string().describe('The repository slug'),
68
+ title: z.string().describe('Pull request title'),
69
+ source_branch: z.string().describe('Source branch name'),
70
+ destination_branch: z.string().optional().describe('Destination branch (defaults to main branch)'),
71
+ description: z.string().optional().describe("Pull request description"),
72
+ close_source_branch: z.boolean().optional().describe('Close source branch after merge'),
73
+ reviewers: z.array(z.string()).optional().describe('List of reviewer UUIDs')
74
+ }),
75
+ update_pull_request: z.object({
76
+ workspace: z.string().describe('The workspace slug'),
77
+ repo_slug: z.string().describe('The repository slug'),
78
+ pr_id: z.number().describe('The pull request ID'),
79
+ title: z.string().optional().describe('New title'),
80
+ description: z.string().optional().describe("New description"),
81
+ destination_branch: z.string().optional().describe('New destination branch')
82
+ }),
83
+ merge_pull_request: z.object({
84
+ workspace: z.string().describe('The workspace slug'),
85
+ repo_slug: z.string().describe('The repository slug'),
86
+ pr_id: z.number().describe('The pull request ID'),
87
+ message: z.string().optional().describe('Merge commit message'),
88
+ close_source_branch: z.boolean().optional().describe('Close source branch after merge'),
89
+ merge_strategy: z.enum([
90
+ 'merge_commit',
91
+ 'squash',
92
+ 'fast_forward'
93
+ ]).optional().describe('Merge strategy')
94
+ }),
95
+ decline_pull_request: z.object({
96
+ workspace: z.string().describe('The workspace slug'),
97
+ repo_slug: z.string().describe('The repository slug'),
98
+ pr_id: z.number().describe('The pull request ID')
99
+ }),
100
+ approve_pull_request: z.object({
101
+ workspace: z.string().describe('The workspace slug'),
102
+ repo_slug: z.string().describe('The repository slug'),
103
+ pr_id: z.number().describe('The pull request ID')
104
+ }),
105
+ request_changes: z.object({
106
+ workspace: z.string().describe('The workspace slug'),
107
+ repo_slug: z.string().describe('The repository slug'),
108
+ pr_id: z.number().describe('The pull request ID')
109
+ }),
110
+ list_pr_comments: z.object({
111
+ workspace: z.string().describe('The workspace slug'),
112
+ repo_slug: z.string().describe('The repository slug'),
113
+ pr_id: z.number().describe('The pull request ID'),
114
+ page: z.number().optional().describe('Page number'),
115
+ pagelen: z.number().optional().describe('Results per page')
116
+ }),
117
+ add_pr_comment: z.object({
118
+ workspace: z.string().describe('The workspace slug'),
119
+ repo_slug: z.string().describe('The repository slug'),
120
+ pr_id: z.number().describe('The pull request ID'),
121
+ content: z.string().describe('Comment content (markdown)'),
122
+ path: z.string().optional().describe('File path for inline comment'),
123
+ line: z.number().optional().describe('Line number for inline comment')
124
+ }),
125
+ get_pr_diff: z.object({
126
+ workspace: z.string().describe('The workspace slug'),
127
+ repo_slug: z.string().describe('The repository slug'),
128
+ pr_id: z.number().describe('The pull request ID')
129
+ }),
130
+ list_branches: z.object({
131
+ workspace: z.string().describe('The workspace slug'),
132
+ repo_slug: z.string().describe('The repository slug'),
133
+ q: z.string().optional().describe('Query string for filtering'),
134
+ sort: z.string().optional().describe('Sort field'),
135
+ page: z.number().optional().describe('Page number'),
136
+ pagelen: z.number().optional().describe('Results per page')
137
+ }),
138
+ get_branch: z.object({
139
+ workspace: z.string().describe('The workspace slug'),
140
+ repo_slug: z.string().describe('The repository slug'),
141
+ branch_name: z.string().describe('The branch name')
142
+ }),
143
+ create_branch: z.object({
144
+ workspace: z.string().describe('The workspace slug'),
145
+ repo_slug: z.string().describe('The repository slug'),
146
+ name: z.string().describe('New branch name'),
147
+ target: z.string().describe('Target commit hash or branch name')
148
+ }),
149
+ delete_branch: z.object({
150
+ workspace: z.string().describe('The workspace slug'),
151
+ repo_slug: z.string().describe('The repository slug'),
152
+ branch_name: z.string().describe('The branch name to delete')
153
+ }),
154
+ list_commits: z.object({
155
+ workspace: z.string().describe('The workspace slug'),
156
+ repo_slug: z.string().describe('The repository slug'),
157
+ branch: z.string().optional().describe('Branch name to filter commits'),
158
+ include: z.string().optional().describe('Commit to include'),
159
+ exclude: z.string().optional().describe('Commit to exclude'),
160
+ page: z.number().optional().describe('Page number'),
161
+ pagelen: z.number().optional().describe('Results per page')
162
+ }),
163
+ get_commit: z.object({
164
+ workspace: z.string().describe('The workspace slug'),
165
+ repo_slug: z.string().describe('The repository slug'),
166
+ commit_hash: z.string().describe('The commit hash')
167
+ }),
168
+ get_commit_diff: z.object({
169
+ workspace: z.string().describe('The workspace slug'),
170
+ repo_slug: z.string().describe('The repository slug'),
171
+ commit_hash: z.string().describe('The commit hash')
172
+ }),
173
+ list_issues: z.object({
174
+ workspace: z.string().describe('The workspace slug'),
175
+ repo_slug: z.string().describe('The repository slug'),
176
+ q: z.string().optional().describe('Query string for filtering'),
177
+ sort: z.string().optional().describe('Sort field'),
178
+ page: z.number().optional().describe('Page number'),
179
+ pagelen: z.number().optional().describe('Results per page')
180
+ }),
181
+ get_issue: z.object({
182
+ workspace: z.string().describe('The workspace slug'),
183
+ repo_slug: z.string().describe('The repository slug'),
184
+ issue_id: z.number().describe('The issue ID')
185
+ }),
186
+ create_issue: z.object({
187
+ workspace: z.string().describe('The workspace slug'),
188
+ repo_slug: z.string().describe('The repository slug'),
189
+ title: z.string().describe('Issue title'),
190
+ content: z.string().optional().describe("Issue content/description"),
191
+ kind: z.enum([
192
+ 'bug',
193
+ 'enhancement',
194
+ 'proposal',
195
+ 'task'
196
+ ]).optional().describe('Issue type'),
197
+ priority: z.enum([
198
+ 'trivial',
199
+ 'minor',
200
+ 'major',
201
+ 'critical',
202
+ 'blocker'
203
+ ]).optional().describe('Priority level'),
204
+ assignee: z.string().optional().describe('Assignee UUID')
205
+ }),
206
+ update_issue: z.object({
207
+ workspace: z.string().describe('The workspace slug'),
208
+ repo_slug: z.string().describe('The repository slug'),
209
+ issue_id: z.number().describe('The issue ID'),
210
+ title: z.string().optional().describe('New title'),
211
+ content: z.string().optional().describe('New content'),
212
+ state: z.enum([
213
+ 'new',
214
+ 'open',
215
+ 'resolved',
216
+ 'on hold',
217
+ 'invalid',
218
+ 'duplicate',
219
+ 'wontfix',
220
+ 'closed'
221
+ ]).optional().describe('New state'),
222
+ kind: z.enum([
223
+ 'bug',
224
+ 'enhancement',
225
+ 'proposal',
226
+ 'task'
227
+ ]).optional().describe('Issue type'),
228
+ priority: z.enum([
229
+ 'trivial',
230
+ 'minor',
231
+ 'major',
232
+ 'critical',
233
+ 'blocker'
234
+ ]).optional().describe('Priority level'),
235
+ assignee: z.string().optional().describe('Assignee UUID')
236
+ }),
237
+ delete_issue: z.object({
238
+ workspace: z.string().describe('The workspace slug'),
239
+ repo_slug: z.string().describe('The repository slug'),
240
+ issue_id: z.number().describe('The issue ID')
241
+ }),
242
+ list_pipelines: z.object({
243
+ workspace: z.string().describe('The workspace slug'),
244
+ repo_slug: z.string().describe('The repository slug'),
245
+ page: z.number().optional().describe('Page number'),
246
+ pagelen: z.number().optional().describe('Results per page')
247
+ }),
248
+ get_pipeline: z.object({
249
+ workspace: z.string().describe('The workspace slug'),
250
+ repo_slug: z.string().describe('The repository slug'),
251
+ pipeline_uuid: z.string().describe('The pipeline UUID')
252
+ }),
253
+ trigger_pipeline: z.object({
254
+ workspace: z.string().describe('The workspace slug'),
255
+ repo_slug: z.string().describe('The repository slug'),
256
+ ref_type: z.enum([
257
+ 'branch',
258
+ 'tag',
259
+ 'bookmark'
260
+ ]).describe('Reference type'),
261
+ ref_name: z.string().describe('Reference name (branch/tag name)'),
262
+ variables: z.array(z.object({
263
+ key: z.string(),
264
+ value: z.string(),
265
+ secured: z.boolean().optional()
266
+ })).optional().describe('Pipeline variables')
267
+ }),
268
+ stop_pipeline: z.object({
269
+ workspace: z.string().describe('The workspace slug'),
270
+ repo_slug: z.string().describe('The repository slug'),
271
+ pipeline_uuid: z.string().describe('The pipeline UUID')
272
+ }),
273
+ search_code: z.object({
274
+ workspace: z.string().describe('The workspace slug'),
275
+ search_query: z.string().describe('Search query string'),
276
+ page: z.number().optional().describe('Page number'),
277
+ pagelen: z.number().optional().describe('Results per page')
278
+ }),
279
+ get_file_content: z.object({
280
+ workspace: z.string().describe('The workspace slug'),
281
+ repo_slug: z.string().describe('The repository slug'),
282
+ path: z.string().describe('File path'),
283
+ ref: z.string().optional().describe('Git ref (branch, tag, or commit)')
284
+ })
285
+ };
286
+ export const toolDefinitions = [
287
+ {
288
+ name: 'list_repositories',
289
+ description: 'List repositories in a workspace. Returns paginated results with repository details.',
290
+ inputSchema: {
291
+ type: 'object',
292
+ properties: {
293
+ workspace: {
294
+ type: 'string',
295
+ description: 'The workspace slug'
296
+ },
297
+ role: {
298
+ type: 'string',
299
+ enum: [
300
+ 'owner',
301
+ 'admin',
302
+ 'contributor',
303
+ 'member'
304
+ ],
305
+ description: 'Filter by role'
306
+ },
307
+ q: {
308
+ type: 'string',
309
+ description: 'Query string for filtering'
310
+ },
311
+ sort: {
312
+ type: 'string',
313
+ description: 'Sort field (e.g., "-updated_on")'
314
+ },
315
+ page: {
316
+ type: 'number',
317
+ description: 'Page number'
318
+ },
319
+ pagelen: {
320
+ type: 'number',
321
+ description: 'Results per page (max 100)'
322
+ }
323
+ },
324
+ required: [
325
+ 'workspace'
326
+ ]
327
+ }
328
+ },
329
+ {
330
+ name: 'get_repository',
331
+ description: 'Get details of a specific repository including its branches, pull requests, and other metadata.',
332
+ inputSchema: {
333
+ type: 'object',
334
+ properties: {
335
+ workspace: {
336
+ type: 'string',
337
+ description: 'The workspace slug'
338
+ },
339
+ repo_slug: {
340
+ type: 'string',
341
+ description: 'The repository slug'
342
+ }
343
+ },
344
+ required: [
345
+ 'workspace',
346
+ 'repo_slug'
347
+ ]
348
+ }
349
+ },
350
+ {
351
+ name: 'create_repository',
352
+ description: 'Create a new repository in the specified workspace.',
353
+ inputSchema: {
354
+ type: 'object',
355
+ properties: {
356
+ workspace: {
357
+ type: 'string',
358
+ description: 'The workspace slug'
359
+ },
360
+ repo_slug: {
361
+ type: 'string',
362
+ description: 'The repository slug'
363
+ },
364
+ name: {
365
+ type: 'string',
366
+ description: 'Repository name'
367
+ },
368
+ description: {
369
+ type: 'string',
370
+ description: "Repository description"
371
+ },
372
+ is_private: {
373
+ type: 'boolean',
374
+ description: 'Whether the repository is private'
375
+ },
376
+ language: {
377
+ type: 'string',
378
+ description: 'Primary language'
379
+ },
380
+ has_issues: {
381
+ type: 'boolean',
382
+ description: 'Enable issue tracker'
383
+ },
384
+ has_wiki: {
385
+ type: 'boolean',
386
+ description: 'Enable wiki'
387
+ },
388
+ project_key: {
389
+ type: 'string',
390
+ description: 'Project key to add repo to'
391
+ }
392
+ },
393
+ required: [
394
+ 'workspace',
395
+ 'repo_slug'
396
+ ]
397
+ }
398
+ },
399
+ {
400
+ name: 'delete_repository',
401
+ description: 'Delete a repository. This action is irreversible.',
402
+ inputSchema: {
403
+ type: 'object',
404
+ properties: {
405
+ workspace: {
406
+ type: 'string',
407
+ description: 'The workspace slug'
408
+ },
409
+ repo_slug: {
410
+ type: 'string',
411
+ description: 'The repository slug'
412
+ }
413
+ },
414
+ required: [
415
+ 'workspace',
416
+ 'repo_slug'
417
+ ]
418
+ }
419
+ },
420
+ {
421
+ name: 'list_repository_forks',
422
+ description: 'List all forks of a repository.',
423
+ inputSchema: {
424
+ type: 'object',
425
+ properties: {
426
+ workspace: {
427
+ type: 'string',
428
+ description: 'The workspace slug'
429
+ },
430
+ repo_slug: {
431
+ type: 'string',
432
+ description: 'The repository slug'
433
+ },
434
+ page: {
435
+ type: 'number',
436
+ description: 'Page number'
437
+ },
438
+ pagelen: {
439
+ type: 'number',
440
+ description: 'Results per page'
441
+ }
442
+ },
443
+ required: [
444
+ 'workspace',
445
+ 'repo_slug'
446
+ ]
447
+ }
448
+ },
449
+ {
450
+ name: 'list_pull_requests',
451
+ description: 'List pull requests for a repository with optional filtering by state.',
452
+ inputSchema: {
453
+ type: 'object',
454
+ properties: {
455
+ workspace: {
456
+ type: 'string',
457
+ description: 'The workspace slug'
458
+ },
459
+ repo_slug: {
460
+ type: 'string',
461
+ description: 'The repository slug'
462
+ },
463
+ state: {
464
+ type: 'string',
465
+ enum: [
466
+ 'OPEN',
467
+ 'MERGED',
468
+ 'DECLINED',
469
+ 'SUPERSEDED'
470
+ ],
471
+ description: 'Filter by state'
472
+ },
473
+ page: {
474
+ type: 'number',
475
+ description: 'Page number'
476
+ },
477
+ pagelen: {
478
+ type: 'number',
479
+ description: 'Results per page'
480
+ }
481
+ },
482
+ required: [
483
+ 'workspace',
484
+ 'repo_slug'
485
+ ]
486
+ }
487
+ },
488
+ {
489
+ name: 'get_pull_request',
490
+ description: 'Get details of a specific pull request including its source, destination, and status.',
491
+ inputSchema: {
492
+ type: 'object',
493
+ properties: {
494
+ workspace: {
495
+ type: 'string',
496
+ description: 'The workspace slug'
497
+ },
498
+ repo_slug: {
499
+ type: 'string',
500
+ description: 'The repository slug'
501
+ },
502
+ pr_id: {
503
+ type: 'number',
504
+ description: 'The pull request ID'
505
+ }
506
+ },
507
+ required: [
508
+ 'workspace',
509
+ 'repo_slug',
510
+ 'pr_id'
511
+ ]
512
+ }
513
+ },
514
+ {
515
+ name: 'create_pull_request',
516
+ description: 'Create a new pull request from a source branch to a destination branch.',
517
+ inputSchema: {
518
+ type: 'object',
519
+ properties: {
520
+ workspace: {
521
+ type: 'string',
522
+ description: 'The workspace slug'
523
+ },
524
+ repo_slug: {
525
+ type: 'string',
526
+ description: 'The repository slug'
527
+ },
528
+ title: {
529
+ type: 'string',
530
+ description: 'Pull request title'
531
+ },
532
+ source_branch: {
533
+ type: 'string',
534
+ description: 'Source branch name'
535
+ },
536
+ destination_branch: {
537
+ type: 'string',
538
+ description: 'Destination branch (defaults to main branch)'
539
+ },
540
+ description: {
541
+ type: 'string',
542
+ description: "Pull request description"
543
+ },
544
+ close_source_branch: {
545
+ type: 'boolean',
546
+ description: 'Close source branch after merge'
547
+ },
548
+ reviewers: {
549
+ type: 'array',
550
+ items: {
551
+ type: 'string'
552
+ },
553
+ description: 'List of reviewer UUIDs'
554
+ }
555
+ },
556
+ required: [
557
+ 'workspace',
558
+ 'repo_slug',
559
+ 'title',
560
+ 'source_branch'
561
+ ]
562
+ }
563
+ },
564
+ {
565
+ name: 'update_pull_request',
566
+ description: "Update a pull request title, description, or destination branch.",
567
+ inputSchema: {
568
+ type: 'object',
569
+ properties: {
570
+ workspace: {
571
+ type: 'string',
572
+ description: 'The workspace slug'
573
+ },
574
+ repo_slug: {
575
+ type: 'string',
576
+ description: 'The repository slug'
577
+ },
578
+ pr_id: {
579
+ type: 'number',
580
+ description: 'The pull request ID'
581
+ },
582
+ title: {
583
+ type: 'string',
584
+ description: 'New title'
585
+ },
586
+ description: {
587
+ type: 'string',
588
+ description: "New description"
589
+ },
590
+ destination_branch: {
591
+ type: 'string',
592
+ description: 'New destination branch'
593
+ }
594
+ },
595
+ required: [
596
+ 'workspace',
597
+ 'repo_slug',
598
+ 'pr_id'
599
+ ]
600
+ }
601
+ },
602
+ {
603
+ name: 'merge_pull_request',
604
+ description: 'Merge an open pull request. Supports merge commit, squash, and fast-forward strategies.',
605
+ inputSchema: {
606
+ type: 'object',
607
+ properties: {
608
+ workspace: {
609
+ type: 'string',
610
+ description: 'The workspace slug'
611
+ },
612
+ repo_slug: {
613
+ type: 'string',
614
+ description: 'The repository slug'
615
+ },
616
+ pr_id: {
617
+ type: 'number',
618
+ description: 'The pull request ID'
619
+ },
620
+ message: {
621
+ type: 'string',
622
+ description: 'Merge commit message'
623
+ },
624
+ close_source_branch: {
625
+ type: 'boolean',
626
+ description: 'Close source branch after merge'
627
+ },
628
+ merge_strategy: {
629
+ type: 'string',
630
+ enum: [
631
+ 'merge_commit',
632
+ 'squash',
633
+ 'fast_forward'
634
+ ],
635
+ description: 'Merge strategy'
636
+ }
637
+ },
638
+ required: [
639
+ 'workspace',
640
+ 'repo_slug',
641
+ 'pr_id'
642
+ ]
643
+ }
644
+ },
645
+ {
646
+ name: 'decline_pull_request',
647
+ description: 'Decline/close a pull request without merging.',
648
+ inputSchema: {
649
+ type: 'object',
650
+ properties: {
651
+ workspace: {
652
+ type: 'string',
653
+ description: 'The workspace slug'
654
+ },
655
+ repo_slug: {
656
+ type: 'string',
657
+ description: 'The repository slug'
658
+ },
659
+ pr_id: {
660
+ type: 'number',
661
+ description: 'The pull request ID'
662
+ }
663
+ },
664
+ required: [
665
+ 'workspace',
666
+ 'repo_slug',
667
+ 'pr_id'
668
+ ]
669
+ }
670
+ },
671
+ {
672
+ name: 'approve_pull_request',
673
+ description: 'Approve a pull request.',
674
+ inputSchema: {
675
+ type: 'object',
676
+ properties: {
677
+ workspace: {
678
+ type: 'string',
679
+ description: 'The workspace slug'
680
+ },
681
+ repo_slug: {
682
+ type: 'string',
683
+ description: 'The repository slug'
684
+ },
685
+ pr_id: {
686
+ type: 'number',
687
+ description: 'The pull request ID'
688
+ }
689
+ },
690
+ required: [
691
+ 'workspace',
692
+ 'repo_slug',
693
+ 'pr_id'
694
+ ]
695
+ }
696
+ },
697
+ {
698
+ name: 'request_changes',
699
+ description: 'Request changes on a pull request.',
700
+ inputSchema: {
701
+ type: 'object',
702
+ properties: {
703
+ workspace: {
704
+ type: 'string',
705
+ description: 'The workspace slug'
706
+ },
707
+ repo_slug: {
708
+ type: 'string',
709
+ description: 'The repository slug'
710
+ },
711
+ pr_id: {
712
+ type: 'number',
713
+ description: 'The pull request ID'
714
+ }
715
+ },
716
+ required: [
717
+ 'workspace',
718
+ 'repo_slug',
719
+ 'pr_id'
720
+ ]
721
+ }
722
+ },
723
+ {
724
+ name: 'list_pr_comments',
725
+ description: 'List all comments on a pull request.',
726
+ inputSchema: {
727
+ type: 'object',
728
+ properties: {
729
+ workspace: {
730
+ type: 'string',
731
+ description: 'The workspace slug'
732
+ },
733
+ repo_slug: {
734
+ type: 'string',
735
+ description: 'The repository slug'
736
+ },
737
+ pr_id: {
738
+ type: 'number',
739
+ description: 'The pull request ID'
740
+ },
741
+ page: {
742
+ type: 'number',
743
+ description: 'Page number'
744
+ },
745
+ pagelen: {
746
+ type: 'number',
747
+ description: 'Results per page'
748
+ }
749
+ },
750
+ required: [
751
+ 'workspace',
752
+ 'repo_slug',
753
+ 'pr_id'
754
+ ]
755
+ }
756
+ },
757
+ {
758
+ name: 'add_pr_comment',
759
+ description: 'Add a comment to a pull request. Can be a general comment or an inline comment on a specific file/line.',
760
+ inputSchema: {
761
+ type: 'object',
762
+ properties: {
763
+ workspace: {
764
+ type: 'string',
765
+ description: 'The workspace slug'
766
+ },
767
+ repo_slug: {
768
+ type: 'string',
769
+ description: 'The repository slug'
770
+ },
771
+ pr_id: {
772
+ type: 'number',
773
+ description: 'The pull request ID'
774
+ },
775
+ content: {
776
+ type: 'string',
777
+ description: 'Comment content (markdown)'
778
+ },
779
+ path: {
780
+ type: 'string',
781
+ description: 'File path for inline comment'
782
+ },
783
+ line: {
784
+ type: 'number',
785
+ description: 'Line number for inline comment'
786
+ }
787
+ },
788
+ required: [
789
+ 'workspace',
790
+ 'repo_slug',
791
+ 'pr_id',
792
+ 'content'
793
+ ]
794
+ }
795
+ },
796
+ {
797
+ name: 'get_pr_diff',
798
+ description: 'Get the diff for a pull request showing all changes.',
799
+ inputSchema: {
800
+ type: 'object',
801
+ properties: {
802
+ workspace: {
803
+ type: 'string',
804
+ description: 'The workspace slug'
805
+ },
806
+ repo_slug: {
807
+ type: 'string',
808
+ description: 'The repository slug'
809
+ },
810
+ pr_id: {
811
+ type: 'number',
812
+ description: 'The pull request ID'
813
+ }
814
+ },
815
+ required: [
816
+ 'workspace',
817
+ 'repo_slug',
818
+ 'pr_id'
819
+ ]
820
+ }
821
+ },
822
+ {
823
+ name: 'list_branches',
824
+ description: 'List all branches in a repository.',
825
+ inputSchema: {
826
+ type: 'object',
827
+ properties: {
828
+ workspace: {
829
+ type: 'string',
830
+ description: 'The workspace slug'
831
+ },
832
+ repo_slug: {
833
+ type: 'string',
834
+ description: 'The repository slug'
835
+ },
836
+ q: {
837
+ type: 'string',
838
+ description: 'Query string for filtering'
839
+ },
840
+ sort: {
841
+ type: 'string',
842
+ description: 'Sort field'
843
+ },
844
+ page: {
845
+ type: 'number',
846
+ description: 'Page number'
847
+ },
848
+ pagelen: {
849
+ type: 'number',
850
+ description: 'Results per page'
851
+ }
852
+ },
853
+ required: [
854
+ 'workspace',
855
+ 'repo_slug'
856
+ ]
857
+ }
858
+ },
859
+ {
860
+ name: 'get_branch',
861
+ description: 'Get details of a specific branch including its latest commit.',
862
+ inputSchema: {
863
+ type: 'object',
864
+ properties: {
865
+ workspace: {
866
+ type: 'string',
867
+ description: 'The workspace slug'
868
+ },
869
+ repo_slug: {
870
+ type: 'string',
871
+ description: 'The repository slug'
872
+ },
873
+ branch_name: {
874
+ type: 'string',
875
+ description: 'The branch name'
876
+ }
877
+ },
878
+ required: [
879
+ 'workspace',
880
+ 'repo_slug',
881
+ 'branch_name'
882
+ ]
883
+ }
884
+ },
885
+ {
886
+ name: 'create_branch',
887
+ description: 'Create a new branch from a specific commit or existing branch.',
888
+ inputSchema: {
889
+ type: 'object',
890
+ properties: {
891
+ workspace: {
892
+ type: 'string',
893
+ description: 'The workspace slug'
894
+ },
895
+ repo_slug: {
896
+ type: 'string',
897
+ description: 'The repository slug'
898
+ },
899
+ name: {
900
+ type: 'string',
901
+ description: 'New branch name'
902
+ },
903
+ target: {
904
+ type: 'string',
905
+ description: 'Target commit hash or branch name'
906
+ }
907
+ },
908
+ required: [
909
+ 'workspace',
910
+ 'repo_slug',
911
+ 'name',
912
+ 'target'
913
+ ]
914
+ }
915
+ },
916
+ {
917
+ name: 'delete_branch',
918
+ description: 'Delete a branch from a repository.',
919
+ inputSchema: {
920
+ type: 'object',
921
+ properties: {
922
+ workspace: {
923
+ type: 'string',
924
+ description: 'The workspace slug'
925
+ },
926
+ repo_slug: {
927
+ type: 'string',
928
+ description: 'The repository slug'
929
+ },
930
+ branch_name: {
931
+ type: 'string',
932
+ description: 'The branch name to delete'
933
+ }
934
+ },
935
+ required: [
936
+ 'workspace',
937
+ 'repo_slug',
938
+ 'branch_name'
939
+ ]
940
+ }
941
+ },
942
+ {
943
+ name: 'list_commits',
944
+ description: 'List commits in a repository with optional filtering by branch.',
945
+ inputSchema: {
946
+ type: 'object',
947
+ properties: {
948
+ workspace: {
949
+ type: 'string',
950
+ description: 'The workspace slug'
951
+ },
952
+ repo_slug: {
953
+ type: 'string',
954
+ description: 'The repository slug'
955
+ },
956
+ branch: {
957
+ type: 'string',
958
+ description: 'Branch name to filter commits'
959
+ },
960
+ include: {
961
+ type: 'string',
962
+ description: 'Commit to include'
963
+ },
964
+ exclude: {
965
+ type: 'string',
966
+ description: 'Commit to exclude'
967
+ },
968
+ page: {
969
+ type: 'number',
970
+ description: 'Page number'
971
+ },
972
+ pagelen: {
973
+ type: 'number',
974
+ description: 'Results per page'
975
+ }
976
+ },
977
+ required: [
978
+ 'workspace',
979
+ 'repo_slug'
980
+ ]
981
+ }
982
+ },
983
+ {
984
+ name: 'get_commit',
985
+ description: 'Get details of a specific commit including its message, author, and parent commits.',
986
+ inputSchema: {
987
+ type: 'object',
988
+ properties: {
989
+ workspace: {
990
+ type: 'string',
991
+ description: 'The workspace slug'
992
+ },
993
+ repo_slug: {
994
+ type: 'string',
995
+ description: 'The repository slug'
996
+ },
997
+ commit_hash: {
998
+ type: 'string',
999
+ description: 'The commit hash'
1000
+ }
1001
+ },
1002
+ required: [
1003
+ 'workspace',
1004
+ 'repo_slug',
1005
+ 'commit_hash'
1006
+ ]
1007
+ }
1008
+ },
1009
+ {
1010
+ name: 'get_commit_diff',
1011
+ description: 'Get the diff for a specific commit showing all changes.',
1012
+ inputSchema: {
1013
+ type: 'object',
1014
+ properties: {
1015
+ workspace: {
1016
+ type: 'string',
1017
+ description: 'The workspace slug'
1018
+ },
1019
+ repo_slug: {
1020
+ type: 'string',
1021
+ description: 'The repository slug'
1022
+ },
1023
+ commit_hash: {
1024
+ type: 'string',
1025
+ description: 'The commit hash'
1026
+ }
1027
+ },
1028
+ required: [
1029
+ 'workspace',
1030
+ 'repo_slug',
1031
+ 'commit_hash'
1032
+ ]
1033
+ }
1034
+ },
1035
+ {
1036
+ name: 'list_issues',
1037
+ description: 'List issues in a repository with optional filtering.',
1038
+ inputSchema: {
1039
+ type: 'object',
1040
+ properties: {
1041
+ workspace: {
1042
+ type: 'string',
1043
+ description: 'The workspace slug'
1044
+ },
1045
+ repo_slug: {
1046
+ type: 'string',
1047
+ description: 'The repository slug'
1048
+ },
1049
+ q: {
1050
+ type: 'string',
1051
+ description: 'Query string for filtering'
1052
+ },
1053
+ sort: {
1054
+ type: 'string',
1055
+ description: 'Sort field'
1056
+ },
1057
+ page: {
1058
+ type: 'number',
1059
+ description: 'Page number'
1060
+ },
1061
+ pagelen: {
1062
+ type: 'number',
1063
+ description: 'Results per page'
1064
+ }
1065
+ },
1066
+ required: [
1067
+ 'workspace',
1068
+ 'repo_slug'
1069
+ ]
1070
+ }
1071
+ },
1072
+ {
1073
+ name: 'get_issue',
1074
+ description: 'Get details of a specific issue.',
1075
+ inputSchema: {
1076
+ type: 'object',
1077
+ properties: {
1078
+ workspace: {
1079
+ type: 'string',
1080
+ description: 'The workspace slug'
1081
+ },
1082
+ repo_slug: {
1083
+ type: 'string',
1084
+ description: 'The repository slug'
1085
+ },
1086
+ issue_id: {
1087
+ type: 'number',
1088
+ description: 'The issue ID'
1089
+ }
1090
+ },
1091
+ required: [
1092
+ 'workspace',
1093
+ 'repo_slug',
1094
+ 'issue_id'
1095
+ ]
1096
+ }
1097
+ },
1098
+ {
1099
+ name: 'create_issue',
1100
+ description: 'Create a new issue in a repository.',
1101
+ inputSchema: {
1102
+ type: 'object',
1103
+ properties: {
1104
+ workspace: {
1105
+ type: 'string',
1106
+ description: 'The workspace slug'
1107
+ },
1108
+ repo_slug: {
1109
+ type: 'string',
1110
+ description: 'The repository slug'
1111
+ },
1112
+ title: {
1113
+ type: 'string',
1114
+ description: 'Issue title'
1115
+ },
1116
+ content: {
1117
+ type: 'string',
1118
+ description: "Issue content/description"
1119
+ },
1120
+ kind: {
1121
+ type: 'string',
1122
+ enum: [
1123
+ 'bug',
1124
+ 'enhancement',
1125
+ 'proposal',
1126
+ 'task'
1127
+ ],
1128
+ description: 'Issue type'
1129
+ },
1130
+ priority: {
1131
+ type: 'string',
1132
+ enum: [
1133
+ 'trivial',
1134
+ 'minor',
1135
+ 'major',
1136
+ 'critical',
1137
+ 'blocker'
1138
+ ],
1139
+ description: 'Priority level'
1140
+ },
1141
+ assignee: {
1142
+ type: 'string',
1143
+ description: 'Assignee UUID'
1144
+ }
1145
+ },
1146
+ required: [
1147
+ 'workspace',
1148
+ 'repo_slug',
1149
+ 'title'
1150
+ ]
1151
+ }
1152
+ },
1153
+ {
1154
+ name: 'update_issue',
1155
+ description: 'Update an existing issue.',
1156
+ inputSchema: {
1157
+ type: 'object',
1158
+ properties: {
1159
+ workspace: {
1160
+ type: 'string',
1161
+ description: 'The workspace slug'
1162
+ },
1163
+ repo_slug: {
1164
+ type: 'string',
1165
+ description: 'The repository slug'
1166
+ },
1167
+ issue_id: {
1168
+ type: 'number',
1169
+ description: 'The issue ID'
1170
+ },
1171
+ title: {
1172
+ type: 'string',
1173
+ description: 'New title'
1174
+ },
1175
+ content: {
1176
+ type: 'string',
1177
+ description: 'New content'
1178
+ },
1179
+ state: {
1180
+ type: 'string',
1181
+ enum: [
1182
+ 'new',
1183
+ 'open',
1184
+ 'resolved',
1185
+ 'on hold',
1186
+ 'invalid',
1187
+ 'duplicate',
1188
+ 'wontfix',
1189
+ 'closed'
1190
+ ],
1191
+ description: 'New state'
1192
+ },
1193
+ kind: {
1194
+ type: 'string',
1195
+ enum: [
1196
+ 'bug',
1197
+ 'enhancement',
1198
+ 'proposal',
1199
+ 'task'
1200
+ ],
1201
+ description: 'Issue type'
1202
+ },
1203
+ priority: {
1204
+ type: 'string',
1205
+ enum: [
1206
+ 'trivial',
1207
+ 'minor',
1208
+ 'major',
1209
+ 'critical',
1210
+ 'blocker'
1211
+ ],
1212
+ description: 'Priority level'
1213
+ },
1214
+ assignee: {
1215
+ type: 'string',
1216
+ description: 'Assignee UUID'
1217
+ }
1218
+ },
1219
+ required: [
1220
+ 'workspace',
1221
+ 'repo_slug',
1222
+ 'issue_id'
1223
+ ]
1224
+ }
1225
+ },
1226
+ {
1227
+ name: 'delete_issue',
1228
+ description: 'Delete an issue from a repository.',
1229
+ inputSchema: {
1230
+ type: 'object',
1231
+ properties: {
1232
+ workspace: {
1233
+ type: 'string',
1234
+ description: 'The workspace slug'
1235
+ },
1236
+ repo_slug: {
1237
+ type: 'string',
1238
+ description: 'The repository slug'
1239
+ },
1240
+ issue_id: {
1241
+ type: 'number',
1242
+ description: 'The issue ID'
1243
+ }
1244
+ },
1245
+ required: [
1246
+ 'workspace',
1247
+ 'repo_slug',
1248
+ 'issue_id'
1249
+ ]
1250
+ }
1251
+ },
1252
+ {
1253
+ name: 'list_pipelines',
1254
+ description: 'List pipeline runs for a repository.',
1255
+ inputSchema: {
1256
+ type: 'object',
1257
+ properties: {
1258
+ workspace: {
1259
+ type: 'string',
1260
+ description: 'The workspace slug'
1261
+ },
1262
+ repo_slug: {
1263
+ type: 'string',
1264
+ description: 'The repository slug'
1265
+ },
1266
+ page: {
1267
+ type: 'number',
1268
+ description: 'Page number'
1269
+ },
1270
+ pagelen: {
1271
+ type: 'number',
1272
+ description: 'Results per page'
1273
+ }
1274
+ },
1275
+ required: [
1276
+ 'workspace',
1277
+ 'repo_slug'
1278
+ ]
1279
+ }
1280
+ },
1281
+ {
1282
+ name: 'get_pipeline',
1283
+ description: 'Get details of a specific pipeline run.',
1284
+ inputSchema: {
1285
+ type: 'object',
1286
+ properties: {
1287
+ workspace: {
1288
+ type: 'string',
1289
+ description: 'The workspace slug'
1290
+ },
1291
+ repo_slug: {
1292
+ type: 'string',
1293
+ description: 'The repository slug'
1294
+ },
1295
+ pipeline_uuid: {
1296
+ type: 'string',
1297
+ description: 'The pipeline UUID'
1298
+ }
1299
+ },
1300
+ required: [
1301
+ 'workspace',
1302
+ 'repo_slug',
1303
+ 'pipeline_uuid'
1304
+ ]
1305
+ }
1306
+ },
1307
+ {
1308
+ name: 'trigger_pipeline',
1309
+ description: 'Trigger a new pipeline run on a branch, tag, or bookmark.',
1310
+ inputSchema: {
1311
+ type: 'object',
1312
+ properties: {
1313
+ workspace: {
1314
+ type: 'string',
1315
+ description: 'The workspace slug'
1316
+ },
1317
+ repo_slug: {
1318
+ type: 'string',
1319
+ description: 'The repository slug'
1320
+ },
1321
+ ref_type: {
1322
+ type: 'string',
1323
+ enum: [
1324
+ 'branch',
1325
+ 'tag',
1326
+ 'bookmark'
1327
+ ],
1328
+ description: 'Reference type'
1329
+ },
1330
+ ref_name: {
1331
+ type: 'string',
1332
+ description: 'Reference name (branch/tag name)'
1333
+ },
1334
+ variables: {
1335
+ type: 'array',
1336
+ items: {
1337
+ type: 'object',
1338
+ properties: {
1339
+ key: {
1340
+ type: 'string'
1341
+ },
1342
+ value: {
1343
+ type: 'string'
1344
+ },
1345
+ secured: {
1346
+ type: 'boolean'
1347
+ }
1348
+ },
1349
+ required: [
1350
+ 'key',
1351
+ 'value'
1352
+ ]
1353
+ },
1354
+ description: 'Pipeline variables'
1355
+ }
1356
+ },
1357
+ required: [
1358
+ 'workspace',
1359
+ 'repo_slug',
1360
+ 'ref_type',
1361
+ 'ref_name'
1362
+ ]
1363
+ }
1364
+ },
1365
+ {
1366
+ name: 'stop_pipeline',
1367
+ description: 'Stop a running pipeline.',
1368
+ inputSchema: {
1369
+ type: 'object',
1370
+ properties: {
1371
+ workspace: {
1372
+ type: 'string',
1373
+ description: 'The workspace slug'
1374
+ },
1375
+ repo_slug: {
1376
+ type: 'string',
1377
+ description: 'The repository slug'
1378
+ },
1379
+ pipeline_uuid: {
1380
+ type: 'string',
1381
+ description: 'The pipeline UUID'
1382
+ }
1383
+ },
1384
+ required: [
1385
+ 'workspace',
1386
+ 'repo_slug',
1387
+ 'pipeline_uuid'
1388
+ ]
1389
+ }
1390
+ },
1391
+ {
1392
+ name: 'search_code',
1393
+ description: 'Search for code across all repositories in a workspace.',
1394
+ inputSchema: {
1395
+ type: 'object',
1396
+ properties: {
1397
+ workspace: {
1398
+ type: 'string',
1399
+ description: 'The workspace slug'
1400
+ },
1401
+ search_query: {
1402
+ type: 'string',
1403
+ description: 'Search query string'
1404
+ },
1405
+ page: {
1406
+ type: 'number',
1407
+ description: 'Page number'
1408
+ },
1409
+ pagelen: {
1410
+ type: 'number',
1411
+ description: 'Results per page'
1412
+ }
1413
+ },
1414
+ required: [
1415
+ 'workspace',
1416
+ 'search_query'
1417
+ ]
1418
+ }
1419
+ },
1420
+ {
1421
+ name: 'get_file_content',
1422
+ description: 'Get the content of a file from a repository.',
1423
+ inputSchema: {
1424
+ type: 'object',
1425
+ properties: {
1426
+ workspace: {
1427
+ type: 'string',
1428
+ description: 'The workspace slug'
1429
+ },
1430
+ repo_slug: {
1431
+ type: 'string',
1432
+ description: 'The repository slug'
1433
+ },
1434
+ path: {
1435
+ type: 'string',
1436
+ description: 'File path'
1437
+ },
1438
+ ref: {
1439
+ type: 'string',
1440
+ description: 'Git ref (branch, tag, or commit)'
1441
+ }
1442
+ },
1443
+ required: [
1444
+ 'workspace',
1445
+ 'repo_slug',
1446
+ 'path'
1447
+ ]
1448
+ }
1449
+ }
1450
+ ];
1451
+ export class ToolHandler {
1452
+ repos;
1453
+ prs;
1454
+ branches;
1455
+ commits;
1456
+ issues;
1457
+ pipelines;
1458
+ search;
1459
+ constructor(client){
1460
+ this.repos = new RepositoriesAPI(client);
1461
+ this.prs = new PullRequestsAPI(client);
1462
+ this.branches = new BranchesAPI(client);
1463
+ this.commits = new CommitsAPI(client);
1464
+ this.issues = new IssuesAPI(client);
1465
+ this.pipelines = new PipelinesAPI(client);
1466
+ this.search = new SearchAPI(client);
1467
+ }
1468
+ async handleTool(name, args) {
1469
+ switch(name){
1470
+ case 'list_repositories':
1471
+ {
1472
+ const params = toolSchemas.list_repositories.parse(args);
1473
+ return this.repos.list(params);
1474
+ }
1475
+ case 'get_repository':
1476
+ {
1477
+ const params = toolSchemas.get_repository.parse(args);
1478
+ return this.repos.get(params);
1479
+ }
1480
+ case 'create_repository':
1481
+ {
1482
+ const params = toolSchemas.create_repository.parse(args);
1483
+ return this.repos.create(params);
1484
+ }
1485
+ case 'delete_repository':
1486
+ {
1487
+ const params = toolSchemas.delete_repository.parse(args);
1488
+ await this.repos.delete(params);
1489
+ return {
1490
+ success: true,
1491
+ message: 'Repository deleted'
1492
+ };
1493
+ }
1494
+ case 'list_repository_forks':
1495
+ {
1496
+ const params = toolSchemas.list_repository_forks.parse(args);
1497
+ return this.repos.listForks(params);
1498
+ }
1499
+ case 'list_pull_requests':
1500
+ {
1501
+ const params = toolSchemas.list_pull_requests.parse(args);
1502
+ return this.prs.list(params);
1503
+ }
1504
+ case 'get_pull_request':
1505
+ {
1506
+ const params = toolSchemas.get_pull_request.parse(args);
1507
+ return this.prs.get(params.workspace, params.repo_slug, params.pr_id);
1508
+ }
1509
+ case 'create_pull_request':
1510
+ {
1511
+ const params = toolSchemas.create_pull_request.parse(args);
1512
+ return this.prs.create(params);
1513
+ }
1514
+ case 'update_pull_request':
1515
+ {
1516
+ const params = toolSchemas.update_pull_request.parse(args);
1517
+ const { workspace, repo_slug, pr_id, ...updates } = params;
1518
+ return this.prs.update(workspace, repo_slug, pr_id, updates);
1519
+ }
1520
+ case 'merge_pull_request':
1521
+ {
1522
+ const params = toolSchemas.merge_pull_request.parse(args);
1523
+ const { workspace, repo_slug, pr_id, ...options } = params;
1524
+ return this.prs.merge(workspace, repo_slug, pr_id, options);
1525
+ }
1526
+ case 'decline_pull_request':
1527
+ {
1528
+ const params = toolSchemas.decline_pull_request.parse(args);
1529
+ return this.prs.decline(params.workspace, params.repo_slug, params.pr_id);
1530
+ }
1531
+ case 'approve_pull_request':
1532
+ {
1533
+ const params = toolSchemas.approve_pull_request.parse(args);
1534
+ await this.prs.approve(params.workspace, params.repo_slug, params.pr_id);
1535
+ return {
1536
+ success: true,
1537
+ message: 'Pull request approved'
1538
+ };
1539
+ }
1540
+ case 'request_changes':
1541
+ {
1542
+ const params = toolSchemas.request_changes.parse(args);
1543
+ await this.prs.requestChanges(params.workspace, params.repo_slug, params.pr_id);
1544
+ return {
1545
+ success: true,
1546
+ message: 'Changes requested'
1547
+ };
1548
+ }
1549
+ case 'list_pr_comments':
1550
+ {
1551
+ const params = toolSchemas.list_pr_comments.parse(args);
1552
+ return this.prs.listComments(params.workspace, params.repo_slug, params.pr_id, {
1553
+ page: params.page,
1554
+ pagelen: params.pagelen
1555
+ });
1556
+ }
1557
+ case 'add_pr_comment':
1558
+ {
1559
+ const params = toolSchemas.add_pr_comment.parse(args);
1560
+ const inline = params.path ? {
1561
+ path: params.path,
1562
+ line: params.line
1563
+ } : undefined;
1564
+ return this.prs.addComment(params.workspace, params.repo_slug, params.pr_id, params.content, inline);
1565
+ }
1566
+ case 'get_pr_diff':
1567
+ {
1568
+ const params = toolSchemas.get_pr_diff.parse(args);
1569
+ const diff = await this.prs.getDiff(params.workspace, params.repo_slug, params.pr_id);
1570
+ return {
1571
+ diff
1572
+ };
1573
+ }
1574
+ case 'list_branches':
1575
+ {
1576
+ const params = toolSchemas.list_branches.parse(args);
1577
+ return this.branches.list(params);
1578
+ }
1579
+ case 'get_branch':
1580
+ {
1581
+ const params = toolSchemas.get_branch.parse(args);
1582
+ return this.branches.get(params.workspace, params.repo_slug, params.branch_name);
1583
+ }
1584
+ case 'create_branch':
1585
+ {
1586
+ const params = toolSchemas.create_branch.parse(args);
1587
+ return this.branches.create(params);
1588
+ }
1589
+ case 'delete_branch':
1590
+ {
1591
+ const params = toolSchemas.delete_branch.parse(args);
1592
+ await this.branches.delete(params.workspace, params.repo_slug, params.branch_name);
1593
+ return {
1594
+ success: true,
1595
+ message: 'Branch deleted'
1596
+ };
1597
+ }
1598
+ case 'list_commits':
1599
+ {
1600
+ const params = toolSchemas.list_commits.parse(args);
1601
+ return this.commits.list(params);
1602
+ }
1603
+ case 'get_commit':
1604
+ {
1605
+ const params = toolSchemas.get_commit.parse(args);
1606
+ return this.commits.get(params.workspace, params.repo_slug, params.commit_hash);
1607
+ }
1608
+ case 'get_commit_diff':
1609
+ {
1610
+ const params = toolSchemas.get_commit_diff.parse(args);
1611
+ const diff = await this.commits.getDiff(params.workspace, params.repo_slug, params.commit_hash);
1612
+ return {
1613
+ diff
1614
+ };
1615
+ }
1616
+ case 'list_issues':
1617
+ {
1618
+ const params = toolSchemas.list_issues.parse(args);
1619
+ return this.issues.list(params);
1620
+ }
1621
+ case 'get_issue':
1622
+ {
1623
+ const params = toolSchemas.get_issue.parse(args);
1624
+ return this.issues.get(params.workspace, params.repo_slug, params.issue_id);
1625
+ }
1626
+ case 'create_issue':
1627
+ {
1628
+ const params = toolSchemas.create_issue.parse(args);
1629
+ return this.issues.create(params);
1630
+ }
1631
+ case 'update_issue':
1632
+ {
1633
+ const params = toolSchemas.update_issue.parse(args);
1634
+ const { workspace, repo_slug, issue_id, ...updates } = params;
1635
+ return this.issues.update(workspace, repo_slug, issue_id, updates);
1636
+ }
1637
+ case 'delete_issue':
1638
+ {
1639
+ const params = toolSchemas.delete_issue.parse(args);
1640
+ await this.issues.delete(params.workspace, params.repo_slug, params.issue_id);
1641
+ return {
1642
+ success: true,
1643
+ message: 'Issue deleted'
1644
+ };
1645
+ }
1646
+ case 'list_pipelines':
1647
+ {
1648
+ const params = toolSchemas.list_pipelines.parse(args);
1649
+ return this.pipelines.list(params);
1650
+ }
1651
+ case 'get_pipeline':
1652
+ {
1653
+ const params = toolSchemas.get_pipeline.parse(args);
1654
+ return this.pipelines.get(params.workspace, params.repo_slug, params.pipeline_uuid);
1655
+ }
1656
+ case 'trigger_pipeline':
1657
+ {
1658
+ const params = toolSchemas.trigger_pipeline.parse(args);
1659
+ return this.pipelines.trigger({
1660
+ workspace: params.workspace,
1661
+ repo_slug: params.repo_slug,
1662
+ target: {
1663
+ type: 'pipeline_ref_target',
1664
+ ref_type: params.ref_type,
1665
+ ref_name: params.ref_name
1666
+ },
1667
+ variables: params.variables
1668
+ });
1669
+ }
1670
+ case 'stop_pipeline':
1671
+ {
1672
+ const params = toolSchemas.stop_pipeline.parse(args);
1673
+ await this.pipelines.stop(params.workspace, params.repo_slug, params.pipeline_uuid);
1674
+ return {
1675
+ success: true,
1676
+ message: 'Pipeline stopped'
1677
+ };
1678
+ }
1679
+ case 'search_code':
1680
+ {
1681
+ const params = toolSchemas.search_code.parse(args);
1682
+ return this.search.searchCode(params);
1683
+ }
1684
+ case 'get_file_content':
1685
+ {
1686
+ const params = toolSchemas.get_file_content.parse(args);
1687
+ const content = await this.repos.getFileContent(params.workspace, params.repo_slug, params.path, params.ref);
1688
+ return {
1689
+ content
1690
+ };
1691
+ }
1692
+ default:
1693
+ throw new Error(`Unknown tool: ${name}`);
1694
+ }
1695
+ }
1696
+ }
1697
+
1698
+ //# sourceMappingURL=index.js.map