modelcontextprotocol / modelcontextprotocol/typescript-sdk
tools/call with null arguments returns -32603 (InternalError) instead of being accepted
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 13.4k
- Forks
- 2.2k
- Ø Merge
- 3 T. 15 Std.
- Gemergte PRs (30 T.)
- 4
Beschreibung
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:
-
nullrejected for an optional field.CallToolRequestParamsSchemauses.optional()which acceptsundefinedbut notnull. The MCP spec says arguments is optional;nullshould be treated as absent. -
Wrong error code. The error is
-32603(InternalError) instead of-32602(InvalidParams). The protocol handler usesschema.parse()which throws a ZodError on failure. ZodError has no numericcodeproperty, so the error handler atprotocol.ts:672falls back toProtocolErrorCode.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/sdkmain branch (also confirmed on published npm package)- Node.js v25.8.2
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit CallToolRequestParamsSchema und dem Protokoll-Handler rund um protocol.ts:672, und reproduziere dann die Anfrage über stdio mit dem gezeigten JSON. Erledigt ist die Aufgabe, wenn tools/call null-Argumente als nicht vorhanden akzeptiert und ungültige Anfragedaten den InvalidParams-Fehler des Protokolls statt InternalError erzeugen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- api, backend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 66/100