YM

yonaka15/mcp-pyodide

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

19 stars 6 forks 品質 53 トレンド 22MIT

モデルコンテキストプロトコル(MCP)のPyodideサーバ実装.

概要

モデルコンテキストプロトコル(MCP)のPyodideサーバ実装。 このサーバーは、MCP インターフェイスを介して Python コードを実行するために、大言語モデル (LLM) を有効にします。 - Pyodide - MCP 準拠サーバーの実装を使用して LLM の Python コード実行機能 - stdio と SSE の両方の転送モードのサポート - TypeScript で書かれた強力な実装 - コマンドラインツールとして使用可能 SSEモードで実行すると、サーバーは次のエンドポイントを提供します。 - SSE接続: http://localhost:3020/sse - メッセージハンドラ: [http://localhost:3020/messages - @modelcontextprotocol/sdk: MCP SDK (^1.4.0) - pyodide: Python のランタイム環境 (^0.27.1) - arktype: 型検証ライブラリ (^2.0.1) - エクスプレス: SSE サポートの Web フレームワーク - SSE サポートの CORS ミドルウェア - ノード.

概要(AI 翻訳)

モデルコンテキストプロトコル(MCP)のPyodideサーバ実装。 このサーバーは、MCP インターフェイスを介して Python コードを実行するために、大言語モデル (LLM) を有効にします。

##特徴

  • Pyodide を用いた LLM の Python コード実行機能
  • MCP準拠サーバ実装
  • stdioおよびSSEの輸送モードのためのサポート
  • TypeScriptで書かれた強力な実装
  • コマンドラインツールとして使用可能

インストール

使用法

サーバーとして

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

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

SSEモードで開始:

##SSEモード

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

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

クライアント接続例:

プロジェクト構成

依存関係

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

開発

要件

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

セットアップ

スクリプト

  • [npm run build]: TypeScript のコンパイルと実行権限の設定

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

mcp-pyodide

A Pyodide server implementation for the Model Context Protocol (MCP). This server enables Large Language Models (LLMs) to execute Python code through the MCP interface.

Features

  • Python code execution capability for LLMs using Pyodide
  • MCP compliant server implementation
  • Support for both stdio and SSE transport modes
  • Robust implementation written in TypeScript
  • Available as a command-line tool

Installation

npm install mcp-pyodide

Usage

As a Server

import { runServer } from "mcp-pyodide";

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

As a Command-line Tool

Start in stdio mode (default):

mcp-pyodide

Start in SSE mode:

mcp-pyodide --sse

SSE Mode

When running in SSE mode, the server provides the following endpoints:

  • SSE Connection: http://localhost:3020/sse
  • Message Handler: http://localhost:3020/messages

Example client connection:

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

Project Structure

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

Dependencies

  • @modelcontextprotocol/sdk: MCP SDK (^1.4.0)
  • pyodide: Python runtime environment (^0.27.1)
  • arktype: Type validation library (^2.0.1)
  • express: Web framework for SSE support
  • cors: CORS middleware for SSE support

Development

Requirements

  • Node.js 18 or higher
  • npm 9 or higher

Setup

# Clone the repository
git clone 

# Install dependencies
npm install

# Build
npm run build

Scripts

  • npm run build: Compile TypeScript and set execution permissions
  • npm start: Run server in stdio mode
  • npm run start:sse: Run server in SSE mode

Environment Variables

  • PYODIDE_CACHE_DIR: Directory for Pyodide cache (default: “./cache”)
  • PYODIDE_DATA_DIR: Directory for mounted data (default: “./data”)
  • PORT: Port for SSE server (default: 3020)

License

MIT

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -am 'Add some amazing feature')
GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →