Skip to main content
OAuth callback server implementation.

CallbackResponse

from mcp_use.auth.oauth_callback import CallbackResponse

Attributes
code
str | None
required
String value
state
str | None
required
String value
error
str | None
required
String value
error_description
str | None
required
String value
error_uri
str | None
required
String value

method init

Parameters
code
str | None
default:"None"
String value
state
str | None
default:"None"
String value
error
str | None
default:"None"
String value
error_description
str | None
default:"None"
String value
error_uri
str | None
default:"None"
String value
Signature
def __init__(code: str | None = None, state: str | None = None, error: str | None = None, error_description: str | None = None, error_uri: str | None = None):

OAuthCallbackServer

from mcp_use.auth.oauth_callback import OAuthCallbackServer

method init

Initialize the callback server.Parameters
port
int
required
Port to listen on.
Signature
def __init__(port: int):

method shutdown

Shutdown the callback server.Signature
def shutdown():

method start

Start the callback server and return the redirect URI.Returns
returns
str
Signature
def start():

method wait_for_code

Wait for the OAuth callback with a timeout (default 5 minutes).Parameters
timeout
float
default:"300"
Timeout duration
Returns
returns
mcp_use.auth.oauth_callback.CallbackResponse
Signature
def wait_for_code(timeout: float = 300):
I