Sean-Walker0 opened a new pull request, #7428:
URL: https://github.com/apache/shenyu/pull/7428

   Fixes #6473
   
   ## Modifications
   
   `McpServerPluginDataHandler#handlerRule` registers an MCP tool under the 
rule handle's tool name when one is configured 
(`isBlank(mcpServerTool.getName()) ? ruleData.getName() : 
mcpServerTool.getName()`), but `removeRule()` always removed by 
`ruleData.getName()`. Whenever the handle carried a custom tool name, deleting 
or updating the rule left the stale tool registered (and callable) on the live 
MCP server.
   
   `removeRule()` now resolves the removal name with the exact same 
handle-first fallback used at registration:
   
   ```java
   ShenyuMcpServerTool mcpServerTool = GsonUtils.getInstance().fromJson(s, 
ShenyuMcpServerTool.class);
   ...
   shenyuMcpServerManager.removeTool(server.getPath(),
           StringUtils.isBlank(mcpServerTool.getName()) ? ruleData.getName() : 
mcpServerTool.getName());
   ```
   
   ## Verifying this change
   
   - [x] New 
`McpServerPluginDataHandlerTest#testRemoveRuleRemovesToolByConfiguredName` — 
registers a tool whose handle name differs from the rule name, then asserts 
`removeTool` targets the configured name. Red on the pre-fix code (the old code 
removed by the rule name), green after.
   - [x] `./mvnw -pl shenyu-plugin/shenyu-plugin-mcp-server -am test -B` — 
99/99 module tests green, checkstyle clean.
   
   ## Notes
   
   - Behavior change: rule removal/update now also cleans up custom-named 
tools; default-named rules behave exactly as before (the fallback chain is 
identical to the registration one).
   - Orthogonality: no open PR modifies `McpServerPluginDataHandler` (verified 
against the file lists of all 92 open PRs). #7033 touches `ShenyuToolCallback` 
— a different class in the same module, different method regions; no overlap 
with this change.
   
   Make sure that:
   
   - [x] You have read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [x] You submit test cases (unit or integration tests) that back your 
changes.
   - [x] Your local test passed `./mvnw clean install 
-Dmaven.javadoc.skip=true` (module-scoped: 
`shenyu-plugin/shenyu-plugin-mcp-server` with `-am`, tests + checkstyle green).


-- 
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]

Reply via email to