MCP Python Interpreter with Docker
Provides tools for managing Python environments, executing code, installing packages, and performing file operations within Python projects.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Python Interpreter with DockerRun Python code: print('Hello, world!')"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Python Interpeter with Docker
Fork of this project which was modified to run inside Docker container.
Prerequisites
Docker installed on your system
Related MCP server: Docker MCP Server
Features
Environment Management: List and use different Python environments (system and conda)
Code Execution: Run Python code or scripts in any available environment
Package Management: List installed packages and install new ones
File Operations:
Read files of any type (text, source code, binary)
Write text and binary files
Python Prompts: Templates for common Python tasks like function creation and debugging
Installation
Run the Docker container
docker compose up -dThis will start the MCP server inside a Docker container and expose it on port 8050.
All neccessary data are stored in the data folder.
Once the server is running, you can run the simple client in a separate terminal to test that server is running:
python client.pyThe client will connect to the server and list available tools, list files in the data directory and read test.py file.
Stop the Docker container
docker compose downAvailable Tools
The Python Interpreter provides the following tools:
Environment and Package Management
list_python_environments: List all available Python environments (system and conda)
list_installed_packages: List packages installed in a specific environment
install_package: Install a Python package in a specific environment
Code Execution
run_python_code: Execute Python code in a specific environment
run_python_file: Execute a Python file in a specific environment
File Operations
read_file: Read contents of any file type, with size and safety limits
Supports text files with syntax highlighting
Displays hex representation for binary files
write_file: Create or overwrite files with text or binary content
write_python_file: Create or overwrite a Python file specifically
list_directory: List Python files in a directory (by default it's
datadirectory)
Available Resources
python://environments: List all available Python environments
python://packages/{env_name}: List installed packages for a specific environment
python://file/{file_path}: Get the content of a Python file
python://directory/{directory_path}: List all Python files in a directory
Prompts
python_function_template: Generate a template for a Python function
refactor_python_code: Help refactor Python code
debug_python_error: Help debug a Python error
Example Usage
Here are some examples of what you can ask LLM to do with this MCP server:
"Show me all available Python environments on my system"
"Run this Python code in my conda-base environment: print('Hello, world!')"
"Create a new Python file called 'hello.py' with a function that says hello"
"Read the contents of my 'data.json' file"
"Write a new configuration file with these settings..."
"List all packages installed in my system Python environment"
"Install the requests package in my system Python environment"
"Run data_analysis.py with these arguments: --input=data.csv --output=results.csv"
File Handling Capabilities
The MCP Python Interpreter now supports comprehensive file operations:
Read text and binary files up to 1MB
Write text and binary files
Syntax highlighting for source code files
Hex representation for binary files
Strict file path security (only within the working directory)
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/beatwad/mcp_docker_python_interpreter'
If you have feedback or need assistance with the MCP directory API, please join our Discord server