@sudocode-ai/mcp 0.1.18-dev.0 → 0.1.18

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,720 @@
1
+ /**
2
+ * Tool Registry for sudocode MCP Server
3
+ *
4
+ * Centralized registry of all MCP tools with their scopes and schemas.
5
+ * Supports filtering by scope and routing to appropriate handlers.
6
+ */
7
+ // =============================================================================
8
+ // Default Scope Tools (CLI-based)
9
+ // =============================================================================
10
+ const DEFAULT_TOOLS = [
11
+ {
12
+ name: "ready",
13
+ scope: "default",
14
+ description: "Shows you the current project state: what issues are ready to work on (no blockers), what's in progress, and what's blocked. Essential for understanding context before making any decisions about what to work on next.",
15
+ inputSchema: {
16
+ type: "object",
17
+ properties: {},
18
+ },
19
+ },
20
+ {
21
+ name: "list_issues",
22
+ scope: "default",
23
+ description: "Search and filter issues. Use this when you need to find specific issues by status, priority, keyword, or when exploring what work exists in the project.",
24
+ inputSchema: {
25
+ type: "object",
26
+ properties: {
27
+ status: {
28
+ type: "string",
29
+ enum: ["open", "in_progress", "blocked", "closed"],
30
+ description: "Filter by workflow status: 'open' (not started), 'in_progress' (currently working), 'blocked' (waiting on dependencies), 'closed' (completed)",
31
+ },
32
+ priority: {
33
+ type: "number",
34
+ description: "Filter by priority level where 0=highest priority and 4=lowest priority",
35
+ },
36
+ archived: {
37
+ type: "boolean",
38
+ description: "Include archived issues. Defaults to false (excludes archived issues from results)",
39
+ },
40
+ limit: {
41
+ type: "number",
42
+ description: "Maximum number of results to return. Defaults to 50.",
43
+ default: 50,
44
+ },
45
+ search: {
46
+ type: "string",
47
+ description: "Search text - matches against issue titles and descriptions (case-insensitive)",
48
+ },
49
+ },
50
+ },
51
+ },
52
+ {
53
+ name: "show_issue",
54
+ scope: "default",
55
+ description: "Get full details about a specific issue. Use this to understand what the issue implements (which specs), what blocks it (dependencies), its current status, and related work. Essential for understanding context before starting implementation.",
56
+ inputSchema: {
57
+ type: "object",
58
+ properties: {
59
+ issue_id: {
60
+ type: "string",
61
+ description: 'Issue ID with format "i-xxxx" (e.g., "i-x7k9")',
62
+ },
63
+ },
64
+ required: ["issue_id"],
65
+ },
66
+ },
67
+ {
68
+ name: "upsert_issue",
69
+ scope: "default",
70
+ description: "Create or update an issue (agent's actionable work item). **Issues implement specs** - use 'link' with type='implements' to connect issue to spec. **Before closing:** provide feedback on the spec using 'add_feedback' if this issue implements a spec. If issue_id is provided, updates the issue; otherwise creates a new one. To close an issue, set status='closed'. To archive an issue, set archived=true.",
71
+ inputSchema: {
72
+ type: "object",
73
+ properties: {
74
+ issue_id: {
75
+ type: "string",
76
+ description: 'Issue ID in format "i-xxxx". Omit to create new issue (auto-generates ID). Provide to update existing issue.',
77
+ },
78
+ title: {
79
+ type: "string",
80
+ description: "Concise issue title describing the work (e.g., 'Implement OAuth login flow'). Required when creating, optional when updating.",
81
+ },
82
+ description: {
83
+ type: "string",
84
+ description: "Detailed description of the work to be done. Supports markdown and inline references using [[id]] syntax.",
85
+ },
86
+ priority: {
87
+ type: "number",
88
+ description: "Priority level: 0 (highest/urgent) to 4 (lowest/nice-to-have).",
89
+ },
90
+ parent: {
91
+ type: "string",
92
+ description: "Parent issue ID for hierarchical organization.",
93
+ },
94
+ tags: {
95
+ type: "array",
96
+ items: { type: "string" },
97
+ description: "Array of tag strings for categorization.",
98
+ },
99
+ status: {
100
+ type: "string",
101
+ enum: ["open", "in_progress", "blocked", "closed"],
102
+ description: "Workflow status.",
103
+ },
104
+ archived: {
105
+ type: "boolean",
106
+ description: "Set to true to archive completed/obsolete issues.",
107
+ },
108
+ },
109
+ },
110
+ },
111
+ {
112
+ name: "list_specs",
113
+ scope: "default",
114
+ description: "Search and browse all specs in the project. Use this to find existing specifications by keyword, or to see what specs are available before creating new ones.",
115
+ inputSchema: {
116
+ type: "object",
117
+ properties: {
118
+ limit: {
119
+ type: "number",
120
+ description: "Maximum number of results to return. Defaults to 50.",
121
+ default: 50,
122
+ },
123
+ search: {
124
+ type: "string",
125
+ description: "Search text - matches against spec titles and descriptions (case-insensitive).",
126
+ },
127
+ },
128
+ },
129
+ },
130
+ {
131
+ name: "show_spec",
132
+ scope: "default",
133
+ description: "Get full details about a specific spec including its content, relationships, and all anchored feedback. Use this to understand requirements before implementing.",
134
+ inputSchema: {
135
+ type: "object",
136
+ properties: {
137
+ spec_id: {
138
+ type: "string",
139
+ description: 'Spec ID with format "s-xxxx" (e.g., "s-14sh").',
140
+ },
141
+ },
142
+ required: ["spec_id"],
143
+ },
144
+ },
145
+ {
146
+ name: "upsert_spec",
147
+ scope: "default",
148
+ description: "Create or update a spec (user's requirements/intent/context document). If spec_id is provided, updates the spec; otherwise creates a new one with a hash-based ID.",
149
+ inputSchema: {
150
+ type: "object",
151
+ properties: {
152
+ spec_id: {
153
+ type: "string",
154
+ description: 'Spec ID in format "s-xxxx". Omit to create new spec (auto-generates hash-based ID).',
155
+ },
156
+ title: {
157
+ type: "string",
158
+ description: "Descriptive spec title. Required when creating.",
159
+ },
160
+ priority: {
161
+ type: "number",
162
+ description: "Priority level: 0 (highest) to 4 (lowest).",
163
+ },
164
+ description: {
165
+ type: "string",
166
+ description: "Full specification content in markdown format.",
167
+ },
168
+ parent: {
169
+ type: "string",
170
+ description: "Parent spec ID for hierarchical organization.",
171
+ },
172
+ tags: {
173
+ type: "array",
174
+ items: { type: "string" },
175
+ description: "Array of tag strings for categorization.",
176
+ },
177
+ },
178
+ },
179
+ },
180
+ {
181
+ name: "link",
182
+ scope: "default",
183
+ description: "Create a relationship between specs and/or issues. Use this to establish the dependency graph and connect work to requirements. Most common: 'implements' (issue → spec) and 'blocks' (dependency ordering).",
184
+ inputSchema: {
185
+ type: "object",
186
+ properties: {
187
+ from_id: {
188
+ type: "string",
189
+ description: "Source entity ID (format 'i-xxxx' or 's-xxxx').",
190
+ },
191
+ to_id: {
192
+ type: "string",
193
+ description: "Target entity ID (format 'i-xxxx' or 's-xxxx').",
194
+ },
195
+ type: {
196
+ type: "string",
197
+ enum: [
198
+ "blocks",
199
+ "implements",
200
+ "references",
201
+ "depends-on",
202
+ "discovered-from",
203
+ "related",
204
+ ],
205
+ description: "Relationship type.",
206
+ },
207
+ },
208
+ required: ["from_id", "to_id"],
209
+ },
210
+ },
211
+ {
212
+ name: "add_reference",
213
+ scope: "default",
214
+ description: "Insert an Obsidian-style [[ID]] reference into spec or issue markdown content.",
215
+ inputSchema: {
216
+ type: "object",
217
+ properties: {
218
+ entity_id: {
219
+ type: "string",
220
+ description: "Entity ID where the reference will be inserted.",
221
+ },
222
+ reference_id: {
223
+ type: "string",
224
+ description: "Entity ID being referenced.",
225
+ },
226
+ display_text: {
227
+ type: "string",
228
+ description: "Optional display text for the reference.",
229
+ },
230
+ relationship_type: {
231
+ type: "string",
232
+ enum: [
233
+ "blocks",
234
+ "implements",
235
+ "references",
236
+ "depends-on",
237
+ "discovered-from",
238
+ "related",
239
+ ],
240
+ description: "Optional relationship type.",
241
+ },
242
+ line: {
243
+ type: "number",
244
+ description: "Line number where reference should be inserted.",
245
+ },
246
+ text: {
247
+ type: "string",
248
+ description: "Text substring to search for as insertion point.",
249
+ },
250
+ format: {
251
+ type: "string",
252
+ enum: ["inline", "newline"],
253
+ description: "How to insert: 'inline' or on 'newline'.",
254
+ default: "inline",
255
+ },
256
+ },
257
+ required: ["entity_id", "reference_id"],
258
+ },
259
+ },
260
+ {
261
+ name: "add_feedback",
262
+ scope: "default",
263
+ description: "**REQUIRED when closing issues that implement specs.** Document implementation results by providing feedback on a spec or issue.",
264
+ inputSchema: {
265
+ type: "object",
266
+ properties: {
267
+ issue_id: {
268
+ type: "string",
269
+ description: "Issue ID that's providing the feedback.",
270
+ },
271
+ to_id: {
272
+ type: "string",
273
+ description: "Target ID receiving the feedback (spec or issue).",
274
+ },
275
+ content: {
276
+ type: "string",
277
+ description: "Feedback content in markdown.",
278
+ },
279
+ type: {
280
+ type: "string",
281
+ enum: ["comment", "suggestion", "request"],
282
+ description: "Feedback type.",
283
+ },
284
+ line: {
285
+ type: "number",
286
+ description: "Line number to anchor feedback.",
287
+ },
288
+ text: {
289
+ type: "string",
290
+ description: "Text to anchor feedback to.",
291
+ },
292
+ },
293
+ required: ["to_id"],
294
+ },
295
+ },
296
+ ];
297
+ // =============================================================================
298
+ // Overview Tools
299
+ // =============================================================================
300
+ const OVERVIEW_TOOLS = [
301
+ {
302
+ name: "project_status",
303
+ scope: "overview",
304
+ description: "Get current project state including ready issues, active executions, and running workflows. " +
305
+ "Use this as your first tool to understand what's happening in the project.",
306
+ inputSchema: {
307
+ type: "object",
308
+ properties: {},
309
+ },
310
+ },
311
+ ];
312
+ // =============================================================================
313
+ // Execution Tools
314
+ // =============================================================================
315
+ const EXECUTION_READ_TOOLS = [
316
+ {
317
+ name: "list_executions",
318
+ scope: "executions:read",
319
+ description: "List executions with optional filters. " +
320
+ "Use to see what's running, recently completed, or filter by issue.",
321
+ inputSchema: {
322
+ type: "object",
323
+ properties: {
324
+ status: {
325
+ type: "array",
326
+ items: { type: "string" },
327
+ description: "Filter by status (running, completed, failed, cancelled, pending)",
328
+ },
329
+ issue_id: {
330
+ type: "string",
331
+ description: "Filter by issue ID",
332
+ },
333
+ limit: {
334
+ type: "number",
335
+ description: "Maximum results (default: 20)",
336
+ },
337
+ since: {
338
+ type: "string",
339
+ description: "Only executions since this ISO timestamp",
340
+ },
341
+ tags: {
342
+ type: "array",
343
+ items: { type: "string" },
344
+ description: "Filter by tags",
345
+ },
346
+ },
347
+ },
348
+ },
349
+ {
350
+ name: "show_execution",
351
+ scope: "executions:read",
352
+ description: "Get detailed information about a specific execution including status, commits, and files changed.",
353
+ inputSchema: {
354
+ type: "object",
355
+ properties: {
356
+ execution_id: {
357
+ type: "string",
358
+ description: "Execution ID to inspect",
359
+ },
360
+ },
361
+ required: ["execution_id"],
362
+ },
363
+ },
364
+ ];
365
+ const EXECUTION_WRITE_TOOLS = [
366
+ {
367
+ name: "start_execution",
368
+ scope: "executions:write",
369
+ description: "Start a new execution for an issue. Returns immediately with execution ID. " +
370
+ "Use show_execution or execution_trajectory to monitor progress.",
371
+ inputSchema: {
372
+ type: "object",
373
+ properties: {
374
+ issue_id: {
375
+ type: "string",
376
+ description: "Issue ID to execute (e.g., i-abc123)",
377
+ },
378
+ agent_type: {
379
+ type: "string",
380
+ enum: ["claude-code", "codex", "copilot", "cursor"],
381
+ description: "Agent type to use (default: claude-code)",
382
+ },
383
+ model: {
384
+ type: "string",
385
+ description: "Model override for the agent",
386
+ },
387
+ prompt: {
388
+ type: "string",
389
+ description: "Additional instructions for the execution",
390
+ },
391
+ },
392
+ required: ["issue_id"],
393
+ },
394
+ },
395
+ {
396
+ name: "start_adhoc_execution",
397
+ scope: "executions:write",
398
+ description: "Start an execution without an associated issue. " +
399
+ "Use for quick tasks or exploratory work.",
400
+ inputSchema: {
401
+ type: "object",
402
+ properties: {
403
+ prompt: {
404
+ type: "string",
405
+ description: "Instructions for the execution",
406
+ },
407
+ agent_type: {
408
+ type: "string",
409
+ enum: ["claude-code", "codex", "copilot", "cursor"],
410
+ description: "Agent type to use (default: claude-code)",
411
+ },
412
+ model: {
413
+ type: "string",
414
+ description: "Model override for the agent",
415
+ },
416
+ },
417
+ required: ["prompt"],
418
+ },
419
+ },
420
+ {
421
+ name: "create_follow_up",
422
+ scope: "executions:write",
423
+ description: "Create a follow-up execution that continues from a previous execution. " +
424
+ "Shares the same worktree and builds on previous work.",
425
+ inputSchema: {
426
+ type: "object",
427
+ properties: {
428
+ execution_id: {
429
+ type: "string",
430
+ description: "Execution ID to follow up on",
431
+ },
432
+ feedback: {
433
+ type: "string",
434
+ description: "Follow-up instructions or feedback",
435
+ },
436
+ },
437
+ required: ["execution_id", "feedback"],
438
+ },
439
+ },
440
+ {
441
+ name: "cancel_execution",
442
+ scope: "executions:write",
443
+ description: "Cancel a running execution.",
444
+ inputSchema: {
445
+ type: "object",
446
+ properties: {
447
+ execution_id: {
448
+ type: "string",
449
+ description: "Execution ID to cancel",
450
+ },
451
+ reason: {
452
+ type: "string",
453
+ description: "Reason for cancellation",
454
+ },
455
+ },
456
+ required: ["execution_id"],
457
+ },
458
+ },
459
+ ];
460
+ // =============================================================================
461
+ // Inspection Tools
462
+ // =============================================================================
463
+ // TODO: Implement execution_trajectory tool once GET /api/executions/:id/trajectory
464
+ // endpoint is added to the server. This tool would return the agent's tool calls
465
+ // and actions during an execution, parsed from execution logs.
466
+ // {
467
+ // name: "execution_trajectory",
468
+ // scope: "inspection",
469
+ // description:
470
+ // "Get the agent's actions and tool calls from an execution. " +
471
+ // "Useful for understanding what happened and debugging issues.",
472
+ // inputSchema: {
473
+ // type: "object",
474
+ // properties: {
475
+ // execution_id: {
476
+ // type: "string",
477
+ // description: "Execution ID to inspect",
478
+ // },
479
+ // max_entries: {
480
+ // type: "number",
481
+ // description: "Maximum entries to return (default: 50)",
482
+ // },
483
+ // },
484
+ // required: ["execution_id"],
485
+ // },
486
+ // },
487
+ const INSPECTION_TOOLS = [
488
+ {
489
+ name: "execution_changes",
490
+ scope: "inspection",
491
+ description: "Get code changes made by an execution including files modified, additions, deletions, and commits.",
492
+ inputSchema: {
493
+ type: "object",
494
+ properties: {
495
+ execution_id: {
496
+ type: "string",
497
+ description: "Execution ID to get changes for",
498
+ },
499
+ include_diff: {
500
+ type: "boolean",
501
+ description: "Include full diff content (default: false)",
502
+ },
503
+ },
504
+ required: ["execution_id"],
505
+ },
506
+ },
507
+ {
508
+ name: "execution_chain",
509
+ scope: "inspection",
510
+ description: "Get the full execution chain including root execution and all follow-ups.",
511
+ inputSchema: {
512
+ type: "object",
513
+ properties: {
514
+ execution_id: {
515
+ type: "string",
516
+ description: "Any execution ID in the chain",
517
+ },
518
+ },
519
+ required: ["execution_id"],
520
+ },
521
+ },
522
+ ];
523
+ // =============================================================================
524
+ // Workflow Tools
525
+ // =============================================================================
526
+ const WORKFLOW_READ_TOOLS = [
527
+ {
528
+ name: "list_workflows",
529
+ scope: "workflows:read",
530
+ description: "List workflows with optional status filter.",
531
+ inputSchema: {
532
+ type: "object",
533
+ properties: {
534
+ status: {
535
+ type: "array",
536
+ items: { type: "string" },
537
+ description: "Filter by status (pending, running, paused, completed, failed)",
538
+ },
539
+ limit: {
540
+ type: "number",
541
+ description: "Maximum results (default: 20)",
542
+ },
543
+ },
544
+ },
545
+ },
546
+ {
547
+ name: "show_workflow",
548
+ scope: "workflows:read",
549
+ description: "Get workflow details including configuration and steps.",
550
+ inputSchema: {
551
+ type: "object",
552
+ properties: {
553
+ workflow_id: {
554
+ type: "string",
555
+ description: "Workflow ID",
556
+ },
557
+ },
558
+ required: ["workflow_id"],
559
+ },
560
+ },
561
+ {
562
+ name: "workflow_status",
563
+ scope: "workflows:read",
564
+ description: "Get extended workflow status including step progress, active executions, and ready steps.",
565
+ inputSchema: {
566
+ type: "object",
567
+ properties: {
568
+ workflow_id: {
569
+ type: "string",
570
+ description: "Workflow ID",
571
+ },
572
+ },
573
+ required: ["workflow_id"],
574
+ },
575
+ },
576
+ ];
577
+ const WORKFLOW_WRITE_TOOLS = [
578
+ {
579
+ name: "create_workflow",
580
+ scope: "workflows:write",
581
+ description: "Create a new workflow from a spec or issue.",
582
+ inputSchema: {
583
+ type: "object",
584
+ properties: {
585
+ source: {
586
+ type: "string",
587
+ description: "Source spec or issue ID (e.g., s-abc123 or i-xyz789)",
588
+ },
589
+ config: {
590
+ type: "object",
591
+ description: "Optional workflow configuration",
592
+ },
593
+ },
594
+ required: ["source"],
595
+ },
596
+ },
597
+ {
598
+ name: "start_workflow",
599
+ scope: "workflows:write",
600
+ description: "Start a pending workflow.",
601
+ inputSchema: {
602
+ type: "object",
603
+ properties: {
604
+ workflow_id: {
605
+ type: "string",
606
+ description: "Workflow ID to start",
607
+ },
608
+ },
609
+ required: ["workflow_id"],
610
+ },
611
+ },
612
+ {
613
+ name: "pause_workflow",
614
+ scope: "workflows:write",
615
+ description: "Pause a running workflow.",
616
+ inputSchema: {
617
+ type: "object",
618
+ properties: {
619
+ workflow_id: {
620
+ type: "string",
621
+ description: "Workflow ID to pause",
622
+ },
623
+ },
624
+ required: ["workflow_id"],
625
+ },
626
+ },
627
+ {
628
+ name: "cancel_workflow",
629
+ scope: "workflows:write",
630
+ description: "Cancel a workflow.",
631
+ inputSchema: {
632
+ type: "object",
633
+ properties: {
634
+ workflow_id: {
635
+ type: "string",
636
+ description: "Workflow ID to cancel",
637
+ },
638
+ },
639
+ required: ["workflow_id"],
640
+ },
641
+ },
642
+ {
643
+ name: "resume_workflow",
644
+ scope: "workflows:write",
645
+ description: "Resume a paused workflow.",
646
+ inputSchema: {
647
+ type: "object",
648
+ properties: {
649
+ workflow_id: {
650
+ type: "string",
651
+ description: "Workflow ID to resume",
652
+ },
653
+ },
654
+ required: ["workflow_id"],
655
+ },
656
+ },
657
+ ];
658
+ // =============================================================================
659
+ // Voice Tools
660
+ // =============================================================================
661
+ const VOICE_TOOLS = [
662
+ {
663
+ name: "speak",
664
+ scope: "voice",
665
+ description: "Narrate text aloud via text-to-speech. Use this to provide voice feedback to the user during execution. " +
666
+ "Keep messages concise and targeted, as the user will still have visibility to your other text messages. " +
667
+ "Avoid unique symbols that may not render well in speech.",
668
+ inputSchema: {
669
+ type: "object",
670
+ properties: {
671
+ text: {
672
+ type: "string",
673
+ description: "Text to speak aloud",
674
+ },
675
+ },
676
+ required: ["text"],
677
+ },
678
+ },
679
+ ];
680
+ // =============================================================================
681
+ // Tool Registry
682
+ // =============================================================================
683
+ /**
684
+ * All tool definitions.
685
+ */
686
+ export const ALL_TOOLS = [
687
+ ...DEFAULT_TOOLS,
688
+ ...OVERVIEW_TOOLS,
689
+ ...EXECUTION_READ_TOOLS,
690
+ ...EXECUTION_WRITE_TOOLS,
691
+ ...INSPECTION_TOOLS,
692
+ ...WORKFLOW_READ_TOOLS,
693
+ ...WORKFLOW_WRITE_TOOLS,
694
+ ...VOICE_TOOLS,
695
+ ];
696
+ /**
697
+ * Get all tools for the given scopes.
698
+ */
699
+ export function getToolsForScopes(scopes) {
700
+ return ALL_TOOLS.filter((tool) => scopes.has(tool.scope));
701
+ }
702
+ /**
703
+ * Get a tool definition by name.
704
+ */
705
+ export function getToolByName(name) {
706
+ return ALL_TOOLS.find((tool) => tool.name === name);
707
+ }
708
+ /**
709
+ * Determine the handler type for a tool.
710
+ */
711
+ export function getHandlerType(tool) {
712
+ return tool.scope === "default" ? "cli" : "api";
713
+ }
714
+ /**
715
+ * Check if a tool requires the API client.
716
+ */
717
+ export function requiresApiClient(tool) {
718
+ return tool.scope !== "default";
719
+ }
720
+ //# sourceMappingURL=tool-registry.js.map