{"record":{"id":"c13f142d13d03148","repo":"rohitg00/agentmemory","slug":"agentmemory-mcp-livez-probe-url-agentmemory","errorCode":null,"errorMessage":"[@agentmemory/mcp] livez probe ${url}/agentmemory/livez failed in ${timeout}ms: ${err instanceof Error ? err.message : String(err)}; falling back to local InMemoryKV (set AGENTMEMORY_FORCE_PROXY=1 to skip the probe, or raise AGENTMEMORY_PROBE_TIMEOUT_MS)","messagePattern":"\\[@agentmemory/mcp\\] livez probe (.+?)/agentmemory/livez failed in (.+?)ms: (.+?); falling back to local InMemoryKV \\(set AGENTMEMORY_FORCE_PROXY=1 to skip the probe, or raise AGENTMEMORY_PROBE_TIMEOUT_MS\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/mcp/rest-proxy.ts","lineNumber":104,"sourceCode":" * dropped before the next call.\n */\nexport function setLivezProbe(fn?: LivezProbe): void {\n  livezProbe = fn ?? defaultLivezProbe;\n}\n\nasync function probe(url: string): Promise<boolean> {\n  const timeout = probeTimeoutMs();\n  try {\n    const res = await livezProbe(url, timeout, authHeader());\n    if (!res.ok) {\n      process.stderr.write(\n        `[@agentmemory/mcp] livez probe ${url}/agentmemory/livez -> ${res.status ?? \"?\"} ${res.statusText ?? \"\"}; falling back to local InMemoryKV (set AGENTMEMORY_FORCE_PROXY=1 to skip the probe)\\n`,\n      );\n    }\n    return res.ok;\n  } catch (err) {\n    process.stderr.write(\n      `[@agentmemory/mcp] livez probe ${url}/agentmemory/livez failed in ${timeout}ms: ${err instanceof Error ? err.message : String(err)}; falling back to local InMemoryKV (set AGENTMEMORY_FORCE_PROXY=1 to skip the probe, or raise AGENTMEMORY_PROBE_TIMEOUT_MS)\\n`,\n    );\n    return false;\n  }\n}\n\nexport function invalidateHandle(): void {\n  cached = null;\n  cachedAt = 0;\n}\n\nexport async function resolveHandle(): Promise<Handle> {\n  const now = Date.now();\n  if (cached) {\n    if (cached.mode === \"local\" && now - cachedAt >= LOCAL_MODE_TTL_MS) {\n      cached = null;\n      cachedAt = 0;\n    } else {\n      return cached;","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/rohitg00/agentmemory/blob/e04ba88819c365c9acf9d6661ea802143e728bd6/src/mcp/rest-proxy.ts#L86-L122","documentation":"When the MCP layer starts, probe() issues a livez HTTP probe against the configured AGENTMEMORY_URL (/agentmemory/livez) to decide whether to proxy to the daemon. On a thrown error (connection refused, DNS failure, abort on timeout) it writes this diagnostic to stderr and returns false, causing the MCP server to fall back to a local InMemoryKV instead of the persistent daemon. It is a warning log, not an exception that propagates.","triggerScenarios":"The fetch to ${url}/agentmemory/livez throws: daemon not running, AGENTMEMORY_URL points to the wrong host/port, a timeout exceeds AGENTMEMORY_PROBE_TIMEOUT_MS, or a transient network error.","commonSituations":"Developer forgot to start the agentmemory daemon before launching the MCP server; AGENTMEMORY_URL misconfigured (wrong port, https vs http); slow daemon startup exceeding the probe timeout in CI or cold containers.","solutions":["Start the agentmemory daemon and verify the URL responds: curl ${AGENTMEMORY_URL}/agentmemory/livez.","Correct AGENTMEMORY_URL (scheme, host, port) to match the running daemon.","Raise AGENTMEMORY_PROBE_TIMEOUT_MS (e.g. 5000) if the daemon is slow to start.","Set AGENTMEMORY_FORCE_PROXY=1 to skip the probe and always proxy if you know the daemon will be there."],"exampleFix":"// before: probe times out against wrong port\n// AGENTMEMORY_URL=http://127.0.0.1:3113\n// after\nexport AGENTMEMORY_URL=http://127.0.0.1:3111\nexport AGENTMEMORY_PROBE_TIMEOUT_MS=5000","handlingStrategy":"retry","validationCode":"const url = process.env.AGENTMEMORY_URL ?? \"http://127.0.0.1:3111\";\ntry {\n  const r = await fetch(`${url}/agentmemory/livez`, { signal: AbortSignal.timeout(5000) });\n  if (!r.ok) throw new Error(`livez ${r.status}`);\n} catch (e) { console.error(\"daemon not reachable; start it or fix AGENTMEMORY_URL\"); }","typeGuard":null,"tryCatchPattern":"let up = false;\nfor (let i = 0; i < 5 && !up; i++) {\n  up = await probe();\n  if (!up) await new Promise(r => setTimeout(r, 500));\n}\nif (!up) console.error(\"falling back to InMemoryKV; data will not persist\");","preventionTips":["Start the daemon before launching the MCP server (supervisor/entrypoint ordering).","Pin AGENTMEMORY_URL explicitly and verify with curl /agentmemory/livez.","Raise AGENTMEMORY_PROBE_TIMEOUT_MS in cold-start environments.","Set AGENTMEMORY_FORCE_PROXY=1 when the daemon is guaranteed but slow to boot."],"tags":["network","mcp","health-check","timeout","fallback"],"backgroundTag":"livez-probe-failed","analyzedSha":"e04ba88819c365c9acf9d6661ea802143e728bd6","analyzedAt":"2026-08-30T01:07:40.754Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}