@ferrfleet/mcp 10.19.0 → 10.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -181,6 +181,18 @@ describe('workflow and event rule tools', () => {
181
181
  ])).toBe(true);
182
182
  expect(accepts('update_workflow', 'outputs', [issueOutput])).toBe(true);
183
183
  });
184
+ it('tolerates next_run_at on an entry and drops it from the parsed value', () => {
185
+ const parsed = field('update_workflow', 'entries').safeParse([
186
+ { ...cronEntry, next_run_at: '2026-11-16T06:00:00Z' },
187
+ { ...cronEntry, id: 'idle', next_run_at: null },
188
+ ]);
189
+ expect(parsed.success).toBe(true);
190
+ expect(parsed.data).toEqual([cronEntry, { ...cronEntry, id: 'idle' }]);
191
+ });
192
+ it('still rejects other unknown keys on an entry', () => {
193
+ expect(accepts('create_workflow', 'entries', [{ ...cronEntry, last_run_at: 'x' }])).toBe(false);
194
+ expect(accepts('create_workflow', 'entries', [{ ...cronEntry, next_run_at: 5 }])).toBe(false);
195
+ });
184
196
  it('rejects unknown kinds and keys', () => {
185
197
  expect(accepts('create_workflow', 'entries', [{ ...cronEntry, kind: 'weekly' }])).toBe(false);
186
198
  expect(accepts('create_workflow', 'entries', [{ ...cronEntry, extra: 1 }])).toBe(false);
@@ -241,6 +253,25 @@ describe('workflow and event rule tools', () => {
241
253
  expect(accepts('run_workflow', 'input', 'x')).toBe(false);
242
254
  expect(accepts('run_workflow', 'input', [1])).toBe(false);
243
255
  });
256
+ it('run_workflow passes entry as a query parameter and keeps the input as the body', async () => {
257
+ await handlers.get('run_workflow')({ workflow_id: ID, entry: 'go', input: { pr: 4 } });
258
+ expect(lastCall()).toEqual({
259
+ url: `${FLEET}/workflows/${ID}/runs?entry=go`,
260
+ method: 'POST',
261
+ body: { pr: 4 },
262
+ });
263
+ });
264
+ it('run_workflow encodes the entry id and sends no query without one', async () => {
265
+ await handlers.get('run_workflow')({ workflow_id: ID, entry: 'a b&c' });
266
+ expect(lastCall().url).toBe(`${FLEET}/workflows/${ID}/runs?entry=a%20b%26c`);
267
+ mockFetch.mockClear();
268
+ await handlers.get('run_workflow')({ workflow_id: ID });
269
+ expect(lastCall().url).toBe(`${FLEET}/workflows/${ID}/runs`);
270
+ });
271
+ it('run_workflow refuses an empty entry', () => {
272
+ expect(accepts('run_workflow', 'entry', '')).toBe(false);
273
+ expect(accepts('run_workflow', 'entry', 'go')).toBe(true);
274
+ });
244
275
  it('list_workflow_runs passes limit as a query parameter', async () => {
245
276
  await handlers.get('list_workflow_runs')({ workflow_id: ID, limit: 20 });
246
277
  expect(lastCall().url).toBe(`${FLEET}/workflows/${ID}/runs?limit=20`);
@@ -270,6 +301,53 @@ describe('workflow and event rule tools', () => {
270
301
  expect(parse(step)).toBe(true);
271
302
  expect(parse(fullStep)).toBe(true);
272
303
  });
304
+ it('accepts literal, auto and from for model and effort', () => {
305
+ for (const model of ['opus', 'sonnet', 'haiku', 'claude-opus-5', 'claude-haiku-4-5']) {
306
+ expect(parse({ ...step, model }), model).toBe(true);
307
+ }
308
+ for (const effort of ['low', 'medium', 'high', 'xhigh', 'max']) {
309
+ expect(parse({ ...step, effort }), effort).toBe(true);
310
+ }
311
+ expect(parse({ ...step, model: 'auto', effort: 'auto' })).toBe(true);
312
+ expect(parse({ ...step, model: { from: 'triage' }, effort: { from: 'triage' } })).toBe(true);
313
+ });
314
+ it('rejects unknown models and efforts', () => {
315
+ for (const model of ['gpt-5', 'Opus', 'claude-', 'claude-Opus', '', 3, null]) {
316
+ expect(parse({ ...step, model }), String(model)).toBe(false);
317
+ }
318
+ for (const effort of ['extreme', 'HIGH', '', 3, null, 'opus']) {
319
+ expect(parse({ ...step, effort }), String(effort)).toBe(false);
320
+ }
321
+ });
322
+ it('refuses a from with extra keys, an empty from or a malformed step id', () => {
323
+ expect(parse({ ...step, model: { from: 'triage', default: 'opus' } })).toBe(false);
324
+ expect(parse({ ...step, effort: { from: 'triage', extra: 1 } })).toBe(false);
325
+ expect(parse({ ...step, model: {} })).toBe(false);
326
+ expect(parse({ ...step, model: { from: '' } })).toBe(false);
327
+ expect(parse({ ...step, effort: { from: 'Bad Id' } })).toBe(false);
328
+ expect(parse({ ...step, effort: { from: 3 } })).toBe(false);
329
+ });
330
+ it('create_workflow and update_workflow pass step model and effort through', async () => {
331
+ const choiceStep = { ...step, model: { from: 'triage' }, effort: 'auto' };
332
+ await handlers.get('create_workflow')({ name: 'W', steps: [choiceStep] });
333
+ expect(lastCall().body).toMatchObject({ steps: [choiceStep] });
334
+ mockFetch.mockClear();
335
+ await handlers.get('update_workflow')({
336
+ workflow_id: ID,
337
+ name: 'W',
338
+ enabled: true,
339
+ entries: [],
340
+ outputs: [],
341
+ steps: [choiceStep],
342
+ });
343
+ expect(lastCall().body).toMatchObject({ steps: [choiceStep] });
344
+ });
345
+ it('a step without model or effort sends neither', async () => {
346
+ await handlers.get('create_workflow')({ name: 'W', steps: [step] });
347
+ const sent = lastCall().body.steps[0];
348
+ expect(sent).not.toHaveProperty('model');
349
+ expect(sent).not.toHaveProperty('effort');
350
+ });
273
351
  it('requires agent_id, id and position', () => {
274
352
  expect(parse({ id: 'a', position: step.position })).toBe(false);
275
353
  expect(parse({ agent_id: 'x', position: step.position })).toBe(false);
@@ -357,6 +435,76 @@ describe('workflow and event rule tools', () => {
357
435
  await handlers.get('create_event_rule')({ name: 'R', outcome });
358
436
  expect(lastCall().body).toEqual({ name: 'R', outcome });
359
437
  });
438
+ it('create_event_rule forwards an issue_labeled rule with a label', async () => {
439
+ const rule = {
440
+ name: 'Ready',
441
+ conditions: {
442
+ kinds: ['issue_labeled'],
443
+ label: 'agent-ready',
444
+ labels: ['backend'],
445
+ opened_by: { kind: 'human' },
446
+ repositories: ['acme/*'],
447
+ },
448
+ outcome: { action: 'workflow', workflow_id: ID },
449
+ };
450
+ await handlers.get('create_event_rule')(rule);
451
+ expect(lastCall().body).toEqual(rule);
452
+ });
453
+ it('update_event_rule forwards an issue_commented skip rule', async () => {
454
+ const outcome = { action: 'skip', reason: 'noise' };
455
+ await handlers.get('update_event_rule')({
456
+ rule_id: ID,
457
+ name: 'R',
458
+ conditions: { kinds: ['issue_commented'] },
459
+ outcome,
460
+ });
461
+ expect(lastCall().body).toEqual({
462
+ name: 'R',
463
+ conditions: { kinds: ['issue_commented'] },
464
+ outcome,
465
+ });
466
+ });
467
+ it.each(['create_event_rule', 'update_event_rule'])('%s refuses a run outcome on an issue kind without calling the API', async (tool) => {
468
+ for (const kinds of [
469
+ ['issue_labeled'],
470
+ ['issue_commented'],
471
+ ['pull_request_opened', 'issue_labeled'],
472
+ ]) {
473
+ const result = await handlers.get(tool)({
474
+ rule_id: ID,
475
+ name: 'R',
476
+ conditions: { kinds },
477
+ outcome: { action: 'run' },
478
+ });
479
+ expect(result.isError, kinds.join()).toBe(true);
480
+ }
481
+ expect(mockFetch).not.toHaveBeenCalled();
482
+ });
483
+ it('still allows a run outcome on pull request kinds and on rules without kinds', async () => {
484
+ await handlers.get('create_event_rule')({
485
+ name: 'R',
486
+ conditions: { kinds: ['pull_request_opened'] },
487
+ outcome: { action: 'run' },
488
+ });
489
+ await handlers.get('create_event_rule')({ name: 'R', outcome: { action: 'run' } });
490
+ expect(mockFetch).toHaveBeenCalledTimes(2);
491
+ });
492
+ describe('conditions schema', () => {
493
+ const conditions = (value) => accepts('create_event_rule', 'conditions', value);
494
+ it('accepts the issue kinds and rejects unknown kinds', () => {
495
+ expect(conditions({ kinds: ['issue_labeled', 'issue_commented'] })).toBe(true);
496
+ expect(conditions({ kinds: ['issue_closed'] })).toBe(false);
497
+ });
498
+ it('accepts label as a non-empty string', () => {
499
+ expect(conditions({ kinds: ['issue_labeled'], label: 'agent-ready' })).toBe(true);
500
+ expect(conditions({ label: '' })).toBe(false);
501
+ expect(conditions({ label: ['a'] })).toBe(false);
502
+ });
503
+ it('still refuses unknown conditions', () => {
504
+ expect(conditions({ lable: 'x' })).toBe(false);
505
+ expect(conditions({ issue_number: 4 })).toBe(false);
506
+ });
507
+ });
360
508
  it('delete_event_rule sends DELETE and reports the id on 204', async () => {
361
509
  mockFetch.mockResolvedValue(respond(204));
362
510
  const result = await handlers.get('delete_event_rule')({ rule_id: ID });
@@ -235,7 +235,91 @@ describe('ferrfleet tools', () => {
235
235
  const keys = Object.keys(schemas.get('create_agent'));
236
236
  expect(keys).not.toContain('runner_mode');
237
237
  expect(keys).not.toContain('enabled');
238
- expect(keys).not.toContain('options');
238
+ });
239
+ it('create_agent forwards options and capabilities unchanged', async () => {
240
+ const options = { max_turns: 5 };
241
+ const capabilities = ['code_review', 'review_followup'];
242
+ await handlers.get('create_agent')({
243
+ id: 'bot',
244
+ name: 'Bot',
245
+ prompt: 'p',
246
+ options,
247
+ capabilities,
248
+ });
249
+ expect(lastCall().body).toEqual({ id: 'bot', name: 'Bot', prompt: 'p', options, capabilities });
250
+ });
251
+ it('create_agent sends an empty capability list instead of dropping it', async () => {
252
+ await handlers.get('create_agent')({ id: 'bot', name: 'Bot', prompt: 'p', capabilities: [] });
253
+ expect(lastCall().body).toEqual({ id: 'bot', name: 'Bot', prompt: 'p', capabilities: [] });
254
+ });
255
+ it('update_agent patches capabilities alone', async () => {
256
+ await handlers.get('update_agent')({ agent_id: 'a1', capabilities: ['debug_action'] });
257
+ expect(lastCall().body).toEqual({ capabilities: ['debug_action'] });
258
+ });
259
+ it('update_agent sends an empty capability list as a real change', async () => {
260
+ const result = await handlers.get('update_agent')({ agent_id: 'a1', capabilities: [] });
261
+ expect(result).not.toMatchObject({ isError: true });
262
+ expect(lastCall().body).toEqual({ capabilities: [] });
263
+ });
264
+ it('update_agent omits capabilities when absent', async () => {
265
+ await handlers.get('update_agent')({ agent_id: 'a1', enabled: true });
266
+ expect(lastCall().body).toEqual({ enabled: true });
267
+ });
268
+ it.each(['create_agent', 'update_agent'])('%s only accepts known capabilities', (tool) => {
269
+ const capabilities = schemas.get(tool).capabilities;
270
+ for (const value of [
271
+ 'code_review',
272
+ 'debug_action',
273
+ 'ticket_implementation',
274
+ 'review_response',
275
+ 'review_followup',
276
+ ]) {
277
+ expect(capabilities.safeParse([value]).success, value).toBe(true);
278
+ }
279
+ expect(capabilities.safeParse([]).success).toBe(true);
280
+ expect(capabilities.safeParse(undefined).success).toBe(true);
281
+ expect(capabilities.safeParse(['deploy']).success).toBe(false);
282
+ expect(capabilities.safeParse(['Code_Review']).success).toBe(false);
283
+ expect(capabilities.safeParse(['code_review', 'deploy']).success).toBe(false);
284
+ expect(capabilities.safeParse('code_review').success).toBe(false);
285
+ expect(capabilities.safeParse(null).success).toBe(false);
286
+ });
287
+ it('create_agent forwards effort and omits it when absent', async () => {
288
+ await handlers.get('create_agent')({ id: 'bot', name: 'Bot', prompt: 'p', effort: 'xhigh' });
289
+ expect(lastCall().body).toEqual({ id: 'bot', name: 'Bot', prompt: 'p', effort: 'xhigh' });
290
+ mockFetch.mockClear();
291
+ await handlers.get('create_agent')({ id: 'bot', name: 'Bot', prompt: 'p' });
292
+ expect(lastCall().body).not.toHaveProperty('effort');
293
+ });
294
+ it('update_agent sends effort, and an empty string to clear it', async () => {
295
+ await handlers.get('update_agent')({ agent_id: 'a1', effort: 'max' });
296
+ expect(lastCall().body).toEqual({ effort: 'max' });
297
+ mockFetch.mockClear();
298
+ const result = await handlers.get('update_agent')({ agent_id: 'a1', effort: '' });
299
+ expect(result).not.toMatchObject({ isError: true });
300
+ expect(lastCall().body).toEqual({ effort: '' });
301
+ });
302
+ it('update_agent omits effort when absent', async () => {
303
+ await handlers.get('update_agent')({ agent_id: 'a1', enabled: true });
304
+ expect(lastCall().body).not.toHaveProperty('effort');
305
+ });
306
+ it('create_agent only accepts the five effort levels', () => {
307
+ const effort = schemas.get('create_agent').effort;
308
+ for (const level of ['low', 'medium', 'high', 'xhigh', 'max']) {
309
+ expect(effort.safeParse(level).success, level).toBe(true);
310
+ }
311
+ for (const bad of ['', 'HIGH', 'extreme', 'auto', 3, null]) {
312
+ expect(effort.safeParse(bad).success, String(bad)).toBe(false);
313
+ }
314
+ });
315
+ it('update_agent accepts the effort levels and an empty string only', () => {
316
+ const effort = schemas.get('update_agent').effort;
317
+ for (const ok of ['low', 'medium', 'high', 'xhigh', 'max', '', undefined]) {
318
+ expect(effort.safeParse(ok).success, String(ok)).toBe(true);
319
+ }
320
+ for (const bad of ['HIGH', 'extreme', 'auto', null]) {
321
+ expect(effort.safeParse(bad).success, String(bad)).toBe(false);
322
+ }
239
323
  });
240
324
  it('update_agent patches the agent with only the fields given', async () => {
241
325
  await handlers.get('update_agent')({ agent_id: 'a1', runner_mode: 'external' });
@@ -1 +1 @@
1
- {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/tools/agents.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAc1E,eAAO,MAAM,gBAAgB,QAAsC,CAAC;AAEpE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,QAqLnD"}
1
+ {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/tools/agents.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAsB1E,eAAO,MAAM,gBAAgB,QAAsC,CAAC;AAEpE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,QAyMnD"}
@@ -1,7 +1,15 @@
1
1
  import { z } from 'zod';
2
2
  import { getToken, toToolText } from '@ferrlabs/mcp-core';
3
3
  import { fleetRequest, orgIdSchema } from '../api-base.js';
4
+ import { effortSchema } from './model-choice.js';
4
5
  const RUNNER_MODES = ['managed', 'external'];
6
+ const AGENT_CAPABILITIES = [
7
+ 'code_review',
8
+ 'debug_action',
9
+ 'ticket_implementation',
10
+ 'review_response',
11
+ 'review_followup',
12
+ ];
5
13
  export const AGENT_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,62}[a-z0-9]$/;
6
14
  export function registerAgentTools(server) {
7
15
  server.tool('list_agents', 'List FerrFleet agents available to the authenticated user (marketplace + custom).', { org_id: orgIdSchema }, async ({ org_id }) => {
@@ -48,7 +56,7 @@ export function registerAgentTools(server) {
48
56
  content: [{ type: 'text', text: toToolText(run) }],
49
57
  };
50
58
  });
51
- server.tool('create_agent', 'Create a FerrFleet agent in the organization. The agent starts with default options and runner_mode=managed; use update_agent to change those or to set enabled.', {
59
+ server.tool('create_agent', 'Create a FerrFleet agent in the organization. The agent starts with default options unless you pass options, and runner_mode=managed; use update_agent to change runner_mode or to set enabled.', {
52
60
  id: z
53
61
  .string()
54
62
  .regex(AGENT_ID_PATTERN)
@@ -62,6 +70,9 @@ export function registerAgentTools(server) {
62
70
  .optional()
63
71
  .describe('Extra prompt appended to the base prompt'),
64
72
  model: z.string().min(1).max(100).optional().describe('Model id; omit for the CLI default'),
73
+ effort: effortSchema
74
+ .optional()
75
+ .describe('Default effort: low, medium, high, xhigh or max; omit for the CLI default'),
65
76
  working_dir: z
66
77
  .string()
67
78
  .min(1)
@@ -75,6 +86,11 @@ export function registerAgentTools(server) {
75
86
  .max(2048)
76
87
  .optional()
77
88
  .describe('Webhook notified when a run finishes'),
89
+ options: z.record(z.string(), z.unknown()).optional().describe('Agent options object'),
90
+ capabilities: z
91
+ .array(z.enum(AGENT_CAPABILITIES))
92
+ .optional()
93
+ .describe('Capabilities the agent can be assigned; duplicates are removed'),
78
94
  }, async ({ org_id, ...fields }) => {
79
95
  const body = Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));
80
96
  const token = await getToken();
@@ -103,6 +119,10 @@ export function registerAgentTools(server) {
103
119
  .max(100)
104
120
  .optional()
105
121
  .describe('Model id; an empty string restores the CLI default'),
122
+ effort: z
123
+ .union([effortSchema, z.literal('')])
124
+ .optional()
125
+ .describe('Default effort: low, medium, high, xhigh or max; an empty string clears it; omit to leave it unchanged'),
106
126
  working_dir: z.string().min(1).max(256).optional().describe('Working directory of the run'),
107
127
  description: z.string().max(500).optional().describe('Short description'),
108
128
  enabled: z.boolean().optional().describe('Whether the agent can be triggered'),
@@ -116,6 +136,10 @@ export function registerAgentTools(server) {
116
136
  .record(z.string(), z.unknown())
117
137
  .optional()
118
138
  .describe('Replaces the whole options object; it is not merged with the existing one'),
139
+ capabilities: z
140
+ .array(z.enum(AGENT_CAPABILITIES))
141
+ .optional()
142
+ .describe('Replaces the whole capability list, it is not merged with the existing one; [] clears it; omit to leave it unchanged; duplicates are removed'),
119
143
  runner_mode: z
120
144
  .enum(RUNNER_MODES)
121
145
  .optional()
@@ -1 +1 @@
1
- {"version":3,"file":"event-rules.d.ts","sourceRoot":"","sources":["../../src/tools/event-rules.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAmF9D,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,QA2FvD"}
1
+ {"version":3,"file":"event-rules.d.ts","sourceRoot":"","sources":["../../src/tools/event-rules.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AA2G9D,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,QA+FvD"}
@@ -7,7 +7,10 @@ const EVENT_KINDS = [
7
7
  'pull_request_updated',
8
8
  'review_requested',
9
9
  'pipeline_failed',
10
+ 'issue_labeled',
11
+ 'issue_commented',
10
12
  ];
13
+ const ISSUE_KINDS = ['issue_labeled', 'issue_commented'];
11
14
  const UPDATE_TYPES = ['patch', 'minor', 'major'];
12
15
  const DEDUP_MODES = ['head_commit', 'none'];
13
16
  const MAX_PATTERNS = 50;
@@ -21,12 +24,17 @@ const conditionsSchema = z
21
24
  .strictObject({
22
25
  sources: z.array(z.literal('github')).describe('Event sources; github today'),
23
26
  kinds: z.array(z.enum(EVENT_KINDS)).describe('Event kinds'),
24
- opened_by: actorSchema.describe('Pull request author'),
27
+ opened_by: actorSchema.describe('Pull request or issue author'),
25
28
  triggered_by: actorSchema.describe('Account that caused this delivery'),
26
29
  repositories: patterns('owner/name globs, case-insensitive'),
27
30
  target_branches: patterns('Base branch globs'),
28
31
  head_branches: patterns('Head branch globs'),
29
- labels: patterns('Pull request labels, any of'),
32
+ labels: patterns('Labels on the pull request or issue (all labels it carries), any of'),
33
+ label: z
34
+ .string()
35
+ .trim()
36
+ .min(1)
37
+ .describe('The label just added, case-insensitive; only meaningful for issue_labeled'),
30
38
  paths: z
31
39
  .strictObject({
32
40
  mode: z.enum(['any', 'all']),
@@ -71,17 +79,34 @@ const ruleFields = {
71
79
  conditions: conditionsSchema.optional(),
72
80
  outcome: outcomeSchema,
73
81
  };
82
+ const issueRunError = (conditions, outcome) => outcome.action === 'run' && conditions?.kinds?.some((kind) => ISSUE_KINDS.includes(kind))
83
+ ? {
84
+ isError: true,
85
+ content: [
86
+ {
87
+ type: 'text',
88
+ text: 'Issue events (issue_labeled, issue_commented) can only start a workflow or be skipped: use a workflow or skip outcome.',
89
+ },
90
+ ],
91
+ }
92
+ : undefined;
74
93
  const ruleIdSchema = z.guid().describe('Rule id from list_event_rules');
75
94
  export function registerEventRuleTools(server) {
76
95
  server.tool('list_event_rules', "List the organization's event rules in evaluation order.", { org_id: orgIdSchema }, async ({ org_id }) => {
77
96
  const token = await getToken();
78
97
  return reply(await fleetRequest('/event-rules', { token, orgId: org_id }));
79
98
  });
80
- server.tool('create_event_rule', 'Add an event rule at the end of the list. Rules are evaluated in order and the first match wins; without a match the bound agent runs once per head commit. The outcome is run, skip (needs a reason) or workflow.', { ...ruleFields, org_id: orgIdSchema }, async ({ org_id, ...body }) => {
99
+ server.tool('create_event_rule', 'Add an event rule at the end of the list. Rules are evaluated in order and the first match wins; without a match the bound agent runs once per head commit. The outcome is run, skip (needs a reason) or workflow. Issue kinds (issue_labeled, issue_commented) only allow a workflow or skip outcome (the API answers 422 for run); for them opened_by is the issue author, triggered_by the account that labelled or commented, labels every label on the issue, and label the one just added (issue_labeled only). Rules without kinds never match an issue event.', { ...ruleFields, org_id: orgIdSchema }, async ({ org_id, ...body }) => {
100
+ const refused = issueRunError(body.conditions, body.outcome);
101
+ if (refused)
102
+ return refused;
81
103
  const token = await getToken();
82
104
  return reply(await fleetRequest('/event-rules', { token, orgId: org_id, method: 'POST', body }));
83
105
  });
84
- server.tool('update_event_rule', 'Replace an event rule. Send the whole rule, not a patch; omitted conditions are cleared.', { rule_id: ruleIdSchema, ...ruleFields, org_id: orgIdSchema }, async ({ rule_id, org_id, ...body }) => {
106
+ server.tool('update_event_rule', 'Replace an event rule. Send the whole rule, not a patch; omitted conditions are cleared. Issue kinds only allow a workflow or skip outcome.', { rule_id: ruleIdSchema, ...ruleFields, org_id: orgIdSchema }, async ({ rule_id, org_id, ...body }) => {
107
+ const refused = issueRunError(body.conditions, body.outcome);
108
+ if (refused)
109
+ return refused;
85
110
  const token = await getToken();
86
111
  return reply(await fleetRequest(`/event-rules/${rule_id}`, {
87
112
  token,
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ export declare const EFFORT_LEVELS: readonly ['low', 'medium', 'high', 'xhigh', 'max'];
3
+ export declare const effortSchema: z.ZodEnum<{
4
+ high: "high";
5
+ low: "low";
6
+ max: "max";
7
+ medium: "medium";
8
+ xhigh: "xhigh";
9
+ }>;
10
+ export declare const stepModelSchema: z.ZodUnion<readonly [z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>, z.ZodLiteral<"auto">, z.ZodObject<{
11
+ from: z.ZodString;
12
+ }, z.core.$strict>]>;
13
+ export declare const stepEffortSchema: z.ZodUnion<readonly [z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>, z.ZodLiteral<"auto">, z.ZodObject<{
14
+ from: z.ZodString;
15
+ }, z.core.$strict>]>;
16
+ //# sourceMappingURL=model-choice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-choice.d.ts","sourceRoot":"","sources":["../../src/tools/model-choice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,aAAa,YAAI,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,CAAC;AAOhF,eAAO,MAAM,YAAY;;;;;;EAAwB,CAAC;AAalD,eAAO,MAAM,eAAe;;oBAA2B,CAAC;AACxD,eAAO,MAAM,gBAAgB;;oBAA2B,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ export const EFFORT_LEVELS = ['low', 'medium', 'high', 'xhigh', 'max'];
3
+ const MODEL_ALIASES = ['opus', 'sonnet', 'haiku'];
4
+ const PINNED_MODEL_PATTERN = /^claude-[a-z0-9][a-z0-9.-]*$/;
5
+ const MAX_PINNED_MODEL_LENGTH = 64;
6
+ const STEP_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,39}$/;
7
+ export const effortSchema = z.enum(EFFORT_LEVELS);
8
+ const modelLiteral = z.union([
9
+ z.enum(MODEL_ALIASES),
10
+ z.string().max(MAX_PINNED_MODEL_LENGTH).regex(PINNED_MODEL_PATTERN),
11
+ ]);
12
+ const fromStep = z.strictObject({
13
+ from: z.string().regex(STEP_ID_PATTERN).describe('Id of an ancestor step'),
14
+ });
15
+ const stepChoice = (literal) => z.union([literal, z.literal('auto'), fromStep]);
16
+ export const stepModelSchema = stepChoice(modelLiteral);
17
+ export const stepEffortSchema = stepChoice(effortSchema);
@@ -1 +1 @@
1
- {"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../src/tools/runs.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAc,MAAM,oBAAoB,CAAC;AA6B1E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,QA+GjD"}
1
+ {"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../src/tools/runs.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAkC1E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,QA+GjD"}
@@ -14,7 +14,7 @@ const RUN_STATUSES = [
14
14
  'superseded',
15
15
  ];
16
16
  export function registerRunTools(server) {
17
- server.tool('list_runs', 'List recent FerrFleet runs for the authenticated org (most recent first).', {
17
+ server.tool('list_runs', 'List recent FerrFleet runs for the authenticated org (most recent first). Each run carries the model and effort it ran with, model_source and effort_source (where each came from: input, step, triage or agent) and choice_note when a step choice could not be applied.', {
18
18
  limit: z
19
19
  .number()
20
20
  .int()
@@ -37,7 +37,7 @@ export function registerRunTools(server) {
37
37
  content: [{ type: 'text', text: toToolText(runs) }],
38
38
  };
39
39
  });
40
- server.tool('get_run', 'Get the metadata of a single FerrFleet run (status, timing, agent, trigger). Use get_run_transcript for the captured output.', {
40
+ server.tool('get_run', 'Get the metadata of a single FerrFleet run (status, timing, agent, trigger, and the model and effort it ran with, with model_source, effort_source and choice_note explaining where they came from). Use get_run_transcript for the captured output.', {
41
41
  run_id: z.string().min(1).describe('Run id'),
42
42
  org_id: orgIdSchema,
43
43
  }, async ({ run_id, org_id }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/tools/workflows.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AA0H9D,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,QAqItD"}
1
+ {"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/tools/workflows.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AA4I9D,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,QA6ItD"}
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { getToken } from '@ferrlabs/mcp-core';
3
3
  import { fleetRequest, orgIdSchema } from '../api-base.js';
4
+ import { stepEffortSchema, stepModelSchema } from './model-choice.js';
4
5
  import { reply } from './reply.js';
5
6
  const JOIN_CONDITIONS = ['all_completed', 'all_finished', 'any_completed'];
6
7
  const ENTRY_KINDS = ['event', 'cron', 'manual'];
@@ -35,6 +36,12 @@ const stepSchema = z.strictObject({
35
36
  .record(z.string(), z.unknown())
36
37
  .optional()
37
38
  .describe('Structured input passed to the agent, up to 8 KiB'),
39
+ model: stepModelSchema
40
+ .optional()
41
+ .describe('Model for this step: opus, sonnet, haiku or a claude-* id; {"from": "<step id>"} to take it from the model key of that ancestor step\'s result; or "auto" to take it from the model key of the result of the only step in needs. Resolution order: run input (top-level model key of the run body) > step field > agent default'),
42
+ effort: stepEffortSchema
43
+ .optional()
44
+ .describe('Effort for this step: low, medium, high, xhigh or max; {"from": "<step id>"} to take it from the effort key of that ancestor step\'s result; or "auto" to take it from the effort key of the result of the only step in needs. Resolution order: run input (top-level effort key of the run body) > step field > agent default'),
38
45
  position: z
39
46
  .strictObject({ x: z.number(), y: z.number() })
40
47
  .describe('Canvas position of the step in the editor'),
@@ -42,7 +49,8 @@ const stepSchema = z.strictObject({
42
49
  const positionSchema = z
43
50
  .strictObject({ x: z.number(), y: z.number() })
44
51
  .describe('Canvas position in the editor');
45
- const entrySchema = z.strictObject({
52
+ const entrySchema = z
53
+ .strictObject({
46
54
  id: z
47
55
  .string()
48
56
  .min(1)
@@ -53,8 +61,14 @@ const entrySchema = z.strictObject({
53
61
  .optional()
54
62
  .describe('Required for cron, refused otherwise: 5 field cron expression, evaluated in UTC'),
55
63
  starts: z.array(z.string().min(1)).describe('Ids of the root steps this entry starts'),
64
+ next_run_at: z
65
+ .string()
66
+ .nullable()
67
+ .optional()
68
+ .describe('Returned by get_workflow on cron entries; accepted and dropped, never sent'),
56
69
  position: positionSchema,
57
- });
70
+ })
71
+ .transform(({ next_run_at: _nextRunAt, ...entry }) => entry);
58
72
  const outputSchema = z.strictObject({
59
73
  id: z
60
74
  .string()
@@ -104,7 +118,7 @@ export function registerWorkflowTools(server) {
104
118
  const token = await getToken();
105
119
  return reply(await fleetRequest(`/workflows/${workflow_id}`, { token, orgId: org_id }));
106
120
  });
107
- server.tool('create_workflow', 'Create a workflow: a graph of agent steps, with optional entries (cron, event, manual) and outputs (github_issue and others). The API refuses cycles, unknown needs or agents, two steps on the same agent that could run at the same time, and invalid entries or outputs.', { ...workflowFields, ...entryAndOutputFields, org_id: orgIdSchema }, async ({ org_id, ...body }) => {
121
+ server.tool('create_workflow', 'Create a workflow: a graph of agent steps, with optional entries (cron, event, manual) and outputs (github_issue and others). The API refuses cycles, unknown needs or agents, two steps on the same agent that could run at the same time, and invalid entries or outputs. A step may set model and effort; see their descriptions for the resolution order.', { ...workflowFields, ...entryAndOutputFields, org_id: orgIdSchema }, async ({ org_id, ...body }) => {
108
122
  const token = await getToken();
109
123
  return reply(await fleetRequest('/workflows', { token, orgId: org_id, method: 'POST', body }));
110
124
  });
@@ -139,16 +153,22 @@ export function registerWorkflowTools(server) {
139
153
  });
140
154
  return reply({ deleted: workflow_id });
141
155
  });
142
- server.tool('run_workflow', 'Start a workflow run now. Returns the run; poll get_workflow_run for step states and agent runs.', {
156
+ server.tool('run_workflow', 'Start a workflow run now. Returns the run; poll get_workflow_run for step states and agent runs. A top-level model or effort key in input overrides every step and agent default for this run.', {
143
157
  workflow_id: workflowIdSchema,
144
158
  org_id: orgIdSchema,
159
+ entry: z
160
+ .string()
161
+ .min(1)
162
+ .optional()
163
+ .describe('Id of a manual entry of the workflow to start from; omit to start every root step'),
145
164
  input: z
146
165
  .record(z.string(), z.unknown())
147
166
  .optional()
148
167
  .describe('Optional input object for the run, up to 64 KiB'),
149
- }, async ({ workflow_id, input, org_id }) => {
168
+ }, async ({ workflow_id, input, entry, org_id }) => {
150
169
  const token = await getToken();
151
- return reply(await fleetRequest(`/workflows/${workflow_id}/runs`, {
170
+ const qs = entry !== undefined ? `?entry=${encodeURIComponent(entry)}` : '';
171
+ return reply(await fleetRequest(`/workflows/${workflow_id}/runs${qs}`, {
152
172
  token,
153
173
  orgId: org_id,
154
174
  method: 'POST',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ferrfleet/mcp",
3
- "version": "10.19.0",
3
+ "version": "10.21.0",
4
4
  "description": "Model Context Protocol server for FerrFleet: agents, runs, skills",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",