Skip to content

When no authorization is required dont fail on missing user scope 401 Unauthorized #615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

yonigottesman
Copy link

@yonigottesman yonigottesman commented May 2, 2025

While developing a mcp server that wil run locally I want to use the sse protocal and not stdio. Because im running local i dont need any authentication, but the default RequireAuthMiddleware will fail if if not isinstance(auth_user, AuthenticatedUser).

I want the solution to be
if not isinstance(auth_user, AuthenticatedUser) and self.required_scopes: so if there are no required scopes I wont have to do anything and i can just connect to the server withtout any autherization

How Has This Been Tested?

I tested it locally to work with cursor

@yonigottesman yonigottesman changed the title When no authorization is required dont fail on missing user scope When no authorization is required dont fail on missing user scope 401 Unauthorized May 2, 2025
@ihrpr ihrpr added this to the 2025-03-26 spec release milestone May 2, 2025
@ihrpr
Copy link
Contributor

ihrpr commented May 2, 2025

@yonigottesman thank you for this PR, this actually highlights a different issue, we need to make sure that when Auth settings aren't set in FastMCP with SSE, we should not even try to go though auth middleware. We'll work on the fix and include it in the next release.

@ihrpr
Copy link
Contributor

ihrpr commented May 6, 2025

should be fixed in v1.7.1

@ihrpr ihrpr closed this May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants