Bug Description
Anthropic tool responses that use Claude Code-shaped MCP tool names can fail Hermes tool dispatch when strip_tool_prefix=True.
A Claude Code / OAuth-shaped Anthropic route may return tool names like mcp_Terminal after outgoing Hermes tools are rewritten from lowercase MCP names such as mcp_terminal to PascalCase names such as mcp_Terminal.
Hermes currently strips the mcp_ prefix, but leaves the rest unchanged. That turns mcp_Terminal into Terminal, which does not match the registered Hermes tool name terminal.
Steps to Reproduce
Using AnthropicTransport.normalize_response(..., strip_tool_prefix=True) with a tool-use block named mcp_Terminal:
from types import SimpleNamespace
from agent.transports.anthropic import AnthropicTransport
block = SimpleNamespace(
type="tool_use",
id="toolu_terminal",
name="mcp_Terminal",
input={"command": "printf OPUS_TOOL_OK"},
)
response = SimpleNamespace(content=[block], stop_reason="tool_use")
normalized = AnthropicTransport().normalize_response(response, strip_tool_prefix=True)
assert normalized.tool_calls[0].name == "terminal"
Expected Behavior
mcp_Terminal should normalize to the registered Hermes tool name:
Likewise, PascalCase Claude Code-shaped MCP names should map back to the corresponding Hermes registered tool names after stripping the mcp_ prefix.
Actual Behavior
Before the local fix, mcp_Terminal normalized to:
That misses the registered terminal tool and can break dispatch.
Proposed Fix
After stripping the mcp_ prefix in AnthropicTransport.normalize_response(..., strip_tool_prefix=True), lowercase the first remaining character if it is uppercase.
Example:
mcp_Terminal -> Terminal -> terminal
This preserves existing lowercase behavior while supporting Claude Code-shaped PascalCase tool names.
Local Verification
Local patch/regression was verified in Hermes:
- Regression:
mcp_Terminal normalizes to terminal.
- Tool-shape matrix: 11/11 PascalCase
mcp_ response names normalized back to registered Hermes tools.
- Focused tests:
22 passed locally.
Related Note
This does not promote or install any admin/OAuth route. It only hardens Anthropic response normalization for Claude Code-shaped mcp_ tool names.
Bug Description
Anthropic tool responses that use Claude Code-shaped MCP tool names can fail Hermes tool dispatch when
strip_tool_prefix=True.A Claude Code / OAuth-shaped Anthropic route may return tool names like
mcp_Terminalafter outgoing Hermes tools are rewritten from lowercase MCP names such asmcp_terminalto PascalCase names such asmcp_Terminal.Hermes currently strips the
mcp_prefix, but leaves the rest unchanged. That turnsmcp_TerminalintoTerminal, which does not match the registered Hermes tool nameterminal.Steps to Reproduce
Using
AnthropicTransport.normalize_response(..., strip_tool_prefix=True)with a tool-use block namedmcp_Terminal:Expected Behavior
mcp_Terminalshould normalize to the registered Hermes tool name:Likewise, PascalCase Claude Code-shaped MCP names should map back to the corresponding Hermes registered tool names after stripping the
mcp_prefix.Actual Behavior
Before the local fix,
mcp_Terminalnormalized to:That misses the registered
terminaltool and can break dispatch.Proposed Fix
After stripping the
mcp_prefix inAnthropicTransport.normalize_response(..., strip_tool_prefix=True), lowercase the first remaining character if it is uppercase.Example:
This preserves existing lowercase behavior while supporting Claude Code-shaped PascalCase tool names.
Local Verification
Local patch/regression was verified in Hermes:
mcp_Terminalnormalizes toterminal.mcp_response names normalized back to registered Hermes tools.22 passedlocally.Related Note
This does not promote or install any admin/OAuth route. It only hardens Anthropic response normalization for Claude Code-shaped
mcp_tool names.