The MCP Python Interpreter server enables LLMs to interact with Python environments and manage development workflows through:
Environment Management: List and use different Python environments (system and conda)
Package Management: List installed packages and install new ones in specific environments
Code Execution: Run Python code or scripts with arguments in any available environment
File Operations:
Read files (text, source code, binary) with size limits for safety
Write text and binary files in the working directory
List Python files in directories
The server maintains security through isolated working directories, file size limits, and path security controls.
Allows interaction with Python environments, execution of Python code, management of packages, and Python-related file operations including reading, writing, and debugging Python files.
MCP Python Interpreter
A Model Context Protocol (MCP) server that allows LLMs to interact with Python environments, read and write files, execute Python code, and manage development workflows.
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
You can install the MCP Python Interpreter using pip:
Or with uv:
Usage with Claude Desktop
Install Claude Desktop
Open Claude Desktop, click on menu, then Settings
Go to Developer tab and click "Edit Config"
Add the following to your
claude_desktop_config.json
:
For Windows:
Restart Claude Desktop
You should now see the MCP tools icon in the chat interface
The --dir
parameter is required and specifies where all files will be saved and executed. This helps maintain security by isolating the MCP server to a specific directory.
Prerequisites
Make sure you have
uv
installed. If not, install it using:curl -LsSf https://astral.sh/uv/install.sh | shFor Windows:
powershell -ExecutionPolicy Bypass -Command "iwr -useb https://astral.sh/uv/install.ps1 | iex"
Available 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
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 Claude 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)
Security Considerations
This MCP server has access to your Python environments and file system. Key security features include:
Isolated working directory
File size limits
Prevented writes outside the working directory
Explicit overwrite protection
Always be cautious about running code or file operations that you don't fully understand.
License
MIT
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Tools
A Model Context Protocol server that allows LLMs to interact with Python environments, execute code, and manage files within a specified working directory.
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that extracts and analyzes Python code structures, focusing on import/export relationships between files to help LLMs understand code context.Last updated -6MIT License
- -securityAlicense-qualityA Model Context Protocol server that enables seamless execution of commands, Python code, web content fetching, and reusable task management with secure credentials handling.Last updated -2MIT License
- -securityAlicense-qualityA Python implementation of the Model Context Protocol that allows applications to provide standardized context for LLMs, enabling creation of servers that expose data and functionality to LLM applications through resources, tools, and prompts.Last updated -MIT License
- AsecurityFlicenseAqualityA Model Context Protocol server that allows LLMs to interact with Python environments, enabling code execution, file operations, package management, and development workflows.Last updated -9