[Client] StdioTransport hangs after successful initialize on Windows (fwrite EINVAL on the second request)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 47/100
Hướng nghiên cứu
Start with the client-side Mcp\Client\Transport\StdioTransport write path and how it handles child stdin on Windows; the issue provides a minimal client and server repro. Run the repro on Windows and trace why the second request fails with fwrite EINVAL while the first succeeds. Done means listTools() returns the advertised tool or fails promptly with a catchable exception.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment
- OS: Windows 11 (10.0.26200), x64
- PHP: 8.4.27 (CLI, NTS)
- mcp/sdk: 0.9.0
- Server: built with the same SDK (0.9.0), served over
Mcp\Server\Transport\StdioTransport - Triggered both directly via
Mcp\Client\Builderand throughsymfony/mcp-bundle1.0.0-BETA1
Description
On Windows, the client-side Mcp\Client\Transport\StdioTransport hangs after a successful
initialize handshake. The first request (initialize/discover) is written and answered fine; the
second request (tools/list) fails to write to the child's stdin and the call never returns.
Observed directly with the SDK client:
[info] Protocol connected to transport {"transport":"Mcp\\Client\\Transport\\StdioTransport"}
[info] Started MCP server process {"command":"php \"...\""}
[debug] Sending request {"id":1,"method":"server\/discover"}
[debug] Sent message to server {...}
[debug] Suspending fiber for response {"id":1}
[info] Client connected and initialized ← handshake OK
[debug] Sending request ← tools/list
[debug] Notice: fwrite(): Write of 270 bytes failed with errno=22 Invalid argument
[error] Failed to list the tools of MCP server "coroner", it contributes none for the next 60 seconds.
php client.php (repro below) then hangs indefinitely (> 5 minutes, no return, no exception —
had to kill the process). conn->listTools() never comes back.
Minimal repro
composer.json:
{
"require": {
"mcp/sdk": "^0.9.0",
"symfony/finder": "^8.0",
"psr/log": "^3.0"
}
}
server.php — a one-tool server, same SDK:
<?php
require __DIR__.'/vendor/autoload.php';
use Mcp\Server;
use Mcp\Server\Capability\Attribute\McpTool;
use Mcp\Server\Transport\StdioTransport;
class PingTools
{
#[McpTool(name: 'ping', description: 'Returns pong')]
public function ping(): string
{
return 'pong';
}
}
exit(
\Mcp\Server::builder()
->setServerInfo('ping-server', '0.0.1')
->setDiscovery(__DIR__, ['.'], excludeDirs: ['vendor'])
->build()
->run(new StdioTransport())
);
client.php:
<?php
require __DIR__.'/vendor/autoload.php';
use Mcp\Client\Builder;
use Mcp\Client\Transport\StdioTransport;
$client = (new Builder())->build();
$conn = $client->connect(new StdioTransport(
command: 'php',
args: [__DIR__.'/server.php'],
cwd: __DIR__,
));
$tools = $conn->listTools(); // ← hangs here on Windows
echo 'TOOLS: '.count($tools)."\n";
$result = $conn->callTool('ping', []);
echo 'ping: '.json_encode($result->content)."\n";
$client->disconnect();
php client.php → prints nothing after connect, hangs forever.
What I ruled out
- Not the protocol era: pinning the client to
2025-11-25changes nothing; the same failure
happens when the client negotiates the modern era (2026-07-28). - Not the server: the same server process responds correctly to a hand-rolled
proc_openclient (write JSON lines, blockingfgets) — initialize,notifications/initialized,
tools/list,tools/callall work, repeatedly, over many writes. - Not HTTP: the same server exposed over the bundle's HTTP transport works flawlessly with
the SDK's HTTP client.
Two additional observations that may help:
- The failing write is always the second one; the first (initialize/discover) succeeds.
- When the parent process is started from Git Bash, the spawned child additionally fails to
resolvephpat all ('php' is not recognized as an internal or external commandin the
child's stderr — POSIX-stylePATHnot survivingproc_openon Windows), which surfaces as
connection retries. That one is likely an environment quirk rather than an SDK bug, but it
makes the client's failure mode hard to diagnose: the child's stderr only shows up at debug
log level, while the user-facing error is a generic "Failed to list the tools …".
Expected behavior
listTools() returns the advertised tools on Windows, exactly like on Linux/macOS — or at the
very least fails fast with a catchable exception instead of hanging.
Workaround we ship
Serve over HTTP instead of STDIO for the bundled client (works perfectly on Windows):
transports: { http: true } + client transport: http.
- Ngôn ngữ chính
- PHP
- Star
- 1.7k
- Fork
- 206
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 100
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/php-sdk
-
[Client] `Builder::addRequestHandler()` rejects the SDK's own handlers under PHPStanCó thể đã có người làm @xixi-box đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
modelcontextprotocol/php-sdk#768 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Server] Handler type uses bare Closure, hard to decorate RegistryInterface under strict PHPStanĐang mởServer
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
modelcontextprotocol/php-sdk#468 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Client] `callTool()` cannot defer `input_required` or send a later retry (MRTR)Có thể đã có người làm @xixi-box đã nhận hôm nay. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
modelcontextprotocol/php-sdk#767 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Server] Answer arguments the input schema refuses with an `isError` result from revision 2025-11-25 onCó thể đã có người làm @falisco đã nhận hôm nay. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
modelcontextprotocol/php-sdk#763 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Server] A `float $x = INF` default makes `tools/list` fail for all toolsCó thể đã có người làm @andre-schade đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
modelcontextprotocol/php-sdk#756 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/php-sdk
Issue tương tự
-
Change: check an identifier filter the same way in every tool - the order of somcp_search_ordersĐang mởconsistency enhancement Orders
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
novalo-dev/Prestashop-MCP-Server#343 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
claude
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
sprain/sprainocchio#45 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
sync-en
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
sync-en
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày