Skip to content

fix(mcp): resolve env vars in agent plugin MCP server definitions#303156

Open
ConsoleTVs wants to merge 5 commits intomicrosoft:mainfrom
ConsoleTVs:fix/plugin-mcp-env-var-substitution
Open

fix(mcp): resolve env vars in agent plugin MCP server definitions#303156
ConsoleTVs wants to merge 5 commits intomicrosoft:mainfrom
ConsoleTVs:fix/plugin-mcp-env-var-substitution

Conversation

@ConsoleTVs
Copy link

Agent plugin MCP servers did not resolve environment variable references because the resolution pipeline was skipped entirely (no variableReplacement was set) and the MCP-standard bare ${VAR} syntax is not recognized by VS Code's configuration resolver.

  • Add variableReplacement to plugin server definitions so the resolution pipeline runs
  • Convert bare ${VAR} references to ${env:VAR} at the plugin boundary so the resolver can look them up in process.env

Fixes #302579

Agent plugin MCP servers did not resolve environment variable references
because the resolution pipeline was skipped entirely (no variableReplacement
was set) and the MCP-standard bare ${VAR} syntax is not recognized by
VS Code's configuration resolver.

- Add variableReplacement to plugin server definitions so the resolution
  pipeline runs
- Convert bare ${VAR} references to ${env:VAR} at the plugin boundary
  so the resolver can look them up in process.env

Fixes microsoft#302579
Replace manual field-by-field cloning with the existing cloneAndChange
utility for a simpler, type-agnostic deep walk that converts bare
${VAR} references to ${env:VAR} in any string value.
connor4312
connor4312 previously approved these changes Mar 19, 2026
Copy link
Member

@connor4312 connor4312 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@connor4312 connor4312 enabled auto-merge (squash) March 19, 2026 21:15
@vs-code-engineering vs-code-engineering bot added this to the 1.113.0 milestone Mar 19, 2026
…or upstream uri property

cloneAndChange deep-clones objects into plain {} via for...in, which
destroys URI prototype methods. Guard with URI.isUri() to return URI
values unchanged. Also add required uri property to all test definitions
after upstream added IAgentPluginMcpServerDefinition.uri.
auto-merge was automatically disabled March 19, 2026 22:22

Head branch was pushed to by a user without write access

@ConsoleTVs
Copy link
Author

@connor4312 Looks like upstream merged some changes that caused type issues. I have made some quick modifications and tested locally that types work. Let's try again :)

@vijayupadya vijayupadya self-requested a review March 19, 2026 23:33
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.

Agent Plugin's MCP does not expand env variables

3 participants