Servlet-based server transports read request body with wrong charset encoding
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 64/100
Direzione di ricerca
Individua le implementazioni di trasporto basate su servlet che chiamano request.getReader(), quindi confronta la gestione del corpo della richiesta con la correzione di StdioServerTransportProvider in PR 826. Aggiungi una copertura di regressione usando un valore JSON-RPC non ASCII e verifica che le richieste senza un charset esplicito conservino i caratteri originali.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug description
The servlet-based server transports call request.getReader() without first calling request.setCharacterEncoding("UTF-8"). Per the Jakarta Servlet spec, getReader() defaults to ISO-8859-1 when the request's Content-Type doesn't include an explicit charset parameter. Since Content-Type: application/json (without charset) is standard and correct per RFC 8259, any non-ASCII characters in the JSON-RPC request body are silently corrupted.
This affects everything in the request payload — tool names, argument values, notification data — for any MCP client that doesn't redundantly declare charset=utf-8 in its Content-Type header. The analogous issue in StdioServerTransportProvider was fixed in https://github.com/modelcontextprotocol/java-sdk/pull/826.
Environment
- MCP Java SDK: 1.0.0
- Java: 21
- No Spring AI or vector store involved — this is a bug in the core servlet request reading logic, not specific to any framework or integration.
Steps to reproduce
- Start an MCP server using any of the servlet-based transports
- Send a tool call with a non-ASCII string argument, e.g. a unicode escape sequence like \u2014 (em dash —).
- The server receives mojibake (e.g. — → â).
Expected behavior
Non-ASCII characters in the JSON-RPC request body (tool names, argument values, etc.) should be preserved correctly. JSON is UTF-8 by definition, so the server should decode request bodies as UTF-8 regardless of whether the client includes charset=utf-8 in the Content-Type header.
Related
- Lingua principale
- Java
- Stelle
- 3.7k
- Fork
- 1.1k
- Merge medio
- 1g 15h
- PR unite (30g)
- 9
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelcontextprotocol/java-sdk
-
area/transport bug P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
modelcontextprotocol/java-sdk#1136 ·
-
area/client bug P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
modelcontextprotocol/java-sdk#1124 · 1 commento ·
-
ServerCapabilities.logging is added unconditionally, overriding the caller's explicit capabilities Apertabug P2 ready for work
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
modelcontextprotocol/java-sdk#1086 · 1 commento ·
-
enhancement good first issue P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
modelcontextprotocol/java-sdk#1067 ·
-
bug P2 ready for work
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
modelcontextprotocol/java-sdk#898 · 1 commento ·
Tutte le issue di modelcontextprotocol/java-sdk
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
bug needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 94/100
objectionary/hone-maven-plugin#1061 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
spring-projects/spring-modulith#1895 ·