{"record":{"id":"0d423111c0262aa8","repo":"coleam00/Archon","slug":"mcp-config-file-not-found-mcppath-resolved-to","errorCode":null,"errorMessage":"MCP config file not found: ${mcpPath} (resolved to ${fullPath})","messagePattern":"MCP config file not found: (.+?) \\(resolved to (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/providers/src/mcp/config.ts","lineNumber":140,"sourceCode":"}\n\n/**\n * Load MCP server config from a JSON file and expand environment variables.\n */\nexport async function loadMcpConfig(\n  mcpPath: string,\n  cwd: string,\n  envSource: EnvSource = process.env\n): Promise<LoadedMcpConfig> {\n  const fullPath = isAbsolute(mcpPath) ? mcpPath : resolve(cwd, mcpPath);\n\n  let raw: string;\n  try {\n    raw = await readFile(fullPath, 'utf-8');\n  } catch (err) {\n    const e = err as NodeJS.ErrnoException;\n    if (e.code === 'ENOENT') {\n      throw new Error(`MCP config file not found: ${mcpPath} (resolved to ${fullPath})`);\n    }\n    throw new Error(`Failed to read MCP config file: ${mcpPath} - ${e.message}`);\n  }\n\n  let parsed: Record<string, unknown>;\n  try {\n    parsed = JSON.parse(raw) as Record<string, unknown>;\n  } catch (parseErr) {\n    const detail = (parseErr as SyntaxError).message;\n    throw new Error(`MCP config file is not valid JSON: ${mcpPath} - ${detail}`);\n  }\n\n  if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n    throw new Error(`MCP config must be a JSON object (Record<string, ServerConfig>): ${mcpPath}`);\n  }\n\n  const normalized = normalizeMcpConfig(parsed, mcpPath);\n  const { expanded, missingVars } = expandEnvVars(normalized, envSource);","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/providers/src/mcp/config.ts#L122-L158","documentation":"loadMcpConfig reads the file at the given path (resolved against cwd when relative) and translates Node's ENOENT into a clear error showing both the path you passed and the resolved absolute path. It exists so a wrong or missing MCP config path fails immediately with actionable context instead of an opaque fs error.","triggerScenarios":"Calling loadMcpConfig(path, cwd) where the file does not exist: typo'd filename, wrong cwd, file deleted, or a relative path resolved against an unexpected working directory.","commonSituations":"Referencing ~/.claude.json or .mcp.json that was never created; running from a different directory than assumed in CI; path built from an env var that is unset/empty; config renamed after an upgrade.","solutions":["Check the resolved path in the message and create or restore the file there.","Pass an absolute mcpPath or verify cwd is the directory you expect.","ls the directory and correct a typo in the filename or extension (.json vs .jsonc)."],"exampleFix":"// before\nawait loadMcpConfig('.mcp.json', process.cwd()); // file actually at ~/.archon/.mcp.json\n// after\nawait loadMcpConfig(join(os.homedir(), '.archon', '.mcp.json'), process.cwd());","handlingStrategy":"validation","validationCode":"import { accessSync, constants } from 'fs';\nconst full = isAbsolute(p) ? p : resolve(cwd, p);\naccessSync(full, constants.F_OK); // throws ENOENT early with your own message\nawait loadMcpConfig(p, cwd);","typeGuard":null,"tryCatchPattern":"// catch (err) {\n//   if (err.message.includes('MCP config file not found')) {\n//     logger.error(`Check path; resolved target missing: ${err.message}`);\n//     process.exitCode = 1;\n//   } else throw err;\n// }","preventionTips":["Use absolute paths (path.resolve/join from a known anchor) instead of relative defaults.","Check file existence (fs.access / existsSync) before configuring MCP.","Log cwd at startup in CI so relative-path resolution is debuggable."],"tags":["filesystem","config","mcp","path"],"backgroundTag":"file-not-found","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}