fix(mcp): resolve every tool's secrets to plaintext so GUI IDEs authenticate - #262
Merged
Merged
Conversation
…nticates
CodeBuddy's IDE runs as a GUI app launched from Dock/Launchpad, which never
inherits the user's shell exports. A ${VAR} placeholder in .codebuddy/mcp.json
therefore expands to empty and the remote server 401s ("缺少或无效的 Bearer
Token"), even though the CLI (which does inherit the shell) connects fine.
Drop CodeBuddy from env-var passthrough so the token is resolved and written
verbatim, present regardless of how the tool is launched. Claude (project
scope) and Cursor keep the placeholder; Codex keeps its named-variable form.
Docs note the deliberate exception and advise gitignoring .codebuddy/mcp.json.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6 tasks
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.
Problem
Even after #260 fixed the
typefield, remote MCP servers still failed with 401 in GUI-launched tools:Root cause: teamai wrote a
${VAR}placeholder and relied on each tool to expand it. But that expansion is fragile and tool-specific — most decisively, IDEs launched from the GUI (Dock/Launchpad) never inherit the user's shellexports, so${VAR}expands to empty →Authorization: Bearer→ 401. The CLI worked only because it does inherit the shell env.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. Also removes the now-deadcodexCanNameEveryVarhelper.${VAR}${env:VAR}bearer_token_env_varhttp_headers)${VAR}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; updated the "unresolvable var skips" comment.teamai pullin a real project):.mcp.json,.cursor/mcp.json,.codebuddy/mcp.jsonall contain resolvedBearer <token>, no${}in any of them.POST /api/ai/mcp→ HTTP 200.🤖 Generated with Claude Code