feat(fastmcp,mcp): expose fail_closed through the adapter auth factories - #21
Open
RobertoIskandarani wants to merge 7 commits into
Open
feat(fastmcp,mcp): expose fail_closed through the adapter auth factories#21RobertoIskandarani wants to merge 7 commits into
RobertoIskandarani wants to merge 7 commits into
Conversation
The core SDK already implements fail_closed on AuthplaneClient.resource(...), but neither authplane_auth() nor authplane_mcp_auth() forwarded it, so factory users opting into revocation checking were locked into fail-open behavior on introspection/revocation-check outages. Both factories now accept fail_closed: bool = False and pass it through at the client.resource(...) boundary. The default preserves today's fail-open behavior. Also adds the previously missing core coverage for fail_closed=True (crashing custom checker and introspection HTTP 500 both reject with TokenRevokedError), forwarding tests for both adapters, and user-guide docs covering the availability/security trade-off, the authenticated-introspection credential requirement, and the circuit-breaker interaction. Requested in #20.
ruff 0.16.0 started formatting Python code blocks inside Markdown files, so CI (which installs the latest ruff satisfying >=0.8) rejects the previously formatted docs. Blank-line normalization only, no content changes.
RobertoIskandarani
force-pushed
the
feat/fastmcp-fail-closed
branch
from
July 28, 2026 19:23
b6a4e4b to
0520af7
Compare
…ases - AuthplaneClient.resource() logs a warning when fail_closed=True is combined with revocation_checker=None. The flag is a security-relevant no-op in that combination, and the misconfiguration should be observable in production, not only documented. The warning lives in the core factory rather than the adapters so direct resource() users get it too. - New core tests pin two fail-closed failure modes that were emergent: AS metadata without introspection_endpoint rejects every token (permanently, since it is a configuration property rather than an outage), and an open circuit breaker rejects all traffic without further HTTP calls (TokenRevokedError with CircuitOpenError as cause). - Both user guides gain the metadata trade-off bullet and note the new warning.
RobertoIskandarani
force-pushed
the
feat/fastmcp-fail-closed
branch
from
July 28, 2026 19:51
40ee361 to
f0442bd
Compare
muralx
previously approved these changes
Jul 29, 2026
muralx
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, please pin ruff version so we avoid formatting changes from happening during feature development and bug fixes.
An unpinned ruff means CI silently adopts each new minor's lint and formatting behavior mid-development (0.16.0 started formatting Markdown code blocks, which is what forced the docs reformat on this branch). Pinning to the current minor keeps patch fixes and makes format checks reproducible; bumping the minor becomes a deliberate change.
mcp 1.27.2, the newest release the previous <1.28.0 ceiling allowed, carries PYSEC-2026-3483; the fix ships in 1.28.1. Adapter tests pass against 1.28.1.
muralx
previously approved these changes
Jul 29, 2026
The <1.29.0 ceiling let mcp 1.28 resolve, but 1.28 renamed the elicitation field to snake_case elicitation_id, which the adapter's url_elicitation path does not handle — every consent-driven exchange would raise a pydantic ValidationError instead of -32042. Keep the ceiling below 1.28 until the adapter is migrated (README already documents the <1.28.0 range). Also document the fail_closed-without-revocation_checker warning in the core user-guide (the direct client.resource() audience); both adapter guides already cover it.
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.
Closes #20.
What
Both adapter factories —
authplane_fastmcp.authplane_auth()andauthplane_mcp.authplane_mcp_auth()— now acceptfail_closed: bool = Falseand forward it toAuthplaneClient.resource(...). The core SDK already implementedfail_closed; the factories simply never exposed it, so integrations opting intoIntrospectionRevocation()were locked into fail-open behavior on introspection/revocation-check outages unless they abandoned the one-call factory and wired the resource manually.authplane-mcphad the same gap asauthplane-fastmcp, so both factories are covered in this PR to keep them in parity with the core API.Changes
fail_closed: bool = Falsekeyword on both factories, forwarded at theclient.resource(...)boundary. Default preserves today's fail-open behavior; fully backward compatible.fail_closed=True(previously untested): a crashing custom checker and an introspection HTTP 500 both reject withTokenRevokedError.False, explicitTrue).revocation_checker.Testing
pytest tests(core): 522 passedpytest testsinauthplane-fastmcp: 55 passedpytest testsinauthplane-mcp: 55 passedruff check/ruff format --check: cleanpyright: 0 errors