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

Uploaded Python 3

File details

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

File metadata

  • Download URL: keycardai_fastmcp-0.2.0.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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.2.0.tar.gz
Algorithm Hash digest
SHA256 20123e1669a3c23a4f6669f26371b580c36952e5b261efed04cd5f3fe6050390
MD5 29d852070de8b2203caa6f3cdf1858dc
BLAKE2b-256 1e028ff5a4aca0ecce18c1966bfa3fc7b0b8f04ad989bb260e11ce36104685ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: keycardai_fastmcp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0297375b9a805c3d504217f98f9b0a6affbfd86fb845b15c3d35f1d663f7cfd
MD5 f76c992c38d810fec074029e21592864
BLAKE2b-256 d49866067d29d1d9208d58847d039d879400aef865232b0b10f77c7437a64100

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