Skip to content

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

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().

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