nanocoai/nanoclaw · error · Error

MCP server "${name}" not found

Error message

MCP server "${name}" not found

What it means

The key `name` does not exist in the group's mcp_servers JSON map, so there is nothing to remove. Checked before plugin-ownership and deletion.

Source

Thrown at src/cli/resources/groups.ts:473

        return { added: name, servers };
      },
    },
    'config remove-mcp-server': {
      access: 'approval',
      description:
        'Remove an MCP server from a group. Requires `ncl groups restart` to take effect. Use --id <group-id> --name <server-name>.',
      handler: async (args) => {
        const id = args.id as string;
        if (!id) throw new Error('--id is required');
        const name = args.name as string;
        if (!name) throw new Error('--name is required');

        const row = await getContainerConfig(id);
        if (!row) throw new Error(`No container config for group: ${id}`);

        const servers = JSON.parse(row.mcp_servers) as Record<string, McpServerConfig>;
        if (!servers[name]) throw new Error(`MCP server "${name}" not found`);
        const owner = mcpServerPluginOwner(servers[name]);
        if (owner) {
          throw new Error(
            `MCP server "${name}" is owned by plugin "${owner}" — ` +
              'it would reappear on the next restamp; remove it from the plugin instead',
          );
        }
        delete servers[name];
        await updateContainerConfigJson(id, 'mcp_servers', servers);

        return { removed: name };
      },
    },
    'config add-package': {
      access: 'approval',
      description:
        'Add a package to a group. Requires `ncl groups restart --rebuild` to take effect. Use --id <group-id> and --apt <pkg> or --npm <pkg>.',
      handler: async (args) => {

View on GitHub (pinned to 294ef2aee8)

Solutions

  1. Run `ncl groups config get --id <g>` and copy the exact server key
  2. Make removal scripts idempotent (check existence first or tolerate this error)
  3. Confirm you're targeting the right group id

Example fix

# before
ncl groups config remove-mcp-server --id g --name tool
# after
ncl groups config get --id g        # shows key "tools"
ncl groups config remove-mcp-server --id g --name tools
Defensive patterns

Strategy: validation

Validate before calling

const cfg = await ncl(`groups config get --id ${groupId} --json`);
if (!Object.keys(cfg.mcpServers ?? {}).includes(serverName)) {
  console.log(`${serverName} already absent — nothing to do`);
  process.exit(0);
}

Type guard

const existsIn = (name: string, map: Record<string, unknown> | undefined) => Boolean(map && name in map);

Try / catch

catch (e) { if (/MCP server ".*" not found/.test(String(e))) { /* treat as already-removed success */ } else throw e; }

Prevention

When it happens

Trigger: Removing a server under a different name than it was added with (e.g. added as `--name tools`, removed as `--name tool`); server already removed; name from a different group's config.

Common situations: Name drift between add and remove commands; double-running a removal script; checking the wrong group's config.

Related errors


AI-assisted analysis of nanocoai/nanoclaw@294ef2aee8 (2026-08-28). Data as JSON: /api/errors/93bc5c984f2407f7. Report an issue: GitHub.