docs(mcp): fix spec inconsistency: empty MCP_SERVICES means zero services

Self-review caught a contradiction: the spec's prose said
'MCP_SERVICES="" (empty) -> zero services mount' but the code example
in the spec used 'if not raw: return services' which conflates unset
and empty (both fall through to 'all mount').

Fix: _filter_by_env now uses 'MCP_SERVICES' not in os.environ to
distinguish unset (backward compat: all mount) from empty (explicit
choice: zero mount). Test cases already specified the correct behavior.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-06-30 11:13:23 +00:00
committed by tao.chen
co-authored by Claude Fable 5
parent 579e81af82
commit f35707c9f3
@@ -121,10 +121,13 @@ BUILTIN_SERVICES: list[str] = [
def _filter_by_env(services: list[McpService]) -> list[McpService]: def _filter_by_env(services: list[McpService]) -> list[McpService]:
"""Whitelist by `MCP_SERVICES` env. Unset = no filter (backward compat).""" """Whitelist by `MCP_SERVICES` env. Unset = no filter (backward compat).
raw = os.environ.get("MCP_SERVICES") Empty string = zero services (explicit operator choice, distinct from unset)."""
if not raw: if "MCP_SERVICES" not in os.environ:
return services return services
raw = os.environ["MCP_SERVICES"]
if not raw:
return []
allowed = {n.strip() for n in raw.split(",") if n.strip()} allowed = {n.strip() for n in raw.split(",") if n.strip()}
return [s for s in services if s.name in allowed] return [s for s in services if s.name in allowed]