skills/mcp-auth-fastmcp-scalekit/SKILL.md
Add Scalekit OAuth authentication to a FastMCP server (Python). Use when you need to protect FastMCP tools with OAuth 2.1 Bearer tokens and enforce per-tool scope checks (e.g. todo:read, todo:write). Authentication is added in 5 lines via ScalekitProvider; scope checks use get_access_token() inside each tool.
npx skillsauth add scalekit-inc/skills mcp-auth-fastmcp-scalekitInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
stateless_http=True that boots an HTTP transport on a configured port.ScalekitProvider — handles token validation, .well-known discovery, and WWW-Authenticate on 401 automatically.get_access_token() from fastmcp.server.dependencies.FastMCP(auth=...) constructor.ScalekitProvider uses resource_id (starts with res_) and mcp_url (base URL + trailing slash)./mcp to the base URL automatically — always register the BASE URL with trailing slash in Scalekit, not the /mcp path.Ask: "Are we scaffolding a new FastMCP server, or adding auth to an existing FastMCP server?"
Create a directory and virtual environment:
mkdir -p <project-name>
cd <project-name>
python3 -m venv venv
source venv/bin/activate
Install dependencies using assets/requirements.txt:
pip install -r requirements.txt
Create .env using assets/env.example (fill real values from Scalekit dashboard).
Copy assets/server-minimal.py to server.py and add your tools.
Run:
python server.py
Test with MCP Inspector (point to http://localhost:3002/mcp — note: /mcp, not /):
npx @modelcontextprotocol/inspector@latest
Leave Authentication fields empty; DCR handles client registration automatically.
Ask for the existing server file. Look for:
FastMCP(...) is instantiatedmcp.run(...) is already presentAdd to .env:
SCALEKIT_ENVIRONMENT_URL=...
SCALEKIT_CLIENT_ID=...
SCALEKIT_RESOURCE_ID=...
MCP_URL=http://localhost:3002/
PORT=3002
from fastmcp.server.auth.providers.scalekit import ScalekitProvider
from fastmcp.server.dependencies import AccessToken, get_access_token
Before (typical):
mcp = FastMCP("My Server")
After:
mcp = FastMCP(
"My Server",
stateless_http=True,
auth=ScalekitProvider(
environment_url=os.getenv("SCALEKIT_ENVIRONMENT_URL"),
client_id=os.getenv("SCALEKIT_CLIENT_ID"),
resource_id=os.getenv("SCALEKIT_RESOURCE_ID"),
mcp_url=os.getenv("MCP_URL"),
),
)
Add once near the top of the file:
def _require_scope(scope: str):
token: AccessToken = get_access_token()
if scope not in token.scopes:
return f"Insufficient permissions: `{scope}` scope required."
return None
At the top of each @mcp.tool function body, add:
error = _require_scope("your:scope")
if error:
return {"error": error}
See assets/tool-template.py for the full pattern.
if __name__ == "__main__":
mcp.run(transport="http", port=int(os.getenv("PORT", "3002")))
See references/TROUBLESHOOTING.md for common issues.
tools
Create or review Scalekit custom providers/connectors for proxy-only usage, including MCP providers. Use this skill when the task is to gather API docs, infer whether a connector is OAuth, Basic, Bearer, or API Key, determine if it is an MCP provider, determine required tracked fields like domain or version, generate provider JSON, check for existing custom providers, show update diffs, run approved create or update curls, and print resolved delete curls.
tools
Use when a developer is new to Scalekit and needs guidance on where to start, doesn't know which auth plugin or skill to choose, wants to connect an AI agent or agentic workflow to third-party services (Gmail, Slack, Notion, Google Calendar), needs OAuth or tool-calling auth for agents, wants to add authentication to a project but hasn't chosen an approach yet, or needs to install the Scalekit plugin for their AI coding tool (Claude Code, Codex, Copilot CLI, Cursor, or other agents).
tools
Use when a user asks to generate, review, validate, or fix any code snippet that uses Scalekit APIs or SDKs. This skill is the single source of truth for Scalekit code correctness — it can generate illustration-quality snippets from scratch (for docs, websites, or integration guides) and review existing code to catch wrong method names, missing parameters, security anti-patterns, and broken auth flows. Covers all four SDKs (Node, Python, Go, Java), raw REST API calls, and both Scalekit product suites — SaaSKit (SSO, login, sessions, RBAC, SCIM) and AgentKit (connections, tool calling, MCP auth). Use when the user says review my Scalekit code, generate a Scalekit example, validate this auth flow, check my SDK usage, fix my Scalekit integration, write a code sample for docs, or anything involving Scalekit code quality.
development
Walks through a structured production readiness checklist for Scalekit SSO implementations. Use when the user says they are going live, launching to production, doing a pre-launch review, hardening their SSO setup, or wants to verify their Scalekit implementation is production-ready.