{"record":{"id":"20ce36cb5b165553","repo":"angular/angular-cli","slug":"failed-to-update-roots-on-notification-e-instan","errorCode":null,"errorMessage":"Failed to update roots on notification: ${e instanceof Error ? e.message : e}","messagePattern":"Failed to update roots on notification: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/angular/cli/src/commands/mcp/mcp-server.ts","lineNumber":149,"sourceCode":"\n  server.server.oninitialized = () => {\n    void (async () => {\n      try {\n        const clientCapabilities = server.server.getClientCapabilities();\n        if (clientCapabilities?.roots) {\n          const { roots } = await server.server.listRoots();\n          const searchRoots = roots?.map((r) => normalize(fileURLToPath(r.uri))) ?? [];\n          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,","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/commands/mcp/mcp-server.ts#L131-L167","documentation":"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.","triggerScenarios":"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.","commonSituations":"MCP clients that declare the roots capability but don't implement listRoots properly; client disconnecting mid-notification; permission-denied roots in editors/agents.","solutions":["Check the MCP client supports and correctly implements the `roots` capability.","Verify the client's workspace roots are valid `file://` URIs accessible to the server.","Inspect the client logs for why the listRoots request failed; restart the MCP connection."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before enabling roots updates, confirm the client advertises the capability:\nconst supportsRoots = clientCapabilities?.roots != null;","typeGuard":"const hasRoots = (c: unknown): c is { roots: { listChanged: boolean } } =>\n  !!c && typeof c === 'object' && 'roots' in c && (c as any).roots != null;","tryCatchPattern":"try {\n  const { roots } = await server.server.listRoots();\n  restrictedHost.setRoots(roots?.map((r) => normalize(fileURLToPath(r.uri))) ?? []);\n} catch (e) {\n  logger.warn(`Keeping previous roots; update failed: ${e instanceof Error ? e.message : e}`);\n}","preventionTips":["Verify the MCP client declares the roots capability with listChanged.","Keep roots URIs as valid, accessible file:// URIs.","Treat roots warnings as non-fatal; last-known roots remain active."],"tags":["mcp","roots","notification","angular-cli"],"backgroundTag":"mcp-roots-update-failed","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}