Merge branch 'main' into 2-14-deprecations

This commit is contained in:
Jeremiah Lowin 2025-11-22 12:22:34 -05:00 committed by GitHub
commit 98d9a2b9d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 1266 additions and 373 deletions

View file

@ -9,8 +9,8 @@ Demonstrates FastMCP server protection with Scalekit OAuth.
**Create a Scalekit Account**:
- Go to [Scalekit Dashboard](https://app.scalekit.com/)
- Navigate to **Developers** → **Settings**
- Copy your Environment URL, Client ID, and Client Secret
- Copy your Environment URL from **Developers** → **Settings**
- Copy Resource ID (res_xxx) from **Developers** → **MCP Servers**
**Register Your MCP Server**:
@ -23,9 +23,10 @@ Create a `.env` file:
```bash
# Required Scalekit credentials
SCALEKIT_ENVIRONMENT_URL=<YOUR_APP_ENVIRONMENT_URL>
SCALEKIT_CLIENT_ID=<YOUR_APP_CLIENT_ID> # skc_7008EXAMPLE46
SCALEKIT_RESOURCE_ID=<YOUR_APP_RESOURCE_ID> # res_926EXAMPLE5878
MCP_URL=http://localhost:8000/mcp
BASE_URL=http://localhost:8000/
# Optional: additional scopes tokens must include (comma-separated)
# SCALEKIT_REQUIRED_SCOPES=read,write
```
### 2. Run the Example

View file

@ -4,9 +4,12 @@ This example demonstrates how to protect a FastMCP server with Scalekit OAuth.
Required environment variables:
- SCALEKIT_ENVIRONMENT_URL: Your Scalekit environment URL (e.g., "https://your-env.scalekit.com")
- SCALEKIT_CLIENT_ID: Your Scalekit OAuth application client ID
- SCALEKIT_RESOURCE_ID: Your Scalekit resource ID
Optional:
- SCALEKIT_REQUIRED_SCOPES: Comma-separated scopes tokens must include
- BASE_URL: Public URL where the FastMCP server is exposed (defaults to `http://localhost:8000/`)
To run:
python server.py
"""
@ -16,12 +19,19 @@ import os
from fastmcp import FastMCP
from fastmcp.server.auth.providers.scalekit import ScalekitProvider
required_scopes_env = os.getenv("SCALEKIT_REQUIRED_SCOPES")
required_scopes = (
[scope.strip() for scope in required_scopes_env.split(",") if scope.strip()]
if required_scopes_env
else None
)
auth = ScalekitProvider(
environment_url=os.getenv("SCALEKIT_ENVIRONMENT_URL")
or "https://your-env.scalekit.com",
client_id=os.getenv("SCALEKIT_CLIENT_ID") or "",
resource_id=os.getenv("SCALEKIT_RESOURCE_ID") or "",
mcp_url=os.getenv("MCP_URL", "http://localhost:8000/mcp"),
base_url=os.getenv("BASE_URL", "http://localhost:8000/"),
required_scopes=required_scopes,
)
mcp = FastMCP("Scalekit OAuth Example Server", auth=auth)