Code Executor

v1.0.0Coding Agentsstable

Allows LLMs to execute Python code in a specified Conda environment, enabling access to necessary libraries and dependencies for efficient code execution.

mcp-code-executormcpai-integration
Share:
216
Stars
0
Downloads
0
Weekly
0/5

What is Code Executor?

Code Executor is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to allows llms to execute python code in a specified conda environment, enabling access to necessary libraries and dependencies for efficient code execution.

Allows LLMs to execute Python code in a specified Conda environment, enabling access to necessary libraries and dependencies for efficient code execution.

This server falls under the Coding Agents category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Allows LLMs to execute Python code in a specified Conda envi

Use Cases

Execute Python code in isolated Conda environments.
Access specific libraries and dependencies.
Run computations with full scientific Python stack.
bazinga012

Maintainer

LicenseMIT License
Languagejavascript
Versionv1.0.0
UpdatedMay 11, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx mcp-code-executor

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Code Executor

MCP Code Executor lets AI language models execute Python code inside a specified environment — Conda, virtualenv, or uv virtualenv — and manage the full lifecycle of code files through the Model Context Protocol. It exposes nine tools covering code snippet execution, dependency installation, package verification, environment configuration, and an incremental file-based execution workflow suited for large code blocks that exceed token limits. This is particularly useful when you want Claude or another LLM to run data science notebooks, scientific computing scripts, or any Python task that requires specific libraries installed in a controlled environment.

Prerequisites

  • Node.js 18+ (the server is built with npm/TypeScript)
  • Python environment: Conda, virtualenv, or uv virtualenv pre-created with required packages
  • An MCP-compatible client such as Claude Desktop or Cursor
  • A writable directory for CODE_STORAGE_DIR where generated scripts will be saved
1

Clone the repository and install Node dependencies

Clone the mcp_code_executor repository, navigate into it, install npm dependencies, and build the TypeScript project.

git clone https://github.com/bazinga012/mcp_code_executor.git
cd mcp_code_executor
npm install
npm run build
2

Create or identify your Python environment

Ensure you have a Python environment with the libraries you need. For Conda, create a named environment; for virtualenv or uv, note the path to the environment directory.

# Conda:
conda create -n myenv python=3.11 numpy pandas scikit-learn
conda activate myenv

# Or virtualenv:
python -m venv /path/to/venv

# Or uv:
uv venv /path/to/uv-venv
3

Configure the MCP client with required environment variables

Add the server to your MCP client config, setting CODE_STORAGE_DIR to a writable directory and the environment type variables appropriate for your Python setup.

{
  "mcpServers": {
    "code-executor": {
      "command": "node",
      "args": ["/absolute/path/to/mcp_code_executor/build/index.js"],
      "env": {
        "CODE_STORAGE_DIR": "/tmp/mcp_code",
        "ENV_TYPE": "conda",
        "CONDA_ENV_NAME": "myenv"
      }
    }
  }
}
4

For virtualenv or uv environments, adjust the env block

If using a standard virtualenv or uv virtualenv instead of Conda, change ENV_TYPE and provide the path variable instead of the environment name.

{
  "mcpServers": {
    "code-executor": {
      "command": "node",
      "args": ["/absolute/path/to/mcp_code_executor/build/index.js"],
      "env": {
        "CODE_STORAGE_DIR": "/tmp/mcp_code",
        "ENV_TYPE": "venv",
        "VENV_PATH": "/path/to/venv"
      }
    }
  }
}
5

Verify the setup by checking installed packages

Ask your MCP client to call check_installed_packages to confirm that the Python environment is accessible and the expected libraries are present before running any code.

Code Executor Examples

Client configuration

Claude Desktop configuration using a Conda environment named 'datascience' with code stored in /tmp/mcp_code.

{
  "mcpServers": {
    "code-executor": {
      "command": "node",
      "args": ["/Users/yourname/mcp_code_executor/build/index.js"],
      "env": {
        "CODE_STORAGE_DIR": "/tmp/mcp_code",
        "ENV_TYPE": "conda",
        "CONDA_ENV_NAME": "datascience"
      }
    }
  }
}

Prompts to try

These prompts work once the server is running and connected to a Python environment.

- "Install the 'lightgbm' package in my Python environment"
- "Execute this pandas code to load data.csv and show the first 10 rows with summary statistics"
- "Write a script that trains a RandomForest classifier on the iris dataset and save it to a file, then run it"
- "Check which version of numpy is installed in my environment"
- "Create a code file for a web scraper, append the parsing logic incrementally, then execute it"

Troubleshooting Code Executor

execute_code fails with 'conda: command not found'

The server needs Conda in PATH when it starts. On macOS/Linux, add the Conda bin directory to your shell profile and restart the MCP client. On Windows, use the Anaconda Prompt or add Conda to the system PATH via the Anaconda installer options.

ModuleNotFoundError for packages that are installed in the environment

Verify that ENV_TYPE matches your actual environment type and that CONDA_ENV_NAME or VENV_PATH is correct. A mismatch causes the executor to use the wrong Python binary. Use check_installed_packages to confirm which environment is being used.

CODE_STORAGE_DIR is not writable and code files cannot be saved

Ensure the directory specified in CODE_STORAGE_DIR exists and is writable by the process running the MCP server. Create it with 'mkdir -p /tmp/mcp_code' and verify permissions with 'ls -la /tmp/mcp_code'.

Frequently Asked Questions about Code Executor

What is Code Executor?

Code Executor is a Model Context Protocol (MCP) server that allows llms to execute python code in a specified conda environment, enabling access to necessary libraries and dependencies for efficient code execution. It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Code Executor?

Follow the installation instructions on the Code Executor GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with Code Executor?

Code Executor works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Code Executor free to use?

Yes, Code Executor is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.

Browse More Coding Agents MCP Servers

Explore all coding agents servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "mcp-code-executor": { "command": "npx", "args": ["-y", "mcp-code-executor"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use Code Executor?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides