angular/angular-cli · warning

Failed to initialize roots on connection: ${e instanceof Err

Error message

Failed to initialize roots on connection: ${e instanceof Error ? e.message : e}

What it means

On a new MCP client connection the server attempts to initialize its workspace roots by requesting the roots list from the client. If this initial request throws (capability missing, client error, invalid URIs), the whole initialization is aborted and the failure is logged as a warning; the server falls back to whatever default roots were configured.

Source

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

          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,
      logger,
      exampleDatabasePath: join(__dirname, '../../../lib/code-examples.db'),
      devservers: new Map<string, Devserver>(),
      host: restrictedHost,
      roots: resolvedRoots,
    },
    toolDeclarations,
  );

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Enable/declare the `roots` capability in the MCP client during initialization.
  2. Ensure the client exposes valid workspace root file:// URIs.
  3. If roots are unsupported, configure search roots explicitly via the server's default configuration.
Defensive patterns

Strategy: try-catch

Validate before calling

// Check the initialized client capabilities before requesting roots:
if (!clientCapabilities?.roots) {
  logger.warn('Client does not support roots; using configured default roots.');
}

Type guard

const supportsRoots = (c: unknown): boolean =>
  !!c && typeof c === 'object' && 'roots' in (c as object);

Try / catch

try {
  const { roots } = await connection.listRoots();
  host.setRoots(roots.map((r) => fileURLToPath(r.uri)));
} catch (e) {
  logger.warn(`Roots init failed, using defaults: ${e instanceof Error ? e.message : e}`);
}

Prevention

When it happens

Trigger: Connecting an MCP client that lacks the `roots` capability or errors on the first roots/list request during connection setup.

Common situations: Custom MCP clients/agents without roots support; misconfigured client capabilities in the MCP handshake; environment where the client cannot expose workspace folders.

Related errors


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