Skip to content

fix(anthropic): use Claude Code-compatible MCP tool prefix for OAuth#17681

Open
JayGwod wants to merge 1 commit into
NousResearch:mainfrom
JayGwod:fix/anthropic-oauth-mcp-prefix
Open

fix(anthropic): use Claude Code-compatible MCP tool prefix for OAuth#17681
JayGwod wants to merge 1 commit into
NousResearch:mainfrom
JayGwod:fix/anthropic-oauth-mcp-prefix

Conversation

@JayGwod

@JayGwod JayGwod commented Apr 30, 2026

Copy link
Copy Markdown

Summary

  • Use Claude Code-compatible mcp__ as the MCP tool-name prefix for native Anthropic OAuth requests.
  • Keep stripping the MCP prefix when normalizing Anthropic tool_use responses back into Hermes tool calls.
  • Cover both request serialization and response normalization with tests.

Why

Claude Code's Anthropic OAuth tool protocol uses a double-underscore MCP marker, for example:

mcp__terminal

Hermes was previously emitting a single-underscore marker on the native Anthropic OAuth path:

mcp_terminal

That can make Hermes OAuth tool requests diverge from the Claude Code-compatible shape even though the request is otherwise using Claude Code/OAuth beta headers. Using the same mcp__ marker makes the OAuth tool schema consistent with Claude Code-style MCP tool naming.

This PR is intentionally scoped only to tool-name compatibility. It does not claim to change Anthropic account/billing behavior such as extra-usage gating.

Tests

./venv/bin/python -m py_compile agent/anthropic_adapter.py agent/transports/anthropic.py
./venv/bin/python -m pytest -o 'addopts=' tests/agent/test_anthropic_adapter.py -q

Result:

140 passed

Additional sanity checks verified:

  • OAuth request tool name serializes as mcp__terminal.
  • Response normalization strips mcp__terminal back to Hermes tool name terminal.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder provider/anthropic Anthropic native Messages API area/auth Authentication, OAuth, credential pools labels Apr 30, 2026
@JayGwod

JayGwod commented May 2, 2026

Copy link
Copy Markdown
Author

Bumping — open for ~2 days.

Status on current upstream/main (f903ceece):

  • Applies cleanly, no rebase needed.
  • pytest tests/agent/test_anthropic_adapter.py -k "mcp or prefix" → 5 passed on a worktree at f903ceece with this commit on top.

Context: this is the prefix companion to the context-1m beta fix in #17680#17752. Anthropic's OAuth path expects MCP tool names to use Claude Code's double-underscore convention (mcp__server__tool). Without it, OAuth + MCP sessions get a 400 from the Anthropic API on tool registration even after the beta-header fix lands.

Happy to take feedback if you'd prefer this fold into a different code path. Thanks!

@JayGwod JayGwod force-pushed the fix/anthropic-oauth-mcp-prefix branch 5 times, most recently from 31f8e92 to 7ec9dd1 Compare May 9, 2026 15:23
@JayGwod JayGwod force-pushed the fix/anthropic-oauth-mcp-prefix branch 2 times, most recently from b2849ab to 0fbddca Compare May 12, 2026 15:58
@JayGwod JayGwod force-pushed the fix/anthropic-oauth-mcp-prefix branch 4 times, most recently from d3d36a7 to 2d9e685 Compare May 22, 2026 18:14
@JayGwod JayGwod force-pushed the fix/anthropic-oauth-mcp-prefix branch from 2d9e685 to 1725d32 Compare May 27, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists provider/anthropic Anthropic native Messages API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants