pydantic/mcp-run-python logo

pydantic/mcp-run-python

Free

Pydantic 出品,在安全的沙盒环境中运行 Python 代码,适合开发编程代理。

FreeFree tier
Type
Open Source
Company
Pydantic

About pydantic/mcp-run-python

MCP Run Python is an MCP (Model Context Protocol) server that executes Python code in a sandboxed WebAssembly environment using Pyodide and Deno. It was originally part of Pydantic AI and provides secure execution by isolating code from the host operating system. Key features include automatic dependency detection and installation, full capture of standard output, standard error, and return values, support for asynchronous code, and detailed error reporting. The project has been archived and is no longer maintained, with the authors noting that Pyodide is not a safe sandbox for untrusted code—it can run arbitrary JavaScript, read/write files accessible to the Deno runtime, and exhaust memory without good limits. Users are advised to exercise extreme caution and to consider the successor project Monty for better security and lower latency.

Key Features

Secure Execution: Python code runs in a sandboxed WebAssembly environment (Pyodide in Deno), isolated from the OS
Package Management: Automatically detects and installs required Python dependencies
Complete Results: Captures standard output, standard error, and return values
Asynchronous Support: Handles async Python code properly
Error Handling: Provides detailed error reports for debugging

Pros & Cons

Pros
  • Isolates Python execution from the host OS using WebAssembly
  • Automatically manages and installs required packages
  • Captures all output (stdout, stderr, return value) for inspection
  • Supports asynchronous Python code
  • Detailed error reports help with debugging
Cons
  • Archived and no longer maintained; not recommended for new projects
  • Pyodide can execute arbitrary JavaScript, posing security risks beyond Python
  • Deno has no built-in way to limit memory usage, risking out-of-memory crashes
  • Latency is high due to Pyodide's overhead, making it unsuitable for real-time use
  • Requires both Python and Deno to be installed on the host system
  • Only runs code in a browser-engine environment, limiting system library support

Best For

Running AI-generated Python code in a controlled, isolated environmentIntegrating with MCP clients like Pydantic AI to execute Python snippetsTesting Python code execution without affecting the host systemEducational or experimental sandbox for Python scripting

FAQ

Is the MCP Run Python project still maintained?
No, the project has been archived and is no longer maintained. The authors recommend using Monty instead for better security and lower latency.
What security risks does running Python in Pyodide have?
Python code running in Pyodide can execute arbitrary JavaScript, which can taint the runtime, read/write files accessible to the Deno process, and consume all memory causing an out-of-memory condition. Deno has no good way to limit memory usage.
What are the system requirements to run this server?
You must have both Python and Deno installed on your system. The server can be started using uvx (e.g., uvx mcp-run-python).
How does this tool handle Python dependencies?
It automatically detects and installs required dependencies. You can also pass additional dependencies via the --deps flag when starting the server.