yera.tools.mcp.oauth_callback
OAuth callback parsing for MCP authorization.
Symbols
LoopbackOAuthCallbackServer
Serve one OAuth callback on a temporary loopback port.
Methods
LoopbackOAuthCallbackServer.__aenter__
__aenter__() → SelfStart the temporary callback server.
LoopbackOAuthCallbackServer.__aexit__
__aexit__(
exc_type: type[BaseException] | None,
exc_value: BaseException | None,
traceback: TracebackType | None,
) → NoneStop the callback server and release its socket.
LoopbackOAuthCallbackServer.await_result
await_result() → OAuthAuthorizationResultWait for the OAuth callback.
Returns
Validated callback values.
OAuthCallbackReceiver
Coordinate one OAuth callback with a waiting authorization flow.
Methods
OAuthCallbackReceiver.capture
capture(
parameters: Mapping[str, str],
) → NoneCapture callback parameters and release the waiter.
Parameters
Decoded OAuth callback query parameters.
OAuthCallbackReceiver.await_result
await_result() → OAuthAuthorizationResultWait for the captured callback result.
Returns
Validated authorization callback values.
Raises
If no callback arrives in time.
If callback validation failed.
OAuthCallbackSession
ProtocolExpose an OAuth redirect destination and its eventual result.
Methods
OAuthCallbackSession.await_result
await_result() → OAuthAuthorizationResultWait for the authorization callback.
Returns
The captured authorization code and state.
parse_oauth_callback
parse_oauth_callback(
parameters: Mapping[str, str],
) → OAuthAuthorizationResultValidate callback parameters returned by an authorization server.
Parameters
Decoded OAuth callback query parameters.
Returns
Authorization values required by the MCP SDK.
Raises
If the authorization server reports failure.
If the callback omits its authorization code or state.
register_oauth_callback_route
register_oauth_callback_route(
app: FastAPI,
receiver: OAuthCallbackReceiver,
path: str = '/oauth/callback',
) → NoneRegister an OAuth redirect endpoint on a FastAPI application.
Parameters
Application receiving the callback route.
Receiver coordinating the callback with OAuth setup.
URL path registered for the authorization redirect.