{"record":{"id":"dd0e2badfaf15c33","repo":"thedotmack/claude-mem","slug":"mcp-server-cjs-not-found-in-plugin-scripts","errorCode":null,"errorMessage":"mcp-server.cjs not found in plugin/scripts","messagePattern":"mcp-server\\.cjs not found in plugin/scripts","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/shared/mcp-client.ts","lineNumber":100,"sourceCode":"      && typeof (item as { text?: unknown }).text === 'string'\n    ))\n    .map(item => item.text)\n    .join('\\n');\n\n  return {\n    text,\n    ...(maybeResult.isError === true ? { isError: true } : {}),\n  };\n}\n\nexport async function callMcpToolOnce(\n  name: string,\n  args: Record<string, unknown>,\n  options: { timeoutMs?: number } = {},\n): Promise<McpToolCallResult> {\n  const scriptPath = resolveMcpServerScriptPath();\n  if (!scriptPath) {\n    throw new Error('mcp-server.cjs not found in plugin/scripts');\n  }\n\n  const transport = new StdioClientTransport({\n    command: resolveNodeCommand(),\n    args: [scriptPath],\n    env: buildMcpSpawnEnv(),\n    cwd: process.cwd(),\n    stderr: 'pipe',\n  });\n  const client = new Client(\n    { name: MCP_CLIENT_NAME, version: MCP_CLIENT_VERSION },\n    { capabilities: {} },\n  );\n\n  const timeoutMs = options.timeoutMs ?? MCP_CALL_TIMEOUT_MS;\n  let timeout: ReturnType<typeof setTimeout> | null = null;\n  const timeoutPromise = new Promise<never>((_, reject) => {\n    timeout = setTimeout(","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d768ba364302d12b76e69e4f021f0bb1d2d50ed6/src/shared/mcp-client.ts#L82-L118","documentation":"Thrown by callMcpToolOnce when resolveMcpServerScriptPath() returns null — neither <MARKETPLACE_ROOT>/plugin/scripts/mcp-server.cjs nor <cwd>/plugin/scripts/mcp-server.cjs exists. The MCP server script is a build artifact of the plugin; its absence means the plugin wasn't built/installed where the client looks.","triggerScenarios":"callMcpToolOnce invoked before/without the plugin built; MARKETPLACE_ROOT resolves somewhere without plugin/scripts; running from a cwd that has no plugin/scripts and the marketplace copy is missing.","commonSituations":"Fresh checkout without running build-and-sync; plugin installed to a marketplace dir that lacks the compiled mcp-server.cjs; package was partially installed; cwd changed so the cwd-relative candidate misses too.","solutions":["Run the plugin build/sync (npm run build-and-sync) so mcp-server.cjs is generated and placed under plugin/scripts.","Verify <MARKETPLACE_ROOT>/plugin/scripts/mcp-server.cjs exists; check MARKETPLACE_ROOT resolution.","Run the process from the project root so the cwd-relative candidate also matches.","Reinstall the marketplace plugin if the file was deleted."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { resolveMcpServerScriptPath } from './mcp-client';\nconst scriptPath = resolveMcpServerScriptPath();\nif (!scriptPath) {\n  throw new Error('mcp-server.cjs missing — run npm run build-and-sync');\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await callMcpToolOnce(name, args, options);\n} catch (err) {\n  if (err instanceof Error && /mcp-server.cjs not found/.test(err.message)) {\n    logger.error('MCP', err.message);\n    // run build-and-sync before retrying\n  }\n  throw err;\n}","preventionTips":["Run the plugin build before any code path that calls callMcpToolOnce.","Verify plugin/scripts/mcp-server.cjs exists in CI.","Run from the project root so the cwd-relative candidate resolves."],"tags":["mcp","plugin","build-artifact","path-resolution"],"backgroundTag":null,"analyzedSha":"d768ba364302d12b76e69e4f021f0bb1d2d50ed6","analyzedAt":"2026-08-12T23:52:55.241Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}