Skip to content

Commit 5815e6c

Browse files
committed
fix: rebase on main and resolve merge conflicts in stdio subprocess logic
Revert "Merge branch 'main' into fix/windows_stdio_subprocess" This reverts commit d3e0975, reversing changes made to 1c6c6fb.
1 parent a550b02 commit 5815e6c

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,12 +585,15 @@ For low level server with Streamable HTTP implementations, see:
585585
- Stateful server: [`examples/servers/simple-streamablehttp/`](examples/servers/simple-streamablehttp/)
586586
- Stateless server: [`examples/servers/simple-streamablehttp-stateless/`](examples/servers/simple-streamablehttp-stateless/)
587587

588+
589+
588590
The streamable HTTP transport supports:
589591
- Stateful and stateless operation modes
590592
- Resumability with event stores
591-
- JSON or SSE response formats
593+
- JSON or SSE response formats
592594
- Better scalability for multi-node deployments
593595

596+
594597
### Mounting to an Existing ASGI Server
595598

596599
> **Note**: SSE transport is being superseded by [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http).

src/mcp/client/stdio/__init__.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ async def stdio_client(server: StdioServerParameters, errlog: TextIO = sys.stder
108108
read_stream_writer, read_stream = anyio.create_memory_object_stream(0)
109109
write_stream, write_stream_reader = anyio.create_memory_object_stream(0)
110110

111-
try:
112-
command = _get_executable_command(server.command)
111+
command = _get_executable_command(server.command)
113112

114113
# Open process with stderr piped for capture
115114
process = await _create_platform_compatible_process(
@@ -179,18 +178,12 @@ async def stdin_writer():
179178
yield read_stream, write_stream
180179
finally:
181180
# Clean up process to prevent any dangling orphaned processes
182-
try:
183-
if sys.platform == "win32":
184-
await terminate_windows_process(process)
185-
else:
186-
process.terminate()
187-
except ProcessLookupError:
188-
# Process already exited, which is fine
189-
pass
181+
if sys.platform == "win32":
182+
await terminate_windows_process(process)
183+
else:
184+
process.terminate()
190185
await read_stream.aclose()
191186
await write_stream.aclose()
192-
await read_stream_writer.aclose()
193-
await write_stream_reader.aclose()
194187

195188

196189
def _get_executable_command(command: str) -> str:

tests/client/test_stdio.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@
22

33
import pytest
44

5-
from mcp.client.session import ClientSession
6-
from mcp.client.stdio import (
7-
StdioServerParameters,
8-
stdio_client,
9-
)
10-
from mcp.shared.exceptions import McpError
5+
from mcp.client.stdio import StdioServerParameters, stdio_client
116
from mcp.shared.message import SessionMessage
12-
from mcp.types import CONNECTION_CLOSED, JSONRPCMessage, JSONRPCRequest, JSONRPCResponse
7+
from mcp.types import JSONRPCMessage, JSONRPCRequest, JSONRPCResponse
138

149
tee: str = shutil.which("tee") # type: ignore
15-
python: str = shutil.which("python") # type: ignore
1610

1711

1812
@pytest.mark.anyio

0 commit comments

Comments
 (0)