Aias00 opened a new issue, #7761: URL: https://github.com/apache/shenyu/issues/7761
### Current limitation MCP request templates and examples advertise non-JSON request types, but body construction remains JSON-only: - [ShenyuToolCallback.java:487–502,582–587](https://github.com/apache/shenyu/blob/66d7d954ca37d651a5ad916f988a8081157a7ab4/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/callback/ShenyuToolCallback.java#L487) applies custom headers and then overwrites Content-Type with application/json for body methods. - [ShenyuToolCallback.java:650–656](https://github.com/apache/shenyu/blob/66d7d954ca37d651a5ad916f988a8081157a7ab4/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/callback/ShenyuToolCallback.java#L650) serializes the body JsonObject to a string. - [BodyWriterExchange.java:53–83](https://github.com/apache/shenyu/blob/66d7d954ca37d651a5ad916f988a8081157a7ab4/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/request/BodyWriterExchange.java#L53) branches on JSON/form/multipart Content-Type but returns the same string in all cases. - [MCP_TOOL_EXAMPLES.md:196](https://github.com/apache/shenyu/blob/66d7d954ca37d651a5ad916f988a8081157a7ab4/shenyu-plugin/shenyu-plugin-mcp-server/MCP_TOOL_EXAMPLES.md#L196) configures a form POST, and [line 364](https://github.com/apache/shenyu/blob/66d7d954ca37d651a5ad916f988a8081157a7ab4/shenyu-plugin/shenyu-plugin-mcp-server/MCP_TOOL_EXAMPLES.md#L364) configures a multipart file upload with a Base64 input. Preserving an explicitly configured header alone would not solve the missing form/multipart serialization. ### Executed evidence / limits A probe compiled the current BodyWriterExchange and captured its actual output for the same structured JSON body under three declared content types: ```text TYPE=application/json BODY={"name":"Ada & Bob"} TYPE=application/x-www-form-urlencoded BODY={"name":"Ada & Bob"} TYPE=multipart/form-data BODY={"name":"Ada & Bob"} ``` The form path does not produce `name=Ada+%26+Bob`, and the multipart path has neither a generated boundary nor parts. The callback's header override and bodyJson-to-string flow were inspected in source; this probe exercises the writer directly and does not execute a full MCP session or upload to an external service. A separate reviewer confirmed the end-to-end scope must include both header choice and body encoding. ### Proposed enhancement / acceptance criteria - Keep current JSON serialization for application/json. - Preserve an explicit supported template Content-Type; use JSON only as the documented default. - Serialize form bodies as properly escaped name/value pairs. - Build real multipart parts and generate a matching boundary parameter. Define how the documented Base64 file input maps to bytes, part names and filenames rather than sending Base64 inside a JSON object. - Make the checked-in form and upload examples consumable by their intended downstream handlers, and document unsupported input shapes clearly. - Maintain correct content length/stream ownership and avoid buffering a binary upload multiple times unnecessarily. ### Related existing work #6254 concerns custom header variable substitution; #6751 concerns URL/path/query argument encoding; #7453 concerns fixed target endpoints being overwritten by URL-valued arguments. #7737 concerns Spring route registration. No matching request-template form/multipart encoding issue was found in complete-title, open-PR and targeted MCP media-type searches. Header precedence and actual encoding are intentionally grouped as one enhancement. ### Reviewed revision Apache ShenYu 2.7.2-SNAPSHOT, `master@66d7d954ca37d651a5ad916f988a8081157a7ab4`. Priority P2 / Medium, high confidence in the described source/runtime behavior. Unit-test and CI issue categories excluded. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
