Skip to content

Commit e8673b4

Browse files
authored
Fix Python 3.13 websockets deprecation warning (#1949)
1 parent d7c6051 commit e8673b4

8 files changed

Lines changed: 19 additions & 9 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies = [
1515
"pydantic[email]>=2.11.7",
1616
"pyperclip>=1.9.0",
1717
"openapi-core>=0.19.5",
18+
"websockets>=15.0.1",
1819
]
1920

2021
requires-python = ">=3.10"
@@ -41,7 +42,6 @@ classifiers = [
4142
]
4243

4344
[project.optional-dependencies]
44-
websockets = ["websockets>=15.0.1"]
4545
openai = ["openai>=1.102.0"]
4646

4747
[dependency-groups]

src/fastmcp/client/oauth_callback.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ async def callback_handler(request: Request):
289289
port=port,
290290
lifespan="off",
291291
log_level="warning",
292+
ws="websockets-sansio",
292293
)
293294
)
294295

src/fastmcp/server/server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,6 +1566,7 @@ async def run_http_async(
15661566
config_kwargs: dict[str, Any] = {
15671567
"timeout_graceful_shutdown": 0,
15681568
"lifespan": "on",
1569+
"ws": "websockets-sansio",
15691570
}
15701571
config_kwargs.update(_uvicorn_config_from_user)
15711572

src/fastmcp/utilities/tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def _run_server(mcp_server: FastMCP, transport: Literal["sse"], port: int) -> No
6666
host="127.0.0.1",
6767
port=port,
6868
log_level="error",
69+
ws="websockets-sansio",
6970
)
7071
)
7172
uvicorn_server.run()

tests/client/test_sse.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ def run_nested_server(host: str, port: int) -> None:
9696
mount = Starlette(routes=[Mount("/nest-inner", app=app)])
9797
mount2 = Starlette(routes=[Mount("/nest-outer", app=mount)])
9898
server = uvicorn.Server(
99-
config=uvicorn.Config(app=mount2, host=host, port=port, log_level="error")
99+
config=uvicorn.Config(
100+
app=mount2, host=host, port=port, log_level="error", ws="websockets-sansio"
101+
)
100102
)
101103
server.run()
102104

tests/client/test_streamable_http.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def run_nested_server(host: str, port: int) -> None:
103103
port=port,
104104
log_level="error",
105105
lifespan="on",
106+
ws="websockets-sansio",
106107
)
107108
)
108109
server.run()

tests/server/auth/test_oauth_proxy.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,13 @@ async def start(self):
243243
self.port = s.getsockname()[1]
244244

245245
self.base_url = f"http://localhost:{self.port}"
246-
config = Config(self.app, host="localhost", port=self.port, log_level="error")
246+
config = Config(
247+
self.app,
248+
host="localhost",
249+
port=self.port,
250+
log_level="error",
251+
ws="websockets-sansio",
252+
)
247253
self.server = Server(config)
248254

249255
# Start server in background

uv.lock

Lines changed: 4 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)