@ferrfleet/mcp 10.13.3 → 10.15.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.
- package/dist/register.d.ts.map +1 -1
- package/dist/register.js +4 -0
- package/dist/tools/__tests__/workflows.test.d.ts +2 -0
- package/dist/tools/__tests__/workflows.test.d.ts.map +1 -0
- package/dist/tools/__tests__/workflows.test.js +346 -0
- package/dist/tools/__tests__/writes.test.js +56 -0
- package/dist/tools/event-rules.d.ts +3 -0
- package/dist/tools/event-rules.d.ts.map +1 -0
- package/dist/tools/event-rules.js +116 -0
- package/dist/tools/reply.d.ts +7 -0
- package/dist/tools/reply.d.ts.map +1 -0
- package/dist/tools/reply.js +4 -0
- package/dist/tools/runs.d.ts.map +1 -1
- package/dist/tools/runs.js +12 -0
- package/dist/tools/workflows.d.ts +3 -0
- package/dist/tools/workflows.d.ts.map +1 -0
- package/dist/tools/workflows.js +110 -0
- package/package.json +2 -2
package/dist/register.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAapD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAYhD"}
|
package/dist/register.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { registerAgentTools } from './tools/agents.js';
|
|
2
2
|
import { registerConnectorTools } from './tools/connectors.js';
|
|
3
|
+
import { registerEventRuleTools } from './tools/event-rules.js';
|
|
3
4
|
import { registerGithubTools } from './tools/github.js';
|
|
4
5
|
import { registerMarketplaceTools } from './tools/marketplace.js';
|
|
5
6
|
import { registerOrgTools } from './tools/orgs.js';
|
|
6
7
|
import { registerRepoTools } from './tools/repos.js';
|
|
7
8
|
import { registerRunnerPoolTools } from './tools/runner-pools.js';
|
|
8
9
|
import { registerRunTools } from './tools/runs.js';
|
|
10
|
+
import { registerWorkflowTools } from './tools/workflows.js';
|
|
9
11
|
import { registerRunReviewPrompt } from './prompts/run-review.js';
|
|
10
12
|
export function register(server) {
|
|
11
13
|
registerAgentTools(server);
|
|
12
14
|
registerConnectorTools(server);
|
|
15
|
+
registerEventRuleTools(server);
|
|
13
16
|
registerGithubTools(server);
|
|
14
17
|
registerMarketplaceTools(server);
|
|
15
18
|
registerOrgTools(server);
|
|
16
19
|
registerRepoTools(server);
|
|
17
20
|
registerRunnerPoolTools(server);
|
|
18
21
|
registerRunTools(server);
|
|
22
|
+
registerWorkflowTools(server);
|
|
19
23
|
registerRunReviewPrompt(server);
|
|
20
24
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflows.test.d.ts","sourceRoot":"","sources":["../../../src/tools/__tests__/workflows.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
process.env.FERRLABS_API_TOKEN = 'test-token';
|
|
4
|
+
const handlers = new Map();
|
|
5
|
+
const schemas = new Map();
|
|
6
|
+
const mockServer = {
|
|
7
|
+
tool: vi.fn((name, _desc, schema, handler) => {
|
|
8
|
+
handlers.set(name, handler);
|
|
9
|
+
schemas.set(name, schema);
|
|
10
|
+
}),
|
|
11
|
+
};
|
|
12
|
+
const mockFetch = vi.fn();
|
|
13
|
+
vi.stubGlobal('fetch', mockFetch);
|
|
14
|
+
function respond(status, body) {
|
|
15
|
+
return {
|
|
16
|
+
ok: status < 400,
|
|
17
|
+
status,
|
|
18
|
+
text: () => Promise.resolve(body === undefined ? '' : JSON.stringify(body)),
|
|
19
|
+
json: () => Promise.resolve(body),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function lastCall() {
|
|
23
|
+
const [url, init] = mockFetch.mock.calls[0];
|
|
24
|
+
return {
|
|
25
|
+
url: String(url),
|
|
26
|
+
method: init.method ?? 'GET',
|
|
27
|
+
body: init.body ? JSON.parse(init.body) : undefined,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const FLEET = 'https://api.ferrfleet.com';
|
|
31
|
+
const ID = '3f0c6a52-8d1e-4b7a-9c2f-5e6d7a8b9c01';
|
|
32
|
+
const OTHER_ID = '7a1d9e34-2b5c-4f80-8e6a-1c3b5d7f9a02';
|
|
33
|
+
const step = { id: 'review', agent_id: 'reviewer', position: { x: 10, y: 20 } };
|
|
34
|
+
const fullStep = {
|
|
35
|
+
...step,
|
|
36
|
+
needs: ['lint'],
|
|
37
|
+
when: 'any_completed',
|
|
38
|
+
instructions: 'Be strict',
|
|
39
|
+
input: { depth: 2 },
|
|
40
|
+
};
|
|
41
|
+
function field(tool, name) {
|
|
42
|
+
return schemas.get(tool)[name];
|
|
43
|
+
}
|
|
44
|
+
function accepts(tool, name, value) {
|
|
45
|
+
return field(tool, name).safeParse(value).success;
|
|
46
|
+
}
|
|
47
|
+
describe('workflow and event rule tools', () => {
|
|
48
|
+
beforeEach(async () => {
|
|
49
|
+
vi.clearAllMocks();
|
|
50
|
+
handlers.clear();
|
|
51
|
+
schemas.clear();
|
|
52
|
+
mockFetch.mockResolvedValue(respond(200, { id: ID }));
|
|
53
|
+
const { registerWorkflowTools } = await import('../workflows.js');
|
|
54
|
+
const { registerEventRuleTools } = await import('../event-rules.js');
|
|
55
|
+
registerWorkflowTools(mockServer);
|
|
56
|
+
registerEventRuleTools(mockServer);
|
|
57
|
+
});
|
|
58
|
+
describe('workflows', () => {
|
|
59
|
+
it('list_workflows reads the collection', async () => {
|
|
60
|
+
await handlers.get('list_workflows')({});
|
|
61
|
+
expect(lastCall()).toMatchObject({ url: `${FLEET}/workflows`, method: 'GET' });
|
|
62
|
+
});
|
|
63
|
+
it('get_workflow reads one workflow', async () => {
|
|
64
|
+
await handlers.get('get_workflow')({ workflow_id: ID });
|
|
65
|
+
expect(lastCall()).toMatchObject({ url: `${FLEET}/workflows/${ID}`, method: 'GET' });
|
|
66
|
+
});
|
|
67
|
+
it('create_workflow posts name, enabled and steps without org_id', async () => {
|
|
68
|
+
await handlers.get('create_workflow')({
|
|
69
|
+
name: 'Review',
|
|
70
|
+
enabled: false,
|
|
71
|
+
steps: [fullStep],
|
|
72
|
+
org_id: OTHER_ID,
|
|
73
|
+
});
|
|
74
|
+
expect(lastCall()).toEqual({
|
|
75
|
+
url: `${FLEET}/workflows`,
|
|
76
|
+
method: 'POST',
|
|
77
|
+
body: { name: 'Review', enabled: false, steps: [fullStep] },
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
it('update_workflow replaces with PUT and keeps workflow_id out of the body', async () => {
|
|
81
|
+
await handlers.get('update_workflow')({ workflow_id: ID, name: 'Review', steps: [step] });
|
|
82
|
+
expect(lastCall()).toEqual({
|
|
83
|
+
url: `${FLEET}/workflows/${ID}`,
|
|
84
|
+
method: 'PUT',
|
|
85
|
+
body: { name: 'Review', steps: [step] },
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
it('delete_workflow sends DELETE and reports the id on 204', async () => {
|
|
89
|
+
mockFetch.mockResolvedValue(respond(204));
|
|
90
|
+
const result = await handlers.get('delete_workflow')({ workflow_id: ID });
|
|
91
|
+
expect(lastCall()).toMatchObject({ url: `${FLEET}/workflows/${ID}`, method: 'DELETE' });
|
|
92
|
+
expect(JSON.parse(result.content[0].text)).toEqual({ deleted: ID });
|
|
93
|
+
});
|
|
94
|
+
it('run_workflow posts the input object as the body', async () => {
|
|
95
|
+
await handlers.get('run_workflow')({ workflow_id: ID, input: { pr: 4 } });
|
|
96
|
+
expect(lastCall()).toEqual({
|
|
97
|
+
url: `${FLEET}/workflows/${ID}/runs`,
|
|
98
|
+
method: 'POST',
|
|
99
|
+
body: { pr: 4 },
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
it('run_workflow sends an empty object when no input is given', async () => {
|
|
103
|
+
await handlers.get('run_workflow')({ workflow_id: ID });
|
|
104
|
+
expect(lastCall().body).toEqual({});
|
|
105
|
+
});
|
|
106
|
+
it('run_workflow only accepts an object as input', () => {
|
|
107
|
+
expect(accepts('run_workflow', 'input', { a: 1 })).toBe(true);
|
|
108
|
+
expect(accepts('run_workflow', 'input', 'x')).toBe(false);
|
|
109
|
+
expect(accepts('run_workflow', 'input', [1])).toBe(false);
|
|
110
|
+
});
|
|
111
|
+
it('list_workflow_runs passes limit as a query parameter', async () => {
|
|
112
|
+
await handlers.get('list_workflow_runs')({ workflow_id: ID, limit: 20 });
|
|
113
|
+
expect(lastCall().url).toBe(`${FLEET}/workflows/${ID}/runs?limit=20`);
|
|
114
|
+
});
|
|
115
|
+
it('list_workflow_runs omits the query string without a limit', async () => {
|
|
116
|
+
await handlers.get('list_workflow_runs')({ workflow_id: ID });
|
|
117
|
+
expect(lastCall().url).toBe(`${FLEET}/workflows/${ID}/runs`);
|
|
118
|
+
});
|
|
119
|
+
it('list_workflow_runs bounds limit to 1..200', () => {
|
|
120
|
+
expect(accepts('list_workflow_runs', 'limit', 200)).toBe(true);
|
|
121
|
+
expect(accepts('list_workflow_runs', 'limit', 201)).toBe(false);
|
|
122
|
+
expect(accepts('list_workflow_runs', 'limit', 0)).toBe(false);
|
|
123
|
+
expect(accepts('list_workflow_runs', 'limit', 1.5)).toBe(false);
|
|
124
|
+
});
|
|
125
|
+
it('get_workflow_run reads the workflow-runs resource', async () => {
|
|
126
|
+
await handlers.get('get_workflow_run')({ run_id: ID });
|
|
127
|
+
expect(lastCall()).toMatchObject({ url: `${FLEET}/workflow-runs/${ID}`, method: 'GET' });
|
|
128
|
+
});
|
|
129
|
+
it.each(['get_workflow', 'update_workflow', 'delete_workflow', 'run_workflow'])('%s rejects a workflow_id that is not a uuid', (tool) => {
|
|
130
|
+
expect(accepts(tool, 'workflow_id', '../runs')).toBe(false);
|
|
131
|
+
expect(accepts(tool, 'workflow_id', ID)).toBe(true);
|
|
132
|
+
});
|
|
133
|
+
describe('steps schema', () => {
|
|
134
|
+
const steps = () => field('create_workflow', 'steps');
|
|
135
|
+
const parse = (value) => steps().safeParse([value]).success;
|
|
136
|
+
it('accepts a minimal and a full step', () => {
|
|
137
|
+
expect(parse(step)).toBe(true);
|
|
138
|
+
expect(parse(fullStep)).toBe(true);
|
|
139
|
+
});
|
|
140
|
+
it('requires agent_id, id and position', () => {
|
|
141
|
+
expect(parse({ id: 'a', position: step.position })).toBe(false);
|
|
142
|
+
expect(parse({ agent_id: 'x', position: step.position })).toBe(false);
|
|
143
|
+
expect(parse({ id: 'a', agent_id: 'x' })).toBe(false);
|
|
144
|
+
expect(parse({ ...step, agent_id: '' })).toBe(false);
|
|
145
|
+
});
|
|
146
|
+
it('rejects an unknown join condition', () => {
|
|
147
|
+
expect(parse({ ...step, when: 'all_completed' })).toBe(true);
|
|
148
|
+
expect(parse({ ...step, when: 'all_finished' })).toBe(true);
|
|
149
|
+
expect(parse({ ...step, when: 'first' })).toBe(false);
|
|
150
|
+
expect(parse({ ...step, when: 'ALL_COMPLETED' })).toBe(false);
|
|
151
|
+
});
|
|
152
|
+
it('only accepts step ids the API accepts', () => {
|
|
153
|
+
expect(parse({ ...step, id: 'step-1' })).toBe(true);
|
|
154
|
+
expect(parse({ ...step, id: 'Step' })).toBe(false);
|
|
155
|
+
expect(parse({ ...step, id: '-a' })).toBe(false);
|
|
156
|
+
expect(parse({ ...step, id: 'a'.repeat(41) })).toBe(false);
|
|
157
|
+
});
|
|
158
|
+
it('requires numeric x and y and rejects extra position keys', () => {
|
|
159
|
+
expect(parse({ ...step, position: { x: 1 } })).toBe(false);
|
|
160
|
+
expect(parse({ ...step, position: { x: '1', y: 2 } })).toBe(false);
|
|
161
|
+
expect(parse({ ...step, position: { x: 1, y: 2, z: 3 } })).toBe(false);
|
|
162
|
+
});
|
|
163
|
+
it('caps instructions at 4000 characters', () => {
|
|
164
|
+
expect(parse({ ...step, instructions: 'a'.repeat(4000) })).toBe(true);
|
|
165
|
+
expect(parse({ ...step, instructions: 'a'.repeat(4001) })).toBe(false);
|
|
166
|
+
});
|
|
167
|
+
it('rejects unknown step keys like the API does', () => {
|
|
168
|
+
expect(parse({ ...step, retries: 3 })).toBe(false);
|
|
169
|
+
});
|
|
170
|
+
it('rejects non-array needs and non-object input', () => {
|
|
171
|
+
expect(parse({ ...step, needs: 'lint' })).toBe(false);
|
|
172
|
+
expect(parse({ ...step, input: 'x' })).toBe(false);
|
|
173
|
+
});
|
|
174
|
+
it('bounds the step count to 1..20', () => {
|
|
175
|
+
const many = (n) => Array.from({ length: n }, (_, i) => ({ ...step, id: `s${i}` }));
|
|
176
|
+
expect(steps().safeParse(many(20)).success).toBe(true);
|
|
177
|
+
expect(steps().safeParse(many(21)).success).toBe(false);
|
|
178
|
+
expect(steps().safeParse([]).success).toBe(false);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
it('create_workflow requires a name of 1 to 100 characters', () => {
|
|
182
|
+
expect(accepts('create_workflow', 'name', undefined)).toBe(false);
|
|
183
|
+
expect(accepts('create_workflow', 'name', '')).toBe(false);
|
|
184
|
+
expect(accepts('create_workflow', 'name', 'a'.repeat(101))).toBe(false);
|
|
185
|
+
expect(accepts('create_workflow', 'enabled', undefined)).toBe(true);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
describe('event rules', () => {
|
|
189
|
+
const skip = { action: 'skip', reason: 'noise' };
|
|
190
|
+
it('list_event_rules reads the collection', async () => {
|
|
191
|
+
await handlers.get('list_event_rules')({});
|
|
192
|
+
expect(lastCall()).toMatchObject({ url: `${FLEET}/event-rules`, method: 'GET' });
|
|
193
|
+
});
|
|
194
|
+
it('create_event_rule posts the rule without org_id', async () => {
|
|
195
|
+
const rule = {
|
|
196
|
+
name: 'Renovate',
|
|
197
|
+
enabled: true,
|
|
198
|
+
conditions: { kinds: ['pull_request_opened'], opened_by: { kind: 'bot' } },
|
|
199
|
+
outcome: { action: 'run', agent_id: 'reviewer', dedup: 'none' },
|
|
200
|
+
};
|
|
201
|
+
await handlers.get('create_event_rule')({ ...rule, org_id: OTHER_ID });
|
|
202
|
+
expect(lastCall()).toEqual({ url: `${FLEET}/event-rules`, method: 'POST', body: rule });
|
|
203
|
+
});
|
|
204
|
+
it('update_event_rule replaces with PUT and keeps rule_id out of the body', async () => {
|
|
205
|
+
await handlers.get('update_event_rule')({ rule_id: ID, name: 'R', outcome: skip });
|
|
206
|
+
expect(lastCall()).toEqual({
|
|
207
|
+
url: `${FLEET}/event-rules/${ID}`,
|
|
208
|
+
method: 'PUT',
|
|
209
|
+
body: { name: 'R', outcome: skip },
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
it('delete_event_rule sends DELETE and reports the id on 204', async () => {
|
|
213
|
+
mockFetch.mockResolvedValue(respond(204));
|
|
214
|
+
const result = await handlers.get('delete_event_rule')({ rule_id: ID });
|
|
215
|
+
expect(lastCall()).toMatchObject({ url: `${FLEET}/event-rules/${ID}`, method: 'DELETE' });
|
|
216
|
+
expect(JSON.parse(result.content[0].text)).toEqual({ deleted: ID });
|
|
217
|
+
});
|
|
218
|
+
it('reorder_event_rules puts the ids to /event-rules/order', async () => {
|
|
219
|
+
await handlers.get('reorder_event_rules')({ ids: [ID, OTHER_ID] });
|
|
220
|
+
expect(lastCall()).toEqual({
|
|
221
|
+
url: `${FLEET}/event-rules/order`,
|
|
222
|
+
method: 'PUT',
|
|
223
|
+
body: { ids: [ID, OTHER_ID] },
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
it('reorder_event_rules rejects ids that are not uuids', () => {
|
|
227
|
+
expect(accepts('reorder_event_rules', 'ids', [ID])).toBe(true);
|
|
228
|
+
expect(accepts('reorder_event_rules', 'ids', ['first'])).toBe(false);
|
|
229
|
+
expect(accepts('reorder_event_rules', 'ids', undefined)).toBe(false);
|
|
230
|
+
});
|
|
231
|
+
it('list_event_decisions passes limit as a query parameter', async () => {
|
|
232
|
+
await handlers.get('list_event_decisions')({ limit: 500 });
|
|
233
|
+
expect(lastCall().url).toBe(`${FLEET}/event-decisions?limit=500`);
|
|
234
|
+
});
|
|
235
|
+
it('list_event_decisions omits the query string without a limit', async () => {
|
|
236
|
+
await handlers.get('list_event_decisions')({});
|
|
237
|
+
expect(lastCall().url).toBe(`${FLEET}/event-decisions`);
|
|
238
|
+
});
|
|
239
|
+
it('list_event_decisions bounds limit to 1..500', () => {
|
|
240
|
+
expect(accepts('list_event_decisions', 'limit', 501)).toBe(false);
|
|
241
|
+
expect(accepts('list_event_decisions', 'limit', 0)).toBe(false);
|
|
242
|
+
});
|
|
243
|
+
describe('outcome schema', () => {
|
|
244
|
+
const ok = (value) => accepts('create_event_rule', 'outcome', value);
|
|
245
|
+
it('accepts run, skip and workflow outcomes', () => {
|
|
246
|
+
expect(ok({ action: 'run' })).toBe(true);
|
|
247
|
+
expect(ok({ action: 'run', agent_id: 'a', instructions: 'x', dedup: 'head_commit' })).toBe(true);
|
|
248
|
+
expect(ok(skip)).toBe(true);
|
|
249
|
+
expect(ok({ action: 'workflow', workflow_id: ID })).toBe(true);
|
|
250
|
+
});
|
|
251
|
+
it('rejects an unknown action', () => {
|
|
252
|
+
expect(ok({ action: 'notify' })).toBe(false);
|
|
253
|
+
expect(ok({ action: 'RUN' })).toBe(false);
|
|
254
|
+
expect(ok({})).toBe(false);
|
|
255
|
+
});
|
|
256
|
+
it('requires a skip reason of 1 to 500 characters', () => {
|
|
257
|
+
expect(ok({ action: 'skip' })).toBe(false);
|
|
258
|
+
expect(ok({ action: 'skip', reason: ' ' })).toBe(false);
|
|
259
|
+
expect(ok({ action: 'skip', reason: 'a'.repeat(501) })).toBe(false);
|
|
260
|
+
});
|
|
261
|
+
it('requires a uuid workflow_id for the workflow action', () => {
|
|
262
|
+
expect(ok({ action: 'workflow' })).toBe(false);
|
|
263
|
+
expect(ok({ action: 'workflow', workflow_id: 'wf' })).toBe(false);
|
|
264
|
+
});
|
|
265
|
+
it('rejects an unknown dedup mode and over-long instructions', () => {
|
|
266
|
+
expect(ok({ action: 'run', dedup: 'always' })).toBe(false);
|
|
267
|
+
expect(ok({ action: 'run', instructions: 'a'.repeat(4001) })).toBe(false);
|
|
268
|
+
});
|
|
269
|
+
it('rejects fields from another variant', () => {
|
|
270
|
+
expect(ok({ action: 'skip', reason: 'x', agent_id: 'a' })).toBe(false);
|
|
271
|
+
expect(ok({ action: 'run', workflow_id: ID })).toBe(false);
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
describe('conditions schema', () => {
|
|
275
|
+
const ok = (value) => accepts('create_event_rule', 'conditions', value);
|
|
276
|
+
it('accepts empty and fully populated conditions', () => {
|
|
277
|
+
expect(ok({})).toBe(true);
|
|
278
|
+
expect(ok({
|
|
279
|
+
sources: ['github'],
|
|
280
|
+
kinds: ['pipeline_failed', 'review_requested'],
|
|
281
|
+
opened_by: { kind: 'login', logins: ['renovate[bot]'] },
|
|
282
|
+
triggered_by: { kind: 'human' },
|
|
283
|
+
repositories: ['acme/*'],
|
|
284
|
+
target_branches: ['main'],
|
|
285
|
+
head_branches: ['renovate/*'],
|
|
286
|
+
labels: ['bug'],
|
|
287
|
+
paths: { mode: 'all', globs: ['docs/**'] },
|
|
288
|
+
update_types: ['patch', 'minor', 'major'],
|
|
289
|
+
})).toBe(true);
|
|
290
|
+
});
|
|
291
|
+
it('rejects a misspelt condition', () => {
|
|
292
|
+
expect(ok({ label: ['bug'] })).toBe(false);
|
|
293
|
+
});
|
|
294
|
+
it('rejects unknown kinds, sources and update types', () => {
|
|
295
|
+
expect(ok({ kinds: ['push'] })).toBe(false);
|
|
296
|
+
expect(ok({ sources: ['gitlab'] })).toBe(false);
|
|
297
|
+
expect(ok({ update_types: ['tiny'] })).toBe(false);
|
|
298
|
+
});
|
|
299
|
+
it('rejects blank and empty entries', () => {
|
|
300
|
+
expect(ok({ labels: [' '] })).toBe(false);
|
|
301
|
+
expect(ok({ paths: { mode: 'any', globs: [] } })).toBe(false);
|
|
302
|
+
expect(ok({ opened_by: { kind: 'login', logins: [] } })).toBe(false);
|
|
303
|
+
});
|
|
304
|
+
it('rejects a bad actor kind or path mode', () => {
|
|
305
|
+
expect(ok({ opened_by: { kind: 'robot' } })).toBe(false);
|
|
306
|
+
expect(ok({ opened_by: { kind: 'bot', logins: ['x'] } })).toBe(false);
|
|
307
|
+
expect(ok({ paths: { mode: 'some', globs: ['a'] } })).toBe(false);
|
|
308
|
+
});
|
|
309
|
+
it('caps a list at 50 entries', () => {
|
|
310
|
+
const labels = (n) => Array.from({ length: n }, (_, i) => `l${i}`);
|
|
311
|
+
expect(ok({ labels: labels(50) })).toBe(true);
|
|
312
|
+
expect(ok({ labels: labels(51) })).toBe(false);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
it('create_event_rule requires name and outcome', () => {
|
|
316
|
+
expect(accepts('create_event_rule', 'name', undefined)).toBe(false);
|
|
317
|
+
expect(accepts('create_event_rule', 'name', '')).toBe(false);
|
|
318
|
+
expect(accepts('create_event_rule', 'outcome', undefined)).toBe(false);
|
|
319
|
+
expect(accepts('create_event_rule', 'conditions', undefined)).toBe(true);
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
it('every new tool is registered with a description and an object schema', () => {
|
|
323
|
+
const tools = mockServer.tool;
|
|
324
|
+
const names = tools.mock.calls.map(([name]) => name);
|
|
325
|
+
expect(names).toEqual([
|
|
326
|
+
'list_workflows',
|
|
327
|
+
'get_workflow',
|
|
328
|
+
'create_workflow',
|
|
329
|
+
'update_workflow',
|
|
330
|
+
'delete_workflow',
|
|
331
|
+
'run_workflow',
|
|
332
|
+
'list_workflow_runs',
|
|
333
|
+
'get_workflow_run',
|
|
334
|
+
'list_event_rules',
|
|
335
|
+
'create_event_rule',
|
|
336
|
+
'update_event_rule',
|
|
337
|
+
'delete_event_rule',
|
|
338
|
+
'reorder_event_rules',
|
|
339
|
+
'list_event_decisions',
|
|
340
|
+
]);
|
|
341
|
+
for (const [, description, shape] of tools.mock.calls) {
|
|
342
|
+
expect(description.length).toBeGreaterThan(10);
|
|
343
|
+
expect(z.object(shape).safeParse({ org_id: 'nope' }).success).toBe(false);
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
});
|
|
@@ -30,6 +30,7 @@ function lastCall() {
|
|
|
30
30
|
const FLEET = 'https://api.ferrfleet.com';
|
|
31
31
|
const ORG_ID = '3f0c6a52-8d1e-4b7a-9c2f-5e6d7a8b9c01';
|
|
32
32
|
const POOL_ID = '0192f3a4-5b6c-7d8e-9f01-23456789abcd';
|
|
33
|
+
const STEP = { id: 'a', agent_id: 'bot', position: { x: 0, y: 0 } };
|
|
33
34
|
const ENV_ORG_ID = '7a1d9e34-2b5c-4f80-8e6a-1c3b5d7f9a02';
|
|
34
35
|
describe('ferrfleet tools', () => {
|
|
35
36
|
beforeEach(async () => {
|
|
@@ -53,6 +54,10 @@ describe('ferrfleet tools', () => {
|
|
|
53
54
|
const { registerConnectorTools } = await import('../connectors.js');
|
|
54
55
|
registerMarketplaceTools(mockServer);
|
|
55
56
|
registerConnectorTools(mockServer);
|
|
57
|
+
const { registerWorkflowTools } = await import('../workflows.js');
|
|
58
|
+
const { registerEventRuleTools } = await import('../event-rules.js');
|
|
59
|
+
registerWorkflowTools(mockServer);
|
|
60
|
+
registerEventRuleTools(mockServer);
|
|
56
61
|
});
|
|
57
62
|
it('every call goes to the FerrFleet API', async () => {
|
|
58
63
|
await handlers.get('list_agents')({});
|
|
@@ -77,6 +82,42 @@ describe('ferrfleet tools', () => {
|
|
|
77
82
|
await handlers.get('trigger_agent_run')({ agent_id: 'a1' });
|
|
78
83
|
expect(lastCall().body).toEqual({ input: {}, reason: null });
|
|
79
84
|
});
|
|
85
|
+
it('retry_run posts to the retry sub-resource of the run, without a body', async () => {
|
|
86
|
+
await handlers.get('retry_run')({ run_id: 'run-9' });
|
|
87
|
+
const call = lastCall();
|
|
88
|
+
expect(call.url).toBe(`${FLEET}/runs/run-9/retry`);
|
|
89
|
+
expect(call.method).toBe('POST');
|
|
90
|
+
expect(call.body).toBeUndefined();
|
|
91
|
+
});
|
|
92
|
+
it('retry_run escapes the run id so it cannot climb the path', async () => {
|
|
93
|
+
await handlers.get('retry_run')({ run_id: '../agents' });
|
|
94
|
+
expect(lastCall().url).toBe(`${FLEET}/runs/..%2Fagents/retry`);
|
|
95
|
+
});
|
|
96
|
+
it('retry_run requires a run id', () => {
|
|
97
|
+
const runId = schemas.get('retry_run').run_id;
|
|
98
|
+
expect(runId.safeParse(undefined).success).toBe(false);
|
|
99
|
+
expect(runId.safeParse('').success).toBe(false);
|
|
100
|
+
expect(runId.safeParse('run-9').success).toBe(true);
|
|
101
|
+
});
|
|
102
|
+
it('retry_run returns the new attempt from the API', async () => {
|
|
103
|
+
mockFetch.mockResolvedValue(ok({ id: 'run-10', retry_of: 'run-9', attempt: 2 }));
|
|
104
|
+
const result = await handlers.get('retry_run')({ run_id: 'run-9' });
|
|
105
|
+
expect(JSON.parse(result.content[0].text)).toEqual({
|
|
106
|
+
id: 'run-10',
|
|
107
|
+
retry_of: 'run-9',
|
|
108
|
+
attempt: 2,
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
it('retry_run does not swallow a refusal from the API', async () => {
|
|
112
|
+
mockFetch.mockResolvedValue({
|
|
113
|
+
ok: false,
|
|
114
|
+
status: 409,
|
|
115
|
+
statusText: 'Conflict',
|
|
116
|
+
text: () => Promise.resolve(JSON.stringify({ error: 'this run was already retried' })),
|
|
117
|
+
json: () => Promise.resolve({ error: 'this run was already retried' }),
|
|
118
|
+
});
|
|
119
|
+
await expect(handlers.get('retry_run')({ run_id: 'run-9' })).rejects.toThrow('this run was already retried');
|
|
120
|
+
});
|
|
80
121
|
it('get_run_transcript reads the transcript sub-resource', async () => {
|
|
81
122
|
await handlers.get('get_run_transcript')({ run_id: 'run-9' });
|
|
82
123
|
const call = lastCall();
|
|
@@ -391,7 +432,22 @@ describe('ferrfleet tools', () => {
|
|
|
391
432
|
['update_connector', { connector_id: 'c1', name: 'Gh' }],
|
|
392
433
|
['list_runs', {}],
|
|
393
434
|
['get_run', { run_id: 'r1' }],
|
|
435
|
+
['retry_run', { run_id: 'r1' }],
|
|
394
436
|
['get_run_transcript', { run_id: 'r1' }],
|
|
437
|
+
['list_workflows', {}],
|
|
438
|
+
['get_workflow', { workflow_id: ENV_ORG_ID }],
|
|
439
|
+
['create_workflow', { name: 'W', steps: [STEP] }],
|
|
440
|
+
['update_workflow', { workflow_id: ENV_ORG_ID, name: 'W', steps: [STEP] }],
|
|
441
|
+
['delete_workflow', { workflow_id: ENV_ORG_ID }],
|
|
442
|
+
['run_workflow', { workflow_id: ENV_ORG_ID }],
|
|
443
|
+
['list_workflow_runs', { workflow_id: ENV_ORG_ID }],
|
|
444
|
+
['get_workflow_run', { run_id: ENV_ORG_ID }],
|
|
445
|
+
['list_event_rules', {}],
|
|
446
|
+
['create_event_rule', { name: 'R', outcome: { action: 'skip', reason: 'noise' } }],
|
|
447
|
+
['update_event_rule', { rule_id: ENV_ORG_ID, name: 'R', outcome: { action: 'run' } }],
|
|
448
|
+
['delete_event_rule', { rule_id: ENV_ORG_ID }],
|
|
449
|
+
['reorder_event_rules', { ids: [ENV_ORG_ID] }],
|
|
450
|
+
['list_event_decisions', {}],
|
|
395
451
|
];
|
|
396
452
|
it.each(CALLS)('%s sends the org_id param as x-ferrfleet-org', async (name, params) => {
|
|
397
453
|
await handlers.get(name)({ ...params, org_id: ORG_ID });
|
|
@@ -0,0 +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;AA0E9D,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,QA2FvD"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getToken } from '@ferrlabs/mcp-core';
|
|
3
|
+
import { fleetRequest, orgIdSchema } from '../api-base.js';
|
|
4
|
+
import { reply } from './reply.js';
|
|
5
|
+
const EVENT_KINDS = [
|
|
6
|
+
'pull_request_opened',
|
|
7
|
+
'pull_request_updated',
|
|
8
|
+
'review_requested',
|
|
9
|
+
'pipeline_failed',
|
|
10
|
+
];
|
|
11
|
+
const UPDATE_TYPES = ['patch', 'minor', 'major'];
|
|
12
|
+
const DEDUP_MODES = ['head_commit', 'none'];
|
|
13
|
+
const MAX_PATTERNS = 50;
|
|
14
|
+
const patterns = (what) => z.array(z.string().trim().min(1)).max(MAX_PATTERNS).describe(what);
|
|
15
|
+
const actorSchema = z.discriminatedUnion('kind', [
|
|
16
|
+
z.strictObject({ kind: z.literal('bot') }),
|
|
17
|
+
z.strictObject({ kind: z.literal('human') }),
|
|
18
|
+
z.strictObject({ kind: z.literal('login'), logins: patterns('GitHub logins').min(1) }),
|
|
19
|
+
]);
|
|
20
|
+
const conditionsSchema = z
|
|
21
|
+
.strictObject({
|
|
22
|
+
sources: z.array(z.literal('github')).describe('Event sources; github today'),
|
|
23
|
+
kinds: z.array(z.enum(EVENT_KINDS)).describe('Event kinds'),
|
|
24
|
+
opened_by: actorSchema.describe('Pull request author'),
|
|
25
|
+
triggered_by: actorSchema.describe('Account that caused this delivery'),
|
|
26
|
+
repositories: patterns('owner/name globs, case-insensitive'),
|
|
27
|
+
target_branches: patterns('Base branch globs'),
|
|
28
|
+
head_branches: patterns('Head branch globs'),
|
|
29
|
+
labels: patterns('Pull request labels, any of'),
|
|
30
|
+
paths: z
|
|
31
|
+
.strictObject({
|
|
32
|
+
mode: z.enum(['any', 'all']),
|
|
33
|
+
globs: patterns('Changed-file globs').min(1),
|
|
34
|
+
})
|
|
35
|
+
.describe('all: every changed file matches a glob. any: at least one does'),
|
|
36
|
+
update_types: z.array(z.enum(UPDATE_TYPES)).describe('Dependency update size'),
|
|
37
|
+
})
|
|
38
|
+
.partial()
|
|
39
|
+
.describe('Every condition is optional and they combine with AND; none matches every event');
|
|
40
|
+
const outcomeSchema = z.discriminatedUnion('action', [
|
|
41
|
+
z.strictObject({
|
|
42
|
+
action: z.literal('run'),
|
|
43
|
+
agent_id: z.string().min(1).optional().describe('Agent to run instead of the repository-bound one'),
|
|
44
|
+
instructions: z.string().max(4000).optional().describe("Appended to the agent's prompt"),
|
|
45
|
+
dedup: z
|
|
46
|
+
.enum(DEDUP_MODES)
|
|
47
|
+
.optional()
|
|
48
|
+
.describe('head_commit (default): one run per head commit. none: every event runs'),
|
|
49
|
+
}),
|
|
50
|
+
z.strictObject({
|
|
51
|
+
action: z.literal('skip'),
|
|
52
|
+
reason: z.string().trim().min(1).max(500).describe('Shown in the decision trace'),
|
|
53
|
+
}),
|
|
54
|
+
z.strictObject({
|
|
55
|
+
action: z.literal('workflow'),
|
|
56
|
+
workflow_id: z.guid().describe('Workflow from list_workflows'),
|
|
57
|
+
}),
|
|
58
|
+
]);
|
|
59
|
+
const ruleFields = {
|
|
60
|
+
name: z.string().trim().min(1).max(100).describe('Rule name'),
|
|
61
|
+
enabled: z.boolean().optional().describe('Disabled rules are skipped; defaults to true'),
|
|
62
|
+
conditions: conditionsSchema.optional(),
|
|
63
|
+
outcome: outcomeSchema,
|
|
64
|
+
};
|
|
65
|
+
const ruleIdSchema = z.guid().describe('Rule id from list_event_rules');
|
|
66
|
+
export function registerEventRuleTools(server) {
|
|
67
|
+
server.tool('list_event_rules', "List the organization's event rules in evaluation order.", { org_id: orgIdSchema }, async ({ org_id }) => {
|
|
68
|
+
const token = await getToken();
|
|
69
|
+
return reply(await fleetRequest('/event-rules', { token, orgId: org_id }));
|
|
70
|
+
});
|
|
71
|
+
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 }) => {
|
|
72
|
+
const token = await getToken();
|
|
73
|
+
return reply(await fleetRequest('/event-rules', { token, orgId: org_id, method: 'POST', body }));
|
|
74
|
+
});
|
|
75
|
+
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 }) => {
|
|
76
|
+
const token = await getToken();
|
|
77
|
+
return reply(await fleetRequest(`/event-rules/${rule_id}`, {
|
|
78
|
+
token,
|
|
79
|
+
orgId: org_id,
|
|
80
|
+
method: 'PUT',
|
|
81
|
+
body,
|
|
82
|
+
}));
|
|
83
|
+
});
|
|
84
|
+
server.tool('delete_event_rule', 'Delete an event rule.', { rule_id: ruleIdSchema, org_id: orgIdSchema }, async ({ rule_id, org_id }) => {
|
|
85
|
+
const token = await getToken();
|
|
86
|
+
await fleetRequest(`/event-rules/${rule_id}`, {
|
|
87
|
+
token,
|
|
88
|
+
orgId: org_id,
|
|
89
|
+
method: 'DELETE',
|
|
90
|
+
});
|
|
91
|
+
return reply({ deleted: rule_id });
|
|
92
|
+
});
|
|
93
|
+
server.tool('reorder_event_rules', 'Set the evaluation order. ids must list every rule exactly once, first evaluated first.', { ids: z.array(z.guid()).describe('All rule ids in the new order'), org_id: orgIdSchema }, async ({ ids, org_id }) => {
|
|
94
|
+
const token = await getToken();
|
|
95
|
+
return reply(await fleetRequest('/event-rules/order', {
|
|
96
|
+
token,
|
|
97
|
+
orgId: org_id,
|
|
98
|
+
method: 'PUT',
|
|
99
|
+
body: { ids },
|
|
100
|
+
}));
|
|
101
|
+
});
|
|
102
|
+
server.tool('list_event_decisions', 'List the most recent event decisions: which rule matched each event and what happened (triggered, queued, skipped, deduplicated, no_agent, failed). Kept 30 days.', {
|
|
103
|
+
org_id: orgIdSchema,
|
|
104
|
+
limit: z
|
|
105
|
+
.number()
|
|
106
|
+
.int()
|
|
107
|
+
.min(1)
|
|
108
|
+
.max(500)
|
|
109
|
+
.optional()
|
|
110
|
+
.describe('Max decisions to return (default 100)'),
|
|
111
|
+
}, async ({ limit, org_id }) => {
|
|
112
|
+
const token = await getToken();
|
|
113
|
+
const qs = limit !== undefined ? `?limit=${limit}` : '';
|
|
114
|
+
return reply(await fleetRequest(`/event-decisions${qs}`, { token, orgId: org_id }));
|
|
115
|
+
});
|
|
116
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reply.d.ts","sourceRoot":"","sources":["../../src/tools/reply.ts"],"names":[],"mappings":"AAEA,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO;;cACP,MAAM;;;EAClC"}
|
package/dist/tools/runs.d.ts.map
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/tools/runs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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 { reply } from './reply.js';
|
|
4
5
|
export function registerRunTools(server) {
|
|
5
6
|
server.tool('list_runs', 'List recent FerrFleet runs for the authenticated org (most recent first).', {
|
|
6
7
|
limit: z
|
|
@@ -49,4 +50,15 @@ export function registerRunTools(server) {
|
|
|
49
50
|
],
|
|
50
51
|
};
|
|
51
52
|
});
|
|
53
|
+
server.tool('retry_run', 'Retry a failed or timed out FerrFleet run of any capability: creates the next attempt as a new run and returns its id, the id of the run it retries and the attempt number. Refused with 409 while the run or another run of the same commit is in flight, when the run was already retried, and for a run of an external agent. Requires a FerrFleet API that has POST /runs/{id}/retry.', {
|
|
54
|
+
run_id: z.string().min(1).describe('Id of the failed or timed out run to retry'),
|
|
55
|
+
org_id: orgIdSchema,
|
|
56
|
+
}, async ({ run_id, org_id }) => {
|
|
57
|
+
const token = await getToken();
|
|
58
|
+
return reply(await fleetRequest(`/runs/${encodeURIComponent(run_id)}/retry`, {
|
|
59
|
+
token,
|
|
60
|
+
orgId: org_id,
|
|
61
|
+
method: 'POST',
|
|
62
|
+
}));
|
|
63
|
+
});
|
|
52
64
|
}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getToken } from '@ferrlabs/mcp-core';
|
|
3
|
+
import { fleetRequest, orgIdSchema } from '../api-base.js';
|
|
4
|
+
import { reply } from './reply.js';
|
|
5
|
+
const JOIN_CONDITIONS = ['all_completed', 'all_finished', 'any_completed'];
|
|
6
|
+
const STEP_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
7
|
+
const stepSchema = z.strictObject({
|
|
8
|
+
id: z
|
|
9
|
+
.string()
|
|
10
|
+
.regex(STEP_ID_PATTERN)
|
|
11
|
+
.describe('Step id, unique in the workflow: lowercase letters, digits and hyphens, up to 40'),
|
|
12
|
+
agent_id: z.string().min(1).describe('Agent that runs this step'),
|
|
13
|
+
needs: z
|
|
14
|
+
.array(z.string().min(1))
|
|
15
|
+
.optional()
|
|
16
|
+
.describe('Ids of the steps that must finish first; omit or leave empty for a root step'),
|
|
17
|
+
when: z
|
|
18
|
+
.enum(JOIN_CONDITIONS)
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('When the step starts once its needs are done: all_completed (default), all_finished or any_completed'),
|
|
21
|
+
instructions: z
|
|
22
|
+
.string()
|
|
23
|
+
.max(4000)
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Extra instructions appended to the agent's prompt for this step"),
|
|
26
|
+
input: z
|
|
27
|
+
.record(z.string(), z.unknown())
|
|
28
|
+
.optional()
|
|
29
|
+
.describe('Structured input passed to the agent, up to 8 KiB'),
|
|
30
|
+
position: z
|
|
31
|
+
.strictObject({ x: z.number(), y: z.number() })
|
|
32
|
+
.describe('Canvas position of the step in the editor'),
|
|
33
|
+
});
|
|
34
|
+
const workflowFields = {
|
|
35
|
+
name: z.string().trim().min(1).max(100).describe('Workflow name'),
|
|
36
|
+
enabled: z.boolean().optional().describe('Whether the workflow can run; defaults to true'),
|
|
37
|
+
steps: z
|
|
38
|
+
.array(stepSchema)
|
|
39
|
+
.min(1)
|
|
40
|
+
.max(20)
|
|
41
|
+
.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
|
+
};
|
|
43
|
+
const workflowIdSchema = z.guid().describe('Workflow id from list_workflows');
|
|
44
|
+
export function registerWorkflowTools(server) {
|
|
45
|
+
server.tool('list_workflows', "List the organization's workflows.", { org_id: orgIdSchema }, async ({ org_id }) => {
|
|
46
|
+
const token = await getToken();
|
|
47
|
+
return reply(await fleetRequest('/workflows', { token, orgId: org_id }));
|
|
48
|
+
});
|
|
49
|
+
server.tool('get_workflow', 'Get a workflow with its steps.', { workflow_id: workflowIdSchema, org_id: orgIdSchema }, async ({ workflow_id, org_id }) => {
|
|
50
|
+
const token = await getToken();
|
|
51
|
+
return reply(await fleetRequest(`/workflows/${workflow_id}`, { token, orgId: org_id }));
|
|
52
|
+
});
|
|
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 }) => {
|
|
54
|
+
const token = await getToken();
|
|
55
|
+
return reply(await fleetRequest('/workflows', { token, orgId: org_id, method: 'POST', body }));
|
|
56
|
+
});
|
|
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 }) => {
|
|
58
|
+
const token = await getToken();
|
|
59
|
+
return reply(await fleetRequest(`/workflows/${workflow_id}`, {
|
|
60
|
+
token,
|
|
61
|
+
orgId: org_id,
|
|
62
|
+
method: 'PUT',
|
|
63
|
+
body,
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
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
|
+
const token = await getToken();
|
|
68
|
+
await fleetRequest(`/workflows/${workflow_id}`, {
|
|
69
|
+
token,
|
|
70
|
+
orgId: org_id,
|
|
71
|
+
method: 'DELETE',
|
|
72
|
+
});
|
|
73
|
+
return reply({ deleted: workflow_id });
|
|
74
|
+
});
|
|
75
|
+
server.tool('run_workflow', 'Start a workflow run now. Returns the run; poll get_workflow_run for step states and agent runs.', {
|
|
76
|
+
workflow_id: workflowIdSchema,
|
|
77
|
+
org_id: orgIdSchema,
|
|
78
|
+
input: z
|
|
79
|
+
.record(z.string(), z.unknown())
|
|
80
|
+
.optional()
|
|
81
|
+
.describe('Optional input object for the run, up to 64 KiB'),
|
|
82
|
+
}, async ({ workflow_id, input, org_id }) => {
|
|
83
|
+
const token = await getToken();
|
|
84
|
+
return reply(await fleetRequest(`/workflows/${workflow_id}/runs`, {
|
|
85
|
+
token,
|
|
86
|
+
orgId: org_id,
|
|
87
|
+
method: 'POST',
|
|
88
|
+
body: input ?? {},
|
|
89
|
+
}));
|
|
90
|
+
});
|
|
91
|
+
server.tool('list_workflow_runs', "List a workflow's recent runs, most recent first.", {
|
|
92
|
+
workflow_id: workflowIdSchema,
|
|
93
|
+
org_id: orgIdSchema,
|
|
94
|
+
limit: z
|
|
95
|
+
.number()
|
|
96
|
+
.int()
|
|
97
|
+
.min(1)
|
|
98
|
+
.max(200)
|
|
99
|
+
.optional()
|
|
100
|
+
.describe('Max runs to return (default 50)'),
|
|
101
|
+
}, async ({ workflow_id, limit, org_id }) => {
|
|
102
|
+
const token = await getToken();
|
|
103
|
+
const qs = limit !== undefined ? `?limit=${limit}` : '';
|
|
104
|
+
return reply(await fleetRequest(`/workflows/${workflow_id}/runs${qs}`, { token, orgId: org_id }));
|
|
105
|
+
});
|
|
106
|
+
server.tool('get_workflow_run', 'Get one workflow run with the state of every step and the agent run behind it.', { run_id: z.guid().describe('Workflow run id'), org_id: orgIdSchema }, async ({ run_id, org_id }) => {
|
|
107
|
+
const token = await getToken();
|
|
108
|
+
return reply(await fleetRequest(`/workflow-runs/${run_id}`, { token, orgId: org_id }));
|
|
109
|
+
});
|
|
110
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ferrfleet/mcp",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.15.0",
|
|
4
4
|
"description": "Model Context Protocol server for FerrFleet: agents, runs, skills",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"model-context-protocol"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@ferrlabs/mcp-core": "^10.14.
|
|
25
|
+
"@ferrlabs/mcp-core": "^10.14.3",
|
|
26
26
|
"zod": "^4.3.6"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|