Skip to main content

Authplane JWT validation adapter for FastMCP

Project description

authplane-fastmcp

PyPI License

Authplane JWT validation for servers built on FastMCP.

Install

pip install authplane-fastmcp

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.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

authplane_fastmcp-0.3.0.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

authplane_fastmcp-0.3.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file authplane_fastmcp-0.3.0.tar.gz.

File metadata

  • Download URL: authplane_fastmcp-0.3.0.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for authplane_fastmcp-0.3.0.tar.gz
Algorithm Hash digest
SHA256 2619218ff8c17f55b5a1090fa44657f645956fafde69e274845e8c07e07f2b9f
MD5 f7dacd743b2ab3ae1692618faac56966
BLAKE2b-256 30c92a1f14aeff71a220f8de39e71f26620756261d240bac1f0f1c55ff42ac06

See more details on using hashes here.

Provenance

The following attestation bundles were made for authplane_fastmcp-0.3.0.tar.gz:

Publisher: publish-pypi.yml on AuthPlane/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file authplane_fastmcp-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for authplane_fastmcp-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 158959afd3248effd0a59ec0be17c6c1027c4aeb02173155118af5e6f27c7d43
MD5 4494396b5872000b653cbf906101a318
BLAKE2b-256 6ccaa7e1ab446136c33787139417d451c1ab4736be81562ffe3735fd832cb610

See more details on using hashes here.

Provenance

The following attestation bundles were made for authplane_fastmcp-0.3.0-py3-none-any.whl:

Publisher: publish-pypi.yml on AuthPlane/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page