mcp-pyodide

hybrid server

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

Integrations

  • Used as the web framework for SSE (Server-Sent Events) support, providing endpoints for SSE connection and message handling

  • The server runs on Node.js, requiring version 18 or higher for development

  • Used for package management and running scripts for the MCP server

mcp-ピオジド

モデルコンテキストプロトコル(MCP)用のPyodideサーバー実装。このサーバーにより、大規模言語モデル(LLM)がMCPインターフェースを介してPythonコードを実行できるようになります。

特徴

  • Pyodide を使用した LLM 向け Python コード実行機能
  • MCP準拠のサーバー実装
  • stdio と SSE トランスポートモードの両方をサポート
  • TypeScriptで書かれた堅牢な実装
  • コマンドラインツールとして利用可能

インストール

npm install mcp-pyodide

使用法

サーバーとして

import { runServer } from "mcp-pyodide"; // Start the server runServer().catch((error: unknown) => { console.error("Error starting server:", error); process.exit(1); });

コマンドラインツールとして

stdio モードで起動します (デフォルト):

mcp-pyodide

SSE モードで起動します。

mcp-pyodide --sse

SSEモード

SSE モードで実行している場合、サーバーは次のエンドポイントを提供します。

  • SSE 接続: http://localhost:3020/sse
  • メッセージハンドラー: http://localhost:3020/messages

クライアント接続の例:

const eventSource = new EventSource("http://localhost:3020/sse"); eventSource.onmessage = (event) => { console.log("Received:", JSON.parse(event.data)); };

プロジェクト構造

mcp-pyodide/ ├── src/ │ ├── formatters/ # Data formatting handlers │ ├── handlers/ # Request handlers │ ├── lib/ # Library code │ ├── tools/ # Utility tools │ ├── utils/ # Utility functions │ └── index.ts # Main entry point ├── build/ # Build artifacts ├── pyodide-packages/ # Pyodide-related packages └── package.json

依存関係

  • @modelcontextprotocol/sdk : MCP SDK (^1.4.0)
  • pyodide : Python ランタイム環境 (^0.27.1)
  • arktype : 型検証ライブラリ (^2.0.1)
  • express : SSE サポート用の Web フレームワーク
  • cors : SSE サポート用の CORS ミドルウェア

発達

要件

  • Node.js 18以上
  • npm 9以上

設定

# Clone the repository git clone <repository-url> # Install dependencies npm install # Build npm run build

スクリプト

  • npm run build : TypeScript をコンパイルし、実行権限を設定する
  • npm start : stdioモードでサーバーを実行する
  • npm run start:sse : SSEモードでサーバーを実行する

環境変数

  • PYODIDE_CACHE_DIR : Pyodide キャッシュのディレクトリ (デフォルト: "./cache")
  • PYODIDE_DATA_DIR : マウントされたデータのディレクトリ(デフォルト: "./data")
  • PORT : SSEサーバーのポート(デフォルト: 3020)

ライセンス

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

貢献

  1. リポジトリをフォークする
  2. 機能ブランチを作成する ( git checkout -b feature/amazing-feature )
  3. 変更をコミットします ( git commit -am 'Add some amazing feature' )
  4. ブランチにプッシュする ( git push origin feature/amazing-feature )
  5. プルリクエストを作成する

重要な注意事項

  • このプロジェクトは開発中であり、APIは変更される可能性があります。
  • 実稼働で使用する前に徹底的にテストする
  • セキュリティ上の理由から、信頼できないコードを実行するときは注意してください
  • SSEモードを使用する場合は、必要に応じて適切なCORS構成を確認してください。

サポート

問題や質問については、問題追跡システムをご利用ください。

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

モデル コンテキスト プロトコル (MCP) を介して大規模言語モデル (LLM) によって Python コードを実行するための Pyodide サーバー。

  1. Features
    1. Installation
      1. Usage
        1. As a Server
        2. As a Command-line Tool
        3. SSE Mode
      2. Project Structure
        1. Dependencies
          1. Development
            1. Requirements
            2. Setup
            3. Scripts
          2. Environment Variables
            1. License
              1. Contributing
                1. Important Notes
                  1. Support
                    ID: pxls43joly