fix(mcp): honor AGENTMEMORY_TOOLS from .env in getVisibleTools#616
Open
ccf wants to merge 1 commit into
Open
Conversation
getVisibleTools() read process.env["AGENTMEMORY_TOOLS"] directly, bypassing
getMergedEnv() — the { ...fileEnv, ...process.env } helper that every other
config reader reaches through getEnvVar(). As a result, AGENTMEMORY_TOOLS=all
set in ~/.agentmemory/.env was silently ignored: the MCP surface stayed at the
8-tool core set instead of the full surface, even though .env.example documents
that variable as the way to opt in.
Route the lookup through getEnvVar() so the documented .env knob takes effect,
while process.env (shell export, --tools flag) keeps precedence over the file.
Fixes rohitg00#553
Signed-off-by: Charles C. Figueiredo <ccf@ccf.io>
|
@ccf is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
getVisibleTools()insrc/mcp/tools-registry.tsreadprocess.env["AGENTMEMORY_TOOLS"]directly, bypassinggetMergedEnv()— the{ ...fileEnv, ...process.env }helper that every other config reader reaches throughgetEnvVar(). This routes the lookup throughgetEnvVar()instead.Why
AGENTMEMORY_TOOLS=allset in~/.agentmemory/.envwas silently ignored. The MCP tool surface stayed at the 8-tool core set instead of the full surface, even though.env.exampledocuments that variable as the way to opt in:Because
getMergedEnv()is{ ...fileEnv, ...process.env },process.env(shell export, the--toolsflag) still takes precedence over the file — only the missing.envfallback is restored.This is the root cause behind #553: the "8 tools, not 51" state is the server returning its
coresurface over a working proxy — not a probe/proxy failure. It may also explain #400 (Codex full-surface) where a healthy server still serves the reduced set.To be clear about scope: this does not address #510, which is the distinct "literal
${AGENTMEMORY_URL}placeholder breaks the shim's localhost fallback" connection bug — that one is already handled onmainby theresolveEnvOrEmptyguard in #588.How to verify
Automated coverage added in
test/tools-visibility-env.test.ts(hermetic; sandboxesHOMEand writes a temp.env):AGENTMEMORY_TOOLS=allin.env→ full surface (getAllTools().length, incl.memory_graph_query)process.envoverrides the.envvalue (precedence preserved)npm run buildis clean and the suite passes (the 5 unrelatedauto-compress/embedding-providerfailures only occur when a real~/.agentmemory/.envis present in the test environment; they pass with a cleanHOME).Fixes #553