fastmcp-server

endou-mame/fastmcp-server

3.1

If you are the rightful owner of fastmcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

FastMCP Server is a simple implementation of a Model Context Protocol (MCP) server using FastAPI to provide an API for communication with AI models.

FastMCP Server

FastMCPを使用したシンプルなModel Context Protocol (MCP) サーバーの実装です。このサーバーは、FastAPIフレームワークを利用してAIモデルとの通信を行うAPIを提供します。

機能

  • /chat エンドポイント:ユーザーのメッセージを受け取り、AIモデルからのレスポンスを返します
  • 環境変数による設定:APIキーやモデル選択などを柔軟に設定可能

必要条件

  • Python 3.9以上
  • APIキー(Anthropic Claude API等)

インストール方法

  1. リポジトリをクローン

    git clone https://github.com/endou-mame/fastmcp-server.git
    cd fastmcp-server
    
  2. 仮想環境を作成して有効化

    python -m venv venv
    source venv/bin/activate  # Linuxの場合
    # または
    venv\Scripts\activate  # Windowsの場合
    
  3. 依存パッケージをインストール

    pip install -r requirements.txt
    
  4. 環境変数の設定

    cp .env.example .env
    # .envファイルを編集して、APIキーなどを設定
    

使用方法

  1. サーバーを起動

    python main.py
    
  2. ブラウザまたはAPIクライアントで http://localhost:8000 にアクセス

  3. /chat エンドポイントにPOSTリクエストを送信

    curl -X POST "http://localhost:8000/chat" \
         -H "Content-Type: application/json" \
         -d '{"message": "こんにちは、AIさん"}'  
    

API仕様

GET /

  • サーバーの状態を確認するためのエンドポイント
  • レスポンス例: {"status": "running", "message": "Simple MCP Server is running"}

POST /chat

  • パラメータ:
    • message: ユーザーからのメッセージ(文字列)
  • レスポンス: AIモデルからのレスポンス
    • 成功時: {"response": "AIからの返答"}
    • エラー時: {"error": "エラーメッセージ"}

ライセンス

MIT