Sean-Walker0 opened a new pull request, #7430: URL: https://github.com/apache/shenyu/pull/7430
Fixes #6472 ## Modifications `RequestConfigHelper#buildPath` can return a **complete URL** taken from the tool input arguments (it short-circuits with `getCompleteUrl(...)` when an input value starts with `http://`/`https://`). But `ShenyuToolCallback#setTargetUri` always prefixed the gateway request's scheme and authority onto the built path: ```java final String newUriStr = oldUri.getScheme() + "://" + oldUri.getAuthority() + path; ``` A tool input URL like `https://target.example/api` was therefore rewritten into a malformed target such as `http://gateway.example:9195https://target.example/api`, so MCP tool calls that rely on complete target URLs could never reach their backend. When the built path is itself an absolute `http(s)` URL — the same detection `RequestConfigHelper#isCompleteUrl` uses — it is now set as the request target unchanged; relative paths keep the gateway-origin prefix: ```java if (path.startsWith("http://") || path.startsWith("https://")) { requestBuilder.uri(new URI(path)); return; } ``` ## Verifying this change - [x] New `ShenyuToolCallbackTest#testSetTargetUriUsesCompleteUrlAsIs` — red on the pre-fix code (`expected: <https://target.example/api> but was: <http://gateway.example:9195https://target.example/api>`), green after. - [x] New `ShenyuToolCallbackTest#testSetTargetUriPrefixesGatewayOriginForRelativePath` — guards the unchanged relative-path behavior (green before and after). - [x] `./mvnw -pl shenyu-plugin/shenyu-plugin-mcp-server -am test -B` — 100/100 module tests green, checkstyle clean. ## Notes - Behavior change: only for tool requests whose built path is already an absolute URL — they are now dispatched to that URL instead of a corrupted gateway-origin URL. - Orthogonality: #7033 (open) modifies `ShenyuToolCallback#configureShenyuContext` — a different method in the same file; its diff was compared line by line and does not touch `setTargetUri` or URL construction, so the changes do not overlap. Make sure that: - [x] 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. - [x] Your local test passed `./mvnw clean install -Dmaven.javadoc.skip=true` (module-scoped: `shenyu-plugin/shenyu-plugin-mcp-server` with `-am`, tests + checkstyle 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]
