yera.tools.mcp.oauth_callback
OAuth callback parsing for MCP authorization.
Symbols
LoopbackOAuthCallbackServer
Serve one OAuth callback on a temporary loopback port.
Methods
LoopbackOAuthCallbackServer.__init__
__init__(
timeout_seconds: float,
host: str = '127.0.0.1',
port: int = 0,
) → NoneConfigure a temporary OAuth callback server.
Parameters
Maximum time to wait for authorization.
Loopback interface on which to listen.
Fixed loopback port, or 0 to allocate an ephemeral port.
Raises
If host is not a loopback address or port is
outside the valid TCP port range.
LoopbackOAuthCallbackServer.__aenter__
__aenter__() → SelfStart the temporary callback server.
Returns
The running callback server.
Raises
If the requested loopback endpoint cannot be opened.
LoopbackOAuthCallbackServer.__aexit__
__aexit__(
exc_type: type[BaseException] | None,
exc_value: BaseException | None,
traceback: TracebackType | None,
) → NoneStop the callback server and release its socket.
Parameters
Type of exception leaving the managed context, if any.
Exception leaving the managed context, if any.
Traceback associated with the exception, if any.
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.__init__
__init__(
timeout_seconds: float,
) → NoneConfigure the callback deadline.
Parameters
Maximum time to wait for a callback.
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 processing finishes without a result or captured error.
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.