Skip to main content
Glama

Why

An agent that writes code needs somewhere to run it: install a package, start a server, run the tests, try three fixes at once and keep the one that passes. Hosted sandboxes do this well and bill by the second, and your code and data go to someone else's cloud. Loaner is the same idea in one image you run yourself.

  • Built for agents first. Every route is an MCP tool (54 of them), and a command still running after 25 seconds answers with the tool to poll next, so long work never hangs a call. Output reads by byte offset, as a live stream or by HTTP range, from any client and after any disconnect. Errors are problem+json with a page per code that says what to change. It serves llms.txt, skills and an OpenAPI document whose examples work as they are.

  • Two kinds of machine. Containers on Loaner's own Docker engine (Debian or Alpine, or a template from any image), at native speed, and optionally under gVisor. Or a Linux kernel compiled to WebAssembly, running inside the server itself, with forks that copy running memory.

  • Safe by default. It asks for keys from the start. A key made for an app sees only the machines it made, within limits you set. Agents can sign in with OAuth, each approved with the admin key. A machine can be held to a list of hosts it may reach, and every refusal is recorded. Disks have quotas, and the host's Docker is never touched.

  • Yours. MIT licensed, one container and one volume, updates you start from the API (signed releases, rolled back if they don't come up).

Related MCP server: paddock

Run it

You need Docker. Loaner runs its own engine inside its container, so the container is privileged.

mkdir loaner && cd loaner
curl -fsSLO https://github.com/escalay/loaner/releases/latest/download/docker-compose.yml
docker compose run --rm loaner keys > .env     # an admin key and an OAuth signing key, once
docker compose up -d

Or the same in one line, which checks Docker first, keeps its keys on a second run, and waits until it answers (PUBLIC_HOST=loaner.example.com before sh sets up HTTPS too):

curl -fsSL https://raw.githubusercontent.com/escalay/loaner/main/deploy/install.sh | sh

Open http://localhost:4400/docs and try any operation with the ADMIN_KEY from .env; each example works as it is. With a domain pointing at the machine, set PUBLIC_HOST=loaner.example.com in .env and start it with docker compose --profile https up -d for automatic certificates. Point *.loaner.example.com at it too, and a machine's server can be shared at its own https://<slug>.loaner.example.com.

On Coolify or anything else that runs one container: the image is ghcr.io/escalay/loaner, it needs --privileged and a volume at /state, and listens on port 80. apps/api/README.md has every setting.

Connect an agent

Loaner's MCP server is at /mcp. In Claude Code:

claude mcp add --transport http loaner https://loaner.example.com/mcp

The first connection opens a sign-in page; approve it with the admin key. An agent signed in this way sees only the machines it made. Clients without OAuth send a key in an Authorization: Bearer header instead (make one per app with POST /api/keys).

Agents that read before they act can start at /llms.txt, and npx skills add https://loaner.example.com -y installs Loaner's skill, with a playbook per job: trying several fixes in parallel, running a server and calling it, keeping a machine's network to a few hosts.

Use it from code

npm install loaner-sdk
import { loanerClient } from 'loaner-sdk'

const loaner = loanerClient({ url: 'https://loaner.example.com', key: process.env.LOANER_KEY })

const machine = await loaner.create()
await machine.files.write('~/calc.sh', 'echo $(( $1 - $2 ))\n') // a bug: it should add

// Two candidate fixes, each on its own copy of the machine; keep the one whose check passes
const copies = await machine.fork({
  commands: [
    `sed -i 's/-/+/' ~/calc.sh && test "$(sh ~/calc.sh 2 3)" = 5`,
    `sed -i 's/-/*/' ~/calc.sh && test "$(sh ~/calc.sh 2 3)" = 5`,
  ],
})
console.log(copies.map(({ result }) => result?.ok)) // [true, false]

await Promise.all([machine, ...copies.map((copy) => copy.machine)].map((one) => one.delete()))

run follows a command however long it takes and returns everything it printed with its exit code. The SDK's README covers the rest, and examples/ has whole programs to copy: sharing a server, a machine held to one host, and the fixes above.

What a machine can do

  • Run commands and scripts, short or long (a 202 and a Location to follow past 25 seconds), with stdin, signals and an interactive terminal.

  • Read, write, edit, search and list files, or move a whole folder in and out as a tar.

  • Start a server and call it through the API, or share its port at a public address.

  • Fork into several copies, each running its own command, and save snapshots to start from later.

  • Start from a template built once from any image or Dockerfile.

  • Install one of 19 apps in one call (Postgres, Valkey, Node, Python, Go, Rust, nginx and more).

  • Report what it uses (memory, CPU, disk, the busiest processes) and, for wasm machines, the kernel's console.

  • Send events as a feed or as signed webhooks: machines starting and stopping, commands ending, connections refused.

How it fits together

flowchart LR
  agents["Agents and apps<br/>MCP, REST, SDK"] --> api["Loaner API<br/>keys, OAuth, policies"]
  api --> docker["Its own Docker engine<br/>containers, gVisor optional"]
  api --> wasm["Wasm kernels<br/>inside the server"]
  docker --> egress["Egress gateway<br/>applies each machine's network policy"]
  api -. updates .-> updater["Updater<br/>verifies signed releases"]

The API knows machines only through one small interface (a driver), so each kind of machine is a folder of its own: drivers/docker for containers, on Loaner's engine or several engines at once, and drivers/unkernel for wasm. A container machine has no network device of its own; it reaches out through a proxy that applies its policy. The details are in docs/architecture.md, and the rules a change keeps in apps/api/AGENTS.md.

Security

The container runs privileged because Loaner starts a Docker engine inside it: machines are containers of that engine, never of your host's. Run strangers' code with DOCKER_RUNTIME=runsc, which puts every container machine under gVisor. Releases are built by GitHub Actions, scanned, and signed with cosign; SECURITY.md shows how to check an image before you run it and how to report a vulnerability.

Updates and telemetry

Loaner checks once a day for a newer release and tells the admin key (GET /api/v1/updates). Asked to update, it leaves a request for the updater beside it, which checks the release's signature, starts it and puts the old version and its data back if it doesn't come up: docs/updates.md.

Once a day it also sends an anonymous usage report: counts in ranges and which options are on, never names, keys or anything that runs on its machines. docs/telemetry.md lists every field; LOANER_TELEMETRY=off stops it.

Develop

pnpm install
pnpm dev                   # the API at http://localhost:4400, wasm machines in the process
DRIVERS=docker,unkernel pnpm dev   # container machines too, on this machine's Docker
pnpm -C apps/api gate      # types, lint, format and tests, as CI runs them
pnpm image                 # the image from this checkout, run the way a release runs
pnpm desktop               # the demo below

AGENTS.md is the map of the repository for people and coding agents, and CONTRIBUTING.md says how changes come in, and docs/roadmap.md what comes next.

The demo

apps/desktop is where Loaner started: unkernel's Linux desktop in a browser tab, with an agent chat docked on the left that types its commands into a terminal you can watch. Bring an OpenRouter key (vendor/unkernel/web/.env.local, VITE_OPENROUTER_KEY=…) and run pnpm desktop.

Credits

Loaner stands on other people's work:

  • unkernel by Pooya Parsa (@pi0) is the Linux kernel compiled to WebAssembly behind Loaner's wasm machines, the browser desktop of the demo, and the app recipes. Without it, Loaner wouldn't exist.

  • agentak, also by Pooya Parsa, is the chat in the demo.

  • gVisor (Google) is the optional sandbox for container machines, and the Moby project's Docker engine runs them.

  • api-kit is the standard the API is built on, with Hono, zod-openapi, Drizzle, dockerode and Scalar for the docs.

  • selfhost-kit's updater carries out updates.

License

MIT, see LICENSE. That covers Loaner's own code. The projects under vendor/ keep their licences: unkernel is GPL-2.0-or-later, except its SDK and its page (the demo's desktop), which are MIT. The image runs the unkernel npm package (MIT AND GPL-2.0-only: it carries a Linux kernel and BusyBox) as a separate program for wasm machines. THIRD-PARTY.md lists what the repository and the image carry, and where each source is.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to work in a persistent, isolated Linux workspace with file management, Bash execution, SSH/SFTP access, and durable storage while keeping workloads contained from the host and private networks.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Gives an AI agent its own fleet of disposable Linux microVMs on hardware you control, with tools to spawn, execute commands in, fork from identical disk states, list, and destroy them. Enables safe parallel exploration and cleanup all within an isolated VM boundary.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to operate disposable Linux computers via MCP, providing tools for shell, file read/write, directory listing, and port exposure. It also supports browser automation and integration with any MCP-compatible client.
      Apache 2.0