@ferrfleet/mcp 10.15.3 → 10.17.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.
@@ -27,6 +27,29 @@ function lastCall() {
27
27
  body: init.body ? JSON.parse(init.body) : undefined,
28
28
  };
29
29
  }
30
+ function callAt(index) {
31
+ const [url, init] = mockFetch.mock.calls[index];
32
+ return {
33
+ url: String(url),
34
+ method: init.method ?? 'GET',
35
+ body: init.body ? JSON.parse(init.body) : undefined,
36
+ };
37
+ }
38
+ const cronEntry = {
39
+ id: 'nightly',
40
+ kind: 'cron',
41
+ cron: '0 6 * * *',
42
+ starts: ['review'],
43
+ position: { x: 0, y: 0 },
44
+ };
45
+ const issueOutput = {
46
+ id: 'file-issue',
47
+ from: 'review',
48
+ kind: 'github_issue',
49
+ connector_id: 'conn-1',
50
+ repo: 'FerrLabs/FerrFleet',
51
+ position: { x: 5, y: 5 },
52
+ };
30
53
  const FLEET = 'https://api.ferrfleet.com';
31
54
  const ID = '3f0c6a52-8d1e-4b7a-9c2f-5e6d7a8b9c01';
32
55
  const OTHER_ID = '7a1d9e34-2b5c-4f80-8e6a-1c3b5d7f9a02';
@@ -77,12 +100,103 @@ describe('workflow and event rule tools', () => {
77
100
  body: { name: 'Review', enabled: false, steps: [fullStep] },
78
101
  });
79
102
  });
80
- it('update_workflow replaces with PUT and keeps workflow_id out of the body', async () => {
103
+ it('create_workflow posts entries and outputs', async () => {
104
+ await handlers.get('create_workflow')({
105
+ name: 'Review',
106
+ steps: [step],
107
+ entries: [cronEntry],
108
+ outputs: [issueOutput],
109
+ });
110
+ expect(lastCall().body).toEqual({
111
+ name: 'Review',
112
+ steps: [step],
113
+ entries: [cronEntry],
114
+ outputs: [issueOutput],
115
+ });
116
+ });
117
+ it('update_workflow keeps stored entries, outputs and enabled when omitted', async () => {
118
+ mockFetch.mockResolvedValueOnce(respond(200, {
119
+ id: ID,
120
+ enabled: false,
121
+ entries: [{ ...cronEntry, next_run_at: '2026-11-12T06:00:00Z' }],
122
+ outputs: [issueOutput],
123
+ }));
81
124
  await handlers.get('update_workflow')({ workflow_id: ID, name: 'Review', steps: [step] });
82
- expect(lastCall()).toEqual({
125
+ expect(callAt(0)).toMatchObject({ url: `${FLEET}/workflows/${ID}`, method: 'GET' });
126
+ expect(callAt(1)).toEqual({
83
127
  url: `${FLEET}/workflows/${ID}`,
84
128
  method: 'PUT',
85
- body: { name: 'Review', steps: [step] },
129
+ body: {
130
+ name: 'Review',
131
+ steps: [step],
132
+ enabled: false,
133
+ entries: [{ ...cronEntry, next_run_at: '2026-11-12T06:00:00Z' }],
134
+ outputs: [issueOutput],
135
+ },
136
+ });
137
+ });
138
+ it('update_workflow clears entries and outputs only when given empty arrays', async () => {
139
+ mockFetch.mockResolvedValueOnce(respond(200, { id: ID, enabled: true, entries: [cronEntry], outputs: [issueOutput] }));
140
+ await handlers.get('update_workflow')({
141
+ workflow_id: ID,
142
+ name: 'Review',
143
+ steps: [step],
144
+ entries: [],
145
+ outputs: [],
146
+ });
147
+ expect(callAt(1).body).toMatchObject({ entries: [], outputs: [], enabled: true });
148
+ });
149
+ it('update_workflow sends the given entries and outputs over the stored ones', async () => {
150
+ mockFetch.mockResolvedValueOnce(respond(200, { id: ID, enabled: true, entries: [], outputs: [issueOutput] }));
151
+ await handlers.get('update_workflow')({
152
+ workflow_id: ID,
153
+ name: 'Review',
154
+ steps: [step],
155
+ entries: [cronEntry],
156
+ });
157
+ expect(callAt(1).body).toMatchObject({ entries: [cronEntry], outputs: [issueOutput] });
158
+ });
159
+ it('update_workflow skips the read when everything is given', async () => {
160
+ await handlers.get('update_workflow')({
161
+ workflow_id: ID,
162
+ name: 'Review',
163
+ steps: [step],
164
+ enabled: true,
165
+ entries: [cronEntry],
166
+ outputs: [issueOutput],
167
+ });
168
+ expect(mockFetch).toHaveBeenCalledTimes(1);
169
+ expect(lastCall()).toMatchObject({ method: 'PUT' });
170
+ });
171
+ it('update_workflow does not write when the stored workflow cannot be read', async () => {
172
+ mockFetch.mockResolvedValueOnce(respond(404, { error: 'not_found' }));
173
+ await expect(handlers.get('update_workflow')({ workflow_id: ID, name: 'Review', steps: [step] })).rejects.toThrow('not_found');
174
+ expect(mockFetch).toHaveBeenCalledTimes(1);
175
+ });
176
+ describe('entries and outputs schemas', () => {
177
+ it('accepts cron and manual entries and a github_issue output', () => {
178
+ expect(accepts('create_workflow', 'entries', [cronEntry])).toBe(true);
179
+ expect(accepts('create_workflow', 'entries', [
180
+ { id: 'go', kind: 'manual', starts: ['review'], position: { x: 0, y: 0 } },
181
+ ])).toBe(true);
182
+ expect(accepts('update_workflow', 'outputs', [issueOutput])).toBe(true);
183
+ });
184
+ it('rejects unknown kinds and keys', () => {
185
+ expect(accepts('create_workflow', 'entries', [{ ...cronEntry, kind: 'weekly' }])).toBe(false);
186
+ expect(accepts('create_workflow', 'entries', [{ ...cronEntry, extra: 1 }])).toBe(false);
187
+ expect(accepts('create_workflow', 'outputs', [{ ...issueOutput, kind: 'sms' }])).toBe(false);
188
+ });
189
+ it('requires starts on an entry and from on an output', () => {
190
+ const { starts: _starts, ...noStarts } = cronEntry;
191
+ const { from: _from, ...noFrom } = issueOutput;
192
+ expect(accepts('create_workflow', 'entries', [noStarts])).toBe(false);
193
+ expect(accepts('create_workflow', 'outputs', [noFrom])).toBe(false);
194
+ });
195
+ it('caps entries and outputs at 10', () => {
196
+ const entries = Array.from({ length: 11 }, (_, i) => ({ ...cronEntry, id: `e${i}` }));
197
+ const outputs = Array.from({ length: 11 }, (_, i) => ({ ...issueOutput, id: `o${i}` }));
198
+ expect(accepts('create_workflow', 'entries', entries)).toBe(false);
199
+ expect(accepts('create_workflow', 'outputs', outputs)).toBe(false);
86
200
  });
87
201
  });
88
202
  it('delete_workflow sends DELETE and reports the id on 204', async () => {
@@ -99,6 +213,10 @@ describe('workflow and event rule tools', () => {
99
213
  body: { pr: 4 },
100
214
  });
101
215
  });
216
+ it('run_workflow starts a workflow that has a cron entry without naming an entry', async () => {
217
+ await handlers.get('run_workflow')({ workflow_id: ID });
218
+ expect(lastCall().url).toBe(`${FLEET}/workflows/${ID}/runs`);
219
+ });
102
220
  it('run_workflow sends an empty object when no input is given', async () => {
103
221
  await handlers.get('run_workflow')({ workflow_id: ID });
104
222
  expect(lastCall().body).toEqual({});
@@ -118,6 +118,38 @@ describe('ferrfleet tools', () => {
118
118
  });
119
119
  await expect(handlers.get('retry_run')({ run_id: 'run-9' })).rejects.toThrow('this run was already retried');
120
120
  });
121
+ it('move_run_to_front posts to the move-to-front sub-resource, without a body', async () => {
122
+ await handlers.get('move_run_to_front')({ run_id: 'run-9' });
123
+ const call = lastCall();
124
+ expect(call.url).toBe(`${FLEET}/runs/run-9/move-to-front`);
125
+ expect(call.method).toBe('POST');
126
+ expect(call.body).toBeUndefined();
127
+ });
128
+ it('move_run_to_front escapes the run id so it cannot climb the path', async () => {
129
+ await handlers.get('move_run_to_front')({ run_id: '../agents' });
130
+ expect(lastCall().url).toBe(`${FLEET}/runs/..%2Fagents/move-to-front`);
131
+ });
132
+ it('move_run_to_front requires a run id', () => {
133
+ const runId = schemas.get('move_run_to_front').run_id;
134
+ expect(runId.safeParse(undefined).success).toBe(false);
135
+ expect(runId.safeParse('').success).toBe(false);
136
+ expect(runId.safeParse('run-9').success).toBe(true);
137
+ });
138
+ it('move_run_to_front returns the API answer', async () => {
139
+ mockFetch.mockResolvedValue(ok({ line: 'pool', moved_ahead_of: 3 }));
140
+ const result = await handlers.get('move_run_to_front')({ run_id: 'run-9' });
141
+ expect(JSON.parse(result.content[0].text)).toEqual({ line: 'pool', moved_ahead_of: 3 });
142
+ });
143
+ it('move_run_to_front does not swallow a refusal from the API', async () => {
144
+ mockFetch.mockResolvedValue({
145
+ ok: false,
146
+ status: 409,
147
+ statusText: 'Conflict',
148
+ text: () => Promise.resolve(JSON.stringify({ error: 'run is not waiting' })),
149
+ json: () => Promise.resolve({ error: 'run is not waiting' }),
150
+ });
151
+ await expect(handlers.get('move_run_to_front')({ run_id: 'run-9' })).rejects.toThrow('run is not waiting');
152
+ });
121
153
  it('get_run_transcript reads the transcript sub-resource', async () => {
122
154
  await handlers.get('get_run_transcript')({ run_id: 'run-9' });
123
155
  const call = lastCall();
@@ -132,6 +164,20 @@ describe('ferrfleet tools', () => {
132
164
  await handlers.get('list_runs')({});
133
165
  expect(lastCall().url).toBe(`${FLEET}/runs`);
134
166
  });
167
+ it('list_runs passes status as a query parameter ahead of limit', async () => {
168
+ await handlers.get('list_runs')({ status: 'pending', limit: 10 });
169
+ expect(lastCall().url).toBe(`${FLEET}/runs?status=pending&limit=10`);
170
+ });
171
+ it('list_runs sends status alone when no limit is given', async () => {
172
+ await handlers.get('list_runs')({ status: 'queued' });
173
+ expect(lastCall().url).toBe(`${FLEET}/runs?status=queued`);
174
+ });
175
+ it('rejects a run status the API does not know', () => {
176
+ const status = schemas.get('list_runs').status;
177
+ expect(status.safeParse(undefined).success).toBe(true);
178
+ expect(status.safeParse('pending').success).toBe(true);
179
+ expect(status.safeParse('waiting').success).toBe(false);
180
+ });
135
181
  it('escapes an agent id so it cannot climb the path', async () => {
136
182
  await handlers.get('get_agent')({ agent_id: '../runs' });
137
183
  expect(lastCall().url).toBe(`${FLEET}/agents/..%2Fruns`);
@@ -308,6 +354,54 @@ describe('ferrfleet tools', () => {
308
354
  expect(name.safeParse('-github').success).toBe(false);
309
355
  expect(name.safeParse('a/b').success).toBe(false);
310
356
  });
357
+ it('create_connector posts a custom http connector with its secret', async () => {
358
+ const config = {
359
+ url: 'https://mcp.example.com',
360
+ headers: { 'x-team': 'a' },
361
+ secret_header: 'authorization',
362
+ };
363
+ await handlers.get('create_connector')({
364
+ type: 'custom',
365
+ name: 'Docs',
366
+ config,
367
+ secret: 'hunter2',
368
+ });
369
+ const call = lastCall();
370
+ expect(call.url).toBe(`${FLEET}/connectors`);
371
+ expect(call.method).toBe('POST');
372
+ expect(call.body).toEqual({ type: 'custom', name: 'Docs', config, secret: 'hunter2' });
373
+ });
374
+ it('create_connector sends no secret or config key when they are omitted', async () => {
375
+ await handlers.get('create_connector')({ type: 'custom', name: 'Docs' });
376
+ expect(lastCall().body).toEqual({ type: 'custom', name: 'Docs' });
377
+ });
378
+ it('create_connector does not echo the secret in the result', async () => {
379
+ mockFetch.mockResolvedValue(ok({ id: 'conn-1', type: 'custom', name: 'Docs', has_secret: true }));
380
+ const result = await handlers.get('create_connector')({
381
+ type: 'custom',
382
+ name: 'Docs',
383
+ secret: 'hunter2',
384
+ });
385
+ const text = result.content[0].text;
386
+ expect(text).not.toContain('hunter2');
387
+ expect(JSON.parse(text)).toMatchObject({ has_secret: true });
388
+ });
389
+ it('create_connector surfaces API validation errors', async () => {
390
+ mockFetch.mockResolvedValue({
391
+ ok: false,
392
+ status: 400,
393
+ text: () => Promise.resolve('bad config'),
394
+ json: () => Promise.resolve({}),
395
+ });
396
+ await expect(handlers.get('create_connector')({ type: 'custom', name: 'Docs', secret: 'hunter2' })).rejects.toThrow(/400(?!.*hunter2)/s);
397
+ });
398
+ it('create_connector only accepts names the API accepts and an object config', () => {
399
+ const { name, config, secret } = schemas.get('create_connector');
400
+ expect(name.safeParse('Docs 1').success).toBe(true);
401
+ expect(name.safeParse('-docs').success).toBe(false);
402
+ expect(config.safeParse('x').success).toBe(false);
403
+ expect(secret.safeParse('').success).toBe(false);
404
+ });
311
405
  it('list_github_installations reads the installations collection', async () => {
312
406
  mockFetch.mockResolvedValue(ok([]));
313
407
  await handlers.get('list_github_installations')({});
@@ -433,6 +527,7 @@ describe('ferrfleet tools', () => {
433
527
  ['list_runs', {}],
434
528
  ['get_run', { run_id: 'r1' }],
435
529
  ['retry_run', { run_id: 'r1' }],
530
+ ['move_run_to_front', { run_id: 'r1' }],
436
531
  ['get_run_transcript', { run_id: 'r1' }],
437
532
  ['list_workflows', {}],
438
533
  ['get_workflow', { workflow_id: ENV_ORG_ID }],
@@ -1 +1 @@
1
- {"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../../src/tools/connectors.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAK1E,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,QAiFvD"}
1
+ {"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../../src/tools/connectors.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAK1E,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,QAgHvD"}
@@ -10,6 +10,31 @@ export function registerConnectorTools(server) {
10
10
  content: [{ type: 'text', text: toToolText(connectors) }],
11
11
  };
12
12
  });
13
+ server.tool('create_connector', 'Create a connector of any type the API accepts (github, custom, ferrtrack, ferrvault, ferrgrowth, playwright, gitlab, forgejo, jira, linear). The config shape depends on the type; for custom it is the http transport: url, headers, secret_header. The secret is optional and can be set later in the UI; it is never returned, only has_secret.', {
14
+ type: z.string().min(1).describe('Connector type, for example custom'),
15
+ name: z
16
+ .string()
17
+ .regex(CONNECTOR_NAME_PATTERN)
18
+ .describe('Display name: letters, digits, spaces, underscores and hyphens, up to 63 chars'),
19
+ config: z.record(z.string(), z.unknown()).optional().describe('Type specific config object'),
20
+ secret: z
21
+ .string()
22
+ .min(1)
23
+ .optional()
24
+ .describe('Secret such as an API token; omit it to set it later in the UI'),
25
+ org_id: orgIdSchema,
26
+ }, async ({ type, name, config, secret, org_id }) => {
27
+ const token = await getToken();
28
+ const connector = await fleetRequest('/connectors', {
29
+ method: 'POST',
30
+ body: { type, name, config, secret },
31
+ token,
32
+ orgId: org_id,
33
+ });
34
+ return {
35
+ content: [{ type: 'text', text: toToolText(connector) }],
36
+ };
37
+ });
13
38
  server.tool('set_agent_connectors', "Set the connectors attached to an agent. This REPLACES the agent's whole connector list: connectors not in connector_ids are detached, and an empty list detaches all of them. Every id must be a connector of the organization (see list_connectors).", {
14
39
  agent_id: z.string().min(1).describe('Agent id'),
15
40
  org_id: orgIdSchema,
@@ -33,7 +58,7 @@ export function registerConnectorTools(server) {
33
58
  ],
34
59
  };
35
60
  });
36
- server.tool('update_connector', "Update a FerrFleet connector's name or config. Only the fields you pass change; at least one is required. config REPLACES the whole config object, it is not merged with the existing one. Secrets cannot be set through this server.", {
61
+ server.tool('update_connector', "Update a FerrFleet connector's name or config. Only the fields you pass change; at least one is required. config REPLACES the whole config object, it is not merged with the existing one. Secrets cannot be changed through this server.", {
37
62
  connector_id: z.string().min(1).describe('Connector id'),
38
63
  org_id: orgIdSchema,
39
64
  name: z
@@ -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;AAc1E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,QAwFjD"}
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"}
@@ -2,6 +2,17 @@ import { z } from 'zod';
2
2
  import { getToken, toToolText } from '@ferrlabs/mcp-core';
3
3
  import { fleetRequest, orgIdSchema } from '../api-base.js';
4
4
  import { reply } from './reply.js';
5
+ const RUN_STATUSES = [
6
+ 'pending',
7
+ 'running',
8
+ 'completed',
9
+ 'failed',
10
+ 'timeout',
11
+ 'cancelled',
12
+ 'expired',
13
+ 'queued',
14
+ 'superseded',
15
+ ];
5
16
  export function registerRunTools(server) {
6
17
  server.tool('list_runs', 'List recent FerrFleet runs for the authenticated org (most recent first).', {
7
18
  limit: z
@@ -11,10 +22,16 @@ export function registerRunTools(server) {
11
22
  .max(100)
12
23
  .optional()
13
24
  .describe('Max runs to return (default 25)'),
25
+ status: z.enum(RUN_STATUSES).optional().describe('Only runs in this status'),
14
26
  org_id: orgIdSchema,
15
- }, async ({ limit, org_id }) => {
27
+ }, async ({ limit, status, org_id }) => {
16
28
  const token = await getToken();
17
- const qs = limit !== undefined ? `?limit=${limit}` : '';
29
+ const params = new URLSearchParams();
30
+ if (status !== undefined)
31
+ params.set('status', status);
32
+ if (limit !== undefined)
33
+ params.set('limit', String(limit));
34
+ const qs = params.size > 0 ? `?${params}` : '';
18
35
  const runs = await fleetRequest(`/runs${qs}`, { token, orgId: org_id });
19
36
  return {
20
37
  content: [{ type: 'text', text: toToolText(runs) }],
@@ -61,4 +78,15 @@ export function registerRunTools(server) {
61
78
  method: 'POST',
62
79
  }));
63
80
  });
81
+ server.tool('move_run_to_front', 'Move a waiting FerrFleet run to the front of the line it waits in: its runner pool, or the cluster slot line. Only runs waiting in a runner pool or for cluster capacity can move. Returns the line and how many runs it moved ahead of (0 when it was already first). Refused with 409 when the run is not waiting (leased, running, finished, held for credits, or an external pipeline run) and with 403 for an org token: needs a personal token. Requires a FerrFleet API that has POST /runs/{id}/move-to-front.', {
82
+ run_id: z.string().min(1).describe('Id of the waiting run to move to the front'),
83
+ org_id: orgIdSchema,
84
+ }, async ({ run_id, org_id }) => {
85
+ const token = await getToken();
86
+ return reply(await fleetRequest(`/runs/${encodeURIComponent(run_id)}/move-to-front`, {
87
+ token,
88
+ orgId: org_id,
89
+ method: 'POST',
90
+ }));
91
+ });
64
92
  }
@@ -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;AAoD9D,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,QAyHtD"}
1
+ {"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/tools/workflows.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAmH9D,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,QAqItD"}
@@ -3,6 +3,14 @@ import { getToken } from '@ferrlabs/mcp-core';
3
3
  import { fleetRequest, orgIdSchema } from '../api-base.js';
4
4
  import { reply } from './reply.js';
5
5
  const JOIN_CONDITIONS = ['all_completed', 'all_finished', 'any_completed'];
6
+ const ENTRY_KINDS = ['event', 'cron', 'manual'];
7
+ const OUTPUT_KINDS = [
8
+ 'github_comment',
9
+ 'github_review',
10
+ 'github_issue',
11
+ 'ferrtrack_ticket',
12
+ 'webhook',
13
+ ];
6
14
  const STEP_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,39}$/;
7
15
  const stepSchema = z.strictObject({
8
16
  id: z
@@ -31,6 +39,38 @@ const stepSchema = z.strictObject({
31
39
  .strictObject({ x: z.number(), y: z.number() })
32
40
  .describe('Canvas position of the step in the editor'),
33
41
  });
42
+ const positionSchema = z
43
+ .strictObject({ x: z.number(), y: z.number() })
44
+ .describe('Canvas position in the editor');
45
+ const entrySchema = z.strictObject({
46
+ id: z
47
+ .string()
48
+ .min(1)
49
+ .describe('Entry id, unique among the steps, entries and outputs of the workflow'),
50
+ kind: z.enum(ENTRY_KINDS).describe('event, cron or manual'),
51
+ cron: z
52
+ .string()
53
+ .optional()
54
+ .describe('Required for cron, refused otherwise: 5 field cron expression, evaluated in UTC'),
55
+ starts: z.array(z.string().min(1)).describe('Ids of the root steps this entry starts'),
56
+ position: positionSchema,
57
+ });
58
+ const outputSchema = z.strictObject({
59
+ id: z
60
+ .string()
61
+ .min(1)
62
+ .describe('Output id, unique among the steps, entries and outputs of the workflow'),
63
+ from: z.string().min(1).describe('Id of the step whose result is delivered'),
64
+ kind: z.enum(OUTPUT_KINDS).describe('Where the result goes'),
65
+ connector_id: z
66
+ .string()
67
+ .optional()
68
+ .describe('Connector of the matching type, from list_connectors (github_*, ferrtrack_ticket)'),
69
+ url: z.string().optional().describe('Target url for a webhook output'),
70
+ project: z.string().optional().describe('Project slug for a ferrtrack_ticket output'),
71
+ repo: z.string().optional().describe('owner/name repository for a github output'),
72
+ position: positionSchema,
73
+ });
34
74
  const workflowFields = {
35
75
  name: z.string().trim().min(1).max(100).describe('Workflow name'),
36
76
  enabled: z.boolean().optional().describe('Whether the workflow can run; defaults to true'),
@@ -40,28 +80,50 @@ const workflowFields = {
40
80
  .max(20)
41
81
  .describe('One to 20 steps forming an acyclic graph with at least one root. Two steps on the same agent must be ordered with needs'),
42
82
  };
83
+ const entriesField = z
84
+ .array(entrySchema)
85
+ .max(10)
86
+ .describe('What starts the workflow: cron schedules, event or manual entries');
87
+ const outputsField = z
88
+ .array(outputSchema)
89
+ .max(10)
90
+ .describe('Where step results are delivered, for example a github_issue');
91
+ const entryAndOutputFields = { entries: entriesField.optional(), outputs: outputsField.optional() };
43
92
  const workflowIdSchema = z.guid().describe('Workflow id from list_workflows');
44
93
  export function registerWorkflowTools(server) {
45
94
  server.tool('list_workflows', "List the organization's workflows.", { org_id: orgIdSchema }, async ({ org_id }) => {
46
95
  const token = await getToken();
47
96
  return reply(await fleetRequest('/workflows', { token, orgId: org_id }));
48
97
  });
49
- server.tool('get_workflow', 'Get a workflow with its steps.', { workflow_id: workflowIdSchema, org_id: orgIdSchema }, async ({ workflow_id, org_id }) => {
98
+ server.tool('get_workflow', 'Get a workflow with its entries, steps and outputs.', { workflow_id: workflowIdSchema, org_id: orgIdSchema }, async ({ workflow_id, org_id }) => {
50
99
  const token = await getToken();
51
100
  return reply(await fleetRequest(`/workflows/${workflow_id}`, { token, orgId: org_id }));
52
101
  });
53
- server.tool('create_workflow', 'Create a workflow: a graph of agent steps. The API refuses cycles, unknown needs or agents, and two steps on the same agent that could run at the same time.', { ...workflowFields, org_id: orgIdSchema }, async ({ org_id, ...body }) => {
102
+ 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 }) => {
54
103
  const token = await getToken();
55
104
  return reply(await fleetRequest('/workflows', { token, orgId: org_id, method: 'POST', body }));
56
105
  });
57
- server.tool('update_workflow', 'Replace a workflow. Send the whole workflow, not a patch: steps you leave out are removed.', { workflow_id: workflowIdSchema, ...workflowFields, org_id: orgIdSchema }, async ({ workflow_id, org_id, ...body }) => {
106
+ server.tool('update_workflow', 'Replace a workflow. Send the whole workflow, not a patch: steps you leave out are removed. entries, outputs and enabled keep their current values when omitted; pass entries: [] or outputs: [] to clear them.', {
107
+ workflow_id: workflowIdSchema,
108
+ ...workflowFields,
109
+ ...entryAndOutputFields,
110
+ org_id: orgIdSchema,
111
+ }, async ({ workflow_id, org_id, ...fields }) => {
58
112
  const token = await getToken();
59
- return reply(await fleetRequest(`/workflows/${workflow_id}`, {
60
- token,
61
- orgId: org_id,
62
- method: 'PUT',
63
- body,
64
- }));
113
+ const path = `/workflows/${workflow_id}`;
114
+ const needsCurrent = fields.entries === undefined ||
115
+ fields.outputs === undefined ||
116
+ fields.enabled === undefined;
117
+ const current = needsCurrent
118
+ ? await fleetRequest(path, { token, orgId: org_id })
119
+ : undefined;
120
+ const body = {
121
+ ...fields,
122
+ enabled: fields.enabled ?? current?.enabled,
123
+ entries: fields.entries ?? current?.entries,
124
+ outputs: fields.outputs ?? current?.outputs,
125
+ };
126
+ return reply(await fleetRequest(path, { token, orgId: org_id, method: 'PUT', body }));
65
127
  });
66
128
  server.tool('delete_workflow', 'Delete a workflow. Fails with workflow_in_use while an event rule names it; change or delete the rule first.', { workflow_id: workflowIdSchema, org_id: orgIdSchema }, async ({ workflow_id, org_id }) => {
67
129
  const token = await getToken();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ferrfleet/mcp",
3
- "version": "10.15.3",
3
+ "version": "10.17.0",
4
4
  "description": "Model Context Protocol server for FerrFleet: agents, runs, skills",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",