bazinga012 avatar

Code Executor

bazinga012/mcp_code_executor

The MCP Code Executor server enables LLMs to execute Python code within a specified environment (Conda, virtualenv, or UV virtualenv) that has access to predefined libraries and dependencies. It provides tools for running code snippets and generating code incrementally to handle large blocks that exceed token limits, while also supporting dynamic package installation and environment configuration. The server solves the problem of LLMs needing to execute and test code in isolated, reproducible Python environments with managed dependencies.

GitHub stars
216
tools
9
last updated
Feb 20, 2026

Tools

9 tools

Public tool metadata for what this MCP can expose to an agent.

execute_codeExecutes Python code in the configured environment. Best for short code snippets.

Executes Python code in the configured environment. Best for short code snippets.

No parameter schema in public metadata yet.

install_dependenciesInstalls Python packages in the environment.

Installs Python packages in the environment.

No parameter schema in public metadata yet.

check_installed_packagesChecks if packages are already installed in the environment.

Checks if packages are already installed in the environment.

No parameter schema in public metadata yet.

configure_environmentDynamically changes the environment configuration.

Dynamically changes the environment configuration.

No parameter schema in public metadata yet.

get_environment_configGets the current environment configuration.

Gets the current environment configuration.

No parameter schema in public metadata yet.

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

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

No parameter schema in public metadata yet.

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

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

No parameter schema in public metadata yet.

execute_code_fileExecutes an existing Python file. Use this as the final step after building up code with initialize_code_file and append_to_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.

No parameter schema in public metadata yet.

read_code_fileReads 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.

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.

No parameter schema in public metadata yet.

Sponsors

Readme

MCP Code Executor

smithery badge

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.

Code Executor MCP server

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


View the full README on GitHub

Details

Repository
github.com/bazinga012/mcp_code_executor