-
Notifications
You must be signed in to change notification settings - Fork 3k
[feat]: shenyu mcp plugin auto register #6163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces ShenYu MCP (Message Communication Protocol) plugin auto-registration functionality, enabling automatic service discovery and registration for MCP tools and services.
- Add complete MCP client and server-side auto-registration infrastructure
- Implement OpenAPI-based MCP tool configuration and metadata generation
- Create comprehensive example application demonstrating MCP integration
Reviewed Changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| shenyu-spring-boot-starter/shenyu-spring-boot-starter-client/shenyu-spring-boot-starter-client-mcp/ | Spring Boot starter module for MCP client integration |
| shenyu-register-center/ | Core registration DTOs and client repository support for MCP tools |
| shenyu-examples/shenyu-examples-mcp/ | Example application showcasing MCP plugin usage |
| shenyu-common/ | Added MCP RPC type enum and plugin name adapter support |
| shenyu-client/shenyu-client-mcp/ | Complete MCP client implementation with OpenAPI generators |
| shenyu-admin/ | Server-side MCP registration service and controller endpoints |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
.../main/java/org/apache/shenyu/springboot/starter/client/mcp/ShenyuMcpClientConfiguration.java
Outdated
Show resolved
Hide resolved
| this.doPersistMcpTools(registerDTO); | ||
| } catch (Exception ex) { | ||
| logger.warn("Failed to persistMcpTools {}, cause:{}", registerDTO, ex.getMessage()); | ||
| this.addFailureApiDocRegister(registerDTO); |
Copilot
AI
Sep 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method call addFailureApiDocRegister(registerDTO) should be addFailureMcpToolsRegister(registerDTO) to properly handle MCP tools registration failures, not API doc registration failures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, this suggestion is right, u should do this
...lient-mcp/src/main/java/org/apache/shenyu/client/mcp/common/annotation/OpenApiParameter.java
Outdated
Show resolved
Hide resolved
| String MCP_TOOLS_TYPE = "mcp"; | ||
|
|
Copilot
AI
Sep 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is trailing whitespace after the constant declaration. This should be removed to maintain code consistency.
...t/shenyu-client-mcp/src/main/java/org/apache/shenyu/client/mcp/common/annotation/Header.java
Outdated
Show resolved
Hide resolved
...u-client-mcp/src/main/java/org/apache/shenyu/client/mcp/common/annotation/OpenApiConfig.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 35 out of 36 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| /** | ||
| * the required of parameter key. | ||
| */ | ||
| public static final String OPEN_API_PATH_PATH_METHOD_PARAMETERS_REQUIRED_KEY = "description"; |
Copilot
AI
Sep 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constant value should be 'required' instead of 'description' as this represents the required field of a parameter, not its description.
| public static final String OPEN_API_PATH_PATH_METHOD_PARAMETERS_REQUIRED_KEY = "description"; | |
| public static final String OPEN_API_PATH_PATH_METHOD_PARAMETERS_REQUIRED_KEY = "required"; |
| * | ||
| * @param clientConfig the client config | ||
| * @param shenyuClientRegisterRepository the shenyu client register repository | ||
| * @return the apache dubbo service bean listener |
Copilot
AI
Sep 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type documentation incorrectly mentions 'apache dubbo service bean listener' but should reference 'MCP service event listener' since this is for MCP, not Dubbo.
| * @return the apache dubbo service bean listener | |
| * @return the MCP service event listener |
| return superUrl; | ||
| } | ||
| return ""; |
Copilot
AI
Sep 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is inverted. When superUrl is blank, it returns the blank value, but when it's not blank, it returns an empty string. This should return superUrl when it's not blank and empty string when it is blank.
| return superUrl; | |
| } | |
| return ""; | |
| return ""; | |
| } | |
| return superUrl; |
| /** | ||
| * the summary of method key. | ||
| */ | ||
| public static final String OPEN_API_PATH_PATH_METHOD_SUMMARY_KEY = "summary"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double PATH
| /** | ||
| * the description of method key. | ||
| */ | ||
| public static final String OPEN_API_PATH_PATH_METHOD_DESCRIPTION_KEY = "description"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double PATH, is that right?
| /** | ||
| * the operationId of method key. | ||
| */ | ||
| public static final String OPEN_API_PATH_PATH_METHOD_OPERATION_ID_KEY = "operationId"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double PATH
| /** | ||
| * the tag of method key. | ||
| */ | ||
| public static final String OPEN_API_PATH_PATH_METHOD_TAG_KEY = "tag"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double PATH
| /** | ||
| * the openApi generator. | ||
| */ | ||
| public class McpOpenApiGenerator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this class should be put in a single module. such as mcp common or mcp core. cause this class may be general
| /** | ||
| * the mcpRequestConfig generator. | ||
| */ | ||
| public class McpRequestConfigGenerator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this class should be put in a single module. such as mcp common or mcp core. cause this class may be general
| /** | ||
| * When register by http, the mcpTools path. | ||
| */ | ||
| String MCP_TOOLS_PATH = "/shenyu-client/register-mcpTools"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just "/shenyu-client/register-mcp" is fine
| * @return the order dto | ||
| */ | ||
| @GetMapping("/findById") | ||
| @ShenyuMcpClient( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ShenyuMcpClient is confusing, i think it is better to be called such as: ShenyuMcpTool.
|
hi, u can take a look at this link: https://docs.spring.io/spring-ai/reference/1.1-SNAPSHOT/api/mcp/mcp-annotations-overview.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why rename? maybe u want to copy from this file? but made a mistake?
| JsonObject method = path.getAsJsonObject(operation.method()); | ||
| JsonArray parameters = method.getAsJsonArray(OpenApiConstants.OPEN_API_PATH_OPERATION_METHOD_PARAMETERS_KEY); | ||
|
|
||
| root.addProperty("name", classMcpClient.toolName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use constants
|
|
||
| io.swagger.v3.oas.annotations.media.Schema schemaAnn = annotation.schema(); | ||
| if (!schemaAnn.implementation().equals(Void.class) | ||
| || !"".equals(schemaAnn.type()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringUtils.isBlank
|
|
||
| <dependency> | ||
| <groupId>org.springdoc</groupId> | ||
| <artifactId>springdoc-openapi-starter-common</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add License for this dep
Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.