Experimenting with a Docker-based MCP server for Julia

This is still very much an experiment, but it’s been working well for my workflows where I want the AI to have access to a full Julia environment without giving it access to my local network or filesystem, so I thought I’d share in case others are interested!

The server is written in TypeScript/Node.js and manages a pair of Docker containers to keep the host system safe ( :warning: no guarantees!). High-level overview:

  • The Sandbox: A persistent execution container that is completely network-isolated (--network none). This is where the Julia REPL lives.

  • The Installer: An ephemeral sidecar container that does have network access. It is used exclusively for Pkg.add() and shares a julia-depot volume with the sandbox so new packages are available immediately.

  • Stateful Sessions: Variables and modules persist across tool calls within a session.

  • File Output: Plots and data files saved to a specific scratch directory in the container are automatically mapped to a host folder for easy access by the user.

  • Precompiled Stack: I’ve pre-baked a few of my favorite packages (e.g., DataFrames, JuMP, CairoMakie) into the image to minimize startup latency.

Let me know what you think!

I had a recent experience with flailing around with MCPs that resulted in a runaway process that burned out the SSD with cache flailing. It’s an irreproducible result, so i can’t pinpoint the exact culprit, but at one point Claude was trying to access it and occupying 32GB of RAM and another 70GB of swapfile. YMMV

:astonished_face: I have resource limits baked in to this, the docker container only gets 4GB of RAM and 2 CPUs by default. I’m quite happy with the setup so far and haven’t really had many problems with it. It’s particularly great for one-off analyses where I just want to explore some data and generate some outputs, or when I just want to quickly test an idea…