@tacitai/mcp-server 0.6.27 → 0.6.29

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.
@@ -51,24 +51,43 @@ export declare function handleAgentList(args: unknown): Promise<{
51
51
  }>;
52
52
  isError?: boolean;
53
53
  }>;
54
- export declare const agentDelegateInputSchema: z.ZodObject<{
55
- agent_id: z.ZodString;
54
+ export declare const agentDelegateInputSchema: z.ZodEffects<z.ZodObject<{
55
+ agent_id: z.ZodOptional<z.ZodString>;
56
+ role_slug: z.ZodOptional<z.ZodString>;
56
57
  task: z.ZodString;
57
58
  kind: z.ZodOptional<z.ZodString>;
58
59
  target_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
59
60
  program_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
60
61
  dossier_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
61
62
  }, "strip", z.ZodTypeAny, {
62
- agent_id: string;
63
63
  task: string;
64
64
  program_ids?: string[] | undefined;
65
+ role_slug?: string | undefined;
66
+ agent_id?: string | undefined;
65
67
  kind?: string | undefined;
66
68
  target_ids?: string[] | undefined;
67
69
  dossier_ids?: string[] | undefined;
68
70
  }, {
69
- agent_id: string;
70
71
  task: string;
71
72
  program_ids?: string[] | undefined;
73
+ role_slug?: string | undefined;
74
+ agent_id?: string | undefined;
75
+ kind?: string | undefined;
76
+ target_ids?: string[] | undefined;
77
+ dossier_ids?: string[] | undefined;
78
+ }>, {
79
+ task: string;
80
+ program_ids?: string[] | undefined;
81
+ role_slug?: string | undefined;
82
+ agent_id?: string | undefined;
83
+ kind?: string | undefined;
84
+ target_ids?: string[] | undefined;
85
+ dossier_ids?: string[] | undefined;
86
+ }, {
87
+ task: string;
88
+ program_ids?: string[] | undefined;
89
+ role_slug?: string | undefined;
90
+ agent_id?: string | undefined;
72
91
  kind?: string | undefined;
73
92
  target_ids?: string[] | undefined;
74
93
  dossier_ids?: string[] | undefined;
@@ -84,6 +103,10 @@ export declare const AGENT_DELEGATE_TOOL_DEF: {
84
103
  type: string;
85
104
  description: string;
86
105
  };
106
+ role_slug: {
107
+ type: string;
108
+ description: string;
109
+ };
87
110
  task: {
88
111
  type: string;
89
112
  description: string;
@@ -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,107 @@ 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
+ }).refine((d) => d.agent_id || d.role_slug, { message: 'Either agent_id or role_slug is required' });
81
108
  export const AGENT_DELEGATE_TOOL_DEF = {
82
109
  name: 'tacit_agent_delegate',
83
- description: 'Delegate a task to a business agent. The task is fingerprint-deduped and dispatched to the run engine. ' +
110
+ description: 'Delegate a task to a business agent. Accepts agent_id (UUID) or role_slug (template name). ' +
111
+ 'When role_slug is used and no instance exists, the agent is created on first delegation. ' +
112
+ 'The task is fingerprint-deduped and dispatched to the run engine. ' +
84
113
  'Returns assignment_id, run_id, and status. Duplicate tasks return status "duplicate" with the existing assignment.',
85
114
  inputSchema: {
86
115
  type: 'object',
87
116
  properties: {
88
- agent_id: { type: 'string', description: 'UUID of the agent to delegate to' },
117
+ agent_id: { type: 'string', description: 'UUID of the agent to delegate to (provide this OR role_slug)' },
118
+ role_slug: { type: 'string', description: 'Role template slug (e.g. "wiki_editor"). Creates instance on first use' },
89
119
  task: { type: 'string', description: 'Task description to delegate' },
90
120
  kind: { type: 'string', description: 'Task kind (default: "task")' },
91
121
  target_ids: { type: 'array', items: { type: 'string' }, description: 'Target entity UUIDs' },
92
122
  program_ids: { type: 'array', items: { type: 'string' }, description: 'Program UUIDs to scope the task' },
93
123
  dossier_ids: { type: 'array', items: { type: 'string' }, description: 'Dossier UUIDs to scope the task' },
94
124
  },
95
- required: ['agent_id', 'task'],
125
+ required: ['task'],
96
126
  },
97
127
  };
128
+ async function resolveAgentId(client, input) {
129
+ if (input.agent_id)
130
+ return { agent_id: input.agent_id };
131
+ const slug = input.role_slug;
132
+ if (!slug)
133
+ return { error: 'Either agent_id or role_slug is required' };
134
+ const template = loadRoleTemplates().find((t) => t.slug === slug);
135
+ if (!template)
136
+ return { error: `Unknown role_slug: ${slug}` };
137
+ try {
138
+ const result = await callAgentTool(client, 'tacit.agents.list', {});
139
+ const r = result;
140
+ const list = Array.isArray(r)
141
+ ? r
142
+ : (r?.items ??
143
+ r?.agents);
144
+ if (Array.isArray(list)) {
145
+ const existing = list.find((i) => i['role_slug'] === slug);
146
+ if (existing) {
147
+ const id = (existing['agent_id'] ?? existing['id']);
148
+ if (id)
149
+ return { agent_id: id };
150
+ }
151
+ }
152
+ }
153
+ catch {
154
+ // list failed — fall through to create
155
+ }
156
+ // No instance exists — create one (lazy materialization)
157
+ try {
158
+ const created = await callAgentTool(client, 'tacit.agents.create', {
159
+ name: template.display_name,
160
+ role_slug: slug,
161
+ archetype: 'executive',
162
+ });
163
+ const id = (created['agent_id'] ?? created['id']);
164
+ if (id)
165
+ return { agent_id: id };
166
+ return { error: 'Agent creation returned no id' };
167
+ }
168
+ catch (err) {
169
+ const msg = err instanceof Error ? err.message : String(err);
170
+ // Unique constraint collision — agent was created concurrently; re-list
171
+ if (msg.includes('duplicate key') || msg.includes('unique constraint')) {
172
+ try {
173
+ const retry = await callAgentTool(client, 'tacit.agents.list', {});
174
+ const rr = retry;
175
+ const rlist = Array.isArray(rr)
176
+ ? rr
177
+ : (rr?.items ??
178
+ rr?.agents);
179
+ if (Array.isArray(rlist)) {
180
+ const found = rlist.find((i) => i['role_slug'] === slug);
181
+ if (found) {
182
+ const fid = (found['agent_id'] ?? found['id']);
183
+ if (fid)
184
+ return { agent_id: fid };
185
+ }
186
+ }
187
+ }
188
+ catch { /* re-list also failed */ }
189
+ }
190
+ return { error: `Failed to create agent instance for ${slug}: ${msg}` };
191
+ }
192
+ }
98
193
  export function buildAgentDelegateRequest(client, input) {
99
194
  return {
100
195
  async execute() {
101
196
  try {
197
+ const resolved = await resolveAgentId(client, input);
198
+ if ('error' in resolved) {
199
+ return { content: [{ type: 'text', text: resolved.error }], isError: true };
200
+ }
102
201
  const spec = { task: input.task };
103
202
  if (input.kind)
104
203
  spec['kind'] = input.kind;
@@ -109,7 +208,7 @@ export function buildAgentDelegateRequest(client, input) {
109
208
  if (input.dossier_ids)
110
209
  spec['dossier_ids'] = input.dossier_ids;
111
210
  const result = await callAgentTool(client, 'tacit.agents.delegate', {
112
- agent_id: input.agent_id,
211
+ agent_id: resolved.agent_id,
113
212
  spec,
114
213
  });
115
214
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
@@ -296,8 +395,9 @@ export function registerAgentTools(server, getClientFn) {
296
395
  const client = await getClientFn();
297
396
  return buildAgentListRequest(client, args).execute();
298
397
  });
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'),
398
+ server.tool('tacit_agent_delegate', 'Delegate a task to a business agent. Accepts agent_id (UUID) or role_slug (template name like "wiki_editor"). Creates instance on first use.', {
399
+ agent_id: z.string().min(1).optional().describe('UUID of the agent to delegate to (provide this OR role_slug)'),
400
+ role_slug: z.string().min(1).optional().describe('Role template slug (e.g. "wiki_editor"). Creates instance on first use'),
301
401
  task: z.string().min(1).describe('Task description to delegate'),
302
402
  kind: z.string().optional().describe('Task kind'),
303
403
  target_ids: z.array(z.string()).optional().describe('Target entity UUIDs'),
@@ -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;