@vibescope/mcp-server 0.3.0 → 0.3.3

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.
Files changed (154) hide show
  1. package/dist/api-client/blockers.d.ts +46 -0
  2. package/dist/api-client/blockers.js +43 -0
  3. package/dist/api-client/cost.d.ts +112 -0
  4. package/dist/api-client/cost.js +76 -0
  5. package/dist/api-client/decisions.d.ts +55 -0
  6. package/dist/api-client/decisions.js +32 -0
  7. package/dist/api-client/discovery.d.ts +62 -0
  8. package/dist/api-client/discovery.js +21 -0
  9. package/dist/api-client/ideas.d.ts +75 -0
  10. package/dist/api-client/ideas.js +36 -0
  11. package/dist/api-client/index.d.ts +749 -0
  12. package/dist/api-client/index.js +291 -0
  13. package/dist/api-client/project.d.ts +132 -0
  14. package/dist/api-client/project.js +45 -0
  15. package/dist/api-client/session.d.ts +163 -0
  16. package/dist/api-client/session.js +52 -0
  17. package/dist/api-client/tasks.d.ts +328 -0
  18. package/dist/api-client/tasks.js +132 -0
  19. package/dist/api-client/types.d.ts +25 -0
  20. package/dist/api-client/types.js +4 -0
  21. package/dist/api-client/worktrees.d.ts +33 -0
  22. package/dist/api-client/worktrees.js +26 -0
  23. package/dist/api-client.d.ts +9 -0
  24. package/dist/api-client.js +104 -25
  25. package/dist/cli-init.d.ts +17 -0
  26. package/dist/cli-init.js +445 -0
  27. package/dist/cli.js +0 -0
  28. package/dist/handlers/cloud-agents.d.ts +21 -0
  29. package/dist/handlers/cloud-agents.js +91 -0
  30. package/dist/handlers/discovery.js +7 -0
  31. package/dist/handlers/index.d.ts +1 -0
  32. package/dist/handlers/index.js +3 -0
  33. package/dist/handlers/session.js +3 -1
  34. package/dist/handlers/tasks.js +10 -12
  35. package/dist/handlers/types.d.ts +2 -1
  36. package/dist/handlers/validation.js +5 -1
  37. package/dist/index.js +8 -3
  38. package/dist/token-tracking.js +2 -2
  39. package/dist/tools/blockers.d.ts +13 -0
  40. package/dist/tools/blockers.js +119 -0
  41. package/dist/tools/bodies-of-work.d.ts +19 -0
  42. package/dist/tools/bodies-of-work.js +280 -0
  43. package/dist/tools/cloud-agents.d.ts +9 -0
  44. package/dist/tools/cloud-agents.js +67 -0
  45. package/dist/tools/connectors.d.ts +14 -0
  46. package/dist/tools/connectors.js +188 -0
  47. package/dist/tools/cost.d.ts +11 -0
  48. package/dist/tools/cost.js +108 -0
  49. package/dist/tools/decisions.d.ts +12 -0
  50. package/dist/tools/decisions.js +108 -0
  51. package/dist/tools/deployment.d.ts +24 -0
  52. package/dist/tools/deployment.js +439 -0
  53. package/dist/tools/discovery.d.ts +10 -0
  54. package/dist/tools/discovery.js +73 -0
  55. package/dist/tools/fallback.d.ts +11 -0
  56. package/dist/tools/fallback.js +108 -0
  57. package/dist/tools/file-checkouts.d.ts +13 -0
  58. package/dist/tools/file-checkouts.js +141 -0
  59. package/dist/tools/findings.d.ts +13 -0
  60. package/dist/tools/findings.js +98 -0
  61. package/dist/tools/git-issues.d.ts +11 -0
  62. package/dist/tools/git-issues.js +127 -0
  63. package/dist/tools/ideas.d.ts +13 -0
  64. package/dist/tools/ideas.js +159 -0
  65. package/dist/tools/index.d.ts +71 -0
  66. package/dist/tools/index.js +98 -0
  67. package/dist/tools/milestones.d.ts +12 -0
  68. package/dist/tools/milestones.js +115 -0
  69. package/dist/tools/organizations.d.ts +17 -0
  70. package/dist/tools/organizations.js +221 -0
  71. package/dist/tools/progress.d.ts +9 -0
  72. package/dist/tools/progress.js +70 -0
  73. package/dist/tools/project.d.ts +13 -0
  74. package/dist/tools/project.js +199 -0
  75. package/dist/tools/requests.d.ts +10 -0
  76. package/dist/tools/requests.js +65 -0
  77. package/dist/tools/roles.d.ts +11 -0
  78. package/dist/tools/roles.js +109 -0
  79. package/dist/tools/session.d.ts +15 -0
  80. package/dist/tools/session.js +178 -0
  81. package/dist/tools/sprints.d.ts +18 -0
  82. package/dist/tools/sprints.js +295 -0
  83. package/dist/tools/tasks.d.ts +27 -0
  84. package/dist/tools/tasks.js +539 -0
  85. package/dist/tools/types.d.ts +7 -0
  86. package/dist/tools/types.js +6 -0
  87. package/dist/tools/validation.d.ts +10 -0
  88. package/dist/tools/validation.js +72 -0
  89. package/dist/tools/worktrees.d.ts +9 -0
  90. package/dist/tools/worktrees.js +63 -0
  91. package/dist/utils.d.ts +66 -0
  92. package/dist/utils.js +102 -0
  93. package/docs/TOOLS.md +55 -2
  94. package/package.json +5 -3
  95. package/scripts/generate-docs.ts +1 -1
  96. package/src/api-client/blockers.ts +86 -0
  97. package/src/api-client/cost.ts +185 -0
  98. package/src/api-client/decisions.ts +87 -0
  99. package/src/api-client/discovery.ts +81 -0
  100. package/src/api-client/ideas.ts +112 -0
  101. package/src/api-client/index.ts +378 -0
  102. package/src/api-client/project.ts +179 -0
  103. package/src/api-client/session.ts +220 -0
  104. package/src/api-client/tasks.ts +450 -0
  105. package/src/api-client/types.ts +32 -0
  106. package/src/api-client/worktrees.ts +53 -0
  107. package/src/api-client.test.ts +136 -9
  108. package/src/api-client.ts +125 -27
  109. package/src/cli-init.ts +504 -0
  110. package/src/handlers/__test-utils__.ts +2 -0
  111. package/src/handlers/cloud-agents.ts +138 -0
  112. package/src/handlers/discovery.ts +7 -0
  113. package/src/handlers/index.ts +3 -0
  114. package/src/handlers/session.ts +3 -1
  115. package/src/handlers/tasks.ts +10 -12
  116. package/src/handlers/tool-categories.test.ts +1 -1
  117. package/src/handlers/types.ts +2 -1
  118. package/src/handlers/validation.ts +6 -1
  119. package/src/index.test.ts +2 -2
  120. package/src/index.ts +8 -2
  121. package/src/token-tracking.ts +3 -2
  122. package/src/tools/blockers.ts +122 -0
  123. package/src/tools/bodies-of-work.ts +283 -0
  124. package/src/tools/cloud-agents.ts +70 -0
  125. package/src/tools/connectors.ts +191 -0
  126. package/src/tools/cost.ts +111 -0
  127. package/src/tools/decisions.ts +111 -0
  128. package/src/tools/deployment.ts +442 -0
  129. package/src/tools/discovery.ts +76 -0
  130. package/src/tools/fallback.ts +111 -0
  131. package/src/tools/file-checkouts.ts +145 -0
  132. package/src/tools/findings.ts +101 -0
  133. package/src/tools/git-issues.ts +130 -0
  134. package/src/tools/ideas.ts +162 -0
  135. package/src/tools/index.ts +131 -0
  136. package/src/tools/milestones.ts +118 -0
  137. package/src/tools/organizations.ts +224 -0
  138. package/src/tools/progress.ts +73 -0
  139. package/src/tools/project.ts +202 -0
  140. package/src/tools/requests.ts +68 -0
  141. package/src/tools/roles.ts +112 -0
  142. package/src/tools/session.ts +181 -0
  143. package/src/tools/sprints.ts +298 -0
  144. package/src/tools/tasks.ts +542 -0
  145. package/src/tools/tools.test.ts +222 -0
  146. package/src/tools/types.ts +9 -0
  147. package/src/tools/validation.ts +75 -0
  148. package/src/tools/worktrees.ts +66 -0
  149. package/src/tools.test.ts +1 -1
  150. package/src/utils.test.ts +229 -0
  151. package/src/utils.ts +117 -0
  152. package/dist/tools.d.ts +0 -2
  153. package/dist/tools.js +0 -3602
  154. package/src/tools.ts +0 -3607
@@ -37,6 +37,7 @@ const startWorkSessionSchema = {
37
37
  role: { type: 'string' as const, default: 'developer' }, // Open-ended - any role name accepted
38
38
  hostname: { type: 'string' as const }, // Machine hostname for worktree tracking
39
39
  agent_type: { type: 'string' as const }, // Open-ended - any agent type accepted
40
+ agent_name: { type: 'string' as const }, // Explicit agent name for cloud/remote agents (skips persona pool)
40
41
  };
41
42
 
42
43
  const heartbeatSchema = {
@@ -54,7 +55,7 @@ const getHelpSchema = {
54
55
  };
55
56
 
56
57
  export const startWorkSession: Handler = async (args, ctx) => {
57
- const { project_id, git_url, mode, model, role, hostname: providedHostname, agent_type } = parseArgs(args, startWorkSessionSchema);
58
+ const { project_id, git_url, mode, model, role, hostname: providedHostname, agent_type, agent_name } = parseArgs(args, startWorkSessionSchema);
58
59
 
59
60
  // Use auto-detected hostname if not provided - enables machine-aware worktree filtering
60
61
  const hostname = providedHostname || MACHINE_HOSTNAME;
@@ -100,6 +101,7 @@ export const startWorkSession: Handler = async (args, ctx) => {
100
101
  role: role as SessionRole,
101
102
  hostname, // Machine hostname for worktree tracking
102
103
  agent_type: agent_type as AgentType | undefined, // Agent type for onboarding
104
+ agent_name: agent_name as string | undefined, // Explicit name for cloud/remote agents
103
105
  });
104
106
 
105
107
  if (!response.ok) {
@@ -35,6 +35,7 @@ import {
35
35
  ValidationError,
36
36
  } from '../validators.js';
37
37
  import { getApiClient } from '../api-client.js';
38
+ import { capPagination, PAGINATION_LIMITS } from '../utils.js';
38
39
 
39
40
  // Auto-detect machine hostname for worktree tracking
40
41
  const MACHINE_HOSTNAME = os.hostname();
@@ -889,9 +890,8 @@ export const searchTasks: Handler = async (args, ctx) => {
889
890
  };
890
891
  }
891
892
 
892
- // Cap limit at 20, safe offset
893
- const cappedLimit = Math.min(limit ?? 10, 20);
894
- const safeOffset = Math.max(0, offset ?? 0);
893
+ // Cap pagination to safe values
894
+ const { cappedLimit, safeOffset } = capPagination(limit ?? 10, offset, PAGINATION_LIMITS.TASK_LIMIT);
895
895
 
896
896
  const api = getApiClient();
897
897
  const response = await api.searchTasks(project_id, {
@@ -925,9 +925,8 @@ export const searchTasks: Handler = async (args, ctx) => {
925
925
  export const getTasksByPriority: Handler = async (args, ctx) => {
926
926
  const { project_id, priority, priority_max, status, limit, offset } = parseArgs(args, getTasksByPrioritySchema);
927
927
 
928
- // Cap limit at 20, safe offset
929
- const cappedLimit = Math.min(limit ?? 10, 20);
930
- const safeOffset = Math.max(0, offset ?? 0);
928
+ // Cap pagination to safe values
929
+ const { cappedLimit, safeOffset } = capPagination(limit ?? 10, offset, PAGINATION_LIMITS.TASK_LIMIT);
931
930
 
932
931
  const api = getApiClient();
933
932
  const response = await api.getTasksByPriority(project_id, {
@@ -962,9 +961,8 @@ export const getTasksByPriority: Handler = async (args, ctx) => {
962
961
  export const getRecentTasks: Handler = async (args, ctx) => {
963
962
  const { project_id, order, status, limit, offset } = parseArgs(args, getRecentTasksSchema);
964
963
 
965
- // Cap limit at 20, safe offset
966
- const cappedLimit = Math.min(limit ?? 10, 20);
967
- const safeOffset = Math.max(0, offset ?? 0);
964
+ // Cap pagination to safe values
965
+ const { cappedLimit, safeOffset } = capPagination(limit ?? 10, offset, PAGINATION_LIMITS.TASK_LIMIT);
968
966
 
969
967
  const api = getApiClient();
970
968
  const response = await api.getRecentTasks(project_id, {
@@ -1043,11 +1041,11 @@ export const getStaleWorktrees: Handler = async (args, ctx) => {
1043
1041
  // Use auto-detected hostname if not provided - filters to only worktrees on THIS machine
1044
1042
  const hostname = providedHostname || MACHINE_HOSTNAME;
1045
1043
 
1046
- // Cap limit to prevent context bloating
1047
- const cappedLimit = Math.min(limit ?? 20, 50);
1044
+ // Cap pagination to safe values
1045
+ const { cappedLimit, safeOffset } = capPagination(limit, offset, PAGINATION_LIMITS.DEFAULT_MAX_LIMIT);
1048
1046
 
1049
1047
  const api = getApiClient();
1050
- const response = await api.getStaleWorktrees(project_id, { hostname, limit: cappedLimit, offset });
1048
+ const response = await api.getStaleWorktrees(project_id, { hostname, limit: cappedLimit, offset: safeOffset });
1051
1049
 
1052
1050
  if (!response.ok) {
1053
1051
  return { result: { error: response.error || 'Failed to get stale worktrees' }, isError: true };
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import { describe, it, expect } from 'vitest';
6
- import { tools } from '../tools.js';
6
+ import { tools } from '../tools/index.js';
7
7
  import { TOOL_CATEGORIES } from './discovery.js';
8
8
 
9
9
  describe('Documentation Generator Prerequisites', () => {
@@ -45,6 +45,7 @@ export interface SessionState {
45
45
  currentSessionId: string | null;
46
46
  currentPersona: string | null;
47
47
  currentRole: AgentRole | null;
48
+ currentProjectId: string | null;
48
49
  tokenUsage: TokenUsage;
49
50
  }
50
51
 
@@ -64,7 +65,7 @@ export interface HandlerContext {
64
65
  auth: AuthContext;
65
66
  session: SessionState;
66
67
  /** Update session state (for handlers that modify session) */
67
- updateSession: (updates: Partial<Pick<SessionState, 'currentSessionId' | 'currentPersona' | 'currentRole' | 'tokenUsage'>>) => void;
68
+ updateSession: (updates: Partial<Pick<SessionState, 'currentSessionId' | 'currentPersona' | 'currentRole' | 'currentProjectId' | 'tokenUsage'>>) => void;
68
69
  /** Get user updates since last sync (for session handlers) */
69
70
  getUserUpdates?: (projectId: string) => Promise<UserUpdates | undefined>;
70
71
  /** Select an available persona for the agent */
@@ -26,6 +26,7 @@ const validateTaskSchema = {
26
26
  approved: { type: 'boolean' as const, required: true as const },
27
27
  validation_notes: { type: 'string' as const },
28
28
  skip_pr_check: { type: 'boolean' as const },
29
+ // Note: pr_checks_passing may arrive as string from some MCP clients, handled in validateTask
29
30
  pr_checks_passing: { type: 'boolean' as const },
30
31
  };
31
32
 
@@ -100,12 +101,16 @@ export const validateTask: Handler = async (args, ctx) => {
100
101
  const { session } = ctx;
101
102
  const currentSessionId = session.currentSessionId;
102
103
 
104
+ // Ensure pr_checks_passing is a proper boolean (MCP may send as string)
105
+ // Cast to unknown first to satisfy TypeScript
106
+ const checksPassingBool = pr_checks_passing === true || (pr_checks_passing as unknown) === 'true';
107
+
103
108
  const apiClient = getApiClient();
104
109
  const response = await apiClient.validateTask(task_id, {
105
110
  approved,
106
111
  validation_notes,
107
112
  skip_pr_check,
108
- pr_checks_passing,
113
+ pr_checks_passing: pr_checks_passing !== undefined ? checksPassingBool : undefined,
109
114
  }, currentSessionId || undefined);
110
115
 
111
116
  if (!response.ok) {
package/src/index.test.ts CHANGED
@@ -636,12 +636,12 @@ describe('MCP Server Entry Point', () => {
636
636
  // =========================================================================
637
637
  describe('Tools Registration', () => {
638
638
  it('should export tools array', async () => {
639
- const { tools } = await import('./tools.js');
639
+ const { tools } = await import('./tools/index.js');
640
640
  expect(Array.isArray(tools)).toBe(true);
641
641
  });
642
642
 
643
643
  it('should have required tool properties', async () => {
644
- const { tools } = await import('./tools.js');
644
+ const { tools } = await import('./tools/index.js');
645
645
  tools.forEach((tool) => {
646
646
  expect(tool).toHaveProperty('name');
647
647
  expect(tool).toHaveProperty('description');
package/src/index.ts CHANGED
@@ -33,9 +33,10 @@ import {
33
33
  RateLimiter,
34
34
  extractProjectNameFromGitUrl,
35
35
  isValidStatusTransition,
36
+ getErrorMessage,
36
37
  } from './utils.js';
37
38
  import { buildHandlerRegistry, type HandlerContext } from './handlers/index.js';
38
- import { tools } from './tools.js';
39
+ import { tools } from './tools/index.js';
39
40
  import {
40
41
  createTokenUsage,
41
42
  trackTokenUsage as trackTokens,
@@ -59,6 +60,9 @@ let currentPersona: string | null = null;
59
60
  // Current role for this agent instance
60
61
  let currentRole: 'developer' | 'validator' | 'deployer' | 'reviewer' | 'maintainer' | null = null;
61
62
 
63
+ // Current project ID for this agent instance
64
+ let currentProjectId: string | null = null;
65
+
62
66
  // Token usage tracking for this session (using token-tracking module)
63
67
  let sessionTokenUsage: TokenUsage = createTokenUsage();
64
68
 
@@ -619,12 +623,14 @@ async function handleTool(
619
623
  currentSessionId,
620
624
  currentPersona,
621
625
  currentRole,
626
+ currentProjectId,
622
627
  tokenUsage: sessionTokenUsage,
623
628
  },
624
629
  updateSession: (updates) => {
625
630
  if (updates.currentSessionId !== undefined) currentSessionId = updates.currentSessionId;
626
631
  if (updates.currentPersona !== undefined) currentPersona = updates.currentPersona;
627
632
  if (updates.currentRole !== undefined) currentRole = updates.currentRole;
633
+ if (updates.currentProjectId !== undefined) currentProjectId = updates.currentProjectId;
628
634
  if (updates.tokenUsage !== undefined) sessionTokenUsage = updates.tokenUsage;
629
635
  },
630
636
  };
@@ -754,7 +760,7 @@ async function main() {
754
760
  }
755
761
 
756
762
  // Handle database errors with better context
757
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
763
+ const errorMessage = getErrorMessage(error);
758
764
  let hint: string | undefined;
759
765
 
760
766
  if (errorMessage.includes('violates foreign key constraint')) {
@@ -5,6 +5,8 @@
5
5
  * Extracted from index.ts to enable unit testing.
6
6
  */
7
7
 
8
+ import { getErrorMessage } from './utils.js';
9
+
8
10
  // ============================================================================
9
11
  // Types
10
12
  // ============================================================================
@@ -39,8 +41,7 @@ export function estimateTokens(obj: unknown): number {
39
41
  return Math.max(1, Math.ceil(json.length / 4));
40
42
  } catch (error) {
41
43
  // Log warning when serialization fails (e.g., circular references, BigInt)
42
- const errorMessage = error instanceof Error ? error.message : String(error);
43
- console.warn(`[Vibescope] Token estimation failed: ${errorMessage}. Returning minimal estimate of 1 token.`);
44
+ console.warn(`[Vibescope] Token estimation failed: ${getErrorMessage(error)}. Returning minimal estimate of 1 token.`);
44
45
  return 1;
45
46
  }
46
47
  }
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Blocker Tool Definitions
3
+ *
4
+ * Tools for managing blockers:
5
+ * - add_blocker
6
+ * - resolve_blocker
7
+ * - get_blocker
8
+ * - get_blockers
9
+ * - get_blockers_stats
10
+ * - delete_blocker
11
+ */
12
+
13
+ import type { Tool } from './types.js';
14
+
15
+ export const blockerTools: Tool[] = [
16
+ {
17
+ name: 'add_blocker',
18
+ description: `Record a blocker preventing progress.`,
19
+ inputSchema: {
20
+ type: 'object',
21
+ properties: {
22
+ project_id: {
23
+ type: 'string',
24
+ description: 'Project UUID',
25
+ },
26
+ description: {
27
+ type: 'string',
28
+ description: 'What is blocking progress?',
29
+ },
30
+ },
31
+ required: ['project_id', 'description'],
32
+ },
33
+ },
34
+ {
35
+ name: 'resolve_blocker',
36
+ description: `Mark a blocker as resolved.`,
37
+ inputSchema: {
38
+ type: 'object',
39
+ properties: {
40
+ blocker_id: {
41
+ type: 'string',
42
+ description: 'Blocker UUID',
43
+ },
44
+ resolution_note: {
45
+ type: 'string',
46
+ description: 'How was it resolved?',
47
+ },
48
+ },
49
+ required: ['blocker_id'],
50
+ },
51
+ },
52
+ {
53
+ name: 'get_blocker',
54
+ description: `Get a single blocker by ID. More token-efficient than get_blockers when you need details for a specific blocker.`,
55
+ inputSchema: {
56
+ type: 'object',
57
+ properties: {
58
+ blocker_id: {
59
+ type: 'string',
60
+ description: 'Blocker UUID',
61
+ },
62
+ },
63
+ required: ['blocker_id'],
64
+ },
65
+ },
66
+ {
67
+ name: 'get_blockers',
68
+ description: `Get blockers for a project, optionally filtered by status.`,
69
+ inputSchema: {
70
+ type: 'object',
71
+ properties: {
72
+ project_id: {
73
+ type: 'string',
74
+ description: 'Project UUID',
75
+ },
76
+ status: {
77
+ type: 'string',
78
+ enum: ['open', 'resolved'],
79
+ description: 'Filter by status (default: open)',
80
+ },
81
+ limit: {
82
+ type: 'number',
83
+ description: 'Max number of blockers to return (default 10, max 200)',
84
+ },
85
+ offset: {
86
+ type: 'number',
87
+ description: 'Number of blockers to skip for pagination (default 0)',
88
+ },
89
+ search_query: {
90
+ type: 'string',
91
+ description: 'Search blockers by description',
92
+ },
93
+ },
94
+ required: ['project_id'],
95
+ },
96
+ },
97
+ {
98
+ name: 'get_blockers_stats',
99
+ description: `Get aggregate statistics about blockers for a project. Returns total count and breakdown by status. Much more token-efficient than get_blockers when you just need to understand the overall state.`,
100
+ inputSchema: {
101
+ type: 'object',
102
+ properties: {
103
+ project_id: { type: 'string', description: 'Project UUID' },
104
+ },
105
+ required: ['project_id'],
106
+ },
107
+ },
108
+ {
109
+ name: 'delete_blocker',
110
+ description: `Delete a blocker.`,
111
+ inputSchema: {
112
+ type: 'object',
113
+ properties: {
114
+ blocker_id: {
115
+ type: 'string',
116
+ description: 'Blocker UUID',
117
+ },
118
+ },
119
+ required: ['blocker_id'],
120
+ },
121
+ },
122
+ ];
@@ -0,0 +1,283 @@
1
+ /**
2
+ * Bodies of Work Tool Definitions
3
+ *
4
+ * Tools for managing grouped task collections:
5
+ * - create_body_of_work
6
+ * - update_body_of_work
7
+ * - get_body_of_work
8
+ * - get_bodies_of_work
9
+ * - delete_body_of_work
10
+ * - add_task_to_body_of_work
11
+ * - remove_task_from_body_of_work
12
+ * - activate_body_of_work
13
+ * - add_task_dependency
14
+ * - remove_task_dependency
15
+ * - get_task_dependencies
16
+ * - get_next_body_of_work_task
17
+ */
18
+
19
+ import type { Tool } from './types.js';
20
+
21
+ export const bodiesOfWorkTools: Tool[] = [
22
+ {
23
+ name: 'create_body_of_work',
24
+ description: `Create a new body of work to group tasks into phases (pre/core/post).
25
+ Bodies of work allow organizing related tasks with optional auto-deployment on completion.`,
26
+ inputSchema: {
27
+ type: 'object',
28
+ properties: {
29
+ project_id: {
30
+ type: 'string',
31
+ description: 'Project UUID',
32
+ },
33
+ title: {
34
+ type: 'string',
35
+ description: 'Title for the body of work',
36
+ },
37
+ description: {
38
+ type: 'string',
39
+ description: 'Optional description',
40
+ },
41
+ auto_deploy_on_completion: {
42
+ type: 'boolean',
43
+ description: 'Automatically request deployment when all tasks complete (default: false)',
44
+ },
45
+ deploy_environment: {
46
+ type: 'string',
47
+ enum: ['development', 'staging', 'production'],
48
+ description: 'Target environment for auto-deploy (default: production)',
49
+ },
50
+ deploy_version_bump: {
51
+ type: 'string',
52
+ enum: ['patch', 'minor', 'major'],
53
+ description: 'Version bump for auto-deploy (default: minor)',
54
+ },
55
+ deploy_trigger: {
56
+ type: 'string',
57
+ enum: ['all_completed', 'all_completed_validated'],
58
+ description: 'When to trigger auto-deploy: all_completed (immediate) or all_completed_validated (requires validation, default)',
59
+ },
60
+ },
61
+ required: ['project_id', 'title'],
62
+ },
63
+ },
64
+ {
65
+ name: 'update_body_of_work',
66
+ description: `Update a body of work's settings.`,
67
+ inputSchema: {
68
+ type: 'object',
69
+ properties: {
70
+ body_of_work_id: {
71
+ type: 'string',
72
+ description: 'Body of work UUID',
73
+ },
74
+ title: {
75
+ type: 'string',
76
+ description: 'Updated title',
77
+ },
78
+ description: {
79
+ type: 'string',
80
+ description: 'Updated description',
81
+ },
82
+ auto_deploy_on_completion: {
83
+ type: 'boolean',
84
+ description: 'Auto-deploy setting',
85
+ },
86
+ deploy_environment: {
87
+ type: 'string',
88
+ enum: ['development', 'staging', 'production'],
89
+ description: 'Target environment',
90
+ },
91
+ deploy_version_bump: {
92
+ type: 'string',
93
+ enum: ['patch', 'minor', 'major'],
94
+ description: 'Version bump type',
95
+ },
96
+ deploy_trigger: {
97
+ type: 'string',
98
+ enum: ['all_completed', 'all_completed_validated'],
99
+ description: 'When to trigger auto-deploy',
100
+ },
101
+ },
102
+ required: ['body_of_work_id'],
103
+ },
104
+ },
105
+ {
106
+ name: 'get_body_of_work',
107
+ description: `Get a body of work with all its tasks organized by phase.`,
108
+ inputSchema: {
109
+ type: 'object',
110
+ properties: {
111
+ body_of_work_id: {
112
+ type: 'string',
113
+ description: 'Body of work UUID',
114
+ },
115
+ },
116
+ required: ['body_of_work_id'],
117
+ },
118
+ },
119
+ {
120
+ name: 'get_bodies_of_work',
121
+ description: `List bodies of work for a project with task counts per phase.`,
122
+ inputSchema: {
123
+ type: 'object',
124
+ properties: {
125
+ project_id: {
126
+ type: 'string',
127
+ description: 'Project UUID',
128
+ },
129
+ status: {
130
+ type: 'string',
131
+ enum: ['draft', 'active', 'completed', 'cancelled'],
132
+ description: 'Filter by status (optional)',
133
+ },
134
+ },
135
+ required: ['project_id'],
136
+ },
137
+ },
138
+ {
139
+ name: 'delete_body_of_work',
140
+ description: `Delete a body of work. Tasks are preserved but no longer grouped.`,
141
+ inputSchema: {
142
+ type: 'object',
143
+ properties: {
144
+ body_of_work_id: {
145
+ type: 'string',
146
+ description: 'Body of work UUID',
147
+ },
148
+ },
149
+ required: ['body_of_work_id'],
150
+ },
151
+ },
152
+ {
153
+ name: 'add_task_to_body_of_work',
154
+ description: `Add a task to a body of work in a specific phase.
155
+ Phases control execution order: pre tasks run first, then core, then post.`,
156
+ inputSchema: {
157
+ type: 'object',
158
+ properties: {
159
+ body_of_work_id: {
160
+ type: 'string',
161
+ description: 'Body of work UUID',
162
+ },
163
+ task_id: {
164
+ type: 'string',
165
+ description: 'Task UUID to add',
166
+ },
167
+ phase: {
168
+ type: 'string',
169
+ enum: ['pre', 'core', 'post'],
170
+ description: 'Task phase (default: core)',
171
+ },
172
+ order_index: {
173
+ type: 'number',
174
+ description: 'Order within phase (auto-assigned if not specified)',
175
+ },
176
+ },
177
+ required: ['body_of_work_id', 'task_id'],
178
+ },
179
+ },
180
+ {
181
+ name: 'remove_task_from_body_of_work',
182
+ description: `Remove a task from its body of work. The task is preserved.`,
183
+ inputSchema: {
184
+ type: 'object',
185
+ properties: {
186
+ task_id: {
187
+ type: 'string',
188
+ description: 'Task UUID to remove',
189
+ },
190
+ },
191
+ required: ['task_id'],
192
+ },
193
+ },
194
+ {
195
+ name: 'activate_body_of_work',
196
+ description: `Activate a draft body of work to start execution.
197
+ Requires at least one task. Once active, tasks can be worked on following phase order.`,
198
+ inputSchema: {
199
+ type: 'object',
200
+ properties: {
201
+ body_of_work_id: {
202
+ type: 'string',
203
+ description: 'Body of work UUID',
204
+ },
205
+ },
206
+ required: ['body_of_work_id'],
207
+ },
208
+ },
209
+ {
210
+ name: 'add_task_dependency',
211
+ description: `Add a dependency between tasks in a body of work.
212
+ The dependent task cannot start until the dependency is completed. Prevents circular dependencies.`,
213
+ inputSchema: {
214
+ type: 'object',
215
+ properties: {
216
+ body_of_work_id: {
217
+ type: 'string',
218
+ description: 'Body of work UUID',
219
+ },
220
+ task_id: {
221
+ type: 'string',
222
+ description: 'Task that depends on another task',
223
+ },
224
+ depends_on_task_id: {
225
+ type: 'string',
226
+ description: 'Task that must complete first',
227
+ },
228
+ },
229
+ required: ['body_of_work_id', 'task_id', 'depends_on_task_id'],
230
+ },
231
+ },
232
+ {
233
+ name: 'remove_task_dependency',
234
+ description: `Remove a dependency between tasks.`,
235
+ inputSchema: {
236
+ type: 'object',
237
+ properties: {
238
+ task_id: {
239
+ type: 'string',
240
+ description: 'Task UUID',
241
+ },
242
+ depends_on_task_id: {
243
+ type: 'string',
244
+ description: 'Dependency task UUID',
245
+ },
246
+ },
247
+ required: ['task_id', 'depends_on_task_id'],
248
+ },
249
+ },
250
+ {
251
+ name: 'get_task_dependencies',
252
+ description: `Get task dependencies for a body of work or specific task.`,
253
+ inputSchema: {
254
+ type: 'object',
255
+ properties: {
256
+ body_of_work_id: {
257
+ type: 'string',
258
+ description: 'Body of work UUID (optional if task_id provided)',
259
+ },
260
+ task_id: {
261
+ type: 'string',
262
+ description: 'Specific task UUID (optional if body_of_work_id provided)',
263
+ },
264
+ },
265
+ },
266
+ },
267
+ {
268
+ name: 'get_next_body_of_work_task',
269
+ description: `Get the next available task from a body of work.
270
+ Considers phase order (pre → core → post) and task dependencies.
271
+ Only returns tasks where all dependencies are completed.`,
272
+ inputSchema: {
273
+ type: 'object',
274
+ properties: {
275
+ body_of_work_id: {
276
+ type: 'string',
277
+ description: 'Body of work UUID',
278
+ },
279
+ },
280
+ required: ['body_of_work_id'],
281
+ },
282
+ },
283
+ ];
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Cloud Agent Tool Definitions
3
+ *
4
+ * Tools for managing cloud-spawned agents:
5
+ * - cleanup_stale_cloud_agents
6
+ * - list_cloud_agents
7
+ */
8
+
9
+ import type { Tool } from '@modelcontextprotocol/sdk/types.js';
10
+
11
+ export const cloudAgentTools: Tool[] = [
12
+ {
13
+ name: 'cleanup_stale_cloud_agents',
14
+ description: `Clean up stale cloud agents that failed to start or lost connection.
15
+
16
+ Finds agents stuck in 'starting' status (or optionally 'running' with no heartbeat)
17
+ and marks them as failed. Only operates on the current session's project.
18
+
19
+ Use this when:
20
+ - You see agents stuck in "starting" status on the dashboard
21
+ - Cloud agents failed to spawn but weren't cleaned up
22
+ - You want to clear ghost agents from a previous session
23
+
24
+ SECURITY: This only affects agents in YOUR current project. Cannot access other users' projects.`,
25
+ inputSchema: {
26
+ type: 'object',
27
+ properties: {
28
+ project_id: {
29
+ type: 'string',
30
+ description: 'Project UUID (required)'
31
+ },
32
+ stale_minutes: {
33
+ type: 'number',
34
+ description: 'Consider agents stale after this many minutes (default: 5)'
35
+ },
36
+ include_running: {
37
+ type: 'boolean',
38
+ description: 'Also clean up "running" agents with no recent heartbeat (default: false)'
39
+ },
40
+ dry_run: {
41
+ type: 'boolean',
42
+ description: 'If true, just report what would be cleaned without actually cleaning (default: false)'
43
+ }
44
+ },
45
+ required: ['project_id']
46
+ }
47
+ },
48
+ {
49
+ name: 'list_cloud_agents',
50
+ description: `List cloud agents for a project.
51
+
52
+ Returns all spawned cloud agents for the project with their current status.
53
+ Use this to check the state of cloud agents before/after cleanup.`,
54
+ inputSchema: {
55
+ type: 'object',
56
+ properties: {
57
+ project_id: {
58
+ type: 'string',
59
+ description: 'Project UUID (required)'
60
+ },
61
+ status: {
62
+ type: 'string',
63
+ enum: ['starting', 'running', 'stopped', 'failed', 'all'],
64
+ description: 'Filter by status (default: all)'
65
+ }
66
+ },
67
+ required: ['project_id']
68
+ }
69
+ }
70
+ ];