BM

bazinga012/mcp_code_executor

Developer tools

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

211 stars 43 forks Качество 65 Тренд 17MIT

bazinga012/mcp_code_executor — это кандидат на MCP-сервер, импортированный из https://github.com/bazinga012/mcp_code_executor.

Обзор

bazinga012/mcp_code_executor — это кандидат на MCP-сервер, импортированный из https://github.com/bazinga012/mcp_code_executor.

Обзор (машинный перевод)

MCP Code Executor — это MCP-сервер, который позволяет LLM выполнять код на Python в определённой среде Python. Это позволяет LLM запускать код с доступом к библиотекам и зависимостям, определённым в окружающей среде. Он также поддерживает инкрементальную генерацию кода для обработки больших блоков кода, которые могут превышать лимиты токенов.

Особенности

  • Выполнять код на Python из LLM-запросов
  • Поддержка инкрементальной генерации кода для преодоления ограничений токенов
  • Запускать код в определённой среде (Conda, virtualenv или UV virtualenv)
  • Установка зависимостей при необходимости
  • Проверить, установлены ли пакеты
  • Динамическая настройка среды во время выполнения
  • Настраиваемый каталог хранения кода

Предварительные требования

  • Node.js установлен
  • Один из следующих:
  • Conda установлен с созданной желаемой средой Conda
  • Python virtualenv
  • UV virtualenv

Подготовка

  1. Клонируйте этот репозиторий:

  2. Перейти в каталог проектов:

  3. Установите Node.js зависимости:

  4. Постройте проект:

Конфигурация

Чтобы настроить сервер исполнения кода MCP, добавьте в конфигурационный файл вашего сервера MCP следующее:

Использование Node.js

Использование Docker

Эта страница переведена автоматически. Технические детали смотрите в оригинале.

README

Показан фрагмент оригинального README. Открыть оригинал.

MCP Code Executor

The MCP Code Executor is an MCP server that allows LLMs to execute Python code within a specified Python environment. This enables LLMs to run code with access to libraries and dependencies defined in the environment. It also supports incremental code generation for handling large code blocks that may exceed token limits.

Features

  • Execute Python code from LLM prompts
  • Support for incremental code generation to overcome token limitations
  • Run code within a specified environment (Conda, virtualenv, or UV virtualenv)
  • Install dependencies when needed
  • Check if packages are already installed
  • Dynamically configure the environment at runtime
  • Configurable code storage directory

Prerequisites

  • Node.js installed
  • One of the following:
    • Conda installed with desired Conda environment created
    • Python virtualenv
    • UV virtualenv

Setup

  1. Clone this repository:
git clone https://github.com/bazinga012/mcp_code_executor.git
  1. Navigate to the project directory:
cd mcp_code_executor
  1. Install the Node.js dependencies:
npm install
  1. Build the project:
npm run build

Configuration

To configure the MCP Code Executor server, add the following to your MCP servers configuration file:

Using Node.js

{
  "mcpServers": {
    "mcp-code-executor": {
      "command": "node",
      "args": [
        "/path/to/mcp_code_executor/build/index.js" 
      ],
      "env": {
        "CODE_STORAGE_DIR": "/path/to/code/storage",
        "ENV_TYPE": "conda",
        "CONDA_ENV_NAME": "your-conda-env"
      }
    }
  }
}

Using Docker

{
  "mcpServers": {
    "mcp-code-executor": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "mcp-code-executor"
      ]
    }
  }
}

Note: The Dockerfile has been tested with the venv-uv environment type only. Other environment types may require additional configuration.

Environment Variables

Required Variables

  • CODE_STORAGE_DIR: Directory where the generated code will be stored

Environment Type (choose one setup)

  • For Conda:

    • ENV_TYPE: Set to conda
    • CONDA_ENV_NAME: Name of the Conda environment to use
  • For Standard Virtualenv:

    • ENV_TYPE: Set to venv
    • VENV_PATH: Path to the virtualenv directory
  • For UV Virtualenv:

    • ENV_TYPE: Set to venv-uv
    • UV_VENV_PATH: Path to the UV virtualenv directory

Available Tools

The MCP Code Executor provides the following tools to LLMs:

1. execute_code

Executes Python code in the configured environment. Best for short code snippets.

Открыть полный README на GitHub

Установка

docker run -i --rm mcp-code-executor
Новичок в MCP? Начните с руководства на mcpskill.org →

Конфигурация

{ "mcpServers": { "mcp-code-executor": { "command": "node", "args": [ "/path/to/mcp_code_executor/build/index.js" ], "env": { "CODE_STORAGE_DIR": "/path/to/code/storage", "ENV_TYPE": "conda", "CONDA_ENV_NAME": "your-conda-env" } } } }