Code Executor

Developer tools

The MCP Code Executor is an MCP server that allows LLMs to execute Python code within a specified Conda environment.

Your AI app calls the Code Executor MCP server, which does the developer tools work and sends the result back to the chat.

About Code Executor

Code Executor is a community MCP server from bazinga012, filed in our directory under developer tools. The MCP Code Executor is an MCP server that allows LLMs to execute Python code within a specified Conda environment.

At a glance

Publisher
bazinga012 (community)
Runs
See the README for setup
Written in
JavaScript
License
MIT
GitHub stars
211

How to set up Code Executor

  1. Follow the install steps in the Code Executor README; it is written in JavaScript, so have that toolchain ready.
  2. Check the Code Executor README for keys or settings; the registry lists none that Code Executor requires.
  3. Add Code Executor to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the Code Executor tools to confirm the connection.
  5. Run one read-only task with Code Executor first, and keep your app asking before each tool call until the results look right.

Code Executor compared with similar servers

  • Taisly Social Media Posting by taisly has fewer GitHub stars than Code Executor (211 against 211); both are community servers, and Taisly Social Media Posting runs as a remote server and Code Executor runs on your own machine.
  • multiCAD by AnCode666 has more GitHub stars than Code Executor (212 against 211); both are community servers, and both run locally.
  • Apache Spark History by kubeflow has fewer GitHub stars than Code Executor (210 against 211); both are community servers, and both run locally.

Before you connect Code Executor

  • Give Code Executor its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each Code Executor tool call until you trust what it does with them.
  • Treat text that Code Executor fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for Code Executor on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for Code Executor

How marketing and sales teams put Code Executor to work, by company size. Pick the size closest to yours and start Code Executor on one use case.

Small business

  • A small business with a developer can use Code Executor to ship site and tracking fixes faster, with the AI reading the code it changes.
  • Technical founders can ask Code Executor to explain and fix a marketing site issue without context switching between tools.
  • Code Executor runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Growth engineers can use Code Executor to build landing pages, tracking and integrations in fewer cycles, with reviews kept in the normal flow.
  • Marketing ops engineers can connect Code Executor to keep scripts and automations documented and versioned as they change.
  • Start Code Executor on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprise engineering teams can roll out Code Executor with repo scopes and audit logs, so agents work only where they are allowed.
  • Platform teams can standardize on Code Executor so web and marketing engineering share one reviewed way of working with AI.
  • Code Executor is a community server, so have security review the code and pin a version before Code Executor touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

Code Executor README

From bazinga012/mcp_code_executor on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

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

  1. Clone this repository:
git clone https://github.com/bazinga012/mcp_code_executor.git
  1. Navigate to the project directory:
cd mcp_code_executor
  1. Install the Node.js dependencies:
npm install
  1. 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 to conda
    • CONDA_ENV_NAME: Name of the Conda environment to use
  • For Standard Virtualenv:

    • ENV_TYPE: Set to venv
    • VENV_PATH: Path to the virtualenv directory
  • For UV Virtualenv:

    • ENV_TYPE: Set to venv-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. Best for short code snippets.

{
  "name": "execute_code",
  "arguments": {
    "code": "import numpy as np\nprint(np.random.rand(3,3))",
    "filename": "matrix_gen"
  }
}
2. install_dependencies

Installs Python packages in the environment.

{
  "name": "install_dependencies",
  "arguments": {
    "packages": ["numpy", "pandas", "matplotlib"]
  }
}
3. check_installed_packages

Checks if packages are already installed in the environment.

{
  "name": "check_installed_packages",
  "arguments": {
    "packages": ["numpy", "pandas", "non_existent_package"]
  }
}
4. configure_environment

Dynamically changes the environment configuration.

{
  "name": "configure_environment",
  "arguments": {
    "type": "conda",
    "conda_name": "new_env_name"
  }
}
5. get_environment_config

Gets the current environment configuration.

{
  "name": "get_environment_config",
  "arguments": {}
}
6. initialize_code_file

Creates a new Python file with initial content. Use this as the first step for longer code that may exceed token limits.

{
  "name": "initialize_code_file",
  "arguments": {
    "content": "def main():\n    print('Hello, world!')\n\nif __name__ == '__main__':\n    main()",
    "filename": "my_script"
  }
}
7. append_to_code_file

Appends content to an existing Python code file. Use this to add more code to a file created with initialize_code_file.

{
  "name": "append_to_code_file",
  "arguments": {
    "file_path": "/path/to/code/storage/my_script_abc123.py",
    "content": "\ndef another_function():\n    print('This was appended to the file')\n"
  }
}
8. execute_code_file

Executes an existing Python file. Use this as the final step after building up code with initialize_code_file and append_to_code_file.

{
  "name": "execute_code_file",
  "arguments": {
    "file_path": "/path/to/code/storage/my_script_abc123.py"
  }
}
9. read_code_file

Reads the content of an existing Python code file. Use this to verify the current state of a file before appending more content or executing it.

{
  "name": "read_code_file",
  "arguments": {
    "file_path": "/path/to/code/storage/my_script_abc123.py"
  }
}

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.

Handling Large Code Blocks

For larger code blocks that might exceed LLM token limits, use the incremental code generation approach:

  1. Initialize a file with the basic structure using initialize_code_file
  2. Add more code in subsequent calls using append_to_code_file
  3. Verify the file content if needed using read_code_file
  4. Execute the complete code using execute_code_file

This approach allows LLMs to write complex, multi-part code without running into token limitations.

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.

Questions about Code Executor

What is the Code Executor MCP server?

The MCP Code Executor is an MCP server that allows LLMs to execute Python code within a specified Conda environment. Code Executor is maintained by bazinga012 on GitHub at bazinga012/mcp_code_executor, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the Code Executor MCP server?

Code Executor doesn't publish a one-line install in the MCP registry, so follow the setup steps in its README on GitHub (bazinga012/mcp_code_executor). Like most servers, Code Executor ends with a command or URL you paste into your AI app's MCP config.

Does Code Executor need an API key?

The registry lists no required keys for Code Executor. Check the Code Executor README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is Code Executor an official MCP server?

No. Code Executor is a community server maintained by bazinga012. Community servers can be excellent; read the code and the open issues before you give Code Executor access to company data.

What license is Code Executor under?

Code Executor is released under the MIT license, according to its GitHub repository. The license covers the code of Code Executor; the service it connects to has its own terms.