Skip to content

Commit 13ed655

Browse files
committed
When no authorization is required dont fail on missing user scope
1 parent 2210c1b commit 13ed655

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/mcp/server/auth/middleware/bearer_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(self, app: Any, required_scopes: list[str]):
7474

7575
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
7676
auth_user = scope.get("user")
77-
if not isinstance(auth_user, AuthenticatedUser):
77+
if not isinstance(auth_user, AuthenticatedUser) and self.required_scopes:
7878
raise HTTPException(status_code=401, detail="Unauthorized")
7979
auth_credentials = scope.get("auth")
8080

0 commit comments

Comments
 (0)