MCP.so
Sign In
Servers

MCP Code Executor

@bazinga012

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

Overview

What is MCP Code Executor?

MCP Code Executor is an MCP server that lets LLMs execute Python code inside a specified Python environment (Conda, virtualenv, or UV virtualenv). It also supports incremental code generation for handling large code blocks that may exceed token limits.

How to use MCP Code Executor?

Install Node.js dependencies, build the project (npm install && npm run build), then configure the server in your MCP clients by adding a JSON block with environment variables (required: CODE_STORAGE_DIR; environment type: ENV_TYPE plus corresponding path or name). LLMs can then call tools like execute_code, or use the incremental file approach (initialize_code_fileappend_to_code_fileexecute_code_file).

Key features of MCP Code Executor

  • Execute Python code from LLM prompts.
  • Incremental code generation to overcome token limits.
  • Run code in Conda, virtualenv, or UV virtualenv.
  • Install and check dependencies dynamically.
  • Configure the environment at runtime.
  • Configurable code storage directory.

Use cases of MCP Code Executor

  • LLM writing and running short Python snippets.
  • Generating multi‑file scripts incrementally to avoid token limits.
  • Testing code with specific library dependencies in a tailored environment.
  • Automating data analysis tasks by executing code on demand.
  • Enabling LLM‑driven development with a full Python environment.

FAQ from MCP Code Executor

What Python environments does MCP Code Executor support?

It supports Conda environments, standard virtualenv (venv), and UV virtualenv (venv-uv). You select one at configuration time using the ENV_TYPE environment variable.

How can I execute a very large code block?

Use the incremental generation workflow: create a file with initialize_code_file, add content with append_to_code_file across multiple turns, and finally run it with execute_code_file.

What are the prerequisites to use MCP Code Executor?

You need Node.js installed, plus one of: Conda (with a created environment), a Python virtualenv, or a UV virtualenv.

Can I change the environment after starting the server?

Yes. Use the configure_environment tool to dynamically switch the environment type, Conda name, or virtualenv path.

Where are the generated code files stored?

All generated files are stored in the directory specified by the CODE_STORAGE_DIR environment variable (required in configuration).

More from Developer Tools