@ferrfleet/mcp 10.14.0 → 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.
@@ -82,6 +82,42 @@ describe('ferrfleet tools', () => {
82
82
  await handlers.get('trigger_agent_run')({ agent_id: 'a1' });
83
83
  expect(lastCall().body).toEqual({ input: {}, reason: null });
84
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
+ });
85
121
  it('get_run_transcript reads the transcript sub-resource', async () => {
86
122
  await handlers.get('get_run_transcript')({ run_id: 'run-9' });
87
123
  const call = lastCall();
@@ -396,6 +432,7 @@ describe('ferrfleet tools', () => {
396
432
  ['update_connector', { connector_id: 'c1', name: 'Gh' }],
397
433
  ['list_runs', {}],
398
434
  ['get_run', { run_id: 'r1' }],
435
+ ['retry_run', { run_id: 'r1' }],
399
436
  ['get_run_transcript', { run_id: 'r1' }],
400
437
  ['list_workflows', {}],
401
438
  ['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;AAa1E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,QAqEjD"}
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,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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ferrfleet/mcp",
3
- "version": "10.14.0",
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",