You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR removes the require_auth built-in authorization check and updates all documentation and examples to use scope-based authorization via require_scopes instead.
Changes Made
Removed require_auth function from fastmcp.server.auth.authorization module
Updated exports in fastmcp.server.auth.__init__.py to remove require_auth
Updated all documentation in docs/development/v3-notes/v3-features.mdx and docs/servers/authorization.mdx:
Removed require_auth examples and references
Updated examples to use require_scopes for all authorization scenarios
Added clarification that when an AuthProvider is configured, all requests must carry valid tokens (unauthenticated requests are rejected at transport level)
Improved documentation on component-level vs server-level authorization
Added comprehensive example showing layered authorization (component + middleware)
Updated the "Built-in checks" section to list only require_scopes and restrict_tag
Updated all tests in tests/server/auth/test_authorization.py:
Removed TestRequireAuth test class
Updated all test cases to use require_scopes instead of require_auth
Updated middleware examples to use scope-based checks
Rationale
The require_auth check was a simple boolean check for token presence, but since the authorization model now requires an AuthProvider to be configured (which rejects unauthenticated requests at the transport level), this check became redundant. Using require_scopes is more explicit and provides better granularity for authorization policies. This change encourages users to define clear scope requirements rather than just checking for token presence.
Testing
All existing tests have been updated to use require_scopes instead of require_auth
Test coverage remains the same with updated examples
Documentation examples are consistent across all files
marvin-context-protocolBot
added
enhancement
Improvement to existing functionality. For issues and smaller PR improvements.
breaking change
Breaks backward compatibility. Requires minor version bump. Critical for maintainer attention.
auth
Related to authentication (Bearer, JWT, OAuth, WorkOS) for client or server.
labels
Feb 6, 2026
This pull request removes require_auth from the public API of fastmcp.server.auth and updates all code examples and documentation to use require_scopes exclusively. Changes include removing the require_auth export from the auth module's __init__.py file, deleting the function definition from authorization.py, and updating all documentation files and middleware examples to demonstrate scope-based authorization patterns instead. No functional changes are made to existing authorization logic or the require_scopes implementation.
The title clearly and concisely summarizes the main change: removing require_auth in favor of scope-based authorization via require_scopes.
Docstring Coverage
✅ Passed
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check
✅ Passed
PR description is comprehensive, clearly structured, and addresses all key aspects: removed functionality, updated documentation, rationale, and testing. All required checklist items are documented.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
Create PR with unit tests
Post copyable unit tests in a comment
Commit unit tests in branch claude/investigate-issue-3090-TACeM
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
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
authRelated to authentication (Bearer, JWT, OAuth, WorkOS) for client or server.enhancementImprovement to existing functionality. For issues and smaller PR improvements.
2 participants
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.
Description
This PR removes the
require_authbuilt-in authorization check and updates all documentation and examples to use scope-based authorization viarequire_scopesinstead.Changes Made
require_authfunction fromfastmcp.server.auth.authorizationmodulefastmcp.server.auth.__init__.pyto removerequire_authdocs/development/v3-notes/v3-features.mdxanddocs/servers/authorization.mdx:require_authexamples and referencesrequire_scopesfor all authorization scenariosAuthProvideris configured, all requests must carry valid tokens (unauthenticated requests are rejected at transport level)require_scopesandrestrict_tagtests/server/auth/test_authorization.py:TestRequireAuthtest classrequire_scopesinstead ofrequire_authRationale
The
require_authcheck was a simple boolean check for token presence, but since the authorization model now requires anAuthProviderto be configured (which rejects unauthenticated requests at the transport level), this check became redundant. Usingrequire_scopesis more explicit and provides better granularity for authorization policies. This change encourages users to define clear scope requirements rather than just checking for token presence.Testing
require_scopesinstead ofrequire_authContributors Checklist
Review Checklist
https://claude.ai/code/session_01WWzwcBfLWnxoN9XNs5Fhxr