fastapi-fastmcp

Integrate FastAPI with FastMCP and OAuth 2.1 Bearer authentication.

2|1|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/scalekit-inc/skills --skill fastapi-fastmcp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fastapi-fastmcp
Source: https://github.com/scalekit-inc/skills/tree/main/skills/mcp-auth/fastapi-fastmcp
Command: npx skills add https://github.com/scalekit-inc/skills --skill fastapi-fastmcp

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Build production-ready MCP servers on FastAPI + FastMCP with scalable, secure token-based access, enabling developers to enforce OAuth 2.1 Bearer authentication with fine-grained control.

Core Features & Use Cases

  • Custom middleware integration: Add rate-limiting, logging, and advanced authorization rules around MCP tool execution.
  • Token validation via Scalekit SDK: Validate issuer, audience, and expiration for each request against Scalekit's authentication.
  • OAuth discovery endpoint: Expose well-known metadata for MCP clients to discover auth requirements.
  • Use Case: Convert an existing FastAPI service into an MCP-enabled app with production-grade auth and token management.

Quick Start

Start the server and verify Bearer token validation against the Scalekit OAuth endpoint.

Frequently Asked Questions about fastapi-fastmcp

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add OAuth bearer token authentication to a FastAPI MCP server?

Protect your FastAPI MCP server using OAuth 2.1 Bearer authentication by integrating FastMCP with the Scalekit SDK. This validates issuer, audience, and expiration metadata for each request, ensuring secure, token-based access control around tool execution.

Can I use custom middleware for rate limiting and logging with FastMCP?

Yes, you can inject custom middleware into your FastAPI service to add rate-limiting, logging, and advanced authorization rules around MCP tool execution, ensuring scalable and monitored API operations.

How does an MCP client discover OAuth authentication requirements?

An MCP client discovers OAuth requirements through an OAuth discovery endpoint. Exposing well-known metadata allows MCP clients to automatically detect authentication configurations and interact securely with your FastAPI application.

Do I need the Scalekit SDK to validate tokens in a FastAPI production environment?

Yes, using the Scalekit SDK is required to validate issuer, audience, and expiration for each request. You must configure environment values for issuer, audience, and metadata endpoints to enforce production-grade OAuth 2.1 Bearer authentication.

What is the best way to convert an existing FastAPI service into an MCP-enabled app?

The best way to convert an existing FastAPI service into an MCP-enabled app is by integrating FastMCP with OAuth 2.1 authentication. This provides production-grade token validation, custom middleware support, and OAuth discovery for scalable and secure APIs.

Why does my FastMCP setup require environment values for issuer and audience?

Your FastMCP setup requires environment values for issuer, audience, and metadata endpoints to perform accurate token validation. These parameters are critical for enforcing OAuth 2.1 Bearer authentication by verifying token expiration and metadata against Scalekit's endpoints.