Pre-compile and unify MCP env-var regex interpolation
Cluster 2711 · mcp. Data as of
Nothing open on GitHub. Fix merged in #26240 on 15 May 2026. Check it covers your case.
The short answer
- Known?
- Yes. 4 related items grouped here, 1 issue already closed.
- Fix event
- A fix was merged to main in PR #26240. Check it covers your case. No release data is tracked.
- Tracker
- The maintainers' tracker marks this
resolved, deciding PR #26240. That is separate from the fix event. - Still open
- Nothing open on GitHub.
These items all address the same change: pre-compiling the environment variable interpolation regex in MCP-related code and unifying that interpolation logic across relevant modules. The members appear to be duplicate or iterative versions of the same fix or refactor.
Open issues0
Open PRs0
Fixes on record
-
#26240 fix(mcp): pre-compile env-var regex and unify interpolation
files:
hermes_cli/mcp_config.py,scripts/release.py,tools/mcp_tool.pyShow the diff
-
hermes_cli/mcp_config.py@@ -25,6 +25,7 @@ ) from hermes_cli.colors import Colors, color from hermes_constants import display_hermes_home +from tools.mcp_tool import _ENV_VAR_PATTERN logger = logging.getLogger(__name__) @@ -551,7 +552,7 @@ def cmd_mcp_test(args): for k, v in headers.items(): if isinstance(v, str) and ("key" in k.lower() or "auth" in k.lower()): # Mask the value - resolved = _interpolate_value(v) + resolved = _ENV_VAR_PATTERN.sub(lambda m: os.getenv(m.group(1), ""), v) if len(resolved) > 8: masked = resolved[:4] + "***" + resolved[-4:] else: @@ -581,13 +582,6 @@ def cmd_mcp_test(args): print() -def _interpolate_value(value: str) -> str: - """Resolve ``${ENV_VAR}`` references in a string.""" - def _replace(m): - return os.getenv(m.group(1), "") - return re.sub(r"\$\{(\w+)\}", _replace, value) - - # ─── hermes mcp login ──────────────────────────────────────────────────────── def cmd_mcp_login(args): -
scripts/release.py@@ -111,6 +111,7 @@ "[email protected]": "oswaldb22", "[redacted:email]": "AJV20", "[redacted:email]": "masonjames", + "[email protected]": "amethystani", "[redacted:email]": "liquidchen", "[redacted:email]": "subtract0", "[redacted:email]": "ReqX", -
tools/mcp_tool.py@@ -279,6 +279,11 @@ def _check_message_handler_support() -> bool: re.IGNORECASE, ) +# Pre-compiled pattern for ${VAR_NAME} style env-var interpolation. +# Supports any non-} characters in the variable name (hyphens, dots, etc.) +# so providers like MY-VAR or my.var work correctly. +_ENV_VAR_PATTERN = re.compile(r"\$\{([^}]+)\}") + # --------------------------------------------------------------------------- # Security helpers @@ -2104,7 +2109,7 @@ def _interpolate_env_vars(value): if isinstance(value, str): def _replace(m): return os.environ.get(m.group(1), m.group(0)) - return re.sub(r"\$\{([^}]+)\}", _replace, value) + return _ENV_VAR_PATTERN.sub(_replace, value) if isinstance(value, dict): return {k: _interpolate_env_vars(v) for k, v in value.items()} if isinstance(value, list):
-
2 PRs closed without merging
From the close comments: merged via another change 1 · other 1
Closed issues · 1
- Closed#2711Pre-compile env-var interpolation regex in mcp_tool.py
How this cluster was grouped
-
Link evidence (
structural links throughout): every member is connected by structural evidence: shared changed files, or a closing/superseded reference. -
Pairwise link density
0.50: the share of item pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36.1.00means every pair is linked.
Pick up a Lab task
Check whether a fix covers the open issues here, with your own agent. Bring back evidence for maintainers.
Open the LabAt a glance
- Subsystem
- mcp
- Merged PRs
- #26240
- Closed issues
- 1
- Attempts
- 2 PRs closed without merging
- Fix link checked
- 15 May 2026