Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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; when `AGENTMEMORY_URL` is empty, the MCP shim uses `http://localhost:3111`.

### Codex CLI (Codex plugin platform)

```bash
Expand Down
6 changes: 5 additions & 1 deletion plugin/.mcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
Comment on lines +6 to +9

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for documentation of env var syntax in MCP-related files and comments

# Check if there are any other .mcp.json examples in the repo
echo "=== Other MCP config examples in repo ==="
fd -e json -e md . | xargs rg -l 'mcpServers.*env' -A5 -B5

# Check README and docs for MCP env var documentation
echo "=== MCP env var documentation in README ==="
rg -C5 'AGENTMEMORY_URL.*localhost.*3111' README.md

# Check if there are integration tests that actually exercise this
echo "=== Tests that might validate runtime behavior ==="
rg -C3 'AGENTMEMORY_URL|AGENTMEMORY_SECRET' test/

Repository: rohitg00/agentmemory

Length of output: 1967


🌐 Web query:

MCP Model Context Protocol environment variable syntax specification

💡 Result:

There is no single, protocol-level “MCP Model Context Protocol environment variable syntax specification” in the upstream MCP spec itself. What is standardized in MCP: 1) The MCP protocol spec defines an HTTP authorization framework for HTTP-based transports, but it explicitly does not require stdio clients/servers to follow that HTTP auth scheme and instead notes that credentials should come from the environment for stdio implementations. [1] What “environment variable syntax” does exist for MCP today: A) MCP client configuration formats (e.g., VS Code / Cursor style mcp.json, and other MCP client tools) each implement their own string interpolation / env expansion rules. - VS Code’s MCP configuration reference shows that the env field is “Environment variables for the server” and also supports an envFile field. [2] - A VS Code issue discussing env-var placeholders in mcp.json shows the commonly used pattern ${env:VARIABLE_NAME} referenced by VS Code’s variable system, and reports that behavior can differ depending on where the config comes from (user mcp.json vs plugin-provided). [3] B) Some MCP client libraries / wrappers don’t expand ${VAR} placeholders at all (they pass them through as literal strings), which is not an MCP spec guarantee. - A LangChain MCP adapters issue states that ${VAR} syntax in the env block is “widely-used” but that their adapter passes those values through without resolving them. [4] C) MCP-related runtimes and deployment tools introduce their own environment-variable templating syntax (again, not MCP core). - Example: code/config templates for an MCP server can use ${VAR}-style substitution in some tooling; one MCP Hub docs page documents ${...} expansion and ${VAR_NAME:-default} defaults as supported by that product. [5] - Example: 1mcp-app/agent documents a set of environment variables for configuring the agent itself (prefixed ONE_MCP_), which is tool-specific rather than part of MCP protocol syntax. [6] So what syntax should you use? - If you are editing an MCP client config file such as VS Code’s mcp.json, use the syntax that that specific client supports. In VS Code discussions, ${env:VARIABLE_NAME} is the referenced form. [3] - If you’re using another MCP client/runtime, follow its docs; some support ${VAR} expansion, others require ${env:VAR}, and some don’t expand placeholders when passed in the env map. [2][4] If you tell me which exact MCP client/tool you’re using (e.g., VS Code Copilot MCP, Cursor, Claude Desktop, a specific SDK like openai-agents-js, or a specific MCP gateway), I can look up that tool’s exact environment-variable placeholder grammar and confirm with citations.

Citations:


Verify MCP client compatibility for environment variable syntax ${VAR:-default}.

The ${VAR:-default} syntax uses shell parameter expansion, not standard JSON. Web search confirms that MCP clients do NOT have a shared standard for environment variable substitution—each client implements its own rules:

  • VS Code/Cursor use ${env:VARIABLE_NAME} syntax
  • Some MCP clients (e.g., LangChain adapters) do not expand ${VAR} placeholders at all, treating them as literal strings
  • A few tools support ${VAR:-default}, but coverage is not universal

This configuration may break when deployed to clients that don't recognize this syntax. Test with your target MCP clients (Claude Code, Cursor, Cline, Windsurf) or use the ${env:VARIABLE_NAME} syntax documented in VS Code's MCP configuration reference if cross-client compatibility is required.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugin/.mcp.json` around lines 6 - 9, The env entries in plugin/.mcp.json use
shell-style "${VAR:-default}" expansion which is not portable across MCP
clients; update the AGENTMEMORY_URL and AGENTMEMORY_SECRET entries to use a
cross-client compatible variable syntax (e.g. the VS Code-style
"${env:AGENTMEMORY_URL}" / "${env:AGENTMEMORY_SECRET}") and remove the
":-default" fallback from the JSON, and implement any defaults in the plugin
initialization code (where AGENTMEMORY_URL and AGENTMEMORY_SECRET are read) so
that functions referencing those keys (AGENTMEMORY_URL, AGENTMEMORY_SECRET) get
a safe default at runtime instead of relying on shell expansion.

}
}
}
18 changes: 18 additions & 0 deletions test/codex-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>;
}
>;
}>(join(pluginRoot, ".mcp.json"));

expect(mcp.mcpServers.agentmemory?.env).toMatchObject({
AGENTMEMORY_URL: "${AGENTMEMORY_URL}",
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<string, unknown> }>(hooksPath);
Expand Down