modelcontextprotocol / modelcontextprotocol/typescript-sdk

tools/call with null arguments returns -32603 (InternalError) instead of being accepted

オープン
#2,012 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug fix proposed P2 ready for work
主要言語
TypeScript
スター
13.4k
フォーク
2.2k
平均マージ
3日 15時間
マージ済み PR(30日)
4

説明

When a client sends a tools/call request where arguments is null (rather than omitted or {}), the SDK returns -32603 InternalError with a raw Zod validation message instead of accepting the request.

This affects every server built on the TypeScript SDK. Clients that serialize missing/empty fields as null (common in Go, Java, and C# JSON libraries) cannot call tools without arguments.

Reproduce

Send this over stdio to any server built with @modelcontextprotocol/sdk:

{"jsonrpc":"2.0","method":"initialize","id":1,"params":{"clientInfo":{"name":"test","version":"1.0"},"protocolVersion":"2025-11-25","capabilities":{}}}
{"jsonrpc":"2.0","method":"tools/call","id":2,"params":{"name":"echo","arguments":null}}

Expected

Request accepted (arguments treated as empty/undefined).

Actual

{
  "jsonrpc": "2.0",
  "id": 2,
  "error": {
    "code": -32603,
    "message": "[\n  {\n    \"expected\": \"record\",\n    \"code\": \"invalid_type\",\n    \"path\": [\"params\", \"arguments\"],\n    \"message\": \"Invalid input: expected record, received null\"\n  }\n]"
  }
}

Two problems:

  1. null rejected for an optional field. CallToolRequestParamsSchema uses .optional() which accepts undefined but not null. The MCP spec says arguments is optional; null should be treated as absent.

  2. Wrong error code. The error is -32603 (InternalError) instead of -32602 (InvalidParams). The protocol handler uses schema.parse() which throws a ZodError on failure. ZodError has no numeric code property, so the error handler at protocol.ts:672 falls back to ProtocolErrorCode.InternalError.

Impact

Tested against @modelcontextprotocol/server-everything: all 13 tools fail with this error when called with null arguments. Any Go, Java, or C# client that serializes missing fields as null will hit this on every server built with the TypeScript SDK.

Versions

  • @modelcontextprotocol/sdk main branch (also confirmed on published npm package)
  • Node.js v25.8.2

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

CallToolRequestParamsSchema と protocol.ts:672 周辺のプロトコルハンドラーから始め、次に、示されている JSON を使って stdio 経由でリクエストを再現します。tools/call が null の引数を存在しないものとして受け入れ、無効なリクエストデータが InternalError ではなくプロトコルの InvalidParams エラーを生成すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
api, backend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
66/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。