Skip to main content

FastMCP integration for Keycard OAuth client with automated token exchange and authentication

Project description

keycardai-fastmcp

FastMCP integration for Keycard OAuth: protect FastMCP servers with Keycard authentication and run delegated OAuth 2.0 token exchange (RFC 8693) for downstream APIs.

This is the canonical home for the integration; keycardai-mcp-fastmcp is preserved as a deprecation bridge for callers still on the old name.

Installation

pip install keycardai-fastmcp

Quick Start

from fastmcp import FastMCP, Context
from keycardai.fastmcp import AuthProvider

auth_provider = AuthProvider(
    zone_id="abc1234",
    mcp_server_name="My Server",
    mcp_base_url="http://localhost:8000",
)

mcp = FastMCP("My Server", auth=auth_provider.get_remote_auth_provider())

@mcp.tool()
@auth_provider.grant("https://api.example.com")
async def call_external_api(ctx: Context, query: str):
    keycardai = await ctx.get_state("keycardai")
    token = keycardai.access("https://api.example.com").access_token
    return f"Results for {query} (token starts with {token[:8]})"

Migration from keycardai-mcp-fastmcp

The old package keeps working: from keycardai.mcp.integrations.fastmcp import AuthProvider emits a DeprecationWarning pointing here and returns the same class. Migrate when convenient.

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

keycardai_fastmcp-0.4.0.tar.gz (30.7 kB view details)

Uploaded Source

Built Distribution

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

keycardai_fastmcp-0.4.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file keycardai_fastmcp-0.4.0.tar.gz.

File metadata

  • Download URL: keycardai_fastmcp-0.4.0.tar.gz
  • Upload date:
  • Size: 30.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for keycardai_fastmcp-0.4.0.tar.gz
Algorithm Hash digest
SHA256 10907197bc5aa5fb557e605858af2c37927f8949351d1d69dc4cdf5bad93b485
MD5 db98c019131f42dfd1b11f0b2cfad4ae
BLAKE2b-256 7b95ec9e8b0dc632abe3744daf6d3b1e1146bef5cdc3bc240c9a09946f8daa4f

See more details on using hashes here.

File details

Details for the file keycardai_fastmcp-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: keycardai_fastmcp-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for keycardai_fastmcp-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7d97b527e28e80d2aa420fd71ffee6276c9975446b4673e0ce86f873150ad74
MD5 0281b801d1f461416cc3b0bbad5ae6e8
BLAKE2b-256 7519d1d64c076d5ece259d41764f5eb14c559113ef028f7d74772756d4cf0be6

See more details on using hashes here.

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