Skip to content

datarobot_genai.drmcpbase.oauth_protected_resource_metadata.manager

manager

SupportedMethodsToSendBearerToken

Bases: Enum

How a client may present its bearer token to this resource server.

RFC 6750 defines three ways a client may present a bearer token: the Authorization header, a form-encoded body parameter, and a URI query parameter. RFC 9728 lets the resource server declare which of them it actually accepts, so a client doesn't have to guess.

We accept the header and nothing else. The other two are discouraged by RFC 6750 itself — a query-string token ends up in access logs, proxy logs, Referer headers and browser history; the body form constrains the content type.

This is a declaration, not an enforcement point: nothing reads it inbound, and the request side only ever looks at OAUTH_TOKEN_HEADERS. Adding a member here would change what is advertised without changing what is accepted.

Source code in datarobot_genai/drmcpbase/oauth_protected_resource_metadata/manager.py
class SupportedMethodsToSendBearerToken(Enum):
    """How a client may present its bearer token to this resource server.

    RFC 6750 defines three ways a client may present a bearer token: the
    Authorization header, a form-encoded body parameter, and a URI query
    parameter. RFC 9728 lets the resource server declare which of them it
    actually accepts, so a client doesn't have to guess.

    We accept the header and nothing else. The other two are discouraged by RFC
    6750 itself — a query-string token ends up in access logs, proxy logs,
    Referer headers and browser history; the body form constrains the content
    type.

    This is a declaration, not an enforcement point: nothing reads it inbound,
    and the request side only ever looks at ``OAUTH_TOKEN_HEADERS``. Adding a
    member here would change what is advertised without changing what is
    accepted.
    """

    HEADER = auto()

    def get_name_in_lower_case(self) -> str:
        return self.name.lower()

    @classmethod
    def get_complete_list_of_supported_methods(cls) -> list[str]:
        return [supported_method.get_name_in_lower_case() for supported_method in cls]

MCPOAuthProtectedResourceMetadataManager

Source code in datarobot_genai/drmcpbase/oauth_protected_resource_metadata/manager.py
class MCPOAuthProtectedResourceMetadataManager:
    def __init__(
        self, metadata_config: MCPOAuthProtectedResourceMetadataConfig | None = None
    ) -> None:
        self._metadata_config = metadata_config

    def load_config(self) -> MCPOAuthProtectedResourceMetadataConfig | None:
        """Return the configured metadata, or ``None`` when nothing was set."""
        if self._metadata_config is None or self._metadata_config.is_empty():
            return None
        return self._metadata_config

    @staticmethod
    def get_admin_config() -> MCPOAuthProtectedResourceMetadataAdminConfig:
        return MCPOAuthProtectedResourceMetadataAdminConfig(
            [SupportedMethodsToSendBearerToken.HEADER.get_name_in_lower_case()]
        )

    def get_protected_resource_metadata(self) -> MCPOAuthProtectedResourceMetadata | None:
        metadata_config = self.load_config()
        if not metadata_config:
            return None
        admin_config = self.get_admin_config()
        return MCPOAuthProtectedResourceMetadata.build(metadata_config, admin_config)

    def get_protected_resource_metadata_api_response(self) -> dict[str, Any] | None:
        metadata = self.get_protected_resource_metadata()
        if not metadata:
            return None
        return metadata.to_dict_without_null_attribute()

load_config

load_config() -> MCPOAuthProtectedResourceMetadataConfig | None

Return the configured metadata, or None when nothing was set.

Source code in datarobot_genai/drmcpbase/oauth_protected_resource_metadata/manager.py
def load_config(self) -> MCPOAuthProtectedResourceMetadataConfig | None:
    """Return the configured metadata, or ``None`` when nothing was set."""
    if self._metadata_config is None or self._metadata_config.is_empty():
        return None
    return self._metadata_config