Awesome MCP FastAPI

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Supports environment variable configuration through .env files when running with Docker, as shown in the docker run command with --env-file flag.

  • Provides Docker support for building and running the MCP server in containers, with detailed instructions for Docker deployment.

  • The MCP server is built on FastAPI, leveraging its ecosystem for automatic OpenAPI documentation generation, dependency injection, middleware support, validation, and async capabilities.

素晴らしいMCP FastAPI

成熟した FastAPI エコシステムを活用し、強化されたツール レジストリ機能を備えた強力な FastAPI ベースのモデル コンテキスト プロトコル (MCP) 実装。

概要

Awesome MCP FastAPIは、モデルコンテキストプロトコル(MCP)の実稼働対応実装であり、FastAPIの堅牢なエコシステムと統合することで、標準MCP機能を強化・拡張します。このプロジェクトは、大規模言語モデル(LLM)向けのAIツールの作成、管理、ドキュメント化を容易にする、改良されたツールレジストリシステムを提供します。

これが標準のMCPよりも優れている理由

モデル コンテキスト プロトコルは AI モデルをツールやデータ ソースに接続するための強固な基盤を提供しますが、私たちの実装にはいくつかの大きな利点があります。

FastAPIの成熟したエコシステム

  • 本番環境対応の Web フレームワーク: OpenAPI ドキュメントの自動生成機能を備えた高性能の最新 Web フレームワークである FastAPI 上に構築されています。
  • 依存性注入: FastAPI の強力な依存性注入システムを活用して、より保守しやすくテストしやすいコードを作成します。
  • ミドルウェア サポート: 認証、監視、その他のミドルウェア コンポーネントとの簡単な統合。
  • 組み込み検証: 堅牢なリクエスト/レスポンス検証とデータ モデリングのための Pydantic 統合。
  • 非同期サポート: 高同時実行アプリケーション向けの async/await パターンに対するファーストクラスのサポート。

強化されたツールレジストリ

私たちの実装は、次の点で標準の MCP ツール レジストリを改善します。

  • 自動ドキュメント生成: ツールは、MCP 形式と OpenAPI 仕様の両方で自動的にドキュメント化されます。
  • 型ヒントの改善: 型情報の抽出が強化され、ツールと IDE サポートが向上しました。
  • より豊富なスキーマ定義: ツールの入力と出力のためのより表現力豊かな JSON スキーマ定義。
  • 改善されたエラー処理: 詳細な情報を含む構造化されたエラー応答。
  • 強化された Docstring サポート: Python の docstring からのドキュメントの抽出が改善されました。

追加機能

  • CORS サポート: クロスオリジン リクエストに対応しており、Web アプリケーションとの統合が容易になります。
  • ライフスパン管理: FastAPI のライフスパン API による適切なリソースの初期化とクリーンアップ。

はじめる

前提条件

  • Python 3.10以上

インストール

# Clone the repository git clone https://github.com/yourusername/awesome-mcp-fastapi.git cd awesome-mcp-fastapi # Create a virtual environment python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate # Install dependencies pip install -e .

サーバーの実行

uvicorn src.main:app --reload

OpenAPI ドキュメントを参照するには、 http://localhost:8000/docsにアクセスしてください。

使用法

ツールの作成

from fastapi import FastAPI from src.utils.tools import auto_tool, bind_app_tools app = FastAPI() bind_app_tools(app) @auto_tool( name="calculator", description="Perform basic arithmetic operations", tags=["math"] ) @app.post("/api/calculator") async def calculator(operation: str, a: float, b: float): """ Perform basic arithmetic operations. Parameters: - operation: The operation to perform (add, subtract, multiply, divide) - a: First number - b: Second number Returns: The result of the operation """ if operation == "add": return {"result": a + b} elif operation == "subtract": return {"result": a - b} elif operation == "multiply": return {"result": a * b} elif operation == "divide": if b == 0: return {"error": "Cannot divide by zero"} return {"result": a / b} else: return {"error": f"Unknown operation: {operation}"}

MCP 経由でツールにアクセスする

LLMはモデルコンテキストプロトコルを通じてツールを検出し、使用できます。Claudeを使用した例:

You can perform calculations using the calculator tool. Try calculating 42 * 13.

Claude は自動的に計算ツールを見つけて使用し、計算を実行します。

建築

私たちのアプリケーションはモジュール型アーキテクチャに従っています。

src/ ├── api/ # API endpoints │ └── v1/ # API version 1 ├── core/ # Core functionality │ └── settings.py # Application settings ├── db/ # Database connections │ └── models/ # Database models ├── main.py # Application entry point └── utils/ # Utility functions └── tools.py # Enhanced tool registry

Docker サポート

Docker でビルドして実行します。

docker build -t awesome-mcp-fastapi . docker run -p 8000:8000 --env-file .env awesome-mcp-fastapi

貢献

貢献を歓迎します!お気軽にプルリクエストを送信してください。

ライセンス

このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細については LICENSE ファイルを参照してください。

-
security - not tested
F
license - not found
-
quality - not tested

FastAPI を使用して構築された本番環境対応の MCP サーバー。大規模言語モデル (LLM) 用の AI ツールを作成、管理、ドキュメント化するための拡張ツール レジストリを提供します。

  1. Overview
    1. Why This Is Better Than Standard MCP
      1. FastAPI's Mature Ecosystem
      2. Enhanced Tool Registry
      3. Additional Features
    2. Getting Started
      1. Prerequisites
      2. Installation
      3. Running the Server
    3. Usage
      1. Creating a Tool
      2. Accessing Tools Through MCP
    4. Architecture
      1. Docker Support
        1. Contributing
          1. License
            ID: 2ysi73d5t3