Integrations
Allows LLMs to execute Python code within a specified Conda environment with access to libraries and dependencies
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.
Features
- Execute Python code from LLM prompts
- 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:
- Navigate to the project directory:
- Install the Node.js dependencies:
- Build the project:
Configuration
To configure the MCP Code Executor server, add the following to your MCP servers configuration file:
Using Node.js
Using Docker
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 toconda
CONDA_ENV_NAME
: Name of the Conda environment to use
- For Standard Virtualenv:
ENV_TYPE
: Set tovenv
VENV_PATH
: Path to the virtualenv directory
- For UV Virtualenv:
ENV_TYPE
: Set tovenv-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.
2. install_dependencies
Installs Python packages in the environment.
3. check_installed_packages
Checks if packages are already installed in the environment.
4. configure_environment
Dynamically changes the environment configuration.
5. get_environment_config
Gets the current environment configuration.
Usage
Once configured, the MCP Code Executor will allow LLMs to execute Python code by generating a file in the specified CODE_STORAGE_DIR
and running it within the configured environment.
LLMs can generate and execute code by referencing this MCP server in their prompts.
Backward Compatibility
This package maintains backward compatibility with earlier versions. Users of previous versions who only specified a Conda environment will continue to work without any changes to their configuration.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
This project is licensed under the MIT License.
You must be authenticated.
local-only server
The server can only run on the client's local machine because it depends on local resources.
Tools
Allows LLMs to execute Python code in a specified Conda environment, enabling access to necessary libraries and dependencies for efficient code execution.
- Features
- Prerequisites
- Setup
- Configuration
- Available Tools
- Usage
- Backward Compatibility
- Contributing
- License
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityA Pyodide server for executing Python code by Large Language Models (LLMs) via the Model Context Protocol (MCP).Last updated -53TypeScriptMIT License
Fused MCP Agentsofficial
-securityAlicense-qualityA Python-based MCP server that allows Claude and other LLMs to execute arbitrary Python code directly through your desktop Claude app, enabling data scientists to connect LLMs to APIs and executable code.Last updated -23MIT License- AsecurityFlicenseAqualityA Python server implementing the Model Context Protocol to provide customizable prompt templates, resources, and tools that enhance LLM interactions in the continue.dev environment.Last updated -2Python
- AsecurityFlicenseAqualityA Model Context Protocol server that allows LLMs to interact with Python environments, execute code, and manage files within a specified working directory.Last updated -98Python