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.2.0.tar.gz (12.4 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.2.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: authplane_fastmcp-0.2.0.tar.gz
  • Upload date:
  • Size: 12.4 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.2.0.tar.gz
Algorithm Hash digest
SHA256 336784567355ed9a7adcee0fdc2828bc0b80afee4308c94f630d5b259d89bcbc
MD5 586a03a70710f0abd93f4b3f46dd0a3d
BLAKE2b-256 fb1e0fc59bdfc9dbde32509a0cc6cd9b08bc4f9830248caafb66064bcdd83cad

See more details on using hashes here.

Provenance

The following attestation bundles were made for authplane_fastmcp-0.2.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.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for authplane_fastmcp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f3d52eafb1417bb8e43b61f8b0799165cc0e2af8790284fdcdae65f5ff97f30
MD5 a9ba5675f8011969d58947f7b3064d8a
BLAKE2b-256 5f367498bbc556ecb82cbf7baf820af8c1dbde4974f80e56724f310c232bf27f

See more details on using hashes here.

Provenance

The following attestation bundles were made for authplane_fastmcp-0.2.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