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:
@@ -121,10 +121,13 @@ BUILTIN_SERVICES: list[str] = [
|
||||
|
||||
|
||||
def _filter_by_env(services: list[McpService]) -> list[McpService]:
|
||||
"""Whitelist by `MCP_SERVICES` env. Unset = no filter (backward compat)."""
|
||||
raw = os.environ.get("MCP_SERVICES")
|
||||
if not raw:
|
||||
"""Whitelist by `MCP_SERVICES` env. Unset = no filter (backward compat).
|
||||
Empty string = zero services (explicit operator choice, distinct from unset)."""
|
||||
if "MCP_SERVICES" not in os.environ:
|
||||
return services
|
||||
raw = os.environ["MCP_SERVICES"]
|
||||
if not raw:
|
||||
return []
|
||||
allowed = {n.strip() for n in raw.split(",") if n.strip()}
|
||||
return [s for s in services if s.name in allowed]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user