Skip to main content

authplane-fastmcp

PyPI License

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.

Metadata

Release files for authplane-fastmcp 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for authplane-fastmcp 0.5.0
File Size Uploaded
authplane_fastmcp-0.5.0.tar.gz 23.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for authplane-fastmcp 0.5.0
File Interpreter ABI Platform
authplane_fastmcp-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 50.3 kB

Release files / authplane_fastmcp-0.5.0.tar.gz

Download URL authplane_fastmcp-0.5.0.tar.gz
Size 23.8 kB
Tags Source
SHA-256 checksum
How to use checksums
26c8ed913157ddba5d2c417547cd80f37a9bb017f758d78fca08b79fe419c6cf
BLAKE2b-256 checksum
How to use checksums
750710fd544c4d6606952cd11a5e07fd56b736e823adf9839db0969494ff310b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / authplane_fastmcp-0.5.0-py3-none-any.whl

Download URL authplane_fastmcp-0.5.0-py3-none-any.whl
Size 26.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fdd216ce4f2955a66636b839eeb8efde4e9e147c1faf37348c1e79bdf4d4cdc5
BLAKE2b-256 checksum
How to use checksums
98114a6058ffc30c1d25883815cec573279d0f745913de00b87149d9db6e013d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page