From 9dfa6ce283784f9bc97abffe3cedfd44e4f1da8c Mon Sep 17 00:00:00 2001 From: laplace young Date: Fri, 15 May 2026 13:22:11 +0800 Subject: [PATCH 1/2] fix: pass plugin mcp env overrides Signed-off-by: laplace young --- README.md | 2 ++ plugin/.mcp.json | 6 +++++- test/codex-plugin.test.ts | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c4dea8294..850634365d 100644 --- a/README.md +++ b/README.md @@ -355,6 +355,8 @@ Implementation details live in `src/cli.ts` (see `runUpgrade` around the `src/cl Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 51 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113. ``` +For remote or protected deployments, launch Claude Code with `AGENTMEMORY_URL` and `AGENTMEMORY_SECRET` set. The plugin passes both values through to its bundled MCP server, with `http://localhost:3111` as the default URL. + ### Codex CLI (Codex plugin platform) ```bash diff --git a/plugin/.mcp.json b/plugin/.mcp.json index 12702a2a5a..db3072d87a 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:-http://localhost:3111}", + "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET:-}" + } } } } diff --git a/test/codex-plugin.test.ts b/test/codex-plugin.test.ts index bb38087643..4b97fd7534 100644 --- a/test/codex-plugin.test.ts +++ b/test/codex-plugin.test.ts @@ -46,6 +46,24 @@ describe("Codex plugin manifest (developers.openai.com/codex/plugins)", () => { expect(existsSync(join(pluginRoot, manifest.hooks))).toBe(true); }); + it("plugin MCP server inherits remote agentmemory environment overrides", () => { + const mcp = readJson<{ + mcpServers: Record< + string, + { + command: string; + args: string[]; + env?: Record; + } + >; + }>(join(pluginRoot, ".mcp.json")); + + expect(mcp.mcpServers.agentmemory?.env).toMatchObject({ + AGENTMEMORY_URL: "${AGENTMEMORY_URL:-http://localhost:3111}", + AGENTMEMORY_SECRET: "${AGENTMEMORY_SECRET:-}", + }); + }); + it("hooks.codex.json contains only events Codex supports (no Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure)", () => { const hooksPath = join(pluginRoot, "hooks/hooks.codex.json"); const hooks = readJson<{ hooks: Record }>(hooksPath); From 66123ee59885e72a944e38a4d8583387604d0e77 Mon Sep 17 00:00:00 2001 From: laplace young Date: Mon, 18 May 2026 16:18:28 +0800 Subject: [PATCH 2/2] fix: simplify plugin mcp env templates --- README.md | 2 +- plugin/.mcp.json | 4 ++-- test/codex-plugin.test.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 850634365d..f799f160cd 100644 --- a/README.md +++ b/README.md @@ -355,7 +355,7 @@ Implementation details live in `src/cli.ts` (see `runUpgrade` around the `src/cl Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 51 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113. ``` -For remote or protected deployments, launch Claude Code with `AGENTMEMORY_URL` and `AGENTMEMORY_SECRET` set. The plugin passes both values through to its bundled MCP server, with `http://localhost:3111` as the default URL. +For remote or protected deployments, launch Claude Code with `AGENTMEMORY_URL` and `AGENTMEMORY_SECRET` set. The plugin passes both values through to its bundled MCP server; when `AGENTMEMORY_URL` is empty, the MCP shim uses `http://localhost:3111`. ### Codex CLI (Codex plugin platform) diff --git a/plugin/.mcp.json b/plugin/.mcp.json index db3072d87a..f7c3760336 100644 --- a/plugin/.mcp.json +++ b/plugin/.mcp.json @@ -4,8 +4,8 @@ "command": "npx", "args": ["-y", "@agentmemory/mcp"], "env": { - "AGENTMEMORY_URL": "${AGENTMEMORY_URL:-http://localhost:3111}", - "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET:-}" + "AGENTMEMORY_URL": "${AGENTMEMORY_URL}", + "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}" } } } diff --git a/test/codex-plugin.test.ts b/test/codex-plugin.test.ts index 4b97fd7534..e7fdf3a031 100644 --- a/test/codex-plugin.test.ts +++ b/test/codex-plugin.test.ts @@ -59,8 +59,8 @@ describe("Codex plugin manifest (developers.openai.com/codex/plugins)", () => { }>(join(pluginRoot, ".mcp.json")); expect(mcp.mcpServers.agentmemory?.env).toMatchObject({ - AGENTMEMORY_URL: "${AGENTMEMORY_URL:-http://localhost:3111}", - AGENTMEMORY_SECRET: "${AGENTMEMORY_SECRET:-}", + AGENTMEMORY_URL: "${AGENTMEMORY_URL}", + AGENTMEMORY_SECRET: "${AGENTMEMORY_SECRET}", }); });