INNER CODE UNIT · Python
_ssl_context
deeplethe/forkd · sdk/mcp/sandstorm_mcp/server.py:49
def _ssl_context() -> ssl.SSLContext | None:
if not SANDSTORM_URL.startswith("https://"):
return None
# As the Python SDK's Controller. A context rather than verify=<path>,
# which httpx deprecated, and cafile= replaces the default trust store
# rather than adding to it, which is what we want: the master's CA is
# the only issuer that should be able to sign for it.
return ssl.create_default_context(cafile=SANDSTORM_CA)
# Built once: loading a PEM per tool call is wasted work, and wait_for_text
# opens a client per poll. A bad SANDSTORM_CA stops the server here.
SSL_CONTEXT = _ssl_context()
def _headers(sandbox_token: str | None = None) -> dict[str, str]:
h = {"Content-Type": "application/json"}
if SANDSTORM_TOKEN: