Skip to main content
Glama

PyPIバージョン Pythonのバージョン ファストAPI CI カバレッジ

特徴

  • 既存の FastAPI 依存関係を使用して、認証が組み込まれています。

  • **FastAPIネイティブ:**単なるOpenAPI -> MCPコンバータではない

  • 設定はゼロ/最小限で済みます。FastAPI アプリを指定するだけで動作します。

  • リクエストモデルとレスポンスモデルのスキーマの保持

  • Swaggerと同じように、すべてのエンドポイントのドキュメントを保存します。

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

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

Related MCP server: FastAPI-MCP

インストール

高速な Python パッケージ インストーラーであるuv の使用をお勧めします。

uv add fastapi-mcp

あるいは、pip を使用してインストールすることもできます。

pip install fastapi-mcp

基本的な使い方

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

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()

これで完了です。自動生成された MCP サーバーがhttps://app.base.url/mcpで利用できるようになります。

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

FastAPI-MCPは包括的なドキュメントを提供しています。さらに、これらの機能の実際の動作を示すコードサンプルについては、 examplesディレクトリをご覧ください。

FastAPIファーストアプローチ

FastAPI-MCPは、APIからMCPツールを生成するコンバーターとしてだけでなく、FastAPIのネイティブ拡張機能として設計されています。このアプローチには、いくつかの重要な利点があります。

  • ネイティブ依存関係: 認証と承認に使い慣れた FastAPI Depends()を使用して MCP エンドポイントを保護します

  • ASGI トランスポート: ASGI インターフェースを使用して FastAPI アプリと直接通信し、MCP から API への HTTP 呼び出しの必要性を排除します。

  • 統合インフラストラクチャ: FastAPI アプリは MCP サーバーから個別に実行する必要はありません (ただし、 個別の展開もサポートされています)

この設計哲学により、既存の FastAPI サービスに MCP 機能を追加する際の摩擦が最小限に抑えられます。

開発と貢献

FastAPI-MCP への貢献をご検討いただきありがとうございます。コミュニティの皆様には、問題の投稿やプルリクエストの作成を歓迎いたします。

始める前に、貢献ガイドをご覧ください。

コミュニティ

MCParty Slack コミュニティに参加して、他の MCP 愛好家と交流したり、質問したり、FastAPI-MCP の経験を共有したりしましょう。

要件

  • Python 3.10+ (推奨 3.12)

  • 紫外線

ライセンス

MITライセンス。Copyright (c) 2024 Tadata Inc.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A zero-configuration tool that automatically converts FastAPI endpoints into Model Context Protocol (MCP) tools, enabling AI systems to interact with your API through natural language.
    2
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Exposes FastAPI endpoints as Model Context Protocol (MCP) tools while preserving existing authentication, schemas, and documentation. It enables seamless integration of FastAPI services into MCP ecosystems using a native ASGI transport layer.
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Turn any OpenAPI spec into MCP tools for Claude — instantly. Point mcp-openapi at any OpenAPI 3.x spec and Claude can call every endpoint through natural language. No custom integration code. No manual tool definitions. One line of config.
    2
    40 npm
    1
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Converts any REST API endpoints into MCP tools, enabling AI clients like Cursor and Claude Desktop to call internal services directly.
    -