feat: support ${VAR} environment variable interpolation in headers#10
Open
mrmodolo wants to merge 1 commit intoagoda-com:mainfrom
Open
feat: support ${VAR} environment variable interpolation in headers#10mrmodolo wants to merge 1 commit intoagoda-com:mainfrom
mrmodolo wants to merge 1 commit intoagoda-com:mainfrom
Conversation
Expand ${VAR_NAME} references in X-Target-URL, X-Target-Headers, and
X-Base-URL header values using os.environ at request time.
This allows MCP client configurations to be version-controlled without
embedding secrets or environment-specific values directly:
"X-Target-Headers": "{\"Authorization\": \"Bearer ${MY_TOKEN\"}"
Unknown variables are left as-is for easy debugging of incomplete configs.
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
Header values like
X-Target-HeadersandX-Target-URLrequire hardcoded secrets and environment-specific URLs, making it difficult to version-control MCP client configurations.Solution
Expand
${VAR_NAME}references in header values usingos.environat request time. Applied to the three headers that typically contain secrets or environment-specific values:X-Target-URLX-Target-HeadersX-Base-URLExample
{ "headers": { "X-Target-URL": "${MY_API_ENDPOINT}", "X-Target-Headers": "{\"Authorization\": \"Bearer ${MY_API_TOKEN}\"}", "X-Base-URL": "${MY_API_BASE_URL}" } }Design decisions
${UNDEFINED}stays literal rather than becoming empty string, making misconfiguration easy to spot.X-API-Type,X-Allow-Unsafe-Paths, etc. are not interpolated.Security note
The expansion runs server-side, so in a shared/multi-tenant deployment a client could potentially read arbitrary env vars. This matches the existing trust model (the user who configures headers already controls the server environment), but is worth noting for anyone considering multi-tenant setups.