FastAPI MCPサーバー
FastAPIのエンドポイントを、リクエスト/レスポンスのスキーマを維持したままMCP toolに変換します。既存のFastAPI認証用dependencyもそのまま利用可能です。
別名 tadata-org/fastapi_mcp, fastapi-mcp
- スター
- 12,030
- ツール
- —
- ダウンロード数(30日間)
- —
- 最新バージョン
- —
- 最終コミット
- 2025年11月24日
- ライセンス
- MIT
FastAPI MCPとは
FastAPIのエンドポイントを、リクエスト/レスポンスのスキーマを維持したままMCP toolに変換します。既存のFastAPI認証用dependencyもそのまま利用可能です。
プロジェクトのREADMEから生成された概要
FastAPI MCP server について
fastapi_mcpを使用することで、開発者は既存のAPIエンドポイントをAIモデルに公開できます。このツールは、元のリクエストおよびレスポンスのスキーマを維持しながら、FastAPIのエンドポイントをModel Context Protocolのtoolへと変換します。ロジックをゼロから再構築することなく、現在のWebサービスをAIクライアントと統合したいPython開発者向けに設計されています。
アプリケーションのネイティブな拡張機能として機能するため、統合は非常に簡単です。既存のFastAPIアプリに直接MCP serverをマウントするか、個別のデプロイを選択できます。システムはASGIトランスポートを使用してアプリケーションと直接通信するため、追加のHTTPコールによるオーバーヘッドを回避できます。FastAPIのエコシステムに組み込まれているため、既存のDepends()による認証および認可のdependencyを使用して、toolを保護できます。
サーバーのセットアップには最小限の設定しか必要ありません。マウントされると、サーバーはベースURL上の特定のエンドポイントで利用可能になります。Swagger UIからのすべてのドキュメントが保持されるため、AIは提供されるすべてのtoolの目的と構造を正確に理解できます。
できること
- 1セキュアなAPI公開AIクライアントは、確立されたセキュリティプロトコルを使用して、保護されたエンドポイントとやり取りできます。
- 2ツールの自動生成手動での設定をほとんど行うことなく、既存のAPIスイート全体をMCP toolに変換できます。
- 3スキーマを意識したAIとの対話AIモデルが、送信すべきデータと返されることを期待するデータを正確に理解できるようにします。
- 4効率的なローカル統合外部HTTPリクエストのレイテンシを発生させることなく、AIをWebサービスに接続します。
プロジェクトの README から作成されています。すべてのユースケースは、その引用と照らし合わせて確認されています。
自動チェック
実行日 2026年11月14日完全なレポート →まだ検証されていません。サーバーには80点のスコア、重大な問題がないこと、および検証に必要な十分なデータが必要です。 チェックの仕組み · 点数を上げるための改善点
- ソースリポジトリがリンクされており、アクセス可能tadata-org/fastapi_mcp is public and reachablegithub.com/tadata-org/fastapi_mcp ↗合格
- パッケージがこのリポジトリをソースとして指定未チェック
- ビルドの来歴 (Sigstore 証明)未チェック
- オープンソースライセンス (OSI)MITspdx.org/licenses/MIT.html ↗合格
- 過去1年以内にコミットまたはリリースありLast commit or release 2025-11-24github.com/tadata-org/fastapi_mcp ↗合格
- OpenSSF Scorecard未チェック
- パッケージ名が有名なパッケージに酷似していない未チェック
- パッケージおよびその依存関係に重大な勧告なし未チェック
- モデルへの隠れた指示がない0 tool descriptions and the README read; no override phrases, credential paths or hidden characters合格
- 破壊的なツールがラベル付けされている未チェック
- リモートエンドポイントが MCP ハンドシェイクに応答未チェック
README
GitHubで見るFeatures
-
Authentication built in, using your existing FastAPI dependencies!
-
FastAPI-native: Not just another OpenAPI -> MCP converter
-
Zero/Minimal configuration required - just point it at your FastAPI app and it works
-
Preserving schemas of your request models and response models
-
Preserve documentation of all your endpoints, just as it is in Swagger
-
Flexible deployment - Mount your MCP server to the same app, or deploy separately
-
ASGI transport - Uses FastAPI's ASGI interface directly for efficient communication
Hosted Solution
If you prefer a managed hosted solution check out tadata.com.
Installation
We recommend using uv, a fast Python package installer:
uv add fastapi-mcp
Alternatively, you can install with pip:
pip install fastapi-mcp
Basic Usage
The simplest way to use FastAPI-MCP is to add an MCP server directly to your FastAPI application:
from fastapi import FastAPI
from fastapi_mcp import FastApiMCP
app = FastAPI()
mcp = FastApiMCP(app)
# Mount the MCP server directly to your FastAPI app
mcp.mount()
That's it! Your auto-generated MCP server is now available at https://app.base.url/mcp.
Documentation, Examples and Advanced Usage
FastAPI-MCP provides comprehensive documentation. Additionaly, check out the examples directory for code samples demonstrating these features in action.
FastAPI-first Approach
FastAPI-MCP is designed as a native extension of FastAPI, not just a converter that generates MCP tools from your API. This approach offers several key advantages:
-
Native dependencies: Secure your MCP endpoints using familiar FastAPI
Depends()for authentication and authorization -
ASGI transport: Communicates directly with your FastAPI app using its ASGI interface, eliminating the need for HTTP calls from the MCP to your API
-
Unified infrastructure: Your FastAPI app doesn't need to run separately from the MCP server (though separate deployment is also supported)
This design philosophy ensures minimum friction when adding MCP capabilities to your existing FastAPI services.
Development and Contributing
Thank you for considering contributing to FastAPI-MCP! We encourage the community to post Issues and create Pull Requests.
Before you get started, please see our Contribution Guide.
Community
Join MCParty Slack community to connect with other MCP enthusiasts, ask questions, and share your experiences with FastAPI-MCP.
Requirements
- Python 3.10+ (Recommended 3.12)
- uv
License
MIT License. Copyright (c) 2025 Tadata Inc.
FastAPI MCPのよくある質問
FastAPIアプリにMCP serverを追加するにはどうすればよいですか?
アプリのインスタンスを使用してFastApiMCPを作成し、mount()を呼び出します。これにより、アプリのベースURLの/mcpでMCP serverが提供されます。
FastAPI-MCPは認証をサポートしていますか?
はい、認証機能は組み込まれており、認証や認可のためのDepends()などの既存のFastAPI dependencyを再利用できます。
エンドポイントのドキュメントやスキーマは維持されますか?
はい、リクエストおよびレスポンスのモデルスキーマが維持され、エンドポイントのドキュメントもSwaggerに表示されている内容が保持されます。
FastAPI-MCPに必要なPythonのバージョンは何ですか?
Python 3.10以降が必要です。3.12を推奨します。
MCP serverをFastAPIアプリとは別にデプロイすることはできますか?
はい、MCP serverを同じアプリにマウントすることも、個別にデプロイすることも可能です。