MCPcopy Create free account
hub / github.com/HKUDS/OpenSpace / get_api_base

Function get_api_base

openspace/cloud/auth.py:63–79  ·  view source on GitHub ↗

Resolve OpenSpace API base URL (for CLI scripts). Priority: ``cli_override`` → env var → host agent config → default.

(cli_override: Optional[str] = None)

Source from the content-addressed store, hash-verified

61
62
63def get_api_base(cli_override: Optional[str] = None) -> str:
64 """Resolve OpenSpace API base URL (for CLI scripts).
65
66 Priority: ``cli_override`` → env var → host agent config → default.
67 """
68 from openspace.host_detection import read_host_mcp_env
69
70 if cli_override:
71 return cli_override.rstrip("/")
72 env_base = os.environ.get("OPENSPACE_API_BASE", "").strip()
73 if env_base:
74 return env_base.rstrip("/")
75 mcp_env = read_host_mcp_env()
76 cfg_base = str(mcp_env.get("OPENSPACE_API_BASE", "")).strip()
77 if cfg_base:
78 return cfg_base.rstrip("/")
79 return OPENSPACE_DEFAULT_BASE
80
81
82def get_auth_headers_or_exit() -> Dict[str, str]:

Callers 2

mainFunction · 0.90
mainFunction · 0.90

Calls 2

read_host_mcp_envFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected