Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Do not require websockets for the OAuth callback server (#5693)

Asem ahmedf925e427aea2
diff --git a/fastmcp_slim/fastmcp/client/oauth_callback.py b/fastmcp_slim/fastmcp/client/oauth_callback.py
index ade1764dc..c31929229 100644
--- a/fastmcp_slim/fastmcp/client/oauth_callback.py
+++ b/fastmcp_slim/fastmcp/client/oauth_callback.py
@@ -235,7 +235,9 @@ def create_oauth_callback_server(
port=port,
lifespan="off",
log_level="warning",
- ws="websockets-sansio",
+ # The callback is a plain HTTP route, and `websockets` is not a
+ # dependency of a client-only install.
+ ws="none",
)
)
diff --git a/tests/client/test_oauth_callback_race.py b/tests/client/test_oauth_callback_race.py
index 417173ea9..b4127ad5a 100644
--- a/tests/client/test_oauth_callback_race.py
+++ b/tests/client/test_oauth_callback_race.py
@@ -62,6 +62,16 @@ def test_oauth_callback_server_uses_configured_host():
assert server.config.host == "localhost"
+def test_oauth_callback_server_does_not_need_websockets():
+ """The callback is a plain HTTP route, and `websockets` is not installed with
+ a client-only `fastmcp-slim[client]`, so uvicorn must not load a WebSocket
+ implementation for it."""
+ server = create_oauth_callback_server(port=find_available_port())
+ server.config.load()
+
+ assert server.config.ws_protocol_class is None
+
+
async def test_oauth_callback_result_captures_iss():
"""RFC 9207: the `iss` query parameter must survive from the raw callback
request through to `OAuthCallbackResult`, the same as `code` and `state`.