[Client] HttpTransport resumes an Amp-suspended Fiber with a JSON-RPC error
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- php, symfony
- 领域
- api, backend, networking
调研方向
从 src/Client/Transport/HttpTransport.php 开始,跟踪 connect()、send() 和 processFiber(),然后对比报告中描述的 v0.7.1、v0.8.1 和 main 的行为。使用显式注入的基于 Amp 的 PSR-18 客户端以及初始化超时进行复现。完成的标准是:Amp 挂起的 Fibers 不会以 MCP 错误恢复,或者不受支持的客户端会被记录在文档中,并以相关错误拒绝。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
HTTP MCP initialization fails with a type error when the HTTP request uses Amp:
HTTP request failed: Amp\Internal\FutureIterator::consume(): Return value must be of type ?array, Mcp\Schema\JsonRpc\Error returned
The suspected cause is competing ownership of the same Fiber. HttpTransport::processFiber() checks whether the active Fiber is suspended, then resumes it with a JSON-RPC response or timeout error. However, an Amp-backed PSR-18 client can suspend that Fiber during sendRequest(), before the SDK reaches its own response wait. The timeout error then reaches Amp's suspension instead of the SDK's response wait.
To Reproduce
Observed in a CLI application using mcp/sdk v0.7.1, with HTTP client discovery left enabled. Three separate HTTP MCP servers fail during initialization, each after approximately 30 seconds.
Steps to isolate the suspected integration conflict:
- Use the SDK HTTP transport with Symfony's
Psr18Client, explicitly backed byAmpHttpClient, so backend selection does not depend on the host's cURL capabilities. - Configure an HTTP MCP endpoint and an initialization timeout.
- Connect through the SDK client.
- Observe whether the SDK resumes the Fiber while Amp is waiting for HTTP I/O, causing the type error above when the initialization timeout expires.
These isolation steps are proposed, not a separately executed minimal reproduction. The application failure and logs below are observed. We have not yet reproduced the failure with an explicitly injected Amp client or rerun it on v0.8.1.
Expected behavior
The HTTP transport must not resume a Fiber suspended by the injected HTTP client. Initialization should complete, or fail with the relevant transport or initialization error, without passing a JSON-RPC object into Amp's internal suspension.
If Fiber-suspending PSR-18 clients are unsupported, that restriction should be documented and enforced rather than failing with an unrelated return-type error.
Logs
Sanitized excerpts from the same application session on 2026-09-09. Each failure was for a different HTTP MCP server:
21:55:26.003694Z MCP server discovery failed
HTTP request failed: Amp\Internal\FutureIterator::consume(): Return value must be of type ?array, Mcp\Schema\JsonRpc\Error returned
21:55:56.000764Z MCP server discovery failed
HTTP request failed: Amp\Internal\FutureIterator::consume(): Return value must be of type ?array, Mcp\Schema\JsonRpc\Error returned
21:56:26.000375Z MCP server discovery failed
HTTP request failed: Amp\Internal\FutureIterator::consume(): Return value must be of type ?array, Mcp\Schema\JsonRpc\Error returned
Additional context
Application dependency lock:
mcp/sdk: v0.7.1, commit785fc3b9b7006ecc8a73322c939d96a4a7154345symfony/http-client: v8.1.5amphp/amp: v3.1.3amphp/http-client: v5.3.6revolt/event-loop: v1.0.9
Relevant source:
- SDK v0.7.1 HttpTransport:
connect()starts an active Fiber.send()calls the PSR-18 client inside it.processFiber()resumes the active Fiber with a JSON-RPC error when a pending request times out. - Amp v3.1.3 FutureIterator:
consume(): ?arrayreturns the value supplied to its event-loop suspension. Receiving an MCP error object here matches the observed exception. - SDK v0.8.1 HttpTransport: source inspection shows the same unconditional resume of a suspended active Fiber. The same logic was also present on
mainwhen checked on 2026-09-09. This is source evidence, not a runtime reproduction on those revisions.
Explicitly injecting Symfony's Psr18Client backed by CurlHttpClient is a proposed application workaround. It has not yet been validated for this failure. It would avoid the Amp path but would not fix Fiber ownership in the SDK.
A search of upstream issues and PRs for Amp, amphp, FutureIterator, and fiber did not find a matching report. PR #425 addresses HTTP status handling, not this suspension conflict.
- 主要语言
- PHP
- 星标
- 1.6k
- 派生
- 173
- 平均合并
- 2 天 49 分钟
- 30 天内合并 PR
- 23
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/php-sdk 的其他 Issue
-
[Server] Handler type uses bare Closure, hard to decorate RegistryInterface under strict PHPStan 未关闭Server
难度 1/5 1 小时以内 新手友好度 78/100
modelcontextprotocol/php-sdk#468 · 2 条评论 ·
-
needs confirmation needs maintainer action Server
难度 2/5 1-3 小时 新手友好度 68/100
modelcontextprotocol/php-sdk#398 · 1 个 reaction ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
modelcontextprotocol/php-sdk#370 ·
-
enhancement
难度 4/5 3-5 天 新手友好度 55/100
modelcontextprotocol/php-sdk#510 · 1 条评论 ·
-
bug P2 Server
难度 4/5 3-5 天 新手友好度 68/100
modelcontextprotocol/php-sdk#498 · 2 条评论 ·
查看 modelcontextprotocol/php-sdk 的全部 Issue
相似的 Issue
-
priority: p3
难度 2/5 1-3 小时 新手友好度 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
难度 2/5 1-3 小时 新手友好度 78/100
nextcloud/fulltextsearch#1011 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
-
难度 2/5 1-3 小时 新手友好度 78/100
phpstan/phpstan-doctrine#794 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
Automattic/static-site-importer#1767 ·