Aias00 commented on code in PR #6163: URL: https://github.com/apache/shenyu/pull/6163#discussion_r2357508295
########## shenyu-client/shenyu-client-mcp/src/main/java/org/apache/shenyu/client/mcp/common/constants/OpenApiConstants.java: ########## @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.client.mcp.common.constants; + +/** + * openApi constants. + */ +public class OpenApiConstants { + + /** + * the version of openApi key. + */ + public static final String OPEN_API_VERSION_KEY = "openapi"; + + /** + * the info of openApi key. + */ + public static final String OPEN_API_INFO_KEY = "info"; + + /** + * the title of info key. + */ + public static final String OPEN_API_INFO_TITLE_KEY = "title"; + + /** + * the description of info key. + */ + public static final String OPEN_API_INFO_DESCRIPTION_KEY = "description"; + + /** + * the version of info key. + */ + public static final String OPEN_API_INFO_VERSION_KEY = "version"; + + /** + * the server of openApi key. + */ + public static final String OPEN_API_SERVER_KEY = "server"; + + /** + * the url of openApi server. + */ + public static final String OPEN_API_SERVER_URL_KEY = "url"; + + /** + * the path of openApi key. + */ + public static final String OPEN_API_PATH_KEY = "paths"; + + /** + * the summary of method key. + */ + public static final String OPEN_API_PATH_PATH_METHOD_SUMMARY_KEY = "summary"; + + /** + * the description of method key. + */ + public static final String OPEN_API_PATH_PATH_METHOD_DESCRIPTION_KEY = "description"; Review Comment: double PATH, is that right? ########## shenyu-common/src/main/java/org/apache/shenyu/common/constant/Constants.java: ########## @@ -642,6 +642,16 @@ public interface Constants { * When register by http, the uri path. */ String URI_PATH = "/shenyu-client/register-uri"; + + /** + * When register by http, the mcpTools path. + */ + String MCP_TOOLS_PATH = "/shenyu-client/register-mcpTools"; Review Comment: just "/shenyu-client/register-mcp" is fine ########## shenyu-client/shenyu-client-mcp/src/main/java/org/apache/shenyu/client/mcp/generator/McpOpenApiGenerator.java: ########## @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.client.mcp.generator; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import org.apache.shenyu.client.mcp.common.annotation.ShenyuMcpClient; +import org.apache.shenyu.client.mcp.common.constants.OpenApiConstants; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +/** + * the openApi generator. + */ +public class McpOpenApiGenerator { Review Comment: this class should be put in a single module. such as mcp common or mcp core. cause this class may be general ########## shenyu-client/shenyu-client-mcp/src/main/java/org/apache/shenyu/client/mcp/common/constants/OpenApiConstants.java: ########## @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.client.mcp.common.constants; + +/** + * openApi constants. + */ +public class OpenApiConstants { + + /** + * the version of openApi key. + */ + public static final String OPEN_API_VERSION_KEY = "openapi"; + + /** + * the info of openApi key. + */ + public static final String OPEN_API_INFO_KEY = "info"; + + /** + * the title of info key. + */ + public static final String OPEN_API_INFO_TITLE_KEY = "title"; + + /** + * the description of info key. + */ + public static final String OPEN_API_INFO_DESCRIPTION_KEY = "description"; + + /** + * the version of info key. + */ + public static final String OPEN_API_INFO_VERSION_KEY = "version"; + + /** + * the server of openApi key. + */ + public static final String OPEN_API_SERVER_KEY = "server"; + + /** + * the url of openApi server. + */ + public static final String OPEN_API_SERVER_URL_KEY = "url"; + + /** + * the path of openApi key. + */ + public static final String OPEN_API_PATH_KEY = "paths"; + + /** + * the summary of method key. + */ + public static final String OPEN_API_PATH_PATH_METHOD_SUMMARY_KEY = "summary"; + + /** + * the description of method key. + */ + public static final String OPEN_API_PATH_PATH_METHOD_DESCRIPTION_KEY = "description"; + + /** + * the operationId of method key. + */ + public static final String OPEN_API_PATH_PATH_METHOD_OPERATION_ID_KEY = "operationId"; + + /** + * the tag of method key. + */ + public static final String OPEN_API_PATH_PATH_METHOD_TAG_KEY = "tag"; Review Comment: double PATH ########## shenyu-client/shenyu-client-mcp/src/main/java/org/apache/shenyu/client/mcp/common/constants/OpenApiConstants.java: ########## @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.client.mcp.common.constants; + +/** + * openApi constants. + */ +public class OpenApiConstants { + + /** + * the version of openApi key. + */ + public static final String OPEN_API_VERSION_KEY = "openapi"; + + /** + * the info of openApi key. + */ + public static final String OPEN_API_INFO_KEY = "info"; + + /** + * the title of info key. + */ + public static final String OPEN_API_INFO_TITLE_KEY = "title"; + + /** + * the description of info key. + */ + public static final String OPEN_API_INFO_DESCRIPTION_KEY = "description"; + + /** + * the version of info key. + */ + public static final String OPEN_API_INFO_VERSION_KEY = "version"; + + /** + * the server of openApi key. + */ + public static final String OPEN_API_SERVER_KEY = "server"; + + /** + * the url of openApi server. + */ + public static final String OPEN_API_SERVER_URL_KEY = "url"; + + /** + * the path of openApi key. + */ + public static final String OPEN_API_PATH_KEY = "paths"; + + /** + * the summary of method key. + */ + public static final String OPEN_API_PATH_PATH_METHOD_SUMMARY_KEY = "summary"; + + /** + * the description of method key. + */ + public static final String OPEN_API_PATH_PATH_METHOD_DESCRIPTION_KEY = "description"; + + /** + * the operationId of method key. + */ + public static final String OPEN_API_PATH_PATH_METHOD_OPERATION_ID_KEY = "operationId"; Review Comment: double PATH ########## shenyu-client/shenyu-client-mcp/src/main/java/org/apache/shenyu/client/mcp/common/constants/OpenApiConstants.java: ########## @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.client.mcp.common.constants; + +/** + * openApi constants. + */ +public class OpenApiConstants { + + /** + * the version of openApi key. + */ + public static final String OPEN_API_VERSION_KEY = "openapi"; + + /** + * the info of openApi key. + */ + public static final String OPEN_API_INFO_KEY = "info"; + + /** + * the title of info key. + */ + public static final String OPEN_API_INFO_TITLE_KEY = "title"; + + /** + * the description of info key. + */ + public static final String OPEN_API_INFO_DESCRIPTION_KEY = "description"; + + /** + * the version of info key. + */ + public static final String OPEN_API_INFO_VERSION_KEY = "version"; + + /** + * the server of openApi key. + */ + public static final String OPEN_API_SERVER_KEY = "server"; + + /** + * the url of openApi server. + */ + public static final String OPEN_API_SERVER_URL_KEY = "url"; + + /** + * the path of openApi key. + */ + public static final String OPEN_API_PATH_KEY = "paths"; + + /** + * the summary of method key. + */ + public static final String OPEN_API_PATH_PATH_METHOD_SUMMARY_KEY = "summary"; Review Comment: double PATH ########## shenyu-client/shenyu-client-mcp/src/main/java/org/apache/shenyu/client/mcp/generator/McpRequestConfigGenerator.java: ########## @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.client.mcp.generator; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import org.apache.shenyu.client.mcp.common.annotation.ShenyuMcpRequestConfig; +import org.apache.shenyu.client.mcp.common.constants.OpenApiConstants; +import org.apache.shenyu.client.mcp.common.constants.RequestTemplateConstants; + +import java.util.Arrays; + + +/** + * the mcpRequestConfig generator. + */ +public class McpRequestConfigGenerator { Review Comment: this class should be put in a single module. such as mcp common or mcp core. cause this class may be general ########## shenyu-examples/shenyu-examples-mcp/src/main/java/org/apache/shenyu/controller/OrderController.java: ########## @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.controller; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.servers.Server; +import org.apache.shenyu.client.apidocs.annotations.ApiDoc; +import org.apache.shenyu.client.apidocs.annotations.ApiModule; +import org.apache.shenyu.client.mcp.common.annotation.ShenyuMcpHeader; +import org.apache.shenyu.client.mcp.common.annotation.ShenyuMcpClient; +import org.apache.shenyu.client.mcp.common.annotation.ShenyuMcpRequestConfig; +import org.apache.shenyu.dto.OrderDTO; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * test controller. + */ +@RestController +@RequestMapping("/order") +@ShenyuMcpClient( + definition = @OpenAPIDefinition( + servers = @Server(url = "http://localhost:8150") + ), toolName = "order" + +) +@ApiModule(value = "order") +public class OrderController { + + /** + * Find by id order dto. + * + * @param id the id + * @return the order dto + */ + @GetMapping("/findById") + @ShenyuMcpClient( Review Comment: ShenyuMcpClient is confusing, i think it is better to be called such as: ShenyuMcpTool. -- 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]
