fix(anthropic): remove mcp_ tool prefix on OAuth path that triggers overage gate - #28872
fix(anthropic): remove mcp_ tool prefix on OAuth path that triggers overage gate#28872zccyman wants to merge 1 commit into
Conversation
…verage gate (NousResearch#28849) The mcp_ prefix was applied to ALL tool names on the Anthropic OAuth path, not just MCP server tools. This caused Pro/Max subscribers to hit HTTP 400 "out of extra usage" on every tool-bearing request because Anthropic treats mcp_-prefixed tools as MCP extensions charged against a separate usage bucket. Removed the prefix logic entirely — Claude Code CLI only prefixes tools from user-installed MCP servers, not built-in tools.
teknium1
left a comment
There was a problem hiding this comment.
Thanks for writing this up and adding focused tests. I don’t think this PR is salvageable as-is because the premise no longer matches the maintained contract on main.
Problems
- The linked issue #28849 has a maintainer comment saying the
mcp_prefix is required for Anthropic OAuth subscription tokens to access tools at all; removing it would block tool-bearing requests for subscription users rather than route them through included quota. - Current main intentionally still prefixes bare OAuth tools in
agent/anthropic_adapter.py:2352throughagent/anthropic_adapter.py:2360. - Main’s regression coverage asserts that contract:
tests/agent/test_anthropic_mcp_prefix_strip.py:202expectsread_fileto be sent asmcp_read_fileon OAuth. The related fix already landed more narrowly ineea9553a9c, skipping only already-prefixed native MCP tools to avoidmcp_mcp_....
Suggested changes
- Don’t remove the prefix wholesale. Any follow-up should preserve bare-tool prefixing and handle extra-usage-disabled OAuth users through guidance/account recovery instead.
Automated hermes-sweeper review.
| max_tokens=1024, | ||
| reasoning_config=None, | ||
| is_oauth=True, | ||
| ) |
There was a problem hiding this comment.
This assertion conflicts with the maintained OAuth contract on current main: tests/agent/test_anthropic_mcp_prefix_strip.py:202 expects bare OAuth tools to be sent with the mcp_ prefix, and #28849 was closed by a maintainer as intended behavior.
|
Closing in favor of #47723, which addresses the same root cause — Anthropic's OAuth billing classifier rejecting single-underscore |
Summary
Remove the
mcp_tool name prefix that was applied to all tools on the Anthropic OAuth path. This prefix triggered Anthropic's overage gate for Pro/Max subscribers, causing every tool-bearing request to fail with HTTP 400 "out of extra usage".Fixes #28849
Problem
build_anthropic_kwargs()unconditionally prefixed every tool name withmcp_whenis_oauth=True:Anthropic treats
mcp_-prefixed tools as MCP server extensions, billing them against a separate "extra usage" bucket. Pro/Max subscribers who have extra usage disabled get an immediate HTTP 400 rejection — even when 95%+ of their included quota remains unused.Root Cause
The prefix was modeled after Claude Code CLI's behavior, but Claude Code only prefixes tools from user-installed MCP servers — not its built-in tools like
Read,Write,Bash. Hermes was incorrectly prefixing all tools including built-in ones (terminal,read_file,web_search, etc.).Fix
Removed the
mcp_prefix logic entirely (steps 3 and 4 in the OAuth block). Tool names are now passed through unchanged.Testing
tests/agent/test_oauth_mcp_prefix_removed.py: