@tacitai/mcp-server 0.6.28 → 0.6.30

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.
@@ -12,6 +12,7 @@
12
12
  import { z } from 'zod';
13
13
  import { getClient, TacitApiError, TokenExpiredError } from '../client.js';
14
14
  import { featureDisabledResult } from './errors.js';
15
+ import { loadRoleTemplates } from '../templates/role-loader.js';
15
16
  function apiErrorResult(err, toolName) {
16
17
  if (err instanceof TokenExpiredError) {
17
18
  return {
@@ -53,8 +54,33 @@ export function buildAgentListRequest(client, input) {
53
54
  const args = {};
54
55
  if (input.limit !== undefined)
55
56
  args['limit'] = input.limit;
56
- const result = await callAgentTool(client, 'tacit.agents.list', args);
57
- return { content: [{ type: 'text', text: JSON.stringify(result) }] };
57
+ const templates = loadRoleTemplates();
58
+ let instances = [];
59
+ try {
60
+ const result = await callAgentTool(client, 'tacit.agents.list', args);
61
+ const r = result;
62
+ const list = Array.isArray(r) ? r : r?.agents;
63
+ if (Array.isArray(list))
64
+ instances = list;
65
+ }
66
+ catch {
67
+ // business_agents table may not exist (migration 349 RESERVED)
68
+ }
69
+ const merged = templates.map((t) => {
70
+ const inst = instances.find((i) => i['role_slug'] === t.slug);
71
+ return {
72
+ role_slug: t.slug,
73
+ display_name: inst?.['name'] ?? t.display_name,
74
+ description: t.description,
75
+ icon: t.icon,
76
+ default_capabilities: t.default_capabilities,
77
+ workflow_types: t.workflow_types,
78
+ instance: inst
79
+ ? { agent_id: inst['agent_id'] ?? inst['id'], status: inst['status'], health: inst['health'] }
80
+ : null,
81
+ };
82
+ });
83
+ return { content: [{ type: 'text', text: JSON.stringify({ agents: merged }) }] };
58
84
  }
59
85
  catch (err) {
60
86
  return apiErrorResult(err, 'tacit_agent_list');
@@ -71,34 +97,154 @@ export async function handleAgentList(args) {
71
97
  }
72
98
  // ─── tacit_agent_delegate ────────────────────────────────────────────────────
73
99
  export const agentDelegateInputSchema = z.object({
74
- agent_id: z.string().min(1).describe('UUID of the agent to delegate to'),
100
+ agent_id: z.string().min(1).optional().describe('UUID of the agent to delegate to (provide this OR role_slug)'),
101
+ role_slug: z.string().min(1).optional().describe('Role template slug (e.g. "wiki_editor"). Resolves to agent_id; creates instance on first use'),
75
102
  task: z.string().min(1).describe('Task description to delegate'),
76
103
  kind: z.string().optional().describe('Task kind (default: "task")'),
77
104
  target_ids: z.array(z.string()).optional().describe('Target entity UUIDs for the task'),
78
105
  program_ids: z.array(z.string()).optional().describe('Program UUIDs to scope the task'),
79
106
  dossier_ids: z.array(z.string()).optional().describe('Dossier UUIDs to scope the task'),
80
- });
107
+ wait: z.boolean().optional().default(true).describe('Wait for the run to complete and return results inline (default: true)'),
108
+ wait_timeout: z.number().int().positive().optional().default(120).describe('Max seconds to wait for completion (default: 120)'),
109
+ }).refine((d) => d.agent_id || d.role_slug, { message: 'Either agent_id or role_slug is required' });
81
110
  export const AGENT_DELEGATE_TOOL_DEF = {
82
111
  name: 'tacit_agent_delegate',
83
- description: 'Delegate a task to a business agent. The task is fingerprint-deduped and dispatched to the run engine. ' +
84
- 'Returns assignment_id, run_id, and status. Duplicate tasks return status "duplicate" with the existing assignment.',
112
+ description: 'Delegate a task to a business agent and wait for results. Accepts agent_id (UUID) or role_slug (template name). ' +
113
+ 'When role_slug is used and no instance exists, the agent is created on first delegation. ' +
114
+ 'By default, waits for the run to complete and returns the agent\'s output messages inline. ' +
115
+ 'Set wait=false to return immediately with just the assignment_id and run_id.',
85
116
  inputSchema: {
86
117
  type: 'object',
87
118
  properties: {
88
- agent_id: { type: 'string', description: 'UUID of the agent to delegate to' },
119
+ agent_id: { type: 'string', description: 'UUID of the agent to delegate to (provide this OR role_slug)' },
120
+ role_slug: { type: 'string', description: 'Role template slug (e.g. "wiki_editor"). Creates instance on first use' },
89
121
  task: { type: 'string', description: 'Task description to delegate' },
90
122
  kind: { type: 'string', description: 'Task kind (default: "task")' },
91
123
  target_ids: { type: 'array', items: { type: 'string' }, description: 'Target entity UUIDs' },
92
124
  program_ids: { type: 'array', items: { type: 'string' }, description: 'Program UUIDs to scope the task' },
93
125
  dossier_ids: { type: 'array', items: { type: 'string' }, description: 'Dossier UUIDs to scope the task' },
126
+ wait: { type: 'boolean', description: 'Wait for run completion and return results inline (default: true)' },
127
+ wait_timeout: { type: 'number', description: 'Max seconds to wait for completion (default: 120)' },
94
128
  },
95
- required: ['agent_id', 'task'],
129
+ required: ['task'],
96
130
  },
97
131
  };
132
+ async function resolveAgentId(client, input) {
133
+ if (input.agent_id)
134
+ return { agent_id: input.agent_id };
135
+ const slug = input.role_slug;
136
+ if (!slug)
137
+ return { error: 'Either agent_id or role_slug is required' };
138
+ const template = loadRoleTemplates().find((t) => t.slug === slug);
139
+ if (!template)
140
+ return { error: `Unknown role_slug: ${slug}` };
141
+ try {
142
+ const result = await callAgentTool(client, 'tacit.agents.list', {});
143
+ const r = result;
144
+ const list = Array.isArray(r)
145
+ ? r
146
+ : (r?.items ??
147
+ r?.agents);
148
+ if (Array.isArray(list)) {
149
+ const existing = list.find((i) => i['role_slug'] === slug);
150
+ if (existing) {
151
+ const id = (existing['agent_id'] ?? existing['id']);
152
+ if (id)
153
+ return { agent_id: id };
154
+ }
155
+ }
156
+ }
157
+ catch {
158
+ // list failed — fall through to create
159
+ }
160
+ // No instance exists — create one (lazy materialization)
161
+ try {
162
+ const created = await callAgentTool(client, 'tacit.agents.create', {
163
+ name: template.display_name,
164
+ role_slug: slug,
165
+ archetype: 'executive',
166
+ });
167
+ const id = (created['agent_id'] ?? created['id']);
168
+ if (id)
169
+ return { agent_id: id };
170
+ return { error: 'Agent creation returned no id' };
171
+ }
172
+ catch (err) {
173
+ const msg = err instanceof Error ? err.message : String(err);
174
+ // Unique constraint collision — agent was created concurrently; re-list
175
+ if (msg.includes('duplicate key') || msg.includes('unique constraint')) {
176
+ try {
177
+ const retry = await callAgentTool(client, 'tacit.agents.list', {});
178
+ const rr = retry;
179
+ const rlist = Array.isArray(rr)
180
+ ? rr
181
+ : (rr?.items ??
182
+ rr?.agents);
183
+ if (Array.isArray(rlist)) {
184
+ const found = rlist.find((i) => i['role_slug'] === slug);
185
+ if (found) {
186
+ const fid = (found['agent_id'] ?? found['id']);
187
+ if (fid)
188
+ return { agent_id: fid };
189
+ }
190
+ }
191
+ }
192
+ catch { /* re-list also failed */ }
193
+ }
194
+ return { error: `Failed to create agent instance for ${slug}: ${msg}` };
195
+ }
196
+ }
197
+ function sleep(ms) {
198
+ return new Promise((resolve) => setTimeout(resolve, ms));
199
+ }
200
+ async function pollForCompletion(client, agentId, runId, timeoutSec) {
201
+ const POLL_INTERVAL_MS = 3000;
202
+ const deadline = Date.now() + timeoutSec * 1000;
203
+ while (Date.now() < deadline) {
204
+ try {
205
+ const timeline = await callAgentTool(client, 'tacit.agents.timeline', {
206
+ agent_id: agentId,
207
+ run_id: runId,
208
+ });
209
+ const events = timeline?.events;
210
+ if (Array.isArray(events)) {
211
+ for (const evt of events) {
212
+ const e = evt;
213
+ const evtType = (e['event_type'] ?? e['type'] ?? '');
214
+ if (evtType.includes('completed') || evtType.includes('succeeded')) {
215
+ return { completed: true, failed: false, events };
216
+ }
217
+ if (evtType.includes('failed') || evtType.includes('error')) {
218
+ return { completed: false, failed: true, events };
219
+ }
220
+ }
221
+ }
222
+ }
223
+ catch {
224
+ // timeline call failed — keep polling
225
+ }
226
+ await sleep(POLL_INTERVAL_MS);
227
+ }
228
+ return { completed: false, failed: false, events: [] };
229
+ }
230
+ async function fetchRunMessages(client, agentId) {
231
+ try {
232
+ const threadResult = await callAgentTool(client, 'tacit.agents.thread', { agent_id: agentId });
233
+ const tr = threadResult;
234
+ return tr?.messages ?? [];
235
+ }
236
+ catch {
237
+ return [];
238
+ }
239
+ }
98
240
  export function buildAgentDelegateRequest(client, input) {
99
241
  return {
100
242
  async execute() {
101
243
  try {
244
+ const resolved = await resolveAgentId(client, input);
245
+ if ('error' in resolved) {
246
+ return { content: [{ type: 'text', text: resolved.error }], isError: true };
247
+ }
102
248
  const spec = { task: input.task };
103
249
  if (input.kind)
104
250
  spec['kind'] = input.kind;
@@ -109,10 +255,29 @@ export function buildAgentDelegateRequest(client, input) {
109
255
  if (input.dossier_ids)
110
256
  spec['dossier_ids'] = input.dossier_ids;
111
257
  const result = await callAgentTool(client, 'tacit.agents.delegate', {
112
- agent_id: input.agent_id,
258
+ agent_id: resolved.agent_id,
113
259
  spec,
114
260
  });
115
- return { content: [{ type: 'text', text: JSON.stringify(result) }] };
261
+ const shouldWait = input.wait !== false;
262
+ const runId = result['run_id'];
263
+ const status = result['status'] ?? '';
264
+ if (!shouldWait || !runId || status === 'duplicate') {
265
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
266
+ }
267
+ // Poll for completion, then fetch output messages
268
+ const timeoutSec = input.wait_timeout ?? 120;
269
+ const poll = await pollForCompletion(client, resolved.agent_id, runId, timeoutSec);
270
+ const messages = await fetchRunMessages(client, resolved.agent_id);
271
+ const combined = {
272
+ ...result,
273
+ wait_result: poll.completed
274
+ ? 'completed'
275
+ : poll.failed
276
+ ? 'failed'
277
+ : 'timeout',
278
+ messages,
279
+ };
280
+ return { content: [{ type: 'text', text: JSON.stringify(combined) }] };
116
281
  }
117
282
  catch (err) {
118
283
  return apiErrorResult(err, 'tacit_agent_delegate');
@@ -296,13 +461,16 @@ export function registerAgentTools(server, getClientFn) {
296
461
  const client = await getClientFn();
297
462
  return buildAgentListRequest(client, args).execute();
298
463
  });
299
- server.tool('tacit_agent_delegate', 'Delegate a task to a business agent.', {
300
- agent_id: z.string().min(1).describe('UUID of the agent to delegate to'),
464
+ server.tool('tacit_agent_delegate', 'Delegate a task to a business agent and wait for results. Accepts agent_id or role_slug. Returns the agent\'s output inline by default.', {
465
+ agent_id: z.string().min(1).optional().describe('UUID of the agent to delegate to (provide this OR role_slug)'),
466
+ role_slug: z.string().min(1).optional().describe('Role template slug (e.g. "wiki_editor"). Creates instance on first use'),
301
467
  task: z.string().min(1).describe('Task description to delegate'),
302
468
  kind: z.string().optional().describe('Task kind'),
303
469
  target_ids: z.array(z.string()).optional().describe('Target entity UUIDs'),
304
470
  program_ids: z.array(z.string()).optional().describe('Program UUIDs'),
305
471
  dossier_ids: z.array(z.string()).optional().describe('Dossier UUIDs'),
472
+ wait: z.boolean().optional().default(true).describe('Wait for completion and return results (default: true)'),
473
+ wait_timeout: z.number().int().positive().optional().default(120).describe('Max seconds to wait (default: 120)'),
306
474
  }, async (args) => {
307
475
  const client = await getClientFn();
308
476
  return buildAgentDelegateRequest(client, args).execute();
@@ -0,0 +1,14 @@
1
+ /**
2
+ * tacit_cmo_lint — deterministic D-rule checks (MV-1539 W3 Step 12b).
3
+ *
4
+ * Applies MR-D01..D08 from MARKETING-RULES.json. H-rules and J-rules
5
+ * (model-dependent) are skill-layer only. Stateless, preCall-exempt.
6
+ */
7
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
8
+ export interface LintViolation {
9
+ ruleId: string;
10
+ title: string;
11
+ detail: string;
12
+ severity: 'FAIL' | 'WARN';
13
+ }
14
+ export declare function registerCmoTools(server: McpServer): void;
@@ -0,0 +1,125 @@
1
+ /**
2
+ * tacit_cmo_lint — deterministic D-rule checks (MV-1539 W3 Step 12b).
3
+ *
4
+ * Applies MR-D01..D08 from MARKETING-RULES.json. H-rules and J-rules
5
+ * (model-dependent) are skill-layer only. Stateless, preCall-exempt.
6
+ */
7
+ import { z } from 'zod';
8
+ import * as fs from 'fs';
9
+ import * as path from 'path';
10
+ const lintSchema = z.object({
11
+ content: z.string().describe('The HTML content to lint'),
12
+ assetType: z.string().optional().describe('Asset type (e.g. report, deck, short-story)'),
13
+ });
14
+ function loadRules() {
15
+ const primary = path.join(process.cwd(), '.claude/skills/cmo/assets/MARKETING-RULES.json');
16
+ const fallback = process.env['MARKETING_RULES_PATH'];
17
+ const filePath = fs.existsSync(primary) ? primary : fallback;
18
+ if (!filePath || !fs.existsSync(filePath))
19
+ return null;
20
+ return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
21
+ }
22
+ function isChannelNative(rulesFile, assetType) {
23
+ if (!assetType)
24
+ return false;
25
+ return rulesFile.asset_type_classes?.channel_native?.types?.includes(assetType) ?? false;
26
+ }
27
+ function checkD02(content) {
28
+ if (!/Quarterback\s+AI\s+Inc\./i.test(content)) {
29
+ return { ruleId: 'MR-D02', title: 'Legal footer present', detail: 'Missing "Quarterback AI Inc." text', severity: 'FAIL' };
30
+ }
31
+ return null;
32
+ }
33
+ function checkD03(content) {
34
+ const violations = [];
35
+ if (!/\d{4}-\d{2}-\d{2}/.test(content)) {
36
+ violations.push({ ruleId: 'MR-D03a', title: 'ISO date missing', detail: 'No ISO 8601 date (YYYY-MM-DD) found', severity: 'FAIL' });
37
+ }
38
+ if (!/v\d+\.\d+/i.test(content)) {
39
+ violations.push({ ruleId: 'MR-D03b', title: 'Version number missing', detail: 'No version number (vN.N) found', severity: 'FAIL' });
40
+ }
41
+ if (!/version\s+history|changelog/i.test(content)) {
42
+ violations.push({ ruleId: 'MR-D03c', title: 'Version history heading missing', detail: 'No "Version History" or "Changelog" heading found', severity: 'FAIL' });
43
+ }
44
+ return violations;
45
+ }
46
+ function checkD04(content) {
47
+ if (!/missions\/|results\/|docs\//i.test(content)) {
48
+ return { ruleId: 'MR-D04', title: 'Deliverable path', detail: 'No deliverable file path reference found', severity: 'WARN' };
49
+ }
50
+ return null;
51
+ }
52
+ function checkD07(content) {
53
+ const hasStoryMarkers = /fiction|fictional|story|narrative|imagin/i.test(content);
54
+ if (hasStoryMarkers && !/this\s+(is\s+)?(a\s+)?fiction|fictional|work\s+of\s+fiction|disclosure/i.test(content)) {
55
+ return { ruleId: 'MR-D07', title: 'Fiction disclosure present', detail: 'Content appears fictional but lacks explicit fiction disclosure', severity: 'FAIL' };
56
+ }
57
+ return null;
58
+ }
59
+ function checkD08(content, allowedDomains) {
60
+ const violations = [];
61
+ const urlRegex = /https?:\/\/([a-zA-Z0-9.-]+)/g;
62
+ let match;
63
+ const seen = new Set();
64
+ while ((match = urlRegex.exec(content)) !== null) {
65
+ const domain = match[1].toLowerCase();
66
+ if (seen.has(domain))
67
+ continue;
68
+ seen.add(domain);
69
+ const allowed = allowedDomains.some((d) => domain === d || domain.endsWith('.' + d));
70
+ if (!allowed) {
71
+ violations.push({ ruleId: 'MR-D08', title: 'Link domain allowlist', detail: `Domain not in allowlist: ${domain}`, severity: 'FAIL' });
72
+ }
73
+ }
74
+ return violations;
75
+ }
76
+ function checkD01(content) {
77
+ const violations = [];
78
+ const hexWhites = /#(?:fff(?:fff)?|fefefe|fdfdfd|fcfcfc|fbfbfb|fafafa|f9f9f9|f8f8f8|f7f7f7|f6f6f6|f5f5f5|f4f4f4|f3f3f3|f2f2f2|f1f1f1|f0f0f0)\b/gi;
79
+ const matches = content.match(hexWhites);
80
+ if (matches && matches.length > 0) {
81
+ const unique = [...new Set(matches.map((m) => m.toLowerCase()))];
82
+ violations.push({ ruleId: 'MR-D01', title: 'No near-white backgrounds', detail: `Near-white hex values found: ${unique.join(', ')}`, severity: 'FAIL' });
83
+ }
84
+ if (/background[^;]*:\s*white\b/i.test(content)) {
85
+ violations.push({ ruleId: 'MR-D01', title: 'No near-white backgrounds', detail: 'CSS "white" keyword used for background', severity: 'FAIL' });
86
+ }
87
+ return violations;
88
+ }
89
+ export function registerCmoTools(server) {
90
+ const rulesFile = loadRules();
91
+ const allowedDomains = rulesFile?.allowed_link_domains.map((d) => d.domain) ?? [];
92
+ server.tool('tacit_cmo_lint', 'Run deterministic D-rule checks (MR-D01..D08) on marketing content. Returns structured violations.', lintSchema.shape, async (args) => {
93
+ const parsed = lintSchema.safeParse(args);
94
+ if (!parsed.success) {
95
+ return { content: [{ type: 'text', text: JSON.stringify({ error: 'invalid_input', detail: parsed.error.message }) }], isError: true };
96
+ }
97
+ const { content, assetType } = parsed.data;
98
+ const violations = [];
99
+ const channelNative = rulesFile ? isChannelNative(rulesFile, assetType) : false;
100
+ // D01: near-white backgrounds
101
+ violations.push(...checkD01(content));
102
+ // D02: legal footer (skip for channel-native per spec)
103
+ if (!channelNative) {
104
+ const v = checkD02(content);
105
+ if (v)
106
+ violations.push(v);
107
+ }
108
+ // D03: date, version, history (skip for channel-native)
109
+ if (!channelNative)
110
+ violations.push(...checkD03(content));
111
+ // D04: deliverable path
112
+ const d04 = checkD04(content);
113
+ if (d04)
114
+ violations.push(d04);
115
+ // D07: fiction disclosure
116
+ const d07 = checkD07(content);
117
+ if (d07)
118
+ violations.push(d07);
119
+ // D08: link domain allowlist
120
+ violations.push(...checkD08(content, allowedDomains));
121
+ return {
122
+ content: [{ type: 'text', text: JSON.stringify({ violations, count: violations.length, rulesChecked: 6, rulesVersion: rulesFile?.rules?.length ?? 0 }) }],
123
+ };
124
+ });
125
+ }
@@ -18,8 +18,10 @@ export function featureDisabledResult(err) {
18
18
  if (parsed?.error?.code !== 'FEATURE_DISABLED')
19
19
  return null;
20
20
  const flagMatch = parsed.error.message?.match(/feature flag ([A-Z][A-Z0-9_]*) is off/);
21
- const flag = flagMatch ? flagMatch[1] : 'unknown';
22
- return error(`Feature flag ${flag} is disabled on this cell. Enable it in the flag registry and restart.`);
21
+ if (flagMatch) {
22
+ return error(`Feature flag ${flagMatch[1]} is disabled on this cell. Enable it in the flag registry and restart.`);
23
+ }
24
+ return error(`Feature disabled: ${parsed.error.message || 'unknown reason'}`);
23
25
  }
24
26
  export function apiErrorResult(err, endpoint) {
25
27
  if (err instanceof TokenExpiredError) {
@@ -110,8 +110,8 @@ export declare const outboxWriteInputSchema: z.ZodObject<{
110
110
  };
111
111
  content_origin: "agent" | "human" | "git_sync";
112
112
  content_format: "MARKDOWN" | "HTML" | "PLAIN_TEXT";
113
- source_agent_id?: string | undefined;
114
113
  autonomy_level?: "MENTAT" | "TWIN" | undefined;
114
+ source_agent_id?: string | undefined;
115
115
  idempotency_key?: string | undefined;
116
116
  replaces_object_id?: string | undefined;
117
117
  }, {
@@ -132,9 +132,9 @@ export declare const outboxWriteInputSchema: z.ZodObject<{
132
132
  })[] | undefined;
133
133
  } | undefined;
134
134
  };
135
+ autonomy_level?: "MENTAT" | "TWIN" | undefined;
135
136
  content_origin?: "agent" | "human" | "git_sync" | undefined;
136
137
  source_agent_id?: string | undefined;
137
- autonomy_level?: "MENTAT" | "TWIN" | undefined;
138
138
  idempotency_key?: string | undefined;
139
139
  replaces_object_id?: string | undefined;
140
140
  content_format?: "MARKDOWN" | "HTML" | "PLAIN_TEXT" | undefined;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Compile-time tool classification. Governs which tools may be called over HTTPS.
3
- * Partition: 6 stdio_only + 18 admin_only + 2 gate_only + 126 https = 152.
3
+ * Partition: 6 stdio_only + 18 admin_only + 2 gate_only + 142 https = 168.
4
4
  */
5
5
  export type ToolTransport = 'https' | 'stdio_only' | 'admin_only' | 'gate_only';
6
6
  export type ToolClass = 'read' | 'write' | 'admin' | 'dispatch';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Compile-time tool classification. Governs which tools may be called over HTTPS.
3
- * Partition: 6 stdio_only + 18 admin_only + 2 gate_only + 126 https = 152.
3
+ * Partition: 6 stdio_only + 18 admin_only + 2 gate_only + 142 https = 168.
4
4
  */
5
5
  const STDIO_ONLY = [
6
6
  'tacit_ingest_file',
@@ -32,6 +32,7 @@ const ADMIN_ONLY = [
32
32
  ];
33
33
  const GATE_ONLY = ['tacit_approve_gate', 'tacit_reject_gate'];
34
34
  const READ_TOOLS = [
35
+ 'tacit_workflow_prereqs',
35
36
  'tacit_agent_approvals',
36
37
  'tacit_agent_list',
37
38
  'tacit_agent_thread',
@@ -46,6 +47,7 @@ const READ_TOOLS = [
46
47
  'tacit_chronicle_graph',
47
48
  'tacit_chronicle_search',
48
49
  'tacit_chronicle_timeline',
50
+ 'tacit_cmo_lint',
49
51
  'tacit_converse_messages',
50
52
  'tacit_converse_sessions',
51
53
  'tacit_crew_history',
@@ -170,6 +172,15 @@ const WRITE_TOOLS = [
170
172
  'tacit_wiki_author',
171
173
  'tacit_wiki_override',
172
174
  'tacit_wiki_write',
175
+ 'tacit_workflow_advance',
176
+ 'tacit_workflow_deactivate',
177
+ 'tacit_workflow_handoff',
178
+ 'tacit_workflow_resume',
179
+ 'tacit_workflow_set_metadata',
180
+ 'tacit_workflow_start',
181
+ 'tacit_workflow_type_create',
182
+ 'tacit_workflow_type_list',
183
+ 'tacit_workflow_type_update',
173
184
  ];
174
185
  function build() {
175
186
  const map = new Map();
@@ -196,8 +207,8 @@ function build() {
196
207
  if (!exclusive.has(n))
197
208
  add(n, classOf(n), 'https', false);
198
209
  }
199
- if (map.size !== 152)
200
- throw new Error(`tool registry expected 152 tools, got ${map.size}`);
210
+ if (map.size !== 163)
211
+ throw new Error(`tool registry expected 163 tools, got ${map.size}`);
201
212
  return map;
202
213
  }
203
214
  export const TOOL_REGISTRY = build();
@@ -0,0 +1,16 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { WorkflowRegistry } from '../workflow-registry.js';
3
+ export interface PrereqsResult {
4
+ tool: string;
5
+ workflowType: string | null;
6
+ chain: string[];
7
+ phases: Array<{
8
+ name: string;
9
+ requiredTools: readonly string[];
10
+ gatedTools: readonly string[];
11
+ approvalGate: boolean;
12
+ }>;
13
+ flagActive: boolean;
14
+ }
15
+ export declare function handleWorkflowPrereqs(registry: WorkflowRegistry, isTypeActive: (name: string) => boolean, toolName: string): PrereqsResult;
16
+ export declare function registerWorkflowPrereqsTool(server: McpServer, registry: WorkflowRegistry): void;
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ export function handleWorkflowPrereqs(registry, isTypeActive, toolName) {
3
+ const typeDef = registry
4
+ .findByTool(toolName)
5
+ .find((d) => d.prereqs.kind === 'phased');
6
+ if (!typeDef || typeDef.prereqs.kind !== 'phased') {
7
+ return { tool: toolName, workflowType: null, chain: [], phases: [], flagActive: true };
8
+ }
9
+ const phases = typeDef.prereqs.phases;
10
+ const chain = [...new Set(phases.flatMap((p) => [...p.requiredTools, ...p.gatedTools]))];
11
+ return {
12
+ tool: toolName,
13
+ workflowType: typeDef.name,
14
+ chain,
15
+ phases: phases.map((p) => ({
16
+ name: p.name,
17
+ requiredTools: p.requiredTools,
18
+ gatedTools: p.gatedTools,
19
+ approvalGate: p.approvalGate ?? false,
20
+ })),
21
+ flagActive: isTypeActive(typeDef.name),
22
+ };
23
+ }
24
+ export function registerWorkflowPrereqsTool(server, registry) {
25
+ server.tool('tacit_workflow_prereqs', 'Discover the workflow prerequisite chain for a tool before calling it. Read-only.', { tool_name: z.string().describe('Name of the tool to look up, e.g. tacit_dispatch_crew') }, async (args) => {
26
+ const result = handleWorkflowPrereqs(registry, () => true, args.tool_name);
27
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
28
+ });
29
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * MCP tools for user-authored workflow types (MV-1539 W7 Step 30).
3
+ *
4
+ * tacit_workflow_type_list — list system + user types for current workspace
5
+ * tacit_workflow_type_create — create a user-authored type (T2 approval gate)
6
+ * tacit_workflow_type_update — update an existing user type definition
7
+ */
8
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
9
+ import type { TacitClient } from '../client.js';
10
+ import type { WorkflowRegistry } from '../workflow-registry.js';
11
+ export declare function registerWorkflowTypeTools(server: McpServer, getClient: () => Promise<TacitClient>, registry: WorkflowRegistry): void;