#1 Persistent memory for AI coding agents based on real-world benchmarks
TypeScript agentmemoryagentsaiclaudeclaudecodecodexcopilotcursorgenaiharnesshermesmemoryompopenclawopencodepi
fix(plugin): inherit AGENTMEMORY_URL/SECRET via env passthrough (#375) (#460)
Rohit Ghumarecaa9f5223e19
diff --git a/plugin/.mcp.json b/plugin/.mcp.jsonindex 12702a2a..f7c37603 100644--- a/plugin/.mcp.json+++ b/plugin/.mcp.json@@ -2,7 +2,11 @@"mcpServers": {"agentmemory": {"command": "npx",- "args": ["-y", "@agentmemory/mcp"]+ "args": ["-y", "@agentmemory/mcp"],+ "env": {+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"+ }}}}diff --git a/src/cli/connect/util.ts b/src/cli/connect/util.tsindex ce9110c6..6d5f61ac 100644--- a/src/cli/connect/util.ts+++ b/src/cli/connect/util.ts@@ -10,11 +10,19 @@ import { dirname, join } from "node:path";import { homedir } from "node:os";import * as p from "@clack/prompts";+// Env values use ${VAR} expansion so the wired MCP entry inherits+// AGENTMEMORY_URL / AGENTMEMORY_SECRET from the user's shell. When the+// vars are unset, the host (Claude Code, Cursor, etc.) substitutes an+// empty string; the standalone shim treats empty as missing and falls+// back to http://localhost:3111. This lets a single wired entry serve+// both local and remote (Kubernetes / reverse-proxied) deployments+// without doctor-warning duplicates (#375).export const AGENTMEMORY_MCP_BLOCK = {command: "npx",args: ["-y", "@agentmemory/mcp"],env: {- AGENTMEMORY_URL: "http://localhost:3111",+ AGENTMEMORY_URL: "${AGENTMEMORY_URL}",+ AGENTMEMORY_SECRET: "${AGENTMEMORY_SECRET}",},};diff --git a/test/cli-connect.test.ts b/test/cli-connect.test.tsindex 4a6c0227..99174dac 100644--- a/test/cli-connect.test.ts+++ b/test/cli-connect.test.ts@@ -112,6 +112,27 @@ describe("agentmemory connect — claude-code adapter (mock filesystem)", () =>expect(second.kind).toBe("already-wired");});+ it("install() writes env passthrough block for AGENTMEMORY_URL + AGENTMEMORY_SECRET (#375)", async () => {+ // Remote deployments (k8s, reverse proxy) set AGENTMEMORY_URL ++ // AGENTMEMORY_SECRET in the shell. The wired MCP entry must honour+ // those via ${VAR} expansion so a single entry covers both local+ // and remote without the user needing to add a duplicate config+ // that triggers a /doctor duplicate-server warning.+ const claudeDir = join(tmpHome, ".claude");+ require("node:fs").mkdirSync(claudeDir, { recursive: true });+ writeFileSync(join(tmpHome, ".claude.json"), JSON.stringify({}));++ const a = await loadAdapter();+ const result = await a.install({ dryRun: false, force: false });+ expect(result.kind).toBe("installed");++ const config = JSON.parse(readFileSync(join(tmpHome, ".claude.json"), "utf-8"));+ const entry = config.mcpServers.agentmemory;+ expect(entry.env).toBeDefined();+ expect(entry.env.AGENTMEMORY_URL).toBe("${AGENTMEMORY_URL}");+ expect(entry.env.AGENTMEMORY_SECRET).toBe("${AGENTMEMORY_SECRET}");+ });+it("install() with --force re-writes even when already wired", async () => {require("node:fs").mkdirSync(join(tmpHome, ".claude"), { recursive: true });writeFileSync(