Get the FREE Ultimate OpenClaw Setup Guide →

mcp-python-interpreter

MCP Python Interpreter: run python code. Python-mcp-server, mcp-python-server, Code Executor

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
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:

  1. Install the MCP Python Interpreter package via pip: pip install mcp-python-interpreter
  2. Or install via uv: uv install mcp-python-interpreter
  3. 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

Sponsor this space

Reach thousands of developers