Skip to content

[BUG] MCP rule removal can leave custom-named tools registered #6473

Closed

Description

@Aias00

Current Behavior

MCP tool registration and removal use different names when the rule handle defines a custom tool name.

During registration, handlerRule() prefers the tool name from the rule handle and only falls back to the rule name:

shenyuMcpServerManager.addTool(server.getPath(),
        StringUtils.isBlank(mcpServerTool.getName()) ? ruleData.getName() : mcpServerTool.getName(),
        ...);

During removal, removeRule() always removes by ruleData.getName():

shenyuMcpServerManager.removeTool(server.getPath(), ruleData.getName());

If mcpServerTool.getName() differs from ruleData.getName(), deleting or updating the rule removes the cache entry but leaves the live MCP server tool registered under the custom name.

Expected Behavior

Rule removal should remove the same tool name that was used during registration.

Impact

Renamed/custom-named MCP tools can remain callable after the backing rule is removed or updated, leaving stale tool definitions in the live MCP server.

Code Location

  • shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/handler/McpServerPluginDataHandler.java
    • handlerRule() registers by handle tool name when present.
    • removeRule() removes only by ruleData.getName().

Activity

  1. github-actions commented on Jul 31, 2026

    @github-actions
    Contributor

    👋 Hello @Aias00

    A new issue has been opened by @Aias00:

    Please review when you have time. Thank you! 🙏

  2. added a commit that references this issue on Oct 8, 2026
    510f65a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions