MCP Server with Docker

MIT License
  • Linux
  • Apple

Integrations

  • Enables the MCP server to run inside Docker containers, providing tool access while maintaining isolation and portability.

  • Provides integration with OpenAI's API, allowing OpenAI models to access and use tools exposed by the MCP server for retrieving information like knowledge base data.

Docker を使用した MCP サーバー

このプロジェクトは、モデル制御プロトコル (MCP) を OpenAI の API と統合し、OpenAI が Docker で実行されている MCP サーバーによって公開されるツールにアクセスして使用できるようにする方法を示します。

前提条件

  • システムにDockerがインストールされている
  • Git(リポジトリのクローンを作成する)

プロジェクト構造

  • server.py : ツールを使ったMCPサーバ実装
  • client.py : サーバーに接続してエージェントを呼び出すクライアント
  • Dockerfile : Dockerイメージを構築するための手順
  • requirements.txt : プロジェクトの Python 依存関係

データフローの説明

  1. ユーザークエリ: ユーザーはシステムにクエリを送信します (例: 「当社の休暇ポリシーは何ですか?」)
  2. OpenAI API : OpenAIはMCPサーバーからクエリと利用可能なツールを受け取ります
  3. ツールの選択: OpenAIはクエリに基づいてどのツールを使用するかを決定します
  4. MCPクライアント:クライアントはOpenAIのツール呼び出し要求を受信し、MCPサーバーに転送します。
  5. MCP サーバー: サーバーは要求されたツールを実行します (例: ナレッジ ベース データの取得)
  6. レスポンスフロー: ツールの結果はMCPクライアントを介してOpenAIに返されます。
  7. 最終応答: OpenAIはツールデータを組み込んだ最終応答を生成する

Dockerで実行する

ステップ1: Dockerイメージを構築する

docker build -t mcp-server .

ステップ2: Dockerコンテナを実行する

docker run -p 8050:8050 mcp-server

これにより、Docker コンテナ内で MCP サーバーが起動し、ポート 8050 で公開されます。

クライアントの実行

サーバーが起動したら、別のターミナルでクライアントを実行できます。

python client.py

クライアントはサーバーに接続し、利用可能なツールを一覧表示し、エージェントを呼び出してクエリに応答します。

トラブルシューティング

接続の問題が発生した場合:

  1. サーバーが実行中かどうかを確認します。docker docker psを使用して Docker コンテナが実行中であることを確認します。
  2. ポート マッピングを確認する: docker psを使用するか、 docker runコマンドの出力をチェックして、ポートが正しくマッピングされていることを確認します。
  3. サーバー ログを確認する: docker logs <container_id>を使用してサーバー ログを表示し、エラーがあるかどうかを確認します。
  4. ホストバインディング:コンテナ外からアクセスできるようにするため、サーバーは127.0.0.1ではなく0.0.0.0にバインドするように設定されています。それでも問題が解決しない場合は、ファイアウォールの設定を確認する必要があるかもしれません。
  5. ネットワークの問題: リモート マシンで Docker を実行している場合は、クライアント マシンからポートにアクセスできることを確認してください。

注記

  • サーバーは SSE (Server-Sent Events) トランスポートを使用するように構成されており、ポート 8050 でリッスンします。
  • クライアントはhttp://localhost:8050/sseでサーバーに接続します。
  • クライアントを起動する前に、サーバーが実行中であることを確認してください。
-
security - not tested
A
license - permissive license
-
quality - not tested

モデル制御プロトコルを OpenAI の API と統合し、OpenAI が Docker 化された MCP サーバーによって公開されるツールにアクセスして利用できるようにするプロジェクト。

  1. Prerequisites
    1. Project Structure
      1. Data Flow Explanation
    2. Running with Docker
      1. Step 1: Build the Docker image
      2. Step 2: Run the Docker container
    3. Running the Client
      1. Troubleshooting
        1. Notes

          Related MCP Servers

          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol (MCP) server that lets you seamlessly use OpenAI's models right from Claude.
            Last updated -
            1
            24
            28
            JavaScript
            MIT License
            • Apple
          • -
            security
            A
            license
            -
            quality
            A simple MCP server for interacting with OpenAI assistants. This server allows other tools (like Claude Desktop) to create and interact with OpenAI assistants through the Model Context Protocol.
            Last updated -
            18
            Python
            MIT License
            • Apple
          • A
            security
            A
            license
            A
            quality
            Enables integration with OpenAI models through the MCP protocol, supporting concise and detailed responses for use with Claude Desktop.
            Last updated -
            1
            1
            Python
            MIT License
            • Apple
            • Linux
          • -
            security
            F
            license
            -
            quality
            A Model Context Protocol server implementation that enables connection between OpenAI APIs and MCP clients for coding assistance with features like CLI interaction, web API integration, and tool-based architecture.
            Last updated -
            9
            Python
            • Linux
            • Apple

          View all related MCP servers

          ID: yu6qfxkcxv