datarobot_genai.dragent.deployment_urls
deployment_urls
Shared URL construction utilities for DataRobot deployment endpoints.
These helpers are the single source of truth for the URL patterns used to reach
a DataRobot-hosted A2A agent and to look up its agent card from the central
registry. Both the server side (advertising its own URL in the agent card) and
the client side (deriving the RPC base URL from a deployment_id) use these
functions so that the patterns stay in sync automatically.
When a workload is served from an Envoy-fronted enclave,
:func:resolve_external_workload_base is the agent's own gateway route and
:func:resolve_external_workload_api_endpoint is the enclave's /api/v2
base (memory service, and so on) — distinct from the control-hub
DATAROBOT_ENDPOINT.
join_mount_path
Append mount_path to base, returning a single trailing slash either way.
A generic composer, not an A2A-specific policy: DRAgentA2AConfig never actually
produces an empty mount_path (mounting A2A at the application root is rejected
there), but this function still handles it, collapsing to base's own trailing
slash rather than leaving a // behind. Slashes on both sides are stripped before
joining so callers need not agree on which side owns the separator.
Parameters
base:
Path the mount hangs off, e.g. "deployments/xyz/directAccess".
mount_path:
Path suffix A2A is mounted under, possibly empty.
Returns
str
"{base}/{mount_path}/", or "{base}/" when mount_path is empty.
Source code in datarobot_genai/dragent/deployment_urls.py
normalize_api_v2_endpoint
Return endpoint with exactly one trailing /api/v2 and no trailing slash.
Callers hand us DATAROBOT_ENDPOINT in both spellings — with and without
the /api/v2 suffix — and the deployment / workload routes live below it.
Normalising in one place keeps .../api/v2/api/v2/... and
.../deployments/... (missing /api/v2) out of the URL builders.
Parameters
endpoint: DataRobot endpoint
str
The endpoint with a single /api/v2 suffix.
Source code in datarobot_genai/dragent/deployment_urls.py
resolve_datarobot_endpoint
Return the effective DataRobot API endpoint from the environment.
Checks environment variables in priority order:
DATAROBOT_PUBLIC_API_ENDPOINT— preferred for externally reachable URLs (on-prem deployments often setDATAROBOT_ENDPOINTto an internal k8s address whileDATAROBOT_PUBLIC_API_ENDPOINTholds the public URL).DATAROBOT_ENDPOINT— standard SDK variable.- Built-in default (
https://app.datarobot.com/api/v2) whenrequireis False.
Parameters
require:
When True, raises :class:ValueError if neither env var is set.
When False (default), falls back to the built-in default endpoint.
Returns
str | None
The resolved endpoint string, or None only when require is
False and both env vars are unset (returns the default instead,
so in practice this always returns a non-None value when
require=False).
Raises
ValueError
If require=True and neither DATAROBOT_PUBLIC_API_ENDPOINT nor
DATAROBOT_ENDPOINT is set.
Source code in datarobot_genai/dragent/deployment_urls.py
resolve_external_workload_base
Return the API gateway's base URL for this workload, or None when not behind one.
An Envoy API gateway serves a workload from a per-enclave host and path prefix that
DATAROBOT_ENDPOINT cannot derive, so it injects both as env vars. Their presence is
the signal that the URLs composed elsewhere in this module are unreachable; both are
required. The host is accepted with or without a scheme (https:// assumed).
Returns
str | None
https://{host}/{prefix}, no trailing slash, or None when either var is unset.
Source code in datarobot_genai/dragent/deployment_urls.py
resolve_external_workload_api_endpoint
Return the enclave API gateway's /api/v2 endpoint, or None when not behind one.
Same presence signal as :func:resolve_external_workload_base (both host and prefix).
The prefix is this workload's own route and is not part of the platform API base —
only the host is used, so the DataRobot client talks to services on the enclave
(memory, and so on) rather than the control hub.
Returns
str | None
https://{host}/api/v2, no trailing slash, or None when either var is unset.
Source code in datarobot_genai/dragent/deployment_urls.py
build_deployment_a2a_url
build_deployment_a2a_url(endpoint: str, deployment_id: str, mount_path: str = A2A_MOUNT_PATH) -> str
Construct the A2A direct-access URL for a DataRobot deployment.
directAccess forwards the full prefixed path to the container, so the suffix
the agent actually mounted A2A under has to appear here too or the advertised URL
would not resolve.
Parameters
endpoint:
DataRobot API endpoint base URL, e.g. https://app.datarobot.com/api/v2.
A trailing slash is stripped before composing the URL.
deployment_id:
The DataRobot deployment ID.
mount_path:
Path suffix A2A is mounted under inside the container, "a2a" by default.
DRAgentA2AConfig never passes "" (it rejects mounting A2A at the
application root), but this generic composer still accepts it.
Returns
str
A URL of the form {endpoint}/deployments/{deployment_id}/directAccess/a2a/,
with a2a replaced by mount_path and omitted entirely when it is empty.
Source code in datarobot_genai/dragent/deployment_urls.py
build_deployment_agent_card_url
Construct the agent card registry URL for a DataRobot deployment.
Parameters
endpoint:
DataRobot API endpoint base URL, e.g. https://app.datarobot.com/api/v2.
A trailing slash is stripped before composing the URL.
deployment_id:
The DataRobot deployment ID.
Returns
str
A URL of the form {endpoint}/deployments/{deployment_id}/agentCard/.
Source code in datarobot_genai/dragent/deployment_urls.py
build_workload_a2a_url
Construct the A2A URL for a DataRobot workload.
The workload route forwards the full prefixed path to the container, so the suffix the agent actually mounted A2A under has to appear here too or the advertised URL would not resolve.
Parameters
endpoint:
DataRobot API endpoint base URL, e.g. https://app.datarobot.com/api/v2.
A trailing slash is stripped before composing the URL.
workload_id:
The DataRobot workload ID.
mount_path:
Path suffix A2A is mounted under inside the container, "a2a" by default.
DRAgentA2AConfig never passes "" (it rejects mounting A2A at the
application root), but this generic composer still accepts it.
Returns
str
A URL of the form {endpoint}/endpoints/workloads/{workload_id}/a2a/, with
a2a replaced by mount_path and omitted entirely when it is empty.
Source code in datarobot_genai/dragent/deployment_urls.py
build_deployment_mcp_url
Construct the MCP URL.
Parameters
endpoint:
DataRobot endpoint, with or without the /api/v2 suffix.
deployment_id:
The DataRobot deployment ID.
Returns
str
A URL of the form
{endpoint}/api/v2/deployments/{deployment_id}/directAccess/mcp.
Source code in datarobot_genai/dragent/deployment_urls.py
workload_mcp_url_from_endpoint
Append the MCP path to the endpoint the platform reported for a workload.
This is the only way to address a workload's MCP server: its route cannot be
composed from a workload ID, due to different endpoints for the API Gateway.
We look up the endpoint from the workload API
(:func:datarobot_genai.core.mcp.config.lookup_workload_endpoint) and append
the path to what it reports.
Parameters
workload_endpoint:
The workload's endpoint field as returned by the Workload API.
path:
Path the MCP server is served from, relative to the endpoint.
Returns
str
{workload_endpoint}/{path}, with duplicate slashes avoided.
Source code in datarobot_genai/dragent/deployment_urls.py
build_local_mcp_url
Construct the MCP URL for an MCP server running locally.
Parameters
port:
Port the local MCP server listens on.
host:
Host name, localhost by default.
Returns
str
A URL of the form http://localhost:{port}/mcp.
Source code in datarobot_genai/dragent/deployment_urls.py
build_workload_agent_card_url
Construct the agent card URL for a DataRobot workload.
Parameters
endpoint:
DataRobot API endpoint base URL, e.g. https://app.datarobot.com/api/v2.
A trailing slash is stripped before composing the URL.
workload_id:
The DataRobot workload ID.
Returns
str
A URL of the form {endpoint}/workloads/{workload_id}/agentCard/.
Source code in datarobot_genai/dragent/deployment_urls.py
build_agent_cards_registry_url
Construct the URL for the central agent card registry.
The central registry lists all agent cards within the user's organisation (tenant context) and requires only API-token authentication, not the per-agent AuthZ that the agent's own card endpoint demands.
Parameters
endpoint:
DataRobot API endpoint base URL, e.g. https://app.datarobot.com/api/v2.
A trailing slash is stripped before composing the URL.
Returns
str
A URL of the form {endpoint}/agentCards/.