OpenSCAD MCP Server

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Manages environment variables for API keys and configuration settings, including remote processing options

  • Build system used to compile the CUDA Multi-View Stereo dependency for 3D reconstruction

  • Used for cloning and managing external dependencies like the cuda-multi-view-stereo repository for 3D reconstruction

OpenSCAD MCP サーバー

マルチビュー再構築と OpenSCAD を使用してパラメトリック 3D モデルを作成することに重点を置いて、ユーザーがテキスト記述または画像から 3D モデルを生成できるようにするモデル コンテキスト プロトコル (MCP) サーバーです。

特徴

  • AI画像生成: Google GeminiまたはVenice.ai APIを使用してテキストの説明から画像を生成します
  • マルチビュー画像生成:再構築のために同じ3Dオブジェクトの複数のビューを作成します
  • 画像承認ワークフロー: 再構築前に生成された画像を確認し、承認/拒否する
  • 3D再構成: CUDAマルチビューステレオを使用して、承認されたマルチビュー画像を3Dモデルに変換します。
  • リモート処理: LAN 内のリモート サーバーで計算負荷の高いタスクを処理します。
  • OpenSCAD 統合: OpenSCAD を使用してパラメトリック 3D モデルを生成する
  • パラメトリックエクスポート: パラメトリックプロパティを保持する形式でモデルをエクスポートします (CSG、AMF、3MF、SCAD)
  • 3Dプリンターの検出: オプションのネットワークプリンターの検出と直接印刷

建築

サーバーは Python MCP SDK を使用して構築され、モジュール アーキテクチャに従います。

openscad-mcp-server/ ├── src/ │ ├── main.py # Main application │ ├── main_remote.py # Remote CUDA MVS server │ ├── ai/ # AI integrations │ │ ├── gemini_api.py # Google Gemini API for image generation │ │ └── venice_api.py # Venice.ai API for image generation (optional) │ ├── models/ # 3D model generation │ │ ├── cuda_mvs.py # CUDA Multi-View Stereo integration │ │ └── code_generator.py # OpenSCAD code generation │ ├── workflow/ # Workflow components │ │ ├── image_approval.py # Image approval mechanism │ │ └── multi_view_to_model_pipeline.py # Complete pipeline │ ├── remote/ # Remote processing │ │ ├── cuda_mvs_client.py # Client for remote CUDA MVS processing │ │ ├── cuda_mvs_server.py # Server for remote CUDA MVS processing │ │ ├── connection_manager.py # Remote connection management │ │ └── error_handling.py # Error handling for remote processing │ ├── openscad_wrapper/ # OpenSCAD CLI wrapper │ ├── visualization/ # Preview generation and web interface │ ├── utils/ # Utility functions │ └── printer_discovery/ # 3D printer discovery ├── scad/ # Generated OpenSCAD files ├── output/ # Output files (models, previews) │ ├── images/ # Generated images │ ├── multi_view/ # Multi-view images │ ├── approved_images/ # Approved images for reconstruction │ └── models/ # Generated 3D models ├── templates/ # Web interface templates └── static/ # Static files for web interface

インストール

  1. リポジトリをクローンします。
    git clone https://github.com/jhacksman/OpenSCAD-MCP-Server.git cd OpenSCAD-MCP-Server
  2. 仮想環境を作成します。
    python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
  3. 依存関係をインストールします:
    pip install -r requirements.txt
  4. OpenSCAD をインストールします。
    • Ubuntu/Debian: sudo apt-get install openscad
    • macOS: brew install openscad
    • Windows: openscad.orgからダウンロード
  5. CUDA Multi-View Stereo をインストールします。
    git clone https://github.com/fixstars/cuda-multi-view-stereo.git cd cuda-multi-view-stereo mkdir build && cd build cmake .. make
  6. API キーを設定します。
    • ルートディレクトリに.envファイルを作成する
    • API キーを追加します:
      GEMINI_API_KEY=your-gemini-api-key VENICE_API_KEY=your-venice-api-key # Optional REMOTE_CUDA_MVS_API_KEY=your-remote-api-key # For remote processing

リモート処理のセットアップ

サーバーは、特にCUDAマルチビューステレオ再構成など、計算負荷の高いタスクのリモート処理をサポートします。これにより、LAN内のより高性能なマシンに処理をオフロードできます。

サーバーのセットアップ(CUDA GPU 搭載マシン上)

  1. サーバーマシンに CUDA Multi-View Stereo をインストールします。
    git clone https://github.com/fixstars/cuda-multi-view-stereo.git cd cuda-multi-view-stereo mkdir build && cd build cmake .. make
  2. リモート CUDA MVS サーバーを起動します。
    python src/main_remote.py
  3. サーバーは、Zeroconf を使用してローカル ネットワーク上で自動的に自分自身をアドバタイズします。

クライアント構成

  1. .envファイルでリモート処理を構成します。
    REMOTE_CUDA_MVS_ENABLED=True REMOTE_CUDA_MVS_USE_LAN_DISCOVERY=True REMOTE_CUDA_MVS_API_KEY=your-shared-secret-key
  2. あるいは、サーバーの URL を直接指定することもできます。
    REMOTE_CUDA_MVS_ENABLED=True REMOTE_CUDA_MVS_USE_LAN_DISCOVERY=False REMOTE_CUDA_MVS_SERVER_URL=http://server-ip:8765 REMOTE_CUDA_MVS_API_KEY=your-shared-secret-key

リモート処理機能

  • 自動サーバー検出: ローカルネットワーク上の CUDA MVS サーバーを検索します
  • ジョブ管理: 画像のアップロード、ジョブのステータスの追跡、結果のダウンロード
  • フォールトトレランス: 自動再試行、サーキットブレーカーパターン、エラー追跡
  • 認証: すべてのリモート操作に対する安全なAPIキー認証
  • ヘルスモニタリング: 継続的なサーバーのヘルスチェックとステータスレポート

使用法

  1. サーバーを起動します。
    python src/main.py
  2. サーバーはhttp://localhost:8000で起動します。
  3. MCP ツールを使用してサーバーと対話します。
    • generate_image_gemini : Google Gemini API を使用して画像を生成する
      { "prompt": "A low-poly rabbit with black background", "model": "gemini-2.0-flash-exp-image-generation" }
    • generate_multi_view_images : 同じ 3D オブジェクトの複数のビューを生成する
      { "prompt": "A low-poly rabbit", "num_views": 4 }
    • create_3d_model_from_images : 承認されたマルチビュー画像から 3D モデルを作成する
      { "image_ids": ["view_1", "view_2", "view_3", "view_4"], "output_name": "rabbit_model" }
    • create_3d_model_from_text : テキストから 3D モデルへの完全なパイプライン
      { "prompt": "A low-poly rabbit", "num_views": 4 }
    • export_model : モデルを特定の形式でエクスポートする
      { "model_id": "your-model-id", "format": "obj" // or "stl", "ply", "scad", etc. }
    • discover_remote_cuda_mvs_servers : ネットワーク上の CUDA MVS サーバーを検索します
      { "timeout": 5 }
    • get_remote_job_status : リモート処理ジョブのステータスを確認する
      { "server_id": "server-id", "job_id": "job-id" }
    • download_remote_model_result : リモートサーバーから完成したモデルをダウンロードする
      { "server_id": "server-id", "job_id": "job-id", "output_name": "model-name" }
    • discover_printers : ネットワーク上の3Dプリンターを発見する
      {}
    • print_model : 接続されたプリンターでモデルを印刷する
      { "model_id": "your-model-id", "printer_id": "your-printer-id" }

画像生成オプション

サーバーは複数の画像生成オプションをサポートしています。

  1. Google Gemini API (デフォルト):高品質の画像生成にGemini 2.0 Flash Experimentalモデルを使用します
    • 一貫したスタイルでマルチビュー生成をサポート
    • Google Gemini APIキーが必要です
  2. Venice.ai API (オプション):代替画像生成サービス
    • flux-devやfluently-xlを含むさまざまなモデルをサポート
    • Venice.ai APIキーが必要です
  3. ユーザー提供画像: 画像生成をスキップして独自の画像を使用する
    • 画像をサーバーに直接アップロードする
    • 既存の写真やレンダリングを扱うのに便利

マルチビューワークフロー

サーバーは、3D 再構築のためのマルチビュー ワークフローを実装します。

  1. 画像生成: 同じ 3D オブジェクトの複数のビューを生成します
  2. 画像承認: 生成された各画像を確認し、承認/拒否します
  3. 3D再構築: CUDA MVSを使用して承認された画像を3Dモデルに変換します。
    • ローカルまたはLAN内のリモートサーバーで処理できます
  4. モデルの改良: オプションでOpenSCADを使用してモデルを改良する

リモート処理ワークフロー

リモート処理ワークフローを使用すると、計算負荷の高いタスクをより強力なマシンにオフロードできます。

  1. サーバー検出: ネットワーク上の CUDA MVS サーバーを自動的に検出します
  2. 画像アップロード: 承認されたマルチビュー画像をリモートサーバーにアップロードします
  3. ジョブ処理: CUDA MVSを使用してリモートサーバー上の画像を処理する
  4. ステータス追跡: ジョブのステータスと進行状況を監視する
  5. 結果ダウンロード: 処理が完了したら完成した3Dモデルをダウンロードします

サポートされているエクスポート形式

サーバーはさまざまな形式でのモデルのエクスポートをサポートしています。

  • OBJ : Wavefront OBJ形式(標準3Dモデル形式)
  • STL : 標準三角形言語(3Dプリント用)
  • PLY : ポリゴンファイル形式(点群およびメッシュ用)
  • SCAD : OpenSCAD ソースコード (パラメトリック モデル用)
  • CSG : OpenSCAD CSG 形式 (すべてのパラメトリック プロパティを保持)
  • AMF : 付加製造ファイル形式(一部のメタデータを保持)
  • 3MF : 3D 製造フォーマット (メタデータ付きの STL の最新代替)

ウェブインターフェース

サーバーは次の Web インターフェイスを提供します。

  • マルチビュー画像の生成と承認
  • 3Dモデルをさまざまな角度からプレビューする
  • さまざまな形式でのモデルのダウンロード

http://localhost:8000/ui/でインターフェースにアクセスします。

ライセンス

マサチューセッツ工科大学

貢献

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

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

AI 画像生成とリモート処理をサポートし、マルチビュー再構築と OpenSCAD を使用して、テキスト記述または画像からパラメトリック 3D モデルを生成できます。

  1. Features
    1. Architecture
      1. Installation
        1. Remote Processing Setup
          1. Server Setup (on the machine with CUDA GPU)
          2. Client Configuration
          3. Remote Processing Features
        2. Usage
          1. Image Generation Options
            1. Multi-View Workflow
              1. Remote Processing Workflow
                1. Supported Export Formats
                  1. Web Interface
                    1. License
                      1. Contributing
                        ID: cnf17irjiq