@ferrfleet/mcp 10.21.1 → 10.22.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.
@@ -390,30 +390,30 @@ describe('ferrfleet tools', () => {
390
390
  });
391
391
  it('bind_repo upserts the binding with the repository and agent', async () => {
392
392
  await handlers.get('bind_repo')({
393
- repo_full_name: 'IdleWarden/idlewarden',
393
+ repo_full_name: 'acme/widgets',
394
394
  agent_id: 'pr-review',
395
395
  });
396
396
  const call = lastCall();
397
397
  expect(call.url).toBe(`${FLEET}/repos/bindings`);
398
398
  expect(call.method).toBe('POST');
399
- expect(call.body).toEqual({ repo_full_name: 'IdleWarden/idlewarden', agent_id: 'pr-review' });
399
+ expect(call.body).toEqual({ repo_full_name: 'acme/widgets', agent_id: 'pr-review' });
400
400
  });
401
401
  it('bind_repo keeps enabled=false so a binding can be switched off', async () => {
402
402
  await handlers.get('bind_repo')({
403
- repo_full_name: 'IdleWarden/idlewarden',
403
+ repo_full_name: 'acme/widgets',
404
404
  agent_id: 'pr-review',
405
405
  enabled: false,
406
406
  });
407
407
  expect(lastCall().body).toEqual({
408
- repo_full_name: 'IdleWarden/idlewarden',
408
+ repo_full_name: 'acme/widgets',
409
409
  agent_id: 'pr-review',
410
410
  enabled: false,
411
411
  });
412
412
  });
413
413
  it('bind_repo only accepts owner/name repositories', () => {
414
414
  const repo = schemas.get('bind_repo').repo_full_name;
415
- expect(repo.safeParse('IdleWarden/idlewarden').success).toBe(true);
416
- expect(repo.safeParse('idlewarden').success).toBe(false);
415
+ expect(repo.safeParse('acme/widgets').success).toBe(true);
416
+ expect(repo.safeParse('widgets').success).toBe(false);
417
417
  expect(repo.safeParse('a/b/c').success).toBe(false);
418
418
  expect(repo.safeParse('../agents').success).toBe(false);
419
419
  });
@@ -497,6 +497,51 @@ describe('ferrfleet tools', () => {
497
497
  await handlers.get('update_agent')({ agent_id: '../runs', enabled: true });
498
498
  expect(lastCall().url).toBe(`${FLEET}/agents/..%2Fruns`);
499
499
  });
500
+ describe('delete_agent', () => {
501
+ const refuse = (status, body) => mockFetch.mockResolvedValue({
502
+ ok: false,
503
+ status,
504
+ text: () => Promise.resolve(body === undefined ? '' : JSON.stringify(body)),
505
+ });
506
+ it('sends DELETE with the escaped id and reports it on 204', async () => {
507
+ mockFetch.mockResolvedValue({ ok: true, status: 204, text: () => Promise.resolve('') });
508
+ const result = await handlers.get('delete_agent')({ agent_id: '../runs' });
509
+ expect(lastCall().url).toBe(`${FLEET}/agents/..%2Fruns`);
510
+ expect(lastCall().method).toBe('DELETE');
511
+ expect(result.isError).toBeUndefined();
512
+ expect(JSON.parse(result.content[0].text)).toEqual({ deleted: '../runs' });
513
+ });
514
+ it('names the workflow when a workflow step uses the agent', async () => {
515
+ refuse(409, {
516
+ error: 'the workflow `Nightly review` has a step that uses this agent',
517
+ code: 'agent_in_use',
518
+ });
519
+ const result = await handlers.get('delete_agent')({ agent_id: 'a1' });
520
+ expect(result.isError).toBe(true);
521
+ expect(result.content[0].text).toContain('Nightly review');
522
+ expect(result.content[0].text).toContain('Remove that step');
523
+ });
524
+ it('points at update_agent when another resource still references the agent', async () => {
525
+ refuse(409);
526
+ const result = await handlers.get('delete_agent')({ agent_id: 'a1' });
527
+ expect(result.isError).toBe(true);
528
+ expect(result.content[0].text).toContain('enabled: false');
529
+ expect(result.content[0].text).not.toContain('workflow');
530
+ });
531
+ it('reports an unknown agent', async () => {
532
+ refuse(404);
533
+ const result = await handlers.get('delete_agent')({ agent_id: 'nope' });
534
+ expect(result.isError).toBe(true);
535
+ expect(result.content[0].text).toBe('Agent not found.');
536
+ });
537
+ it('lets any other failure through instead of hiding it', async () => {
538
+ refuse(500, { error: 'boom' });
539
+ await expect(handlers.get('delete_agent')({ agent_id: 'a1' })).rejects.toThrow('boom');
540
+ });
541
+ it('requires a non-empty agent_id', () => {
542
+ expect(schemas.get('delete_agent').agent_id.safeParse('').success).toBe(false);
543
+ });
544
+ });
500
545
  it('list_marketplace_agents reads the catalog and returns it unchanged', async () => {
501
546
  const templates = [{ id: 'pr-review', name: 'PR review', imported: false }];
502
547
  mockFetch.mockResolvedValue(ok(templates));
@@ -602,6 +647,7 @@ describe('ferrfleet tools', () => {
602
647
  ['trigger_agent_run', { agent_id: 'a1' }],
603
648
  ['create_agent', { id: 'bot', name: 'Bot', prompt: 'Go' }],
604
649
  ['update_agent', { agent_id: 'a1', enabled: true }],
650
+ ['delete_agent', { agent_id: 'a1' }],
605
651
  ['list_runner_pools', {}],
606
652
  ['list_marketplace_agents', {}],
607
653
  ['import_marketplace_agent', { template_id: 't1' }],
@@ -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;AAsB1E,eAAO,MAAM,gBAAgB,QAAsC,CAAC;AAEpE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,QAyMnD"}
1
+ {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/tools/agents.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,KAAK,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAuB3F,eAAO,MAAM,gBAAgB,QAAsC,CAAC;AAYpE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,QA8NnD"}
@@ -1,7 +1,8 @@
1
1
  import { z } from 'zod';
2
- import { getToken, toToolText } from '@ferrlabs/mcp-core';
2
+ import { ApiRequestError, getToken, toToolText } from '@ferrlabs/mcp-core';
3
3
  import { fleetRequest, orgIdSchema } from '../api-base.js';
4
4
  import { effortSchema } from './model-choice.js';
5
+ import { reply } from './reply.js';
5
6
  const RUNNER_MODES = ['managed', 'external'];
6
7
  const AGENT_CAPABILITIES = [
7
8
  'code_review',
@@ -11,6 +12,18 @@ const AGENT_CAPABILITIES = [
11
12
  'review_followup',
12
13
  ];
13
14
  export const AGENT_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,62}[a-z0-9]$/;
15
+ function deleteRefusal(error) {
16
+ if (!(error instanceof ApiRequestError))
17
+ return undefined;
18
+ if (error.status === 404)
19
+ return 'Agent not found.';
20
+ if (error.status !== 409)
21
+ return undefined;
22
+ if (error.code === 'agent_in_use') {
23
+ return `${error.message}. Remove that step from the workflow first, then delete the agent.`;
24
+ }
25
+ return 'The agent is still referenced by another resource (such as an event rule) and cannot be deleted. Change or delete that resource first, or disable the agent with update_agent and enabled: false.';
26
+ }
14
27
  export function registerAgentTools(server) {
15
28
  server.tool('list_agents', 'List FerrFleet agents available to the authenticated user (marketplace + custom).', { org_id: orgIdSchema }, async ({ org_id }) => {
16
29
  const token = await getToken();
@@ -170,4 +183,21 @@ export function registerAgentTools(server) {
170
183
  content: [{ type: 'text', text: toToolText(agent) }],
171
184
  };
172
185
  });
186
+ server.tool('delete_agent', "Delete a FerrFleet agent. Irreversible: the agent's runs and transcripts, schedules, skills, repository bindings and connector attachments are deleted with it (the connectors and repositories themselves stay). Refused with agent_in_use while a workflow step uses the agent (remove the step first), and refused while an event rule names it. To stop an agent without deleting it, use update_agent with enabled: false.", { agent_id: z.string().min(1).describe('Agent id'), org_id: orgIdSchema }, async ({ agent_id, org_id }) => {
187
+ const token = await getToken();
188
+ try {
189
+ await fleetRequest(`/agents/${encodeURIComponent(agent_id)}`, {
190
+ token,
191
+ orgId: org_id,
192
+ method: 'DELETE',
193
+ });
194
+ }
195
+ catch (error) {
196
+ const refusal = deleteRefusal(error);
197
+ if (refusal === undefined)
198
+ throw error;
199
+ return { isError: true, content: [{ type: 'text', text: refusal }] };
200
+ }
201
+ return reply({ deleted: agent_id });
202
+ });
173
203
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ferrfleet/mcp",
3
- "version": "10.21.1",
3
+ "version": "10.22.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.16.0",
25
+ "@ferrlabs/mcp-core": "^10.17.1",
26
26
  "zod": "^4.3.6"
27
27
  },
28
28
  "publishConfig": {