A handler's -32002 (resource not found) is rewritten to -32602 on 2025-era sessions
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, typescript
調査の方向性
The issue identifies the era codecs and ProtocolError.fromError as the affected paths, but gives no file paths or test names. Start by locating the -32002 mapping and the client error conversion, then read the protocol version negotiation and existing error tests. Done means a 2025-11-25 session preserves -32002 on the wire and client error, while the 2026-07-28 behavior remains correct.
索引モデルが issue の本文から書いたものです。
説明
Packages: @modelcontextprotocol/server and @modelcontextprotocol/client 2.4.0
Compared with: @modelcontextprotocol/sdk 1.32.1
Runtime: Node.js 24.22.1
Summary
Both era codecs map an error code of -32002 to -32602 (encodeErrorCode: (code) => code === -32002 ? -32602 : code), so a resources/read handler that throws -32002 answers -32602 on a session that negotiated 2025-11-25, not only on 2026-07-28. SEP-2164 (implemented here in #2194) moves a missing resource to -32602 in the 2026-07-28 revision, but the 2025-11-25 specification still lists -32002, and servers and clients built on 1.x send and check that code. On the client side, ProtocolError.fromError turns a -32002 whose data carries uri into ResourceNotFoundError, whose code is -32602, so a client can no longer see that the server sent -32002.
Reproduction
const { Server, InMemoryTransport, ProtocolError } = require('@modelcontextprotocol/server');
const { Client } = require('@modelcontextprotocol/client');
(async () => {
const server = new Server({ name: 'repro', version: '1.0.0' }, { capabilities: { resources: {} } });
server.setRequestHandler('resources/read', async (request) => {
throw new ProtocolError(-32002, `Resource not found: ${request.params.uri}`, { uri: request.params.uri });
});
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
await server.connect(serverTransport);
const client = new Client({ name: 'c', version: '1' });
await client.connect(clientTransport);
console.log('negotiated:', client.getNegotiatedProtocolVersion()); // 2025-11-25
const deliver = clientTransport.onmessage;
clientTransport.onmessage = (message, extra) => {
if (message.error) console.log('wire error code:', message.error.code);
deliver(message, extra);
};
const error = await client.readResource({ uri: 'file:///missing.txt' }).catch((e) => e);
console.log('client error:', error.constructor.name, error.code);
})();
Expected (2025-11-25 session)
wire error code: -32002
client error: … -32002
(1.32.1 prints -32002 for both.)
Actual
wire error code: -32602
client error: ResourceNotFoundError -32602
Suggestion
Map -32002 to -32602 only in the 2026-07-28 codec, so a 2025-era session keeps the code its revision documents, or let a server opt out of the mapping. On the client, keep the received code on the error (for example as code, with the normalized code elsewhere), so code written against 2025-era servers keeps working.
- 主要言語
- TypeScript
- スター
- 13.8k
- フォーク
- 2.5k
- 平均マージ
- 6日 23時間
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 件 ·
メンテナーはふだん 1 日以内に返信