Raise HTTP 403 with insufficient_scope instead of tool/prompt not found on scope failure#65
Merged
yeison-liscano merged 3 commits intomainfrom Mar 18, 2026
Merged
Conversation
…cope is insufficient Co-authored-by: yeison-liscano <104051061+yeison-liscano@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add documentation on how mcp_auth package works
Raise HTTP 403 with insufficient_scope instead of tool/prompt not found on scope failure
Mar 17, 2026
yeison-liscano
approved these changes
Mar 18, 2026
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.
When an authenticated request lacks the required OAuth scopes, the server was returning a JSON-RPC
RESOURCE_NOT_FOUNDerror ("Tool X not found"). This prevents MCP clients from distinguishing a missing resource from an authorization failure and blocks the OAuth 2.1 step-up flow.Changes
InsufficientScopeError— new exception (not aServerErrorsubclass) carryingrequired_scopes; propagates through the transport layer rather than being swallowed as a JSON-RPC errorserver.py—call_tool/get_promptnow raiseInsufficientScopeErrorinstead ofToolNotFoundError/PromptNotFoundErrorwhen the resource exists but scope check fails_transport_http.py— catchesInsufficientScopeErrorin_process_messagesand sends HTTP 403 Forbidden with{"error":"insufficient_scope"};AuthErrorMiddlewarethen adds theWWW-Authenticateheader_stdio_transport.py— catchesInsufficientScopeErrorand falls back to a JSON-RPCRESOURCE_NOT_FOUNDerror with required scopes in the description (STDIO doesn't use OAuth per the MCP spec)middleware.py—AuthErrorMiddlewarenow setserror="insufficient_scope"inWWW-Authenticateon 403 responses (wasnullpreviously), satisfying RFC 6750Before / After
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
releases.astral.sh/home/REDACTED/.local/bin/uv uv sync(dns block)If you need me to access, download, or install something from one of these locations, you can either:
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.