[v2] Expose the JSON-RPC request id to callers of request() (onRequestId)
维护者通常 1 天内回复
@Arham-Begani 已经在做这个了。
开始于 2026年10月24日。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 55/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- api
调研方向
Start with _requestWithSchemaViaCodec in packages/core-internal/src/shared/protocol.ts and trace how Protocol.request() builds and sends the JSON-RPC message. Check the RequestOptions definitions and related request tests to see how options are passed through. Done means the generated request id is available to callers before sending, with coverage for the callback or chosen return API.
由索引模型根据 Issue 内容生成。
描述
Summary
Protocol.request() assigns the JSON-RPC id internally (this._requestMessageId++) and never exposes it to the caller. An extension that opens a long-lived request, and then receives notifications correlated to that request, can't tell which request a given notification belongs to.
Why it matters
In the Events extension (SEP-3415, see #2945), a client may hold several events/stream requests open at once. Each stream starts with a notifications/events/active that confirms the subscription. On transports without per-request streams (stdio), the client needs the request id to match that notification to the open that produced it.
In @mastra/mcp we first bound each open to the first unclaimed active notification. That can mismatch subscriptions when one confirmation arrives late after a timeout. We now work around it by wrapping transport.send to observe the outgoing message and read its id. That relies on internal envelope details.
Proposal
Expose the id through a RequestOptions callback, for example onRequestId?: (id: RequestId) => void, invoked synchronously before the message is sent. An alternative would be a lower-level API that returns { id, result } for the request.
Versions
We hit this on @modelcontextprotocol/[email protected]. It's still present on main (c05225a6), in _requestWithSchemaViaCodec in packages/core-internal/src/shared/protocol.ts.
- 主要语言
- TypeScript
- 星标
- 13.8k
- 派生
- 2.5k
- 平均合并
- 6 天 23 小时
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/typescript-sdk 的其他 Issue
-
v2
难度 1/5 1 小时以内 新手友好度 72/100
modelcontextprotocol/typescript-sdk#3270 · 1 条评论 ·
维护者通常 1 天内回复
-
`callTool` with `allowInputRequired: true` throws on an `input_required` result when the tool declares an `outputSchema`可能已有人在做 @mgoldsborough 于 6 天前认领。 未关闭v2
难度 2/5 1-3 小时 新手友好度 78/100
modelcontextprotocol/typescript-sdk#3249 ·
维护者通常 1 天内回复
-
v2
难度 2/5 1-3 小时 新手友好度 68/100
modelcontextprotocol/typescript-sdk#3243 · 3 条评论 ·
维护者通常 1 天内回复
-
TypeScript client accepts an unknown `resultType` in the first `server/discover` reply可能已有人在做 @Tidehyc 于 7 天前认领。 未关闭v2
难度 2/5 1-3 小时 新手友好度 72/100
modelcontextprotocol/typescript-sdk#3235 · 3 条评论 ·
维护者通常 1 天内回复
-
UriTemplate.match() throws a TypeError on an empty expression it accepts可能已有人在做 @yunusemrejs 于 12 天前认领。 未关闭v1 v2
难度 2/5 1-3 小时 新手友好度 80/100
modelcontextprotocol/typescript-sdk#3221 · 3 条评论 ·
维护者通常 1 天内回复
查看 modelcontextprotocol/typescript-sdk 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 68/100
Vessel9817/onion-site-template#512 ·
维护者通常 1 天内回复
-
nightly-tests
难度 2/5 1-3 小时 新手友好度 68/100
BlackBeltTechnology/pi-agent-dashboard#1256 ·
维护者通常 1 天内回复
-
approved
难度 2/5 1-3 小时 新手友好度 85/100
fritzprix/libr-agent#3266 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
better-auth/better-auth#13101 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复