Skip to content

Resolve env templates in remote MCP server urls#279

Open
anticomputer wants to merge 1 commit into
mainfrom
anticomputer/streamable-url-env
Open

Resolve env templates in remote MCP server urls#279
anticomputer wants to merge 1 commit into
mainfrom
anticomputer/streamable-url-env

Conversation

@anticomputer

Copy link
Copy Markdown
Contributor

Apply swap_env to the url of sse and streamable toolboxes so a remote MCP endpoint can be sourced from the environment.

Why

Stdio toolboxes already env-template their args and env, and both remote transports env-template their headers, but the url was passed to the client verbatim. That meant a toolbox could not do:

server_params:
  kind: streamable
  url: "{{ env('CONTAINER_SHELL_URL') }}"

The literal {{ env(...) }} string reached MCPServerStreamableHttp and the connection failed. This blocks remote toolboxes whose endpoint is only known at runtime, such as a container_shell server reached over an allowlisted host service port.

What

mcp_client_params now runs swap_env(sp.url) for both the sse and streamable branches (guarded for None). Behavior is unchanged for urls without a template.

Tests

Added a parametrized test (streamable and sse) asserting that url: "{{ env('CONTAINER_SHELL_URL') }}" resolves to the concrete endpoint through mcp_client_params. Full suite: 547 passed, 2 skipped.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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() to server_params["url"] for sse and streamable transports (with a None guard).
  • Add a parametrized test covering both streamable and sse URL 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

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.

2 participants