Resolve env templates in remote MCP server urls#279
Open
anticomputer wants to merge 1 commit into
Open
Conversation
Apply swap_env to the url of sse and streamable toolboxes so a remote
endpoint can be sourced from the environment, for example
url: "{{ env('CONTAINER_SHELL_URL') }}". This matches how stdio args and
env and how headers are already resolved; previously the raw template
string was passed straight to the client.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0fc0c170-07c4-4eff-b075-3e1f420c4ba3
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes remote MCP toolbox configuration so url values for sse and streamable transports are env-templated (via swap_env), enabling endpoints to be provided at runtime through environment variables (consistent with existing templating for stdio args/env and remote headers).
Changes:
- Apply
swap_env()toserver_params["url"]forsseandstreamabletransports (with aNoneguard). - Add a parametrized test covering both
streamableandsseURL env-templating resolution.
Show a summary per file
| File | Description |
|---|---|
| src/seclab_taskflow_agent/mcp_utils.py | Env-templates remote MCP url for sse and streamable client params construction. |
| tests/test_mcp_utils.py | Adds regression test ensuring env-templated remote url resolves for both transports. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Low
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.
Apply
swap_envto theurlofsseandstreamabletoolboxes so a remote MCP endpoint can be sourced from the environment.Why
Stdio toolboxes already env-template their
argsandenv, and both remote transports env-template theirheaders, but theurlwas passed to the client verbatim. That meant a toolbox could not do:The literal
{{ env(...) }}string reachedMCPServerStreamableHttpand the connection failed. This blocks remote toolboxes whose endpoint is only known at runtime, such as acontainer_shellserver reached over an allowlisted host service port.What
mcp_client_paramsnow runsswap_env(sp.url)for both thesseandstreamablebranches (guarded forNone). Behavior is unchanged for urls without a template.Tests
Added a parametrized test (
streamableandsse) asserting thaturl: "{{ env('CONTAINER_SHELL_URL') }}"resolves to the concrete endpoint throughmcp_client_params. Full suite: 547 passed, 2 skipped.