←back to thread

MCP Run Python

(github.com)
173 points xrd | 2 comments | | HN request time: 0s | source
Show context
behnamoh ◴[] No.43718268[source]
So their method of sandboxing Python code is to spin up a JS runtime (deno), run Pyodide on it, and then run the Python code in Pyodide.

Seems a lot of work to me. Is this really the best way to create and run Python sandboxes?

replies(11): >>43718335 #>>43718770 #>>43718841 #>>43719300 #>>43719370 #>>43719672 #>>43719881 #>>43721408 #>>43722369 #>>43723869 #>>43726452 #
simonw ◴[] No.43719672[source]
I've been trying to find a good option for this for ages. The Deno/Pyodide one is genuinely one of the top contenders: https://til.simonwillison.net/deno/pyodide-sandbox

I'm hoping some day to find a recipe I really like for running Python code in a WASM container directly inside Python. Here's the closest I've got, using wasmtime: https://til.simonwillison.net/webassembly/python-in-a-wasm-s...

replies(5): >>43721214 #>>43722664 #>>43724984 #>>43725448 #>>43828320 #
singularity2001 ◴[] No.43721214[source]
one wasmtime dependency and a self contained python file with 100 loc seems reasonable!

much better than calling deno, at least if you have no pip dependencies...

just had to update to new api:

# store.add_fuel(fuel) store.set_fuel(fuel) fuel_consumed=fuel-store.get_fuel()

and it works!!

time to hello world: hello_wasm_python311.py 0.20s user 0.03s system 97% cpu 0.234 total

replies(3): >>43721856 #>>43722093 #>>43728345 #
1. lopuhin ◴[] No.43721856[source]
it's pretty difficult to package native python dependencies for wasmtime or other wasi runtimes, e.g. lxml
replies(1): >>43726861 #
2. Already__Taken ◴[] No.43726861[source]
yeh if you can't shove numpy in there its not really useful.