TO

tadata-org/fastapi_mcp

API development

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

1.2万 stars 967 forks 品質 62 トレンド 31MIT

FastAPIエンドポイントをモデルコンテキストプロトコル(MCP)ツールとして公開し、Auth!を使います。

概要

FastAPIエンドポイントをモデルコンテキストプロトコル(MCP)ツールとして公開し、Auth!を使います。 - 既存のFastAPI依存関係を活用して組み込みます! - 単なるOpenAPI -> MCPコンバータではない - 必須 - FastAPIアプリに向けるだけで動作します - リクエストモデルとレスポンスモデルの - Swaggerのように、すべてのエンドポイントの中で - - MCPサーバーを同じアプリにマウントするか、別途展開する - - 効率的な通信のためにFastAPIのASGIインターフェースを直接使用しています

概要(AI 翻訳)

タダタ製

FastAPI-MCP

FastAPIエンドポイントをモデルコンテキストプロトコル(MCP)ツールとして公開し、Auth!を使います。

特徴

  • 認証が内蔵されており、既存のFastAPI依存関係を利用しています!

  • FastAPIネイティブ: 単なるOpenAPI ->MCPコンバーターではありません

  • ゼロ/最小限の設定が必要 - FastAPIアプリに向ければ動作します

  • リクエストモデルおよびレスポンスモデルのスキーマを保持

  • **すべてのエンドポイントのドキュメントをSwaggerと同様に保持する

  • 柔軟な展開 - MCPサーバーを同じアプリにマウントするか、別々に展開する

  • ASGIトランスポート - FastAPIのASGIインターフェースを直接使用し、効率的な通信を実現します

ホスティングソリューション

管理型ホスティングソリューションを好むなら tadata.com をチェックしてみてください。

設置

高速Pythonパッケージインストーラーuvの使用をおすすめします:

あるいは、PIPでインストールすることもできます:

基本用法

FastAPI-MCPを使う最も簡単な方法は、FastAPIアプリケーションに直接MCPサーバーを追加することです:

それで終わりです!あなたの自動生成MCPサーバーがhttps://app.base.url/mcpで利用可能になりました。

ドキュメント、例、高度な利用法

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

FastAPI-MCP

Expose your FastAPI endpoints as Model Context Protocol (MCP) tools, with Auth!

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

GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →