fix(mcp): use type for cursor/codebuddy remote servers and keep secrets off disk - #260
Merged
Merged
Conversation
…rets off disk CodeBuddy and Cursor were getting remote (http/sse) MCP servers written with `transportType: "streamable-http"`, a field both tools ignore — so the Authorization header never shipped and the server 401'd. Both key the transport off `type`, exactly like the claude family. Emit `type` for them. While fixing the format, restore placeholder passthrough for these two tools so team secrets no longer land on disk (undoing that part of #258 for them): - CodeBuddy interpolates the bare `${VAR}` in every scope — pass it through. - Cursor interpolates `${env:NAME}` — rewrite `${VAR}` into that syntax. `supportsEnvExpansion` now returns true for cursor/buddy; the renderers carry the per-tool placeholder syntax. The resolve-to-plaintext path remains only as a fallback (user-scope claude, codex placeholders it cannot name as a whole header). Verified end-to-end against the real test repo in a project-scope install: claude keeps `${VAR}`, codebuddy `type:"http"` + `${VAR}`, cursor `type:"http"` + `${env:VAR}`; a POST to the backend with the resolved token returns HTTP 200, confirming the header now ships. Docs (EN + zh-CN) updated. 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
After the project-scope secret work landed (#258/#259), CodeBuddy and Cursor remote MCP servers still failed to authenticate — CodeBuddy returned
401 缺少或无效的 Bearer Tokenon both streamable-HTTP and SSE.Two independent bugs:
transportType: "streamable-http". Both tools ignore that field — they key the transport offtype, exactly like the claude family. With no recognized transport, theAuthorizationheader was never sent → 401.${VAR}to the literal value and write it into their config file (which lives in the repo and is typically committed). Both tools can actually expand env vars themselves; we just weren't using it.Fix
renderBuddy/renderCursornow emittype: def.transportfor remote servers (matching the claude family), instead of the ignoredtransportType.supportsEnvExpansionreturnstruefor cursor and buddy in every scope, so the placeholder is passed through and the secret stays off disk.${VAR}→ passed through unchanged.${env:NAME}→${VAR}is rewritten into that syntax.Test Plan
npx tsc --noEmit— cleannpx vitest run— 1827 passing (updated the project-scope secret test to assert per-tool placeholder syntax; scoped the "unresolved ${VAR} skips" test to claude, the only resolving target)npm run buildteamai-dev-repo, project scope in../llm):.mcp.json:type:"http"+Bearer ${GPU_ANALYSIS_TOKEN}.codebuddy/mcp.json:type:"http"+Bearer ${GPU_ANALYSIS_TOKEN}(wastransportType).cursor/mcp.json:type:"http"+Bearer ${env:GPU_ANALYSIS_TOKEN}curl -X POSTto the backend with the resolved token + streamable-HTTP headers → HTTP 200, confirming the header now ships and the 401 is resolved.docs/usage-guide.md+docs/usage-guide.zh-CN.md).🤖 Generated with Claude Code