angular/angular-cli · warning

Failed to update roots on notification: ${e instanceof Error

Error message

Failed to update roots on notification: ${e instanceof Error ? e.message : e}

What it means

In the MCP server, when the client sends a roots-changed notification, the server calls listRoots() to refresh the workspace roots it will search. If that round-trip fails (client rejects, lacks roots capability, or returns bad URIs), the failure is caught and logged as a warning; the previously set roots remain in effect.

Source

Thrown at packages/angular/cli/src/commands/mcp/mcp-server.ts:149

  server.server.oninitialized = () => {
    void (async () => {
      try {
        const clientCapabilities = server.server.getClientCapabilities();
        if (clientCapabilities?.roots) {
          const { roots } = await server.server.listRoots();
          const searchRoots = roots?.map((r) => normalize(fileURLToPath(r.uri))) ?? [];
          restrictedHost.setRoots(searchRoots);

          if (clientCapabilities.roots.listChanged) {
            server.server.setNotificationHandler('notifications/roots/list_changed', async () => {
              try {
                const { roots: updatedRoots } = await server.server.listRoots();
                const updatedSearchRoots =
                  updatedRoots?.map((r) => normalize(fileURLToPath(r.uri))) ?? [];
                restrictedHost.setRoots(updatedSearchRoots);
              } catch (e) {
                logger.warn(
                  `Failed to update roots on notification: ${e instanceof Error ? e.message : e}`,
                );
              }
            });
          }
        }
      } catch (e) {
        logger.warn(
          `Failed to initialize roots on connection: ${e instanceof Error ? e.message : e}`,
        );
      }
    })();
  };

  await registerTools(
    server,
    {
      workspace: options.workspace,

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Check the MCP client supports and correctly implements the `roots` capability.
  2. Verify the client's workspace roots are valid `file://` URIs accessible to the server.
  3. Inspect the client logs for why the listRoots request failed; restart the MCP connection.
Defensive patterns

Strategy: try-catch

Validate before calling

// Before enabling roots updates, confirm the client advertises the capability:
const supportsRoots = clientCapabilities?.roots != null;

Type guard

const hasRoots = (c: unknown): c is { roots: { listChanged: boolean } } =>
  !!c && typeof c === 'object' && 'roots' in c && (c as any).roots != null;

Try / catch

try {
  const { roots } = await server.server.listRoots();
  restrictedHost.setRoots(roots?.map((r) => normalize(fileURLToPath(r.uri))) ?? []);
} catch (e) {
  logger.warn(`Keeping previous roots; update failed: ${e instanceof Error ? e.message : e}`);
}

Prevention

When it happens

Trigger: An MCP client emits the roots/list_changed notification but then fails or refuses the subsequent roots/list request, or returns URIs that cannot be converted to file paths.

Common situations: MCP clients that declare the roots capability but don't implement listRoots properly; client disconnecting mid-notification; permission-denied roots in editors/agents.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/20ce36cb5b165553. Report an issue: GitHub.