This is an automated email from the ASF dual-hosted git repository.

liuhongyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new ae6ddc5abe Fix shenyu mcp bugs (#6227)
ae6ddc5abe is described below

commit ae6ddc5abe3e88f1c0a5a9201a59bcdb74a04157
Author: Yu Siheng <[email protected]>
AuthorDate: Sat Nov 8 19:16:08 2025 +0800

    Fix shenyu mcp bugs (#6227)
    
    * fix:shenyu-examples-mcp
    
    * fix some bug
    
    * fix: fix the mcp client and mcp examples bug
---
 .../org/apache/shenyu/client/mcp/McpServiceEventListener.java |  3 ++-
 .../java/org/apache/shenyu/controller/OrderController.java    |  4 ++--
 .../shenyu-examples-mcp/src/main/resources/application.yml    | 11 ++++++-----
 .../plugin/mcp/server/manager/ShenyuMcpServerManager.java     |  2 +-
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git 
a/shenyu-client/shenyu-client-mcp/shenyu-client-mcp-register/src/main/java/org/apache/shenyu/client/mcp/McpServiceEventListener.java
 
b/shenyu-client/shenyu-client-mcp/shenyu-client-mcp-register/src/main/java/org/apache/shenyu/client/mcp/McpServiceEventListener.java
index 0994bb6e89..61cb7e2700 100644
--- 
a/shenyu-client/shenyu-client-mcp/shenyu-client-mcp-register/src/main/java/org/apache/shenyu/client/mcp/McpServiceEventListener.java
+++ 
b/shenyu-client/shenyu-client-mcp/shenyu-client-mcp-register/src/main/java/org/apache/shenyu/client/mcp/McpServiceEventListener.java
@@ -270,7 +270,8 @@ public class McpServiceEventListener extends 
AbstractContextRefreshedEventListen
         for (String cp : classPaths) {
             for (String mp : methodPaths) {
                 String path = concatPaths(cp, mp);
-                combinedPaths.add(path);
+                String finalPath = concatPaths(getContextPath(), path);
+                combinedPaths.add(finalPath);
             }
         }
         return combinedPaths;
diff --git 
a/shenyu-examples/shenyu-examples-mcp/src/main/java/org/apache/shenyu/controller/OrderController.java
 
b/shenyu-examples/shenyu-examples-mcp/src/main/java/org/apache/shenyu/controller/OrderController.java
index a2b8636825..e09f3c7d51 100644
--- 
a/shenyu-examples/shenyu-examples-mcp/src/main/java/org/apache/shenyu/controller/OrderController.java
+++ 
b/shenyu-examples/shenyu-examples-mcp/src/main/java/org/apache/shenyu/controller/OrderController.java
@@ -59,7 +59,7 @@ public class OrderController {
     @GetMapping("/findById")
     @ShenyuMcpTool(
             operation = @Operation(
-                    method = "Get", description = "find order by id"
+                    method = "GET", description = "find order by id"
             ),
             requestConfig = @ShenyuMcpRequestConfig(
                     bodyToJson = "false",
@@ -96,7 +96,7 @@ public class OrderController {
     @GetMapping("/findAll")
     @ShenyuMcpTool(
             operation = @Operation(
-                    method = "Get", description = "find all order"
+                    method = "GET", description = "find all order"
             ),
             requestConfig = @ShenyuMcpRequestConfig(
                     bodyToJson = "false",
diff --git 
a/shenyu-examples/shenyu-examples-mcp/src/main/resources/application.yml 
b/shenyu-examples/shenyu-examples-mcp/src/main/resources/application.yml
index 30a89cd200..333b9e099e 100644
--- a/shenyu-examples/shenyu-examples-mcp/src/main/resources/application.yml
+++ b/shenyu-examples/shenyu-examples-mcp/src/main/resources/application.yml
@@ -18,7 +18,8 @@ server:
   address: 0.0.0.0
   tomcat:
     max-http-form-post-size: 100MB
-
+  servlet:
+    context-path: /mcp
 shenyu:
   namespace: 649330b6-c2d7-4edc-be8e-8a54df9eb385
   register:
@@ -31,9 +32,9 @@ shenyu:
   client:
     mcp:
       props:
-        contextPath: /order
-        appName: /order
+        contextPath: /mcp
+        appName: mcp
     http:
       props:
-        contextPath: /order
-        appName: order
\ No newline at end of file
+        contextPath: /mcp
+        appName: mcp
diff --git 
a/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/manager/ShenyuMcpServerManager.java
 
b/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/manager/ShenyuMcpServerManager.java
index aaad6a9e72..d0180f3f7c 100644
--- 
a/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/manager/ShenyuMcpServerManager.java
+++ 
b/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/manager/ShenyuMcpServerManager.java
@@ -288,7 +288,7 @@ public class ShenyuMcpServerManager {
 
         // For sub-paths, extract the main MCP server path
         String[] pathSegments = basePath.split("/");
-        if (pathSegments.length > 2) {
+        if (pathSegments.length >= 2) {
             // Keep only the first two segments (empty + server-name)
             basePath = "/" + pathSegments[1];
         }

Reply via email to