Skip to content

fix(anthropic): remove mcp_ tool prefix on OAuth path that triggers overage gate - #28872

Closed
zccyman wants to merge 1 commit into
NousResearch:mainfrom
atyou2happy:fix/anthropic-mcp-prefix-oauth-overage
Closed

fix(anthropic): remove mcp_ tool prefix on OAuth path that triggers overage gate#28872
zccyman wants to merge 1 commit into
NousResearch:mainfrom
atyou2happy:fix/anthropic-mcp-prefix-oauth-overage

Conversation

@zccyman

@zccyman zccyman commented May 19, 2026

Copy link
Copy Markdown
Contributor

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 with mcp_ when is_oauth=True:

# Before (removed)
if is_oauth:
    for tool in anthropic_tools:
        tool["name"] = "mcp_" + tool["name"]  # e.g. "mcp_terminal"

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

  • 4 new tests in tests/agent/test_oauth_mcp_prefix_removed.py:
    • Tool names not prefixed on OAuth path
    • Tool names not prefixed on non-OAuth path
    • Tool names in message history not prefixed
    • No crash when tools=None
  • 163 total tests passed (4 new + 159 existing anthropic adapter + oauth guard tests)

…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.
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/anthropic Anthropic native Messages API area/auth Authentication, OAuth, credential pools P1 High — major feature broken, no workaround labels May 19, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:2352 through agent/anthropic_adapter.py:2360.
  • Main’s regression coverage asserts that contract: tests/agent/test_anthropic_mcp_prefix_strip.py:202 expects read_file to be sent as mcp_read_file on OAuth. The related fix already landed more narrowly in eea9553a9c, skipping only already-prefixed native MCP tools to avoid mcp_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,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Closing in favor of #47723, which addresses the same root cause — Anthropic's OAuth billing classifier rejecting single-underscore mcp_ tool names with HTTP 400 'extra usage, not plan limits'. #47723 takes the double-underscore mcp__ route (verified on a live Max subscription to bill to plan) plus a symmetric response-side round-trip, and also covers mcp_<server>_<tool> MCP-server tools. Your diagnosis of the overage-gate trigger was correct — thank you. Tracking the fix in #47723.

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 runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P1 High — major feature broken, no workaround 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.

OAuth Anthropic + Pro/Max plan: mcp_ tool-name prefix triggers "out of extra usage" 400 on every tool-bearing request

4 participants