mcp-pyodide
mcp-ピオジド
モデルコンテキストプロトコル(MCP)用のPyodideサーバー実装。このサーバーにより、大規模言語モデル(LLM)がMCPインターフェースを介してPythonコードを実行できるようになります。
特徴
Pyodide を使用した LLM 向け Python コード実行機能
MCP準拠のサーバー実装
stdio と SSE トランスポートモードの両方をサポート
TypeScriptで書かれた堅牢な実装
コマンドラインツールとして利用可能
Related MCP server: Sandbox MCP
インストール
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-pyodideSSE モードで起動します。
mcp-pyodide --sseSSEモード
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)
ライセンス
マサチューセッツ工科大学
貢献
リポジトリをフォークする
機能ブランチを作成する (
git checkout -b feature/amazing-feature)変更をコミットします (
git commit -am 'Add some amazing feature')ブランチにプッシュする (
git push origin feature/amazing-feature)プルリクエストを作成する
重要な注意事項
このプロジェクトは開発中であり、APIは変更される可能性があります。
実稼働で使用する前に徹底的にテストする
セキュリティ上の理由から、信頼できないコードを実行するときは注意してください
SSEモードを使用する場合は、必要に応じて適切なCORS構成を確認してください。
サポート
問題や質問については、問題追跡システムをご利用ください。
Available Tools
5 toolspyodide_executeA
Execute Python code using Pyodide with output capture. When generating images, they will be automatically saved to the output directory instead of being displayed. Images can be accessed from the saved file paths that will be included in the output.
Inputs: code (required), timeout.
pyodide_get-mount-pointsB
List mounted directories
Inputs: no named parameters.
pyodide_install-packagesC
Install Python packages using Pyodide. Multiple packages can be specified using space-separated format.
Inputs: package (required).
pyodide_list-mounted-directoryB
List contents of a mounted directory
Inputs: mountName (required).
pyodide_read-imageC
Read an image from a mounted directory
Inputs: mountName (required), imagePath (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Most tools have distinct purposes: execute code, list mount points, install packages, list directory contents, and read images. However, pyodide_get-mount-points and pyodide_list-mounted-directory could cause minor confusion as both relate to directory listing, but their scopes differ (mount points vs. specific directory contents).
All tools follow a consistent pyodide_verb-noun naming pattern with hyphens for multi-word verbs or nouns. This uniformity makes the tool set predictable and easy to understand, with no mixing of conventions.
With 5 tools, the count is reasonable for a Pyodide execution server, covering core operations like code execution, package management, and file handling. It might benefit from additional tools for writing files or managing environments, but it's well-scoped for basic functionality.
The tools cover key areas such as code execution, package installation, and file reading/listing, but there are notable gaps. For example, there's no tool for writing or saving files (beyond automatic image saving), deleting files, or managing Python environments more comprehensively, which could limit agent workflows.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
MCP server for AI dialogue using various LLM models via AceDataCloud
Related MCP Servers
- AlicenseAqualityBmaintenanceA Model Context Protocol server that allows LLMs to interact with Python environments, execute code, and manage files within a specified working directory.10495 PyPI104MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server that enables LLMs to run ANY code safely in isolated Docker containers.125MIT
- AlicenseBqualityDmaintenanceA secure Model Context Protocol server that allows AI assistants and LLM applications to safely execute Python and JavaScript code snippets in containerized environments.2205MIT
- AlicenseAqualityDmaintenanceA production-grade MCP server providing a persistent Python REPL with multi-session support, sandboxing, and timeout protection, enabling LLM agents to execute Python code across multiple turns with variables that persist between calls.1231 PyPI1MIT