Skip to content

datarobot_genai.drmcpbase.dynamic_tools.deployment.config

config

Pure configuration assembly for DataRobot deployment tools.

All functions in this module are pure: they take explicit arguments and do not call request_user_dr_client or access any request context.

get_deployment_base_url

get_deployment_base_url(deployment: Deployment, datarobot_endpoint: str) -> str

Compute the prediction base URL for a deployment.

Parameters:

Name Type Description Default
deployment Deployment

The DataRobot deployment object.

required
datarobot_endpoint str

The DataRobot API endpoint (e.g. https://app.datarobot.com).

required
Returns
Deployment-scoped prediction URL.
Raises
ValueError: If prediction server cannot be determined.
Source code in datarobot_genai/drmcpbase/dynamic_tools/deployment/config.py
def get_deployment_base_url(deployment: dr.Deployment, datarobot_endpoint: str) -> str:
    """Compute the prediction base URL for a deployment.

    Args:
        deployment: The DataRobot deployment object.
        datarobot_endpoint: The DataRobot API endpoint (e.g. https://app.datarobot.com).

    Returns
    -------
        Deployment-scoped prediction URL.

    Raises
    ------
        ValueError: If prediction server cannot be determined.
    """
    if _is_serverless_deployment(deployment):
        base_url = datarobot_endpoint
    elif "datarobot-nginx" in datarobot_endpoint:
        # On-prem / ST SaaS environments
        base_url = "http://datarobot-prediction-server:80/predApi/v1.0"
    else:
        # Regular prediction server
        pred_server = deployment.default_prediction_server
        if not pred_server:
            raise ValueError(f"Deployment {deployment.id} has no default prediction server")
        url = pred_server["url"]
        if not url:
            raise ValueError(f"Deployment {deployment.id} prediction server has no URL")
        base_url = f"{url}/predApi/v1.0"

    return urljoin(base_url.rstrip("/") + "/", f"deployments/{deployment.id}/")

build_deployment_auth_headers

build_deployment_auth_headers(deployment: Deployment, token: str) -> dict[str, str]

Build authentication headers for a deployment.

Parameters:

Name Type Description Default
deployment Deployment

The DataRobot deployment object.

required
token str

The bearer token to use for authentication.

required
Returns
Dictionary of authentication headers.
Source code in datarobot_genai/drmcpbase/dynamic_tools/deployment/config.py
def build_deployment_auth_headers(deployment: dr.Deployment, token: str) -> dict[str, str]:
    """Build authentication headers for a deployment.

    Args:
        deployment: The DataRobot deployment object.
        token: The bearer token to use for authentication.

    Returns
    -------
        Dictionary of authentication headers.
    """
    headers = {"Authorization": f"Bearer {token}"}
    if not _is_serverless_deployment(deployment):
        pred_server = deployment.default_prediction_server
        if pred_server:
            dr_key = pred_server.get("datarobot-key")
            if dr_key:
                headers["datarobot-key"] = dr_key
    return headers

assemble_deployment_tool_config

assemble_deployment_tool_config(deployment: Deployment, metadata: MetadataBase, base_url: str, auth_headers: dict[str, str]) -> ExternalToolRegistrationConfig

Assemble an ExternalToolRegistrationConfig from pre-computed parts.

This is the pure counterpart to create_deployment_tool_config in drmcp. All expensive lookups (URL, auth, metadata) are done by the caller and passed in as plain arguments.

Parameters:

Name Type Description Default
deployment Deployment

The DataRobot deployment object.

required
metadata MetadataBase

Resolved MetadataBase adapter.

required
base_url str

Pre-computed prediction base URL.

required
auth_headers dict[str, str]

Pre-computed authentication headers.

required
Returns
ExternalToolRegistrationConfig ready for tool creation.
Source code in datarobot_genai/drmcpbase/dynamic_tools/deployment/config.py
def assemble_deployment_tool_config(
    deployment: dr.Deployment,
    metadata: MetadataBase,
    base_url: str,
    auth_headers: dict[str, str],
) -> ExternalToolRegistrationConfig:
    """Assemble an ExternalToolRegistrationConfig from pre-computed parts.

    This is the pure counterpart to create_deployment_tool_config in drmcp.
    All expensive lookups (URL, auth, metadata) are done by the caller and
    passed in as plain arguments.

    Args:
        deployment: The DataRobot deployment object.
        metadata: Resolved MetadataBase adapter.
        base_url: Pre-computed prediction base URL.
        auth_headers: Pre-computed authentication headers.

    Returns
    -------
        ExternalToolRegistrationConfig ready for tool creation.
    """
    merged_headers = {**auth_headers, **metadata.headers}
    endpoint = metadata.endpoint.lstrip("/")
    tool_name = _get_tool_name(deployment, metadata)
    tool_description = _get_tool_description(deployment, metadata)

    return ExternalToolRegistrationConfig(
        name=tool_name,
        title=deployment.label,
        description=tool_description,
        method=metadata.method,
        base_url=base_url,
        endpoint=endpoint,
        headers=merged_headers,
        input_schema=metadata.input_schema,
        tags=set(),
    )