MCP Python Interpreter logo

MCP Python Interpreter

Run Python code, manage environments and packages, and read or write files through MCP.

Install MCP Python Interpreter

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "mcp-python-interpreter": {
      "command": "uvx",
      "args": [
        "mcp-python-interpreter"
      ]
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

We couldn’t confirm it starts correctly

We ran the install command but it didn't respond within our test window — this can mean a slow first-time install rather than a real problem.

uvx mcp-python-interpreter

No response to initialize.

This is an experimental automated check and can have false negatives — missing environment variables, a slow cold install, etc. It doesn’t necessarily mean something’s wrong. Last checked .

Overview

The mcp-python-interpreter MCP server lets language models work with local Python environments, execute code, manage packages, and handle text or binary files. It can discover system and conda environments, run inline code or Python files, and expose environment, package, file, and directory data as MCP resources. Use it for development workflows that need local Python execution, but treat executed code as fully trusted because it runs with the server user's permissions and is not sandboxed.

Use cases

  • Run analysis scripts in a selected conda environment
  • Inspect and install packages in local Python environments
  • Create, read, and update Python or configuration files
  • Execute a Python file with command-line arguments
  • Debug and refactor Python code with reusable prompts

Key features

  • Discover system and conda Python environments
  • Execute inline Python code or Python files
  • List and install packages
  • Read and write text or binary files
  • Expose environment, package, file, and directory resources
  • Generate Python task prompts

Tools9

What MCP Python Interpreter lets your agent do. Expand a tool for its parameters.

Self-reported~180 tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

14/14 checks healthy over the last 30d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 14d ago via OSV.dev · mcp-python-interpreter (PyPI)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars104Stargazers on the source repository.
Last commit1mo agoMost recent push to the default branch.
Install checkInconclusiveDidn't respond in our test window — often a slow first install.
Tools exposed9Callable tools this server registers over MCP.

How MCP Python Interpreter works

What mcp-python-interpreter does

The mcp-python-interpreter exposes local Python development operations through the Model Context Protocol. An MCP client can inspect available system and conda environments, check installed packages, install packages into a selected environment, run Python code, and execute Python files.

It also provides file operations for common development tasks. The server can read text and binary files, write text or binary content, create Python files, list Python files in a directory, and save code before execution. Text and source files can be shown with syntax highlighting, while binary data can be represented in hexadecimal form.

Prompt templates cover three recurring tasks: creating a Python function, refactoring Python code, and debugging a Python error. Resources expose environment lists, package lists, Python file contents, and directory listings through URI patterns.

How it works

Install the package with pip or install it as a tool with uv. It runs as an MCP server and can be configured in an MCP-compatible client. The Claude Desktop example starts it with uvx, sets a working directory with --dir, and optionally selects a Python executable with --python-path.

The working directory controls the default scope for file tools and for the save_as option on run_python_code. Resolved paths, including symlinks, are checked against that directory. Setting MCP_ALLOW_SYSTEM_ACCESS=1 allows system access for those path checks; the example configuration uses MCP_ALLOW_SYSTEM_ACCESS=0.

Code may run inline or in a subprocess. A subprocess has separate interpreter state, but neither execution mode provides an operating-system sandbox. Python code can access files and the network using the server user's permissions, regardless of the file-tool path checks.

Setup and configuration

Install one of the supported package forms:

  • pip install mcp-python-interpreter
  • uv tool install mcp-python-interpreter

The documented Claude Desktop configuration uses uvx mcp-python-interpreter, along with --dir and --python-path arguments. The --dir value defaults to the directory in which the server starts when it is omitted. Existing files require an explicit overwrite setting when saved through the relevant tools.

The server supports MCP Python SDK 1.x through FastMCP and SDK 2.x through MCPServer. Transport-related settings include MCP_TRANSPORT, MCP_HOST, MCP_PORT, MCP_JSON_RESPONSE, and MCP_STATELESS_HTTP.

Tools and capabilities

Available tools include:

  • list_python_environments for system and conda environment discovery.
  • list_installed_packages and install_package for package inspection and installation.
  • run_python_code for inline or subprocess execution, with optional .py saving.
  • run_python_file for running a Python file in a chosen environment.
  • read_file, write_file, and write_python_file for text and binary file handling.
  • list_directory for listing Python files.

Resources include python://environments, python://packages/{env_name}, python://file/{file_path}, and python://directory/{directory_path}. File reads support files up to 1 MB and include safety and size limits.

Limitations and notes

Run only trusted Python code. Inline execution has no enforced timeout, and sys.exit() is returned as an execution error without stopping the MCP server. The working-directory checks apply to file tools and saved snippets, not to arbitrary file or network access performed by executed Python. For stronger isolation, run the complete server in a container or under a restricted user account.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about MCP Python Interpreter

mcp-python-interpreter is an MCP server that connects language models to local Python environments and files. Its main tools discover environments, list or install packages, run Python code or files, read and write text or binary files, and list directories. It also provides resources and prompts for common Python workflows.

Install it with `pip install mcp-python-interpreter` or `uv tool install mcp-python-interpreter`. The documented Claude Desktop setup starts it with `uvx`, and requires `uv` to be installed.

Set the `--dir` argument to the directory the server should use. File tools and `run_python_code(save_as=...)` check resolved paths against this directory by default; if omitted, it defaults to the directory where the server starts.

No, mcp-python-interpreter is not a sandbox. Executed Python runs with the server user's permissions and can access files or the network independently of file-tool path checks. Use trusted code or isolate the server in a container or restricted account.

Yes, it works with Claude Desktop through an MCP server configuration. The documented setup uses `uvx mcp-python-interpreter`, with optional `--dir` and `--python-path` arguments, followed by restarting Claude Desktop.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewMCP Python Interpreter AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/mcp-python-interpreter?style=directory)](https://allmcps.com/mcp/mcp-python-interpreter)
HTML Embed
<a href="https://allmcps.com/mcp/mcp-python-interpreter"><img src="https://allmcps.com/api/badge/mcp-python-interpreter?style=directory" alt="MCP Python Interpreter on AllMCPs" /></a>