Skip to main content
Glama
mcp-pyodide
by yonaka15

mcp-пиодид

Реализация сервера Pyodide для Model Context Protocol (MCP). Этот сервер позволяет моделям больших языков (LLM) выполнять код Python через интерфейс MCP.

Функции

  • Возможность выполнения кода Python для LLM с использованием Pyodide

  • Реализация сервера, совместимого с 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-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

  • cors : промежуточное ПО CORS для поддержки SSE

Разработка

Требования

  • Node.js 18 или выше

  • нпм 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.

Поддерживать

Для решения проблем и вопросов используйте систему отслеживания проблем.

Available Tools

5 tools
pyodide_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

    B3.4/5.0

    Scored across 5 tools

    Disambiguation4/5

    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).

    Naming Consistency5/5

    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.

    Tool Count4/5

    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.

    Completeness3/5

    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

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol (MCP) server that enables LLMs to run ANY code safely in isolated Docker containers.
      125
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A secure Model Context Protocol server that allows AI assistants and LLM applications to safely execute Python and JavaScript code snippets in containerized environments.
      2
      205
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      A 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.
      12
      31 PyPI
      1
      MIT