Skip to content

Commit 114f3f4

Browse files
committed
Merge origin/main (websocket removal, stdio test rebuild, timeout deflake)
- src/mcp/client/websocket.py: accepted main's deletion over our resync_tracer addition - uv.lock: kept main's removal of the ws extra and websockets package, kept our opentelemetry-sdk dev dependency
2 parents 3853a6d + b478bff commit 114f3f4

26 files changed

Lines changed: 2670 additions & 1471 deletions

docs/migration.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,50 @@ The `headers`, `timeout`, `sse_read_timeout`, and `auth` parameters have been re
105105

106106
Note: `sse_client` retains its `headers`, `timeout`, `sse_read_timeout`, and `auth` parameters — only the streamable HTTP transport changed.
107107

108+
### `terminate_windows_process` removed
109+
110+
The deprecated `mcp.os.win32.utilities.terminate_windows_process` function has been
111+
removed. Process termination is handled internally by the `stdio_client` context
112+
manager; there is no replacement API. The Windows tree-termination helper
113+
`terminate_windows_process_tree` no longer accepts a `timeout_seconds` argument —
114+
the value was never used (Job Object termination is immediate).
115+
116+
### `stdio_client` no longer kills children of a gracefully-exited server on POSIX
117+
118+
When a server exits on its own after `stdio_client` closes its stdin, background
119+
child processes the server leaves behind are no longer killed on POSIX — their
120+
lifetime is the server's business. The old behavior was a side effect of a shutdown
121+
wait gated on the stdio pipes closing rather than on process exit: a child holding
122+
an inherited pipe made a well-behaved server look hung, so its whole process tree
123+
was killed. (That gating is an asyncio behavior specific to Python 3.11+ — on
124+
Python 3.10 and the trio backend the old wait already resolved on process exit, so
125+
the spurious kill never fired there.) A server that does not exit within the grace
126+
period is still terminated
127+
along with its entire process group. On Windows, children stay in the server's Job
128+
Object and are still killed at shutdown — now deterministically when the job handle
129+
is closed, rather than whenever the handle happened to be garbage-collected.
130+
131+
If you relied on `stdio_client` killing everything the server spawned, make the
132+
server terminate its own children on shutdown (its stdin reaching EOF is the
133+
shutdown signal), or clean up the process tree from the host application after
134+
`stdio_client` exits.
135+
136+
Two related shutdown refinements: `stdio_client` now closes its end of the pipes
137+
deterministically at shutdown, so a surviving child that keeps writing to an
138+
inherited stdout receives `EPIPE`/`SIGPIPE` once the client is gone (previously the
139+
pipe lingered until garbage collection); and a failed write to a server that is
140+
still running now surfaces as a closed connection (`CONNECTION_CLOSED`) on the read
141+
side instead of leaving requests waiting indefinitely.
142+
143+
`terminate_posix_process_tree` now requires the process to lead its own process
144+
group (spawned with `start_new_session=True`); the `getpgid()` lookup and the
145+
per-process terminate/kill fallback are gone. The win32 utilities logger is now
146+
named `mcp.os.win32.utilities` (was `client.stdio.win32`).
147+
148+
### WebSocket transport removed
149+
150+
The WebSocket transport has been removed: `mcp.client.websocket.websocket_client`, `mcp.server.websocket.websocket_server`, and the `ws` optional dependency extra (`mcp[ws]`) no longer exist. WebSocket was never part of the MCP specification. Use the streamable HTTP transport instead (`mcp.client.streamable_http.streamable_http_client` on the client, `streamable_http_app()` on the server), which supports bidirectional communication with server-to-client streaming over standard HTTP.
151+
108152
### Removed type aliases and classes
109153

110154
The following deprecated type aliases and classes have been removed from `mcp.types`:

pyproject.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ dependencies = [
5050
[project.optional-dependencies]
5151
rich = ["rich>=13.9.4"]
5252
cli = ["typer>=0.16.0", "python-dotenv>=1.0.0"]
53-
ws = ["websockets>=15.0.1"]
5453

5554
[project.scripts]
5655
mcp = "mcp.cli:app [cli]"
@@ -79,8 +78,8 @@ build-constraint-dependencies = [
7978

8079
[dependency-groups]
8180
dev = [
82-
# We add mcp[cli,ws] so `uv sync` considers the extras.
83-
"mcp[cli,ws]",
81+
# We add mcp[cli] so `uv sync` considers the extras.
82+
"mcp[cli]",
8483
"pyright>=1.1.400",
8584
"pytest>=8.4.0",
8685
"ruff>=0.8.5",
@@ -209,9 +208,6 @@ addopts = """
209208
"""
210209
filterwarnings = [
211210
"error",
212-
# This should be fixed on Uvicorn's side.
213-
"ignore::DeprecationWarning:websockets",
214-
"ignore:websockets.server.WebSocketServerProtocol is deprecated:DeprecationWarning",
215211
# pywin32 internal deprecation warning
216212
"ignore:getargs.*The 'u' format is deprecated:DeprecationWarning",
217213
]

0 commit comments

Comments
 (0)