Spaces:
Paused
Paused
File size: 1,386 Bytes
fd33581 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | """Pure runtime-configuration policies used by the Space boot process."""
from __future__ import annotations
from typing import Any
def apply_optional_mcp_policy(
config: dict[str, Any],
*,
linear_enabled: bool,
linear_tokens_available: bool,
unreal_enabled: bool,
) -> dict[str, Any]:
"""Park unavailable optional MCP entries without touching other servers.
The returned dictionary describes what changed and why. ``config`` is
mutated intentionally so the caller can persist the same authoritative
state that every Hermes child process will subsequently load.
"""
result: dict[str, Any] = {"removed": [], "linear_unconfigured": False}
servers = config.get("mcp_servers")
if not isinstance(servers, dict):
return result
for name in list(servers):
normalized = str(name).strip().lower()
if normalized == "unreal-engine" and not unreal_enabled:
servers.pop(name, None)
result["removed"].append(str(name))
elif normalized == "linear":
if not linear_enabled:
servers.pop(name, None)
result["removed"].append(str(name))
elif not linear_tokens_available:
servers.pop(name, None)
result["removed"].append(str(name))
result["linear_unconfigured"] = True
return result
|