123123213weqw opened a new pull request, #5756:
URL: https://github.com/apache/rocketmq-dashboard/pull/5756

   ## What\n\n`McpToolRegistrar.callTool` — the handler behind the in-process 
stdio MCP server the hosted agent (`claude`/`qoder` via `rmqctl`) calls — had 
two gaps the HTTP tool paths (`ToolController`, `McpToolController`) do 
not:\n\n1. **No payload budget.** `AiPayloadGuard.validateToolInvocation` 
bounds tool name and arguments to 256 KiB of UTF-8 on every HTTP entry point, 
but the stdio handler never checked it. MCP arguments are model-controlled — a 
model echoing a huge string into `body` flowed through unbounded.\n2. 
**Uncontained failures.** The handler caught only `ToolExecutionException`. 
Anything else — concretely, `serialize` throwing `IllegalStateException` for a 
result Jackson cannot map — escaped the handler. The MCP SDK treats a throwing 
handler as a failure of the whole exchange, killing the agent's tool channel 
for the rest of the run instead of reporting one bad call.\n\n## The fix\n\n- 
Validate the invocation through the shared guard before dispatching, m
 apping a `BusinessException` refusal to a `TOOL_PAYLOAD_INVALID` error 
result.\n- Catch the uncaught `RuntimeException` and return an 
`EXECUTION_FAILED` error result carrying the reason, so the agent sees the 
failure and carries on.\n- `AiPayloadGuard` becomes public (class + 
`validateToolInvocation`) so the `ops.ai.mcp` package can share it; no 
behaviour change for the existing callers.\n\n## Test\n\nRed-first, both in 
`McpToolRegistrarTest`:\n- `boundsToolArgumentsLikeTheHttpToolPathsTest` — a 
300 KB argument must produce an error result with the handler never invoked 
(previously executed).\n- 
`anUntranslatableFailureReturnsAnErrorResultInsteadOfEscapingTheHandlerTest` — 
an unserialisable result must produce an error result (previously the 
`IllegalStateException` escaped the handler).\n\nAdjacent classes 
(`ToolControllerTest`, `AiPayloadGuardTest`, `McpConfigurationTest`) stay green.


-- 
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]

Reply via email to