π The fast, Pythonic way to build MCP servers and clients.
fix oauth pyright
William Eastond1615dfe20d3
diff --git a/src/fastmcp/client/auth/oauth.py b/src/fastmcp/client/auth/oauth.pyindex 06f71253e..9a369bf4d 100644--- a/src/fastmcp/client/auth/oauth.py+++ b/src/fastmcp/client/auth/oauth.py@@ -3,6 +3,7 @@ from __future__ import annotationsimport asyncioimport jsonimport webbrowser+from _asyncio import Futurefrom pathlib import Pathfrom typing import Any, Literalfrom urllib.parse import urlparse@@ -18,6 +19,7 @@ from mcp.shared.auth import (OAuthToken as OAuthToken,)from pydantic import AnyHttpUrl, ValidationError+from uvicorn.server import Serverfrom fastmcp import settings as fastmcp_global_settingsfrom fastmcp.client.oauth_callback import (@@ -253,14 +255,16 @@ class OAuth(OAuthClientProvider):async def callback_handler(self) -> tuple[str, str | None]:"""Handle OAuth callback and return (auth_code, state)."""# Create a future to capture the OAuth response- response_future = asyncio.get_running_loop().create_future()+ response_future: Future[Any] = asyncio.get_running_loop().create_future()# Create server with the future- server = create_oauth_callback_server(+ server: Server = create_oauth_callback_server(port=self.redirect_port,server_url=self.server_base_url,response_future=response_future,)+ auth_code: str+ state: str | None# Run server until response is received with timeout logicasync with anyio.create_task_group() as tg:@@ -280,3 +284,5 @@ class OAuth(OAuthClientProvider):server.should_exit = Trueawait asyncio.sleep(0.1) # Allow server to shutdown gracefullytg.cancel_scope.cancel()++ raise RuntimeError("OAuth callback handler could not be started")\ No newline at end of file