Aias00 opened a new issue, #6472:
URL: https://github.com/apache/shenyu/issues/6472

   ### Current Behavior
   
   MCP tool request configuration can return a complete URL from tool input, 
but the callback later treats that value as a path and prepends the gateway 
request scheme and authority.
   
   `RequestConfigHelper.buildPath()` explicitly short-circuits when an input 
argument is already a complete URL:
   
   ```java
   if (isCompleteUrl(argsPosition, inputJson)) {
       return getCompleteUrl(argsPosition, inputJson);
   }
   ```
   
   `ShenyuToolCallback.setTargetUri()` then always builds the target URI as:
   
   ```java
   final URI oldUri = originExchange.getRequest().getURI();
   final String newUriStr = oldUri.getScheme() + "://" + oldUri.getAuthority() 
+ path;
   requestBuilder.uri(new URI(newUriStr));
   ```
   
   If `path` is `https://target.example/api`, the constructed URI becomes 
malformed, for example:
   
   ```text
   http://gateway.examplehttps://target.example/api
   ```
   
   ### Expected Behavior
   
   When the built path is already an absolute URL, the MCP callback should use 
it directly instead of prefixing the gateway origin.
   
   ### Impact
   
   MCP tool flows that rely on absolute/complete target URLs cannot dispatch 
correctly because the gateway rewrites them into invalid gateway-host URLs.
   
   ### Code Location
   
   - 
`shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/request/RequestConfigHelper.java`
     - `buildPath()` returns complete URLs from input.
   - 
`shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/callback/ShenyuToolCallback.java`
     - `setTargetUri()` always prefixes the gateway scheme and authority.
   


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