code-executor
Free允许 AI 在指定的 Conda 环境中执行 Python 代码。
FreeFree tier
About code-executor
A Model Context Protocol (MCP) server that enables LLMs to execute Python code within a specified Python environment. Supports Conda, virtualenv, and UV virtualenv environments. Includes features for incremental code generation to handle large code blocks that may exceed token limits, dynamic environment configuration, and dependency management (install and check packages). The generated code is stored in a configurable directory. Built with Node.js and provided as an open-source tool via GitHub.
Key Features
Execute Python code from LLM prompts
Support for incremental code generation to overcome token limitations
Run code within Conda, virtualenv, or UV virtualenv environments
Install Python dependencies when needed
Check if packages are already installed
Dynamically configure the environment at runtime
Configurable code storage directory
Pros & Cons
Pros
- Supports multiple environment types: Conda, virtualenv, and UV virtualenv
- Incremental code generation allows handling of large code blocks
- Dependency management integrated (install and check packages)
- Dynamic environment configuration at runtime
- Configurable storage directory for generated code
- Open source and free to use
Cons
- Requires Node.js installation and project build
- Requires Conda or virtualenv to be set up on the host machine
- Docker support only tested with UV virtualenv environment type
- Limited to Python code execution; no support for other languages
Best For
Enabling LLMs to run Python code with access to specific libraries and dependenciesExecuting data analysis or visualization scripts generated by AITesting code snippets and debugging in isolated environmentsRunning calculations and simulations using custom Python environments
FAQ
What environments does the MCP Code Executor support?
It supports Conda, standard Python virtualenv (venv), and UV virtualenv (venv-uv) environments.
How do I configure the environment?
Environment variables such as ENV_TYPE, CONDA_ENV_NAME, VENV_PATH, or UV_VENV_PATH are used to specify the environment. Detailed configuration examples are provided in the README.
Is Docker supported?
Yes, a Dockerfile is provided, but it has only been tested with the venv-uv environment type. Other environment types may require additional configuration.
What tools are available for LLMs?
Four tools: execute_code (run Python code), install_dependencies (install packages), check_installed_packages (verify installation), and configure_environment (dynamically change environment settings).