Skip to content

Commit ae6ddc5

Browse files
authored
Fix shenyu mcp bugs (#6227)
* fix:shenyu-examples-mcp * fix some bug * fix: fix the mcp client and mcp examples bug
1 parent 80596c8 commit ae6ddc5

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

shenyu-client/shenyu-client-mcp/shenyu-client-mcp-register/src/main/java/org/apache/shenyu/client/mcp/McpServiceEventListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ private List<String> findMergeUrl(final Class<?> clazz, final Method method) {
270270
for (String cp : classPaths) {
271271
for (String mp : methodPaths) {
272272
String path = concatPaths(cp, mp);
273-
combinedPaths.add(path);
273+
String finalPath = concatPaths(getContextPath(), path);
274+
combinedPaths.add(finalPath);
274275
}
275276
}
276277
return combinedPaths;

shenyu-examples/shenyu-examples-mcp/src/main/java/org/apache/shenyu/controller/OrderController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class OrderController {
5959
@GetMapping("/findById")
6060
@ShenyuMcpTool(
6161
operation = @Operation(
62-
method = "Get", description = "find order by id"
62+
method = "GET", description = "find order by id"
6363
),
6464
requestConfig = @ShenyuMcpRequestConfig(
6565
bodyToJson = "false",
@@ -96,7 +96,7 @@ public OrderDTO findById(@ShenyuMcpToolParam(
9696
@GetMapping("/findAll")
9797
@ShenyuMcpTool(
9898
operation = @Operation(
99-
method = "Get", description = "find all order"
99+
method = "GET", description = "find all order"
100100
),
101101
requestConfig = @ShenyuMcpRequestConfig(
102102
bodyToJson = "false",

shenyu-examples/shenyu-examples-mcp/src/main/resources/application.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ server:
1818
address: 0.0.0.0
1919
tomcat:
2020
max-http-form-post-size: 100MB
21-
21+
servlet:
22+
context-path: /mcp
2223
shenyu:
2324
namespace: 649330b6-c2d7-4edc-be8e-8a54df9eb385
2425
register:
@@ -31,9 +32,9 @@ shenyu:
3132
client:
3233
mcp:
3334
props:
34-
contextPath: /order
35-
appName: /order
35+
contextPath: /mcp
36+
appName: mcp
3637
http:
3738
props:
38-
contextPath: /order
39-
appName: order
39+
contextPath: /mcp
40+
appName: mcp

shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/manager/ShenyuMcpServerManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ private String extractBasePath(final String uri) {
288288

289289
// For sub-paths, extract the main MCP server path
290290
String[] pathSegments = basePath.split("/");
291-
if (pathSegments.length > 2) {
291+
if (pathSegments.length >= 2) {
292292
// Keep only the first two segments (empty + server-name)
293293
basePath = "/" + pathSegments[1];
294294
}

0 commit comments

Comments
 (0)