mcp-python-interpreter
MCP Python Interpreter: run python code. Python-mcp-server, mcp-python-server, Code Executor
claude mcp add --transport stdio yzfly-mcp-python-interpreter uvx mcp-python-interpreter --dir /path/to/your/work/dir --python-path /path/to/your/python \ --env MCP_ALLOW_SYSTEM_ACCESS="0"
How to use
This MCP server exposes a Python interpreter environment that lets LLMs interact with Python environments, run code, manage packages, and perform file operations. It supports switching between system Python and conda environments, listing installed packages, installing new ones, executing Python code or scripts, and reading or writing files within a secure working directory. Use the available tools to inspect environments, execute code snippets, manage dependencies, and manipulate files through natural language prompts or structured commands. The server is designed to be used with Claude Desktop by configuring the mcpServers entry in claude_desktop_config.json, and by providing a working directory via the --dir parameter to ensure all actions occur in isolation.
How to install
Prerequisites:
-
Install uv (the universal verifier/runner) if you haven't already. On Unix-like systems: curl -LsSf https://astral.sh/uv/install.sh | sh
-
For Windows users, install uv with the provided PowerShell command from the same source.
Installation steps:
- Install the MCP Python Interpreter package via pip: pip install mcp-python-interpreter
- Or install via uv: uv install mcp-python-interpreter
- Confirm installation by listing available mcp servers or running a test command that uses the mcp-python-interpreter features.
Optional: If you plan to integrate with Claude Desktop, proceed to add the mcp-python-interpreter configuration to claude_desktop_config.json as shown in the README.
Additional notes
Tips and considerations:
- The --dir parameter is required and defines the isolated working directory where files are saved and code executes. This helps restrict access and improve security.
- The MCP_ALLOW_SYSTEM_ACCESS environment variable controls whether the MCP server can access the host system beyond the dedicated working directory. Set MCP_ALLOW_SYSTEM_ACCESS to 0 to restrict access.
- Ensure the specified --python-path points to a valid Python executable in your environment. You can switch between system Python and conda environments using the exposed tools.
- File operations have size and safety limits; be mindful when reading or writing large or binary files. The server provides hex view for binary files and syntax highlighting for text/source files.
- If you encounter issues with environment discovery, check that the Python environments are properly configured and that the working directory has appropriate permissions.
- When integrating with Claude Desktop, keep the configuration section in claude_desktop_config.json up to date with the correct path and environment settings.
Related MCP Servers
mcp-proxy
An MCP proxy server that aggregates and serves multiple MCP resource servers through a single HTTP server.
mcp-pinecone
Model Context Protocol server to allow for reading and writing from Pinecone. Rudimentary RAG
pfsense
pfSense MCP Server enables security administrators to manage their pfSense firewalls using natural language through AI assistants like Claude Desktop. Simply ask "Show me blocked IPs" or "Run a PCI compliance check" instead of navigating complex interfaces. Supports REST/XML-RPC/SSH connections, and includes built-in complian
MCPSecBench
MCPSecBench: A Systematic Security Benchmark and Playground for Testing Model Context Protocols
mlb
MCP server for advanced baseball analytics (statcast, fangraphs, baseball reference, mlb stats API) with client demo
mcpkit
Easy to use Official MCP Registry Client UI. npx @cybertheory/mcpkit