fastmcp/tests/server/http
Pierre Audonnet a57f1c8b20
Add subject field to AccessToken initialization (#4267)
* Add subject field to AccessToken initialization

Fixes #4266

Add `subject` property to the AccessToken.

```python
        return AccessToken(
            token=access_token_as_dict["token"],
            client_id=access_token_as_dict["client_id"],
            scopes=access_token_as_dict["scopes"],
            subject=access_token_as_dict["subject"],
            # Optional fields
            expires_at=access_token_as_dict.get("expires_at"),
            resource=access_token_as_dict.get("resource"),
            claims=access_token_as_dict.get("claims") or {},
        )
```

* Populate AccessToken.subject across all token verifiers

Closes #4266. get_access_token().subject was always None: the SDK's
AccessToken.subject wasn't carried into FastMCP's AccessToken by the
dependency-layer conversion, and none of the built-in TokenVerifiers
(JWT, introspection, and the OAuth-provider verifiers for Discord,
Clerk, Google, WorkOS, HuggingFace, GitHub, and Cognito) populated it
from the sub claim/field they already extract.

---------

Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2026-07-18 21:15:13 -04:00
..
__init__.py clean up test inits 2025-05-31 19:32:08 -04:00
test_bearer_auth_backend.py Add loq file size limits and clean up type ignores (#2859) 2026-01-13 07:29:12 -05:00
test_custom_routes.py Internal refactor of MCP handlers (#2005) 2025-10-05 08:45:10 -04:00
test_http_auth_middleware.py Forward-port HTTP host guard compatibility (#4474) 2026-07-08 20:55:56 -04:00
test_http_dependencies.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_http_middleware.py Migrate to MCP SDK v2.0.0b2 (httpx2) (#4503) 2026-07-18 15:12:47 -04:00
test_lifespan_once_per_process.py Test lifespan fires once per process over HTTP (#4480) 2026-07-17 17:02:26 -04:00
test_session_idle_timeout.py Drive the FastMCP lifespan through the SDK session manager (#4446) 2026-07-07 07:49:16 -04:00
test_session_owner_enforcement.py Drive the FastMCP lifespan through the SDK session manager (#4446) 2026-07-07 07:49:16 -04:00
test_stale_access_token.py Add subject field to AccessToken initialization (#4267) 2026-07-18 21:15:13 -04:00
test_streamable_http_shutdown.py fix(http): terminate active streamable-HTTP transports before lifespan shutdown (#4118) 2026-05-10 10:58:13 -04:00