[BUG] MessageHandlingResult.getResponseBodyAsJson serializes MCP types with plain ObjectMapper (wrong serializer)
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
- severity: Medium
- files: `shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/transport/MessageHandlingResult.java:87-98`
- description: `getResponseBodyAsJson()` does `new ObjectMapper().writeValueAsString(responseBody)`. When `responseBody` is a `McpSchema.JSONRPCMessage`, serialization uses a vanilla ObjectMapper without the MCP Jackson module that the configured `JacksonMcpJsonMapper` would apply. MCP sealed-record/polymorphic types may serialize incorrectly.
- impact: Streamable HTTP responses may be malformed when the body is an MCP schema object.
- suggested_fix: Reuse the transport's configured `McpJsonMapper`/`ObjectMapper` instead of `new ObjectMapper()`.
- confidence: Medium
- related_existing: none — PERF-22 is perf only.
---
_Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/06-medium-tiers.md`](docs/scan2-2026-08-02/06-medium-tiers.md)._
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/transport/MessageHandlingResult.java:87-98 and inspect getResponseBodyAsJson(), then trace the transport's configured McpJsonMapper/ObjectMapper. Done means Streamable HTTP responses serialize MCP schema objects with the configured MCP-aware mapper rather than a vanilla ObjectMapper.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100