forkd-mcp

v0.2.1
forkd-mcp Checked 1 day ago Published 4 months ago

Model Context Protocol server for forkd microVM sandboxes (BRANCH, diff snapshots, prewarm)

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_snapshots

List parent snapshots registered with the forkd controller. Each snapshot is a tagged warmed-VM image you can fork children from. Returns SnapshotInfo objects: tag, dir, created_at_unix.

spawn_sandboxes

Fork N children from a parent snapshot. Args: snapshot_tag: Name of a registered snapshot (see list_snapshots). n: Number of children to spawn, 1..1000. per_child_netns: When true, each child is placed in a per-child network namespace forkd-child-<i>. The host must have run scripts/netns-setup.sh N first. memory_limit_mib: Cgroup memory.max for each child. prewarm: When true, the daemon performs a throwaway snapshot immediately after restore to amortize the cold-cache penalty. Relocates the cold cost f…

ParameterTypeDescription
snapshot_tag *string
live_forkboolean
memory_limit_mibinteger
ninteger
per_child_netnsboolean
prewarmboolean

branch_sandbox

Branch a running sandbox into a new snapshot. Pauses the source sandbox briefly, snapshots its memory + vCPU state, and resumes the source. The resulting snapshot is a new tag that any later spawn_sandboxes call can use as its snapshot_tag — fan out N children that all inherit the source's exact state at branch time. This is forkd's core primitive. Modal does this as their proprietary moat; forkd is the open-source equivalent. Args: sandbox_id: Id of the source sandbox (see list_sandboxes). tag: Optional name for the new snapshot. When unset…

ParameterTypeDescription
sandbox_id *string
diffboolean
measure_diffboolean
mode
tag
waitboolean

create_snapshot

Build a parent snapshot from a kernel + rootfs. Boots a fresh VM with the given kernel + rootfs, waits `boot_wait_secs` for the guest to settle, snapshots it, and registers the snapshot under `tag` so later spawn_sandboxes calls can fork children from it. Args: tag: Name to register the snapshot under (alnum + dash/ underscore, 1-64 chars). kernel: Host path to a vmlinux kernel image. rootfs: Host path to a rootfs image (.ext4 for writable, .squashfs for read-only). rw: When true, mount the rootfs read-write. Auto-en…

ParameterTypeDescription
kernel *string
rootfs *string
tag *string
boot_wait_secsinteger
rwboolean
tap

wait_for_text

Poll a file inside a sandbox until it contains a marker string. Common pattern: agent writes its progress to a stdout log inside the guest; the orchestrator (you, the MCP client) polls until a marker like "READY_TO_BRANCH" appears, then triggers branch. Avoids busy-waiting from outside the daemon's exec round-trip. Args: sandbox_id: Target sandbox. path: Absolute path inside the guest of the file to poll. marker: Substring to wait for. Returned as-is when found. timeout_secs: Max wall-clock seconds to wait. Default 60. poll_interval…

ParameterTypeDescription
marker *string
path *string
sandbox_id *string
poll_interval_msinteger
timeout_secsnumber

list_sandboxes

List currently-alive child sandboxes.

get_sandbox

Fetch metadata about one sandbox by id.

ParameterTypeDescription
sandbox_id *string

kill_sandbox

Terminate one sandbox. Kills Firecracker, removes its cgroup leaf.

ParameterTypeDescription
sandbox_id *string

exec_command

Run a subprocess inside a sandbox. Example: exec_command("sb-abc-0000", ["python3", "-c", "print(2+2)"]) Returns: {stdout, stderr, exit_code}.

ParameterTypeDescription
args *array
sandbox_id *string
timeout_secsinteger

eval_code

Evaluate a Python expression against the sandbox's warmed PID-1. The parent VM already imported numpy / torch / etc.; eval returns in single-digit ms instead of ~100 ms for a fresh subprocess. Returns: {result, error, exit_code}.

ParameterTypeDescription
code *string
sandbox_id *string

ping_sandbox

Round-trip to the in-guest agent. Returns its health and runtime info.

ParameterTypeDescription
sandbox_id *string