home / mcp / python sandbox mcp server
Provides a Python sandbox MCP server that runs code securely and exposes a Gradio UI for LM Studio interactions.
Configuration
View docs{
"mcpServers": {
"aamir-gmail-lm_studio_mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-p",
"8000:8000",
"-e",
"PUBLIC_BASE_URL=http://{YOUR_LOCAL_IP}:8000",
"python-sandbox-integrated_v2:latest",
"python",
"/app/mcp_server.py",
"--stdio"
],
"env": {
"PUBLIC_BASE_URL": "http://{YOUR_LOCAL_IP}:8000"
}
}
}
}You can run a Python-based sandboxed MCP server that integrates with a Gradio UI to interact with language models and execute Python code securely. This setup is designed for Linux environments and provides a streamlined path from building a container to running the MCP server for local testing and experiments.
You run the MCP server inside a Docker container and start it with the included runtime command. Once started, you can connect your MCP client to the running server to delegate Python tool execution to the sandbox, view results, plots, and data files, and continue the conversation with the language model inside a Gradio-based UI.
Prerequisites you need on your system: a Linux environment (tested on Ubuntu 22.04 LTS), Docker, and Docker Compose (if you plan to use the sidecar workflow). You will also want network access to pull images and expose ports for local testing.
Step by step commands to get started:
Clone or obtain the project files that contain the MCP core server and related configurations.
Build the Docker image for the core MCP server.
docker build -t python-sandbox-integrated_v2:latestRun the MCP server container with the standard runtime to start the stdio MCP process.
docker run --rm -i -p 8000:8000 -e PUBLIC_BASE_URL=http://{YOUR_LOCAL_IP}:8000 python-sandbox-integrated_v2:latest python /app/mcp_server.py --stdioIf you plan to use the sidecar approach with Docker Compose, prepare the environment file and compose configuration, then bring up the services.
docker compose up -dTroubleshooting tips include ensuring your local volumes are mounted correctly in Docker, setting the proper IP address in environment variables, and opening firewall ports used by the container. If you encounter a URL-like address, copy the URL portion into your browser to access the UI or API endpoint. Always ensure the environment file (.env) and Docker Compose configurations reference absolute paths to local volumes.
Important for Python environment stability is using the provided system prompt (system_prompt.txt) when launching the sandbox, and selecting a model capable of tool calling (such as qwen.qwen3-coder-30b-instruct) for robust code execution.