authplane-fastmcp
Authplane JWT validation for servers built on FastMCP.
Install
pip install authplane-fastmcp
Compatibility
Supported fastmcp range: >=3.2, <4.0.0. This adapter also imports the top-level mcp package directly (mcp.shared.exceptions, mcp.types), so it carries its own mcp constraint: >=1.28.1, <2.0.0. The floor is 1.28.1 because earlier releases (<=1.28.0) are affected by PYSEC-2026-3483, fixed in 1.28.1; fastmcp>=3.2 alone does not guarantee that floor. The adapter targets the mcp 1.x camelCase URL-elicitation field (ElicitRequestURLParams(elicitationId=...)), which is the shape of the current 1.x line. As a belt-and-braces measure the adapter does not hard-code that spelling: it resolves the elicitation-id field name from the model's own schema — a known spelling is checked at import, then resolved per call — so a rename within 1.x would be picked up automatically rather than breaking the consent path. mcp 2.0 is not yet supported: it renames the elicitation field to snake_case elicitation_id, which is a separate port. If your project needs mcp 2.0, please open an issue.
Quickstart
import asyncio
from authplane_fastmcp import authplane_auth
from fastmcp import FastMCP
from fastmcp.server.auth import AccessToken, require_scopes
from fastmcp.dependencies import CurrentAccessToken
async def main():
mcp = FastMCP(
"My MCP Server",
**await authplane_auth(
issuer="https://auth.company.com",
base_url="https://mcp.company.com",
scopes=["tools/query", "tools/write"],
),
)
@mcp.tool(auth=require_scopes("tools/query"))
async def query_database(query: str, token: AccessToken = CurrentAccessToken()) -> str:
user_id = token.claims.get("sub")
return f"Query: {query}, User: {user_id}"
await mcp.run_async(transport="http", host="0.0.0.0", port=8080)
asyncio.run(main())
authplane_auth() holds background JWKS and metadata refresh tasks; call aclose() on the returned client during server shutdown.
Hand-rolling the auth provider
authplane_auth() returns a VerbatimPRMRemoteAuthProvider, a RemoteAuthProvider
subclass that serves the Protected Resource Metadata identifiers byte-for-byte.
It matters: upstream builds the PRM from pydantic.AnyHttpUrl fields, which append
a trailing slash to an empty-path authority, and the core SDK compares identifiers
verbatim — so a client that follows the advertised value literally is rejected.
If you build a RemoteAuthProvider yourself instead of calling authplane_auth()
— a documented FastMCP pattern — use the subclass rather than the base class:
from authplane_fastmcp import VerbatimPRMRemoteAuthProvider
from pydantic import AnyHttpUrl
provider = VerbatimPRMRemoteAuthProvider(
token_verifier=token_verifier,
authorization_servers=[AnyHttpUrl(issuer)],
base_url=AnyHttpUrl(base_url),
scopes_supported=scopes,
# The two that make it verbatim. Pass the identifiers exactly as configured,
# not the AnyHttpUrl forms above — that is the whole point: those normalize.
verbatim_issuer=issuer,
verbatim_resource=resource,
)
base_url is the server's base URL and verbatim_resource is the full resource
identifier; they are not the same value when the MCP server is mounted under a
path.
If you cannot subclass, rewrite_prm_routes_verbatim(routes, issuer=..., resource=...)
is exported as a supported hook — apply it to the route list your provider returns.
Documentation
PRM behavior, dev mode, revocation checking, manual setup, scope enforcement semantics, claim access, the full authplane_auth / AuthplaneTokenVerifier API, and error handling: User Guide.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file authplane_fastmcp-0.4.0.tar.gz.
File metadata
- Download URL: authplane_fastmcp-0.4.0.tar.gz
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9b4c49a30694b12d0e5c211d806f359752a00f1680f9b13bd7ddee7a52e6e19
|
|
| MD5 |
7f4bd88e74fd6d3efde8bddeb6fc5efa
|
|
| BLAKE2b-256 |
5c1136dee7bfb90b980a9cecf09eab9c188baf3b1009d57eadf2c86df135dc48
|
Provenance
The following attestation bundles were made for authplane_fastmcp-0.4.0.tar.gz:
Publisher:
publish-pypi.yml on AuthPlane/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
authplane_fastmcp-0.4.0.tar.gz -
Subject digest:
d9b4c49a30694b12d0e5c211d806f359752a00f1680f9b13bd7ddee7a52e6e19 - Sigstore transparency entry: 2627075820
- Sigstore integration time:
-
Permalink:
AuthPlane/python-sdk@eb2fdfa668d9ac7802743fb4ae6582745c537eb3 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/AuthPlane
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@eb2fdfa668d9ac7802743fb4ae6582745c537eb3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file authplane_fastmcp-0.4.0-py3-none-any.whl.
File metadata
- Download URL: authplane_fastmcp-0.4.0-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fa2513ac94ba2f82c03ca5bc5b282dd8ac182a1aa400db834f39424e55963ec
|
|
| MD5 |
491aeccdab47204c1370bded7982afa2
|
|
| BLAKE2b-256 |
2f995344787c8f56dc9ad52dd778ff59d27b83cb93b40b6346e19e21fd145004
|
Provenance
The following attestation bundles were made for authplane_fastmcp-0.4.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on AuthPlane/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
authplane_fastmcp-0.4.0-py3-none-any.whl -
Subject digest:
4fa2513ac94ba2f82c03ca5bc5b282dd8ac182a1aa400db834f39424e55963ec - Sigstore transparency entry: 2627075884
- Sigstore integration time:
-
Permalink:
AuthPlane/python-sdk@eb2fdfa668d9ac7802743fb4ae6582745c537eb3 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/AuthPlane
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@eb2fdfa668d9ac7802743fb4ae6582745c537eb3 -
Trigger Event:
push
-
Statement type: