Skip to content

datarobot_genai.drmcp.core.middleware

middleware

Wire drmcpbase FastMCP middleware to drtools auth resolution.

create_oauth_middleware

create_oauth_middleware(extract_auth_context: AuthContextExtractor | None = None) -> OAuthMiddleWare

Build OAuth middleware wired to drtools request/auth context injection.

Source code in datarobot_genai/drmcp/core/middleware.py
def create_oauth_middleware(
    extract_auth_context: AuthContextExtractor | None = None,
) -> OAuthMiddleWare:
    """Build OAuth middleware wired to drtools request/auth context injection."""
    return OAuthMiddleWare(
        inject_headers=set_request_headers,
        extract_auth_context=extract_auth_context or extract_auth_context_from_headers,
        set_auth_context=set_auth_context,
        auth_context_state_key=AUTH_CTX_KEY,
    )

initialize_oauth_middleware

initialize_oauth_middleware(mcp: Any) -> None

Register OAuth middleware with the template MCP server.

Source code in datarobot_genai/drmcp/core/middleware.py
def initialize_oauth_middleware(mcp: Any) -> None:
    """Register OAuth middleware with the template MCP server."""
    register_oauth_middleware(mcp, create_oauth_middleware())