fix(anthropic): use double-underscore mcp__ prefix for OAuth tool names - #46687
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(anthropic): use double-underscore mcp__ prefix for OAuth tool names#46687liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
Anthropic's Claude-Code request classifier treats tool names with a single-underscore `mcp_<x>` prefix as non-Claude-Code / third-party, routing the request to extra-usage billing (HTTP 400). Real Claude Code uses double underscores: `mcp__<server>__<tool>`. Change the tool-name prefix from `mcp_` to `mcp__` in both the outgoing path (build_anthropic_kwargs) and the incoming path (normalize_response). Update the skip-guard to check for both `mcp_` and `mcp__` prefixes so native MCP server tools (which use the legacy single-underscore format) are not double-prefixed. Fixes NousResearch#46675
Collaborator
|
Related: fix PR for #46675. |
|
can we merge it |
Collaborator
|
Superseded by #47723, which cherry-picks this commit (your |
This was referenced Jul 30, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Changes the Anthropic OAuth tool-name prefix from single underscore (
mcp_) to double underscore (mcp__) so that tool-using requests over Max OAuth are correctly classified as Claude Code and route to plan billing instead of being rejected as third-party (HTTP 400).Related Issue
Fixes #46675
Type of Change
Changes Made
agent/anthropic_adapter.py: Changed_MCP_TOOL_PREFIXfrom"mcp_"to"mcp__". Updatedstartswithguards to check both"mcp__"and"mcp_"prefixes via a_MCP_SKIPtuple, preventing double-prefixing of native MCP server tools that use the legacy single-underscore format.agent/transports/anthropic.py: Changed the local_MCP_PREFIXfrom"mcp_"to"mcp__"innormalize_responseso the response-side stripping matches the new outgoing prefix.tests/agent/test_anthropic_mcp_prefix_strip.py: Updated all test assertions to usemcp__prefix. Addedtest_legacy_single_underscore_native_mcp_not_strippedto verify that native MCP tools with the oldmcp_format are not incorrectly stripped.How to Test
hermes auth add anthropic --type oauthservice_tier: standard(plan-eligible)pytest tests/agent/test_anthropic_mcp_prefix_strip.py -vChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/agent/test_anthropic_mcp_prefix_strip.py -vand all 12 tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
agent/anthropic_adapter.py::_MCP_TOOL_PREFIX,agent/transports/anthropic.py::normalize_responsemcp_prefix from Hermes-native MCP tool names, breaking registry lookup #25255 (original mcp_ prefix guard), OAuth billing classifier