
bazinga012/mcp_code_executor
Developer toolsЭта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал
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
Подготовка
-
Клонируйте этот репозиторий:
-
Перейти в каталог проектов:
-
Установите Node.js зависимости:
-
Постройте проект:
Конфигурация
Чтобы настроить сервер исполнения кода 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
- Clone this repository:
git clone https://github.com/bazinga012/mcp_code_executor.git
- Navigate to the project directory:
cd mcp_code_executor
- Install the Node.js dependencies:
npm install
- 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 tocondaCONDA_ENV_NAME: Name of the Conda environment to use
-
For Standard Virtualenv:
ENV_TYPE: Set tovenvVENV_PATH: Path to the virtualenv directory
-
For UV Virtualenv:
ENV_TYPE: Set tovenv-uvUV_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.
Установка
docker run -i --rm mcp-code-executorКонфигурация
{
"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"
}
}
}
}