{"record":{"id":"d11bed5e86d5c8e8","repo":"angular/angular-cli","slug":"failed-to-initialize-roots-on-connection-e-inst","errorCode":null,"errorMessage":"Failed to initialize roots on connection: ${e instanceof Error ? e.message : e}","messagePattern":"Failed to initialize roots on connection: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/angular/cli/src/commands/mcp/mcp-server.ts","lineNumber":157,"sourceCode":"          restrictedHost.setRoots(searchRoots);\n\n          if (clientCapabilities.roots.listChanged) {\n            server.server.setNotificationHandler('notifications/roots/list_changed', async () => {\n              try {\n                const { roots: updatedRoots } = await server.server.listRoots();\n                const updatedSearchRoots =\n                  updatedRoots?.map((r) => normalize(fileURLToPath(r.uri))) ?? [];\n                restrictedHost.setRoots(updatedSearchRoots);\n              } catch (e) {\n                logger.warn(\n                  `Failed to update roots on notification: ${e instanceof Error ? e.message : e}`,\n                );\n              }\n            });\n          }\n        }\n      } catch (e) {\n        logger.warn(\n          `Failed to initialize roots on connection: ${e instanceof Error ? e.message : e}`,\n        );\n      }\n    })();\n  };\n\n  await registerTools(\n    server,\n    {\n      workspace: options.workspace,\n      logger,\n      exampleDatabasePath: join(__dirname, '../../../lib/code-examples.db'),\n      devservers: new Map<string, Devserver>(),\n      host: restrictedHost,\n      roots: resolvedRoots,\n    },\n    toolDeclarations,\n  );","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/commands/mcp/mcp-server.ts#L139-L175","documentation":"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.","triggerScenarios":"Connecting an MCP client that lacks the `roots` capability or errors on the first roots/list request during connection setup.","commonSituations":"Custom MCP clients/agents without roots support; misconfigured client capabilities in the MCP handshake; environment where the client cannot expose workspace folders.","solutions":["Enable/declare the `roots` capability in the MCP client during initialization.","Ensure the client exposes valid workspace root file:// URIs.","If roots are unsupported, configure search roots explicitly via the server's default configuration."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check the initialized client capabilities before requesting roots:\nif (!clientCapabilities?.roots) {\n  logger.warn('Client does not support roots; using configured default roots.');\n}","typeGuard":"const supportsRoots = (c: unknown): boolean =>\n  !!c && typeof c === 'object' && 'roots' in (c as object);","tryCatchPattern":"try {\n  const { roots } = await connection.listRoots();\n  host.setRoots(roots.map((r) => fileURLToPath(r.uri)));\n} catch (e) {\n  logger.warn(`Roots init failed, using defaults: ${e instanceof Error ? e.message : e}`);\n}","preventionTips":["Enable the roots capability in your MCP client during initialization.","Expose valid workspace folders from the client.","Configure explicit default roots for clients without roots support."],"tags":["mcp","roots","initialization","angular-cli"],"backgroundTag":"mcp-roots-init-failed","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}