Neymar-10-JR opened a new pull request, #7823:
URL: https://github.com/apache/shenyu/pull/7823
Fixes #7761.
MCP request templates advertised form and multipart uploads, but the
callback overwrote Content-Type with application/json and forwarded JSON text
for every body type. This change encodes the mapped body according to the
configured media type while retaining JSON as the default.
- Use Spring's form and multipart writers, including charset-aware form
encoding and repeated fields/parts.
- Represent files explicitly as
{"filename":"hello.txt","content":"aGVsbG8=","contentType":"text/plain"}.
Decode standard Base64 once per file; default the optional file media type to
application/octet-stream. Strings remain text fields, and arrays create
repeated parts under the mapped field name.
- Generate a request-owned boundary before downstream headers are read and
use that same boundary when publishing the body. Remove stale framing headers
and compose body insertion with downstream subscription instead of subscribing
independently.
- Keep JSON-looking strings literal in form/multipart requests, preserve
existing JSON value formatting, and prevent empty body methods from forwarding
the outer MCP envelope.
- Reject unsupported media types, nested form values and invalid file
objects. Update both Chinese and English examples with executable tool
arguments.
Validation:
```bash
./mvnw -pl
shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-mcp-server
-am verify -DskipTests=false -Dmaven.javadoc.skip=true
```
All 16 selected reactor modules passed, including Checkstyle and Apache RAT.
The MCP Server module ran 176 tests with zero failures, errors or skipped
tests. Tests exercise the documented form, single-file and multiple-file
examples through the tool callback against in-process WebFlux downstream
handlers, asserting filenames and actual file bytes. Additional cases cover
Unicode, binary and empty files, repeated values, invalid input, boundary
consistency, empty bodies and JSON compatibility.
Upload arguments remain JSON/Base64 in memory; this does not introduce a
direct streaming upload API. Multipart output is emitted by Spring without
aggregating the complete encoded request body. The full-repository clean
install command was not run for this change.
Make sure that:
- [ ] You have read the [contribution
guidelines](https://shenyu.apache.org/community/contributor-guide).
- [x] You submit test cases (unit or integration tests) that back your
changes.
- [ ] Your local test passed `./mvnw clean install
-Dmaven.javadoc.skip=true`.
--
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]