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.1.0.tar.gz (21.2 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.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: authplane_fastmcp-0.1.0.tar.gz
  • Upload date:
  • Size: 21.2 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.1.0.tar.gz
Algorithm Hash digest
SHA256 1b507c5ac29a7d546f3d58d6b7b1f2489f98938e842c7fd0015b187dcfb860b2
MD5 e52096d94953533f136931cfe84b890a
BLAKE2b-256 6788011b2f585240ad8a4164067bf7d635f77317371e0850cb07be8946001bd5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for authplane_fastmcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f047c4d6d397138a6938770d0c5c506143cf36964f4035129199395f0faa978
MD5 f599e4744ba36e660c046822c23692c3
BLAKE2b-256 780fb40cb2366ddfc55366c470d545413d6437a3bced909f0cabd772d093b22b

See more details on using hashes here.

Provenance

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