feat(McpHub): inject env vars on whole mcp config #3970
Merged
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.
Related GitHub Issue
Resolves #4014
Description
From
@axmo
reporting via Discord, some MCPs require inputting secrets via the CLI args, instead ofenv
, and/or for any other reason, user would like to havecommand
orargs
to have value inferred from the env, like usingbunx
ornpx
, configuring mcp args via env without code committing,...The PR also fixes an unreported problem: env vars is not injected for
sse
transport, currently it's injected forstdio
only.Test Procedure
There is unit tests covering the usage and I also do some manual tests via VSCode debug to make sure all works good, just add breakpoint at the line.
Type of Change
src
or test files.Pre-Submission Checklist
npm run lint
).console.log
) has been removed.npm test
).main
branch.npm run changeset
if this PR includes user-facing changes or dependency updates.Documentation Updates
Currently the docs does not note about the ability to reference env variables in the mcp config at all, would be great if anyone can help add it, normal user might not know about this feature and commit API keys.
Additional Notes
Get in Touch
@NamesMT
Important
Inject environment variables into MCP configurations for both
stdio
andsse
transports, fixing a bug inMcpHub.ts
.stdio
andsse
transports inMcpHub.ts
.injectEnv
function inconfig.ts
to support both string and object configurations.sse
transport inMcpHub.ts
.This description was created by
for 8961614. You can customize this summary. It will automatically update as commits are pushed.