Python MCP Sandbox

Python MCP Sandbox

An interactive Python code execution environment that allows users and LLMs to safely execute Python code and install packages in isolated Docker containers.

Category
Visit Server

README

Python MCP Sandbox

Python Version

Python MCP Sandbox is an interactive Python code execution environment that allows users and llms to safely execute Python code and install packages in isolated Docker containers.

Features

  • 🐳 Docker Isolation: Securely run Python code in isolated Docker containers
  • 📦 Package Management: Easily install and manage Python packages
  • 📊 File Generation: Support for generating files and accessing them via web links
  • 🔄 Automatic Cleanup: Containers and generated files are automatically cleaned up after a period of inactivity

Installation

# Clone the repository
git clone https://github.com/JohanLi233/python-mcp-sandbox.git
cd python-mcp-sandbox

uv venv

# Start the server
uv run mcp_sandbox.py

The default SSE endpoint is http://localhost:8000/sse, and you can interact with it via the MCP Inspector through SSE or any other client that supports SSE connections.

Available Tools

  1. Create Python Environment: Creates a new Docker container for Python execution and returns its ID
  2. Execute Python Code: Executes Python code in a specified Docker container
  3. Install Python Package: Installs Python packages in a specified Docker container

Project Structure

python-mcp-sandbox/
├── mcp_sandbox.py     # Main application file
├── Dockerfile         # Docker configuration for Python containers
├── results/           # Directory for generated files
└── README.md          # Project documentation

Example Prompt

I've configured a Python code execution environment for you. You can run Python code using the following steps:

1. First, use the "Create Python virtual environment" tool to create a virtual environment
   - This will return an environment ID which you'll need for subsequent operations

2. If you need to install packages, use the "Install Python package" tool
   - Parameters: env_id (environment ID) and package_name (e.g., numpy, pandas)
   - Example: Install numpy and matplotlib

3. Use the "Execute Python code" tool to run your code
   - Parameters: env_id (environment ID) and code (Python code)
   - You can write any Python code including data processing, visualization, file operations, etc.

Example workflow:
- Create environment → Get environment ID
- Install necessary packages (like pandas, matplotlib)
- Execute code (such as data analysis, chart generation)
- View execution results and generated file links

Code execution happens in a secure sandbox environment. Generated files (images, CSVs, etc.) will be automatically provided with download links.

Remeber not to show the image directly, do not use plt.plot() etc.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured