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.
fix(mcp): advertise slash-less protected-resource at root mount #1088
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
base: main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
fix(mcp): advertise slash-less protected-resource at root mount #1088
Changes from all commits
821551487d818dFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: airbytehq/PyAirbyte
Length of output: 8076
🌐 Web query:
FastMCP dependency injection verify_token return type AccessToken | None💡 Result:
In FastMCP, the
verify_tokenmethod, which is implemented by authentication providers to validate bearer tokens, indeed has a return type ofAccessToken | None[1][2][3]. When a token is valid, it returns anAccessTokenobject containing information such as the client ID, scopes, expiration, and claims [1][4][5]. If the token is invalid, expired, or otherwise fails verification, it returnsNone[1][6][7]. Regarding dependency injection: - To access the authenticated user's token in a tool or dependency, you can useget_access_token(), which returnsAccessToken | None[4][8][9]. This is useful when authentication is optional [4][10]. - For cases where you want to enforce authentication and have the dependency raise an error if no token is found, you can useCurrentAccessToken()(an injectable dependency) [4][8][10].Citations:
🏁 Script executed:
Repository: airbytehq/PyAirbyte
Length of output: 407
🏁 Script executed:
Repository: airbytehq/PyAirbyte
Length of output: 706
🌐 Web query:
FastMCP verify_token return type "async def verify_token" "AccessToken | None"💡 Result:
In the FastMCP framework, the
verify_tokenmethod is defined as an asynchronous function (async def) that returns anAccessTokenobject if the token is valid, orNoneif the token is invalid, expired, or otherwise fails validation [1][2][3]. This signature is a core requirement for classes implementing theTokenVerifierprotocol [1][4][5]. When implementing a custom token verifier, yourverify_tokenmethod should follow this pattern [6]: async def verify_token(self, token: str) -> AccessToken | None: # Perform validation logic if is_valid(token): return AccessToken(...) return None TheAccessTokenobject returned contains authentication details such as the token string, client ID, granted scopes, expiration time, and additional claims [7].Citations:
Preserve FastMCP’s
verify_tokenreturn annotation?TokenVerifier.verify_tokenisAsyncCallable[..., AccessToken | None], so-> Noneis runtime-safe here because this fake always returnsNone, but-> AccessToken | Nonewould close the static override gap. What do you think?🤖 Prompt for AI Agents
Source: MCP tools
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Not fixing.
-> Noneis a valid (covariant) narrowing of the baseAsyncCallable[..., AccessToken | None]return type, so it's runtime-safe and statically sound — Pyrefly is clean. This fake never returns a token; annotating-> AccessToken | Nonewould only widen it to a value it never produces. Keeping-> Noneavoids an extraAccessTokenimport for a test whose subject is the resource-URL logic, not token verification. Happy to change it if a maintainer prefers the exact base signature.Devin session
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 Not fixing — false positive.
ruff checkpasses clean on this file withSLFenabled. Ruff'sflake8-selfintentionally does not flag private-member access when the receiver is an instance of a class defined in the same module (_FakeProviderhere), so no# noqa: SLF001is needed. Adding one would itself triggerRUF100(unused-noqa).Devin session
Uh oh!
There was an error while loading. Please reload this page.