mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-10 07:39:10 +02:00
* Add JWT audience validation and RFC 8707 warnings to auth providers * chore: Update SDK documentation * Update AuthKit example README env var name * Move RFC 8707 warnings inside default verifier guard * chore: Update SDK documentation --------- Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
32 lines
749 B
Python
32 lines
749 B
Python
"""AuthKit DCR server example for FastMCP.
|
|
|
|
This example demonstrates how to protect a FastMCP server with AuthKit DCR.
|
|
|
|
Required environment variables:
|
|
- FASTMCP_SERVER_AUTH_AUTHKITPROVIDER_AUTHKIT_DOMAIN: Your AuthKit domain (e.g., "https://your-app.authkit.app")
|
|
|
|
To run:
|
|
python server.py
|
|
"""
|
|
|
|
import os
|
|
|
|
from fastmcp import FastMCP
|
|
from fastmcp.server.auth.providers.workos import AuthKitProvider
|
|
|
|
auth = AuthKitProvider(
|
|
authkit_domain=os.getenv("AUTHKIT_DOMAIN") or "",
|
|
base_url="http://localhost:8000",
|
|
)
|
|
|
|
mcp = FastMCP("AuthKit DCR Example Server", auth=auth)
|
|
|
|
|
|
@mcp.tool
|
|
def echo(message: str) -> str:
|
|
"""Echo the provided message."""
|
|
return message
|
|
|
|
|
|
if __name__ == "__main__":
|
|
mcp.run(transport="http", port=8000)
|