fix(mcp): resolve every tool's secrets to plaintext so GUI IDEs authenticate - #263
Merged
Conversation
Env-var passthrough was tried per tool (claude project scope, cursor ${env:},
codex bearer_token_env_var, codebuddy ${VAR}), but each tool expands variables
under different, fragile conditions. The decisive one: IDEs launched from the
GUI never inherit the user's shell exports, so a ${VAR} placeholder resolves to
empty and the server 401s.
Make supportsEnvExpansion always false so every tool/scope resolves the secret
to plaintext and writes it verbatim. The token is then present regardless of
how the tool is launched. Drop the now-dead codexCanNameEveryVar helper. Docs
warn that project-scope MCP configs now carry the literal secret and must be
gitignored.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Context
Follow-up to #262. That PR merged only the first commit (CodeBuddy-only plaintext); the "all tools plaintext" change did not land on
main. So cursor still writes${env:VAR}and codex still writesbearer_token_env_var— both of which a GUI-launched tool cannot resolve (no shell env), producing the same 401 CodeBuddy had.Fix
Make
supportsEnvExpansionalwaysfalse— every tool, every scope resolves the secret to its value and writes it verbatim. The token is then present no matter how the tool is started. Removes the now-deadcodexCanNameEveryVarhelper.${VAR}${env:VAR}bearer_token_env_varhttp_headers)Docs (both languages) warn that project-scope MCP configs now carry the literal secret and must be gitignored.
Test Plan
npx tsc --noEmit— cleannpm run build— successnpx vitest run— 1827 passed, 0 failedBearer <token>in every tool.teamai pullin a real project):.mcp.json,.cursor/mcp.json,.codebuddy/mcp.jsonall contain resolvedBearer <token>, no${}anywhere.POST /api/ai/mcp→ HTTP 200.🤖 Generated with Claude Code