{"record":{"id":"aa4949cd45d84a73","repo":"ruvnet/RuView","slug":"mcp-repository-access-requires-a-trusted-root-conf","errorCode":null,"errorMessage":"MCP repository access requires a trusted root configured at server startup","messagePattern":"MCP repository access requires a trusted root configured at server startup","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"harness/homecore/src/tools.js","lineNumber":140,"sourceCode":"  const paths = String(env.PATH || env.Path || '').split(delimiter).filter(Boolean);\n  return paths.flatMap((path) => extensions.map((suffix) => join(path, `${command}${suffix}`)));\n}\n\nexport function executableOnPath(command, env = process.env) {\n  return executableCandidates(command, env).some((path) => {\n    try {\n      return existsSync(path) && statSync(path).isFile();\n    } catch {\n      return false;\n    }\n  });\n}\n\nfunction resolveRepo(repo, context = {}) {\n  const candidate = repo ? resolve(repo) : (context.trustedRoot || findHomecoreRepo());\n  if (!candidate) return null;\n  if (context.source === 'mcp' && !context.trustedRoot) {\n    throw new Error('MCP repository access requires a trusted root configured at server startup');\n  }\n  return assertTrustedHomecoreRepo(candidate, {\n    trustedRoot: context.source === 'mcp' ? context.trustedRoot : candidate,\n  });\n}\n\nexport async function doctor(args = {}, context = {}) {\n  const kernel = await getKernelStatus({ strict: args.strict_wasm === true });\n  const nodeMajor = Number(process.versions.node.split('.')[0]);\n  const repo = resolveRepo(args.repo, context);\n  const repoRequired = typeof args.repo === 'string';\n  const checks = {\n    nodeSupported: Number.isInteger(nodeMajor) && nodeMajor >= 20,\n    kernelLoaded: kernel.mcpValidation === null,\n    wasmRequirement: args.strict_wasm === true ? kernel.resolvedBackend === 'wasm' : true,\n    repository: repo ? true : !repoRequired,\n  };\n  return {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/harness/homecore/src/tools.js#L122-L158","documentation":"All repository-touching MCP tools in harness/homecore/src/tools.js resolve repositories through resolveRepo, which refuses any call with context.source === 'mcp' unless the server was started with a configured trustedRoot. This fail-closed rule prevents MCP clients from directing the server at arbitrary directories.","triggerScenarios":"Invoking the doctor/verify/guidance MCP tools when 'homecore mcp start' was launched outside a RuView checkout (no trustedRoot detected or set at startup), or embedding the tools in a custom host that never populates context.trustedRoot.","commonSituations":"Starting the MCP server from the home directory, editors spawning MCP servers with a cwd outside the checkout, custom integrations skipping startup configuration.","solutions":["Start the MCP server from inside the trusted RuView checkout so startup records the trusted root","For ad-hoc repositories use the CLI instead: node harness/homecore/bin/cli.js <cmd> --repo <path>","If embedding the tools, resolve and pass the trusted root at server construction time"],"exampleFix":"# before\n$ cd ~ && node harness/homecore/bin/cli.js mcp start   # trustedRoot never set\n\n# after\n$ cd /path/to/RuView && node harness/homecore/bin/cli.js mcp start","handlingStrategy":"validation","validationCode":"// At MCP server startup, before serving any tool call:\nimport { assertTrustedHomecoreRepo } from './harness/homecore/src/repo-trust.js';\nconst trustedRoot = assertTrustedHomecoreRepo(process.cwd());\n// Attach it to every tool invocation context:\nconst context = { source: 'mcp', trustedRoot };","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always launch 'mcp start' from inside the trusted RuView checkout","Fail server startup loudly when no trusted root can be established, instead of serving tool calls that will refuse","Use the CLI with --repo for one-off repositories; MCP access is intentionally restricted to the startup root"],"tags":["security","mcp","configuration","homecore"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}