Skip to main content
Glama

FastAPI-MCP

by tadata-org

特徴

  • 既存の FastAPI 依存関係を使用して、認証が組み込まれています。
  • **FastAPIネイティブ:**単なるOpenAPI -> MCPコンバータではない
  • 設定はゼロ/最小限で済みます。FastAPI アプリを指定するだけで動作します。
  • リクエストモデルとレスポンスモデルのスキーマの保持
  • Swaggerと同じように、すべてのエンドポイントのドキュメントを保存します
  • 柔軟な展開- MCP サーバーを同じアプリにマウントするか、個別に展開します
  • ASGIトランスポート- 効率的な通信のためにFastAPIのASGIインターフェースを直接使用します

インストール

高速な 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.

-
security - not tested
A
license - permissive license
-
quality - not tested

FastAPI エンドポイントをモデル コンテキスト プロトコル (MCP) ツールとして自動的に公開するゼロ構成ツール。これにより、Claude などの LLM システムが追加のコーディングなしで API と対話できるようになります。

  1. インストール
    1. 基本的な使い方
      1. ドキュメント、例、高度な使用法
        1. FastAPIファーストアプローチ
          1. 開発と貢献
            1. コミュニティ
              1. 要件
                1. ライセンス

                  Related MCP Servers

                  • -
                    security
                    F
                    license
                    -
                    quality
                    A MCP server that exposes OpenAPI schema information to LLMs like Claude. This server allows an LLM to explore and understand large OpenAPI schemas through a set of specialized tools, without needing to load the whole schema into the context
                    Last updated -
                    37
                    5
                    JavaScript
                    • Apple
                    • Linux
                  • -
                    security
                    F
                    license
                    -
                    quality
                    A simple application demonstrating Model Context Protocol (MCP) integration with FastAPI and Streamlit, allowing users to interact with LLMs through a clean interface.
                    Last updated -
                    3
                    Python
                    • Linux
                  • A
                    security
                    A
                    license
                    A
                    quality
                    A Model Context Protocol server that loads multiple OpenAPI specifications and exposes them to LLM-powered IDE integrations, enabling AI to understand and work with your APIs directly in development tools like Cursor.
                    Last updated -
                    7
                    292
                    7
                    TypeScript
                    MIT License
                  • -
                    security
                    A
                    license
                    -
                    quality
                    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.
                    Last updated -
                    1
                    Python
                    MIT License

                  View all related MCP servers

                  MCP directory API

                  We provide all the information about MCP servers via our MCP API.

                  curl -X GET 'https://glama.ai/api/mcp/v1/servers/tadata-org/fastapi_mcp'

                  If you have feedback or need assistance with the MCP directory API, please join our Discord server