MCP Python Interpreter
Enables interaction with Python environments, including executing code, managing packages, reading and writing files, and handling development workflows across different Python installations.
Click on "Deploy 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 run this Python code: import pandas as pd; print(pd.__version__)"
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 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
Related MCP server: MCP Web Tools Server
Installation
You can install the MCP Python Interpreter using pip:
pip install mcp-python-interpreterOr with uv:
uv install mcp-python-interpreterUsage 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:
{
"mcpServers": {
"mcp-python-interpreter": {
"command": "uvx",
"args": [
"mcp-python-interpreter",
"--dir",
"/path/to/your/work/dir",
"--python-path",
"/path/to/your/python"
],
"env": {
"MCP_ALLOW_SYSTEM_ACCESS": 0
},
}
}
}For Windows:
{
"mcpServers": {
"python-interpreter": {
"command": "uvx",
"args": [
"mcp-python-interpreter",
"--dir",
"C:\\path\\to\\your\\working\\directory",
"--python-path",
"/path/to/your/python"
],
"env": {
"MCP_ALLOW_SYSTEM_ACCESS": 0
}
}
}
}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
uvinstalled. 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
Available Tools
9 toolsinstall_packageA
Install a Python package in the specified environment.
Args:
package_name: Name of the package to install
environment: Name of the Python environment (default if custom path provided, otherwise system)
upgrade: Whether to upgrade the package if already installed (default: False)
Inputs: package_name (required), environment, upgrade.
list_directoryA
List all Python files in a directory or subdirectory.
Args:
directory_path: Path to directory (relative to working directory or absolute, empty for working directory)
Inputs: directory_path.
list_installed_packagesA
List installed packages for a specific Python environment.
Args:
environment: Name of the Python environment (default: default if custom path provided, otherwise system)
Inputs: environment.
list_python_environmentsB
List all available Python environments (system Python and conda environments).
Inputs: no named parameters.
read_fileA
Read the content of any file, with size limits for safety.
Args:
file_path: Path to the file (relative to working directory or absolute)
max_size_kb: Maximum file size to read in KB (default: 1024)
Returns:
str: File content or an error message
Inputs: file_path (required), max_size_kb.
run_python_codeB
Execute Python code and return the result. Code runs in the working directory.
Args:
code: Python code to execute
environment: Name of the Python environment to use (default if custom path provided, otherwise system)
save_as: Optional filename to save the code before execution (useful for future reference)
Inputs: code (required), environment, save_as.
run_python_fileB
Execute a Python file and return the result.
Args:
file_path: Path to the Python file to execute (relative to working directory or absolute if system access is enabled)
environment: Name of the Python environment to use (default if custom path provided, otherwise system)
arguments: List of command-line arguments to pass to the script
Inputs: file_path (required), arguments, environment.
write_fileB
Write content to a file in the working directory or system-wide if allowed.
Args:
file_path: Path to the file to write (relative to working directory or absolute if system access is enabled)
content: Content to write to the file
overwrite: Whether to overwrite the file if it exists (default: False)
encoding: File encoding (default: utf-8)
Returns:
str: Status message about the file writing operation
Inputs: content (required), file_path (required), encoding, overwrite.
write_python_fileB
Write content to a Python file in the working directory or system-wide if allowed.
Args:
file_path: Path to the file to write (relative to working directory or absolute if system access is enabled)
content: Content to write to the file
overwrite: Whether to overwrite the file if it exists (default: False)
Inputs: content (required), file_path (required), overwrite.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Most tools have distinct purposes, but there is some overlap between write_file and write_python_file, as both handle file writing with similar arguments, which could cause confusion. However, descriptions clarify that write_python_file is specifically for Python files, reducing ambiguity.
All tool names follow a consistent verb_noun pattern (e.g., install_package, list_directory, run_python_code), with clear and predictable naming throughout the set. No deviations or mixed conventions are present.
With 9 tools, the count is well-scoped for a Python interpreter server, covering package management, file operations, code execution, and environment handling. Each tool serves a clear purpose without being excessive or insufficient.
The toolset provides comprehensive coverage for core Python interpreter tasks, including installation, execution, and file management. Minor gaps exist, such as no tool for deleting files or packages, but agents can work around this using existing tools like write_file with overwrite or system commands.
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.
Enable secure connectivity between Sentry issues and debugging data, and LLM clients, using a Model Context Protocol (MCP) server.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that allows LLMs to execute shell commands and receive their output in a controlled manner.7MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that allows LLMs to interact with web content through standardized tools, currently supporting web scraping functionality.1MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that extracts and analyzes Python code structures, focusing on import/export relationships between files to help LLMs understand code context.7MIT
- AlicenseDqualityDmaintenanceA Model Context Protocol server that enables LLMs to interact with databases (currently MongoDB) through natural language, supporting operations like querying, inserting, deleting documents, and running aggregation pipelines.5MIT