datarobot_genai.drmcp.core.middleware
middleware
Wire drmcpbase FastMCP middleware to drtools auth resolution.
BaseAuthZMiddleware
Bases: BaseHTTPMiddleware, ABC
Applies the mcp_enable_oauth_claim_validation gate before any AuthZ work runs.
Subclasses implement run_authz and in order not to repeat the gate check, the
dispatch method is overridden to call the run_authz method.
Source code in datarobot_genai/drmcp/core/middleware.py
OAuthJWTTokenHandlerMiddleware
Bases: BaseAuthZMiddleware
ASGI middleware parsing OAuth JWT token and setting it in request scope. The parsed JWT token can be reused in the downstream validation (e.g., audience, tool scope).
Source code in datarobot_genai/drmcp/core/middleware.py
GeneralOAuthClaimValidationMiddleware
Bases: BaseAuthZMiddleware
ASGI middleware validating the audience claim in a JWT token. The naming general in this context means claim validations in this middleware is not MCP protocol specific check to be only triggerd by a specific MCP protocol (e.g., call a tool). This middleware is expected to be triggered after OAuthJWTTokenHandlerMiddleware which parses JWT token and sets it the request scope which is to be validated in this middleware.
Source code in datarobot_genai/drmcp/core/middleware.py
OAuthMCPToolCallScopeValidationMiddleware
Bases: BaseAuthZMiddleware
ASGI middleware validating the scope claim in a JWT token. It is now enforced only on
tools/call requests.
This middleware is expected to be triggered after OAuthJWTTokenHandlerMiddleware which
parses JWT token and sets it the request scope which is to be validated in this middleware.
Source code in datarobot_genai/drmcp/core/middleware.py
is_path_exempt_from_oauth_validation
Please refer datarobot_genai/drmcp/core/routes.py for the route definition.
Source code in datarobot_genai/drmcp/core/middleware.py
should_run_claim_validation
Whether the AuthZ validators run for this request.
mcp_enable_oauth_claim_validation gates all of them; exempt paths never run one.
Source code in datarobot_genai/drmcp/core/middleware.py
create_oauth_middleware
create_oauth_middleware(extract_auth_context: AuthContextExtractor | None = None) -> OAuthMiddleWare
Build OAuth middleware wired to drtools request/auth context injection.