yzfly/mcp-python-interpreter
Free安全、标准化的 Python 环境,支持代码执行、环境和包管理。
FreeFree tier
About yzfly/mcp-python-interpreter
MCP Python Interpreter is an open-source Model Context Protocol (MCP) server that enables LLMs to safely interact with Python environments. It supports listing and switching between Python environments (system and conda), executing Python code or scripts, managing packages (install/list), reading and writing files (text, binary, source code), and provides Python-specific prompt templates for common tasks like function creation and debugging. Designed to work with MCP clients such as Claude Desktop, it enforces security by restricting file operations to a specified working directory and allowing optional system access control.
Key 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) and write text/binary files
Python Prompts: templates for common Python tasks like function creation and debugging
Security isolation via required working directory and system access control flag
Pros & Cons
Pros
- Safe execution with directory isolation and optional system access restrictions
- Supports multiple Python environments including conda
- Easy installation via pip or uv
- Provides both code execution and file manipulation tools
- Open source (MIT license) with active community (101 stars, 35 forks)
Cons
- Requires MCP-compatible client (e.g., Claude Desktop) to use
- Only supports Python environments, not other languages
- Security depends on proper configuration (e.g., setting MCP_ALLOW_SYSTEM_ACCESS=0)
Best For
AI coding assistants that need to execute Python code on behalf of usersAutomated Python scripting and testing within LLM workflowsDebugging and exploring Python environments via natural languagePackage management and dependency inspection for LLM-driven development
FAQ
What is MCP Python Interpreter?
It is an open-source Model Context Protocol (MCP) server that allows LLMs to interact with Python environments, execute code, manage packages, and perform file operations.
How do I install MCP Python Interpreter?
You can install it using pip (`pip install mcp-python-interpreter`) or uv (`uv install mcp-python-interpreter`). Ensure you have uv installed if using the latter.
How do I use it with Claude Desktop?
Add a configuration entry to `claude_desktop_config.json` specifying the command `uvx mcp-python-interpreter` with required arguments like `--dir` for the working directory and `--python-path` for the Python executable. Set `MCP_ALLOW_SYSTEM_ACCESS` to 0 for security.
What tools does it provide?
It provides tools for listing environments, listing/installing packages, executing Python code/files, reading/writing files, and listing directories. Resources are also available for environments and packages.
Is it secure?
The server enforces security by requiring a `--dir` parameter to isolate file operations. The environment variable `MCP_ALLOW_SYSTEM_ACCESS` can be set to 0 to restrict system access.