@ferrfleet/mcp 10.15.2 → 10.16.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.
@@ -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`);
@@ -433,6 +479,7 @@ describe('ferrfleet tools', () => {
433
479
  ['list_runs', {}],
434
480
  ['get_run', { run_id: 'r1' }],
435
481
  ['retry_run', { run_id: 'r1' }],
482
+ ['move_run_to_front', { run_id: 'r1' }],
436
483
  ['get_run_transcript', { run_id: 'r1' }],
437
484
  ['list_workflows', {}],
438
485
  ['get_workflow', { workflow_id: ENV_ORG_ID }],
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ferrfleet/mcp",
3
- "version": "10.15.2",
3
+ "version": "10.16.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.4",
25
+ "@ferrlabs/mcp-core": "^10.14.5",
26
26
  "zod": "^4.3.6"
27
27
  },
28
28
  "publishConfig": {