Skip to content

fix(mcp): resolve every tool's secrets to plaintext so GUI IDEs authenticate - #262

Merged
jeff-r2026 merged 1 commit into
mainfrom
worktree-codebuddy-resolve-plaintext
Jul 29, 2026
Merged

fix(mcp): resolve every tool's secrets to plaintext so GUI IDEs authenticate#262
jeff-r2026 merged 1 commit into
mainfrom
worktree-codebuddy-resolve-plaintext

Conversation

@jeff-r2026

@jeff-r2026 jeff-r2026 commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Problem

Even after #260 fixed the type field, remote MCP servers still failed with 401 in GUI-launched tools:

streamableHttp connect failed: ... {"error": "缺少或无效的 Bearer Token"}
connect sse failed: SSE error: Non-200 status code (401)

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 shell exports, so ${VAR} expands to empty → Authorization: Bearer → 401. The CLI worked only because it does inherit the shell env.

Fix

Make supportsEnvExpansion always false — 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-dead codexCanNameEveryVar helper.

tool before after
Claude (project) ${VAR} plaintext
Cursor ${env:VAR} plaintext
Codex bearer_token_env_var plaintext (http_headers)
CodeBuddy ${VAR} plaintext

Docs (both languages) warn that project-scope MCP configs now carry the literal secret and must be gitignored.

Test Plan

  • npx tsc --noEmit — clean
  • npm run build — success
  • npx vitest run — 1827 passed, 0 failed
  • Rewrote the project-secret and codex tests to assert plaintext Bearer <token> in every tool; updated the "unresolvable var skips" comment.
  • End-to-end (teamai pull in a real project): .mcp.json, .cursor/mcp.json, .codebuddy/mcp.json all contain resolved Bearer <token>, no ${} in any of them.
  • Backend probe with the resolved token: POST /api/ai/mcpHTTP 200.

🤖 Generated with Claude Code

…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>
@jeff-r2026
jeff-r2026 merged commit a2e62ca into main Jul 29, 2026
6 checks passed
@jeff-r2026 jeff-r2026 changed the title fix(mcp): resolve CodeBuddy secrets to plaintext so its GUI IDE authenticates fix(mcp): resolve every tool's secrets to plaintext so GUI IDEs authenticate Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant