top of page

MCP Run Python: Secure, Sandboxed Python Execution

  • Secure Sandboxed Execution: `mcp-run-python` enables secure execution of Python code within a sandboxed WebAssembly environment using Pyodide and Deno, isolating it from the host system. This enhances security compared to traditional `npx` execution.
  • Automated Dependency Management: The server automatically detects and installs Python dependencies, either by inferring them from `import` statements or by parsing inline script metadata (PEP 723) within comment blocks. The latter also allows for version pinning of non-binary packages.
  • Comprehensive Result Capture: The system captures standard output, standard error, and return values from the executed Python code, providing detailed error reports for debugging, including tracebacks and exception messages.
  • Asynchronous Code Support: The server properly handles and executes asynchronous Python code.
  • MCP Transport Flexibility: The server supports both Stdio and SSE MCP transports, allowing it to be run as a local subprocess or as an HTTP server for local or remote connections. The `warmup` option pre-caches the Python standard library.
  • Logging via MCP: The system supports emitting `stdout` and `stderr` from Python executions as MCP logging messages, configurable via the logging level when connecting to the server, although there's a known bug in the Python MCP Client preventing demonstration of this feature. According to additional sources, the `modelcontextprotocol` Python SDK facilitates interaction with Model Context Protocol (MCP) servers and clients.
Source:
bottom of page