fastmcp/tests/server/auth
Chris Guidry 547daf7a36
Replace vendored DI with uncalled-for (#3301)
* Replace vendored DI with uncalled-for

FastMCP vendored a minimal DI engine extracted from Docket (~164 lines)
with try/except fallback patterns everywhere. The `uncalled-for` package
is a clean, typed extraction of this same system, and since Docket will
also depend on it (chrisguidry/docket#353), `uncalled_for.Dependency`
becomes the single canonical base class.

This deletes the `_vendor/docket_di/` directory, replaces all the
try/except import patterns with direct `uncalled_for` imports, and
updates the `Dependency.execution` → `current_execution` ContextVar
references to match the Docket branch. The `Progress` class now
delegates to an internal impl and returns `self` from `__aenter__`
(matching Docket's pattern) so that ty's generic resolution works
without `type: ignore` suppressions.

Temporarily points pydocket at the `use-uncalled-for` branch so both
sides can be validated together in CI.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Re-export Dependency from fastmcp.dependencies

Internal code like azure.py should import from the fastmcp namespace
rather than reaching into uncalled_for directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Import Dependency from fastmcp namespace in tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add generic type parameters to Dependency subclasses

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Mention uncalled-for in DI docs

The DI engine now comes from uncalled-for, so the docs should credit
it alongside Docket. Also updates the Docket docs link to docket.lol.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Point docket dependency at main

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Bump uncalled-for pin to >=0.2.0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix uncalled-for imports for 0.2.0 API changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Support Shared() dependencies without docket

Enters a SharedContext at server lifetime so that Shared() dependencies
from uncalled-for resolve once and are cached across tool/resource/prompt
calls. When running with docket, the Worker already handles this; this
covers the non-docket path and direct call_tool() usage.

Also re-exports Shared from fastmcp.dependencies.

Closes #3251

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Bump docket lockfile to latest main

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Remove duplicate test classes from rebase conflict resolution

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Point docket dependency at pydocket>=0.18.0 release

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Pair SharedContext __aenter__ with __aexit__ in Context lifecycle

The old `_ensure_shared_context` on the server called `__aenter__()` on a
lazy `SharedContext` but never `__aexit__()`, leaking the exit stack and
its resources. Moved the SharedContext management into Context's own
enter/exit so it's properly paired: when docket is available the lifespan
handles it, otherwise Context creates and cleans up a per-request one.

Updated Shared() tests to use Client (which runs the lifespan) rather
than calling server methods directly, since cross-request sharing
requires a lifespan.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Hoist SharedContext import to module level

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 16:35:15 -05:00
..
oauth_proxy Add CIMD (Client ID Metadata Document) support for OAuth (#2871) 2026-02-06 13:44:52 -05:00
providers Replace vendored DI with uncalled-for (#3301) 2026-03-02 16:35:15 -05:00
__init__.py Add WorkOS and Azure OAuth providers (#1550) 2025-08-20 16:22:03 -04:00
test_auth_provider.py Upgrade to MCP 1.17+ with RFC 9728 compliance (#2122) 2025-10-17 09:29:23 -04:00
test_authorization.py Handle AuthorizationError as exclusion in AuthMiddleware list hooks 2026-03-01 13:23:02 -05:00
test_cimd.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
test_cimd_validators.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
test_debug_verifier.py Add DebugTokenVerifier with custom sync/async validation (#2296) 2025-10-31 10:38:01 -04:00
test_enhanced_error_responses.py Use MemoryStore for OAuth proxy tests 2026-02-01 02:30:05 +00:00
test_jwt_issuer.py feat: option to add upstream claims to the FastMCP proxy JWT (#2997) 2026-01-28 15:57:24 -05:00
test_jwt_provider.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
test_jwt_provider_bearer.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
test_multi_auth.py Add MultiAuth for composing multiple token verification sources (#3335) 2026-03-02 12:09:22 -05:00
test_oauth_consent_flow.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
test_oauth_consent_page.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
test_oauth_mounting.py Use MemoryStore for OAuth proxy tests 2026-02-01 02:30:05 +00:00
test_oauth_proxy_redirect_validation.py Fix CIMD redirect allowlist bypass and cache revalidation (#3098) 2026-02-06 20:08:23 -05:00
test_oauth_proxy_storage.py Drop diskcache dependency (CVE-2025-69872) (#3185) 2026-02-16 16:43:15 -05:00
test_oidc_proxy.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
test_oidc_proxy_token.py Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
test_redirect_validation.py Add CIMD (Client ID Metadata Document) support for OAuth (#2871) 2026-02-06 13:44:52 -05:00
test_remote_auth_provider.py Add AzureJWTVerifier for Managed Identity token verification (#3058) 2026-02-02 19:59:13 -05:00
test_ssrf_protection.py Add CIMD (Client ID Metadata Document) support for OAuth (#2871) 2026-02-06 13:44:52 -05:00
test_static_token_verifier.py Add documentation for get_access_token() dependency function (#1446) 2025-08-11 13:01:44 -04:00