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.
- 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
- Node.js installed
- One of the following:
- Conda installed with desired Conda environment created
- Python virtualenv
- UV virtualenv
- 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 buildTo configure the MCP Code Executor server, add the following to your MCP servers configuration file: