Skip to content

Conversation

@478320
Copy link
Contributor

@478320 478320 commented Sep 16, 2025

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

@478320
Copy link
Contributor Author

478320 commented Sep 16, 2025

#5923

@478320 478320 changed the title Shenyu mcp plugin auto register [feat]: shenyu mcp plugin auto register Sep 16, 2025
@Aias00 Aias00 requested a review from Copilot September 17, 2025 07:44
Copy link
Contributor

Copilot AI left a 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.

this.doPersistMcpTools(registerDTO);
} catch (Exception ex) {
logger.warn("Failed to persistMcpTools {}, cause:{}", registerDTO, ex.getMessage());
this.addFailureApiDocRegister(registerDTO);
Copy link

Copilot AI Sep 17, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

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

Comment on lines 654 to 655
String MCP_TOOLS_TYPE = "mcp";

Copy link

Copilot AI Sep 17, 2025

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.

Copilot uses AI. Check for mistakes.
@Aias00 Aias00 requested a review from Copilot September 18, 2025 04:10
Copy link
Contributor

Copilot AI left a 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";
Copy link

Copilot AI Sep 18, 2025

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.

Suggested change
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";

Copilot uses AI. Check for mistakes.
*
* @param clientConfig the client config
* @param shenyuClientRegisterRepository the shenyu client register repository
* @return the apache dubbo service bean listener
Copy link

Copilot AI Sep 18, 2025

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.

Suggested change
* @return the apache dubbo service bean listener
* @return the MCP service event listener

Copilot uses AI. Check for mistakes.
Comment on lines 133 to 135
return superUrl;
}
return "";
Copy link

Copilot AI Sep 18, 2025

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.

Suggested change
return superUrl;
}
return "";
return "";
}
return superUrl;

Copilot uses AI. Check for mistakes.
/**
* the summary of method key.
*/
public static final String OPEN_API_PATH_PATH_METHOD_SUMMARY_KEY = "summary";
Copy link
Contributor

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";
Copy link
Contributor

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";
Copy link
Contributor

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";
Copy link
Contributor

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 {
Copy link
Contributor

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 {
Copy link
Contributor

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";
Copy link
Contributor

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(
Copy link
Contributor

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.

@Aias00
Copy link
Contributor

Aias00 commented Sep 18, 2025

Copy link
Contributor

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());
Copy link
Contributor

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())
Copy link
Contributor

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>
Copy link
Contributor

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

Aias00
Aias00 previously approved these changes Sep 22, 2025
@Aias00 Aias00 merged commit 4cc679e into apache:master Sep 22, 2025
43 checks passed
@Aias00 Aias00 modified the milestones: 2.7.1, 2.7.0.3 Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants