Skip to content

datarobot_genai.drmcp.core.runtime_identity

runtime_identity

The module is intentionally standalone: drmcp does not depend on datarobot_genai.core or on dragent, so the few env var names and URL patterns are restated here rather than shared. Keeping the MCP and agent trees independently evolvable is worth more than removing this much duplication.

GatewayType

Bases: Enum

It is the gateway behind which MCP is deployed.

Source code in datarobot_genai/drmcp/core/runtime_identity.py
class GatewayType(Enum):
    """It is the gateway behind which MCP is deployed."""

    PUBLIC_API_BASED_GATEWAY = auto()
    NON_PUBLIC_API_BASED_GATEWAY = auto()

    def get_workload_deployment_url_segment(self, deployment_id: str) -> str:
        if self == GatewayType.PUBLIC_API_BASED_GATEWAY:
            url_segment = f"/endpoints/workloads/{deployment_id}/"
        else:
            url_segment = f"/workloads/{deployment_id}/"
        return url_segment.strip("/")

    def get_mlops_deployment_url_segment(self, deployment_id: str) -> str:
        if self == GatewayType.PUBLIC_API_BASED_GATEWAY:
            url_segment = f"/deployments/{deployment_id}/directAccess/"
            return url_segment.strip("/")
        else:
            raise ValueError(
                "MLOps deployment URL is not supported in a non-public-API-based gateway."
            )

get_deployment_id

get_deployment_id() -> str | None

Return the platform-injected deployment id, or None when not on a deployment.

Source code in datarobot_genai/drmcp/core/runtime_identity.py
def get_deployment_id() -> str | None:
    """Return the platform-injected deployment id, or None when not on a deployment."""
    return _env(DEPLOYMENT_ID_ENV)

get_workload_id

get_workload_id() -> str | None

Return the platform-injected workload id, or None when not on a workload.

Source code in datarobot_genai/drmcp/core/runtime_identity.py
def get_workload_id() -> str | None:
    """Return the platform-injected workload id, or None when not on a workload."""
    return _env(WORKLOAD_ID_ENV)

resolve_datarobot_endpoint

resolve_datarobot_endpoint() -> str | None

Return the externally reachable DataRobot API endpoint, or None when unset.

Prefers DATAROBOT_PUBLIC_API_ENDPOINT over DATAROBOT_ENDPOINT; see the module docstring for why that order matters and why there is no default.

Source code in datarobot_genai/drmcp/core/runtime_identity.py
def resolve_datarobot_endpoint() -> str | None:
    """Return the externally reachable DataRobot API endpoint, or None when unset.

    Prefers ``DATAROBOT_PUBLIC_API_ENDPOINT`` over ``DATAROBOT_ENDPOINT``; see
    the module docstring for why that order matters and why there is no default.
    """
    return _env(PUBLIC_ENDPOINT_ENV) or _env(ENDPOINT_ENV)

build_deployment_url

build_deployment_url(endpoint: str, deployment_id: str, path: str) -> str

{endpoint}/deployments/{deployment_id}/directAccess/{path}.

Source code in datarobot_genai/drmcp/core/runtime_identity.py
def build_deployment_url(endpoint: str, deployment_id: str, path: str) -> str:
    """``{endpoint}/deployments/{deployment_id}/directAccess/{path}``."""
    base = endpoint.rstrip("/")
    return f"{base}/deployments/{deployment_id}/{DEPLOYMENT_DIRECT_ACCESS_SEGMENT}/{path}"

build_workload_url

build_workload_url(endpoint: str, workload_id: str, path: str) -> str

{endpoint}/endpoints/workloads/{workload_id}/{path}.

Source code in datarobot_genai/drmcp/core/runtime_identity.py
def build_workload_url(endpoint: str, workload_id: str, path: str) -> str:
    """``{endpoint}/endpoints/workloads/{workload_id}/{path}``."""
    base = endpoint.rstrip("/")
    return f"{base}/{WORKLOAD_ENDPOINTS_SEGMENT}/{workload_id}/{path}"