cli: allow resolving MCP URL containing ${ENV_VAR}#342
Merged
peterj merged 1 commit intoagentregistry-dev:mainfrom Mar 13, 2026
Merged
cli: allow resolving MCP URL containing ${ENV_VAR}#342peterj merged 1 commit intoagentregistry-dev:mainfrom
peterj merged 1 commit intoagentregistry-dev:mainfrom
Conversation
\# Description
Allows resolving MCP URLs containing ${ENV_VAR} using
dynamic URL resolution from environment variables at runtime.
This is extremely useful to not hardcode the MCP URL in
the agent code and instead specify them during deployment
using environment variables, decoupling code from runtime
values that are dynamic.
\# Change Type
```
/kind new_feature
```
\# Changelog
```release-note
Allows MCP URLs containing environment variables to be resolved
at runtime.
```
Signed-off-by: Shashank Ram <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Enables MCP remote URLs in agent manifests to include ${ENV_VAR} placeholders by relaxing CLI validation (sanitizing placeholders before parsing) and resolving placeholders at runtime in the generated Python agent code.
Changes:
- Update CLI manifest validation for remote MCP URLs to tolerate
${VAR}placeholders. - Add unit tests covering remote MCP URL validation with
${VAR}in host/port/path. - Resolve
${VAR}placeholders in MCP URLs at runtime in the ADK Python agent template.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/cli/agent/frameworks/common/manifest_manager.go | Sanitizes ${VAR} placeholders prior to url.Parse for remote MCP URL validation. |
| internal/cli/agent/frameworks/common/manifest_manager_test.go | Adds test cases ensuring placeholder-containing remote URLs pass validation. |
| internal/cli/agent/frameworks/adk/python/templates/agent/mcp_tools.py.tmpl | Resolves ${VAR} placeholders in MCP URL (and already in headers) at runtime. |
Comments suppressed due to low confidence (1)
internal/cli/agent/frameworks/common/manifest_manager.go:105
- Current placeholder-sanitization makes URLs that are entirely an env var placeholder (e.g. "${FULL_URL}") fail scheme validation. This conflicts with the PR description’s goal of avoiding hardcoded MCP URLs; consider either allowing a full-placeholder URL (and deferring scheme validation to runtime) or explicitly documenting that scheme/host must be literal and only parts of the URL may be env-substituted (and adjust the validation error message accordingly).
// Replace ${VAR} placeholders with dummy values so url.Parse can
// validate the structure. The actual env vars are resolved at runtime.
// Port placeholders (e.g. :${PORT}) need a numeric replacement.
sanitized := envVarPortPattern.ReplaceAllString(srv.URL, ":8080")
sanitized = envVarPattern.ReplaceAllString(sanitized, "placeholder")
parsed, err := url.Parse(sanitized)
if err != nil {
return fmt.Errorf("mcpServers[%d]: url is not a valid URL: %v", i, err)
}
if parsed.Scheme != "http" && parsed.Scheme != "https" {
return fmt.Errorf("mcpServers[%d]: url scheme must be http or https", i)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
internal/cli/agent/frameworks/adk/python/templates/agent/mcp_tools.py.tmpl
Show resolved
Hide resolved
internal/cli/agent/frameworks/adk/python/templates/agent/mcp_tools.py.tmpl
Show resolved
Hide resolved
peterj
approved these changes
Mar 13, 2026
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.
Description
Allows resolving MCP URLs containing ${ENV_VAR} using dynamic URL resolution from environment variables at runtime. This is extremely useful to not hardcode the MCP URL in the agent code and instead specify them during deployment using environment variables, decoupling code from runtime values that are dynamic.
E.g.
arctl agent add-mcp --remote http://\${ADDRESS}/mcpChange Type
Changelog