# xpumesh for developers: CLI, MCP server, Python SDK and API

Source a GPU from any provider with one command, MCP tool call or Python call. Ordered fallback, exact spend caps, idempotent launches, proven teardown.

## xpumesh for developers

Open source, Apache-2.0. One Rust core. Four front doors: CLI, MCP server, Python SDK, HTTPS API. Every source behind one provider interface.

sh:

```
$ pip install xpumesh            # SDK, plus the xpumesh and xpumesh-mcp binaries
$ xpumesh doctor
$ xpumesh launch 8xh100 --on-demand --max '$60/hr' --launch-cap 500 --max-runtime-seconds 14400
```

No toolchain: `npx -y xpumesh agent setup cursor` or `uvx --from xpumesh xpumesh-mcp`.

## One request, three ways to send it

All three call the same code and return the same JSON.

CLI:

```
$ xpumesh launch 8xh100 --on-demand --max '$60/hr' --launch-cap 500 \
    --max-runtime-seconds 14400 --json
```


MCP:

```
{"tool": "launch", "arguments": {
  "gpu": "8xh100", "billing": "on-demand", "max": "$60/hr", "launch_cap": "500",
  "max_runtime_seconds": 14400, "client_token": "<uuid4>"}}
```


Python:

```
import xpumesh
lease = xpumesh.launch(gpu="8xh100", billing="on-demand", max="$60/hr",
                       launch_cap="500", max_runtime_seconds=14400)
```

Required: gpu, billing, max, launch_cap. Filters: `--region`, `--provider`, `--interconnect`, `--min-vcpu`, `--min-ram`, `--image`, `--port`, `--ssh-ref`.

## What a launch does


output, illustrative:

```
8 × H100, on-demand, under $60/hr, cheapest first
1 Lambda       gpu_8x_h100_sxm5       $23.92  sold out
2 Nebius       gpu-h100-sxm, 8gpu     $30.96  no quota
3 CoreWeave    gd-8xh100ib-i128       $49.24  running
4 AWS          p5.48xlarge            $55.04

can't confirm
  Azure        Standard_ND96isr_H100_v5
  Oracle Cloud BM.GPU.H100.8

over your $60/hr ceiling
  Google Cloud a3-highgpu-8g          $88.49
```

- Confirmed capacity miss: drop that offer, try the next
- Confirmed quota failure: drop that provider
- Unknown outcome: stop, reconcile, never double-launch
- Same `client_token`: same lease, every time
- Missing price or cap: refused before any provider call

## Launch templates and guardrails

A template is ordered steps with conditions. It can narrow a guardrail, never loosen one.

agent-training.json:

```
{"schema_version": 1, "name": "agent-training", "level": "auto",
 "match":  {"caller": {"kind": "agent"}, "gpu": ["h100", "h200"], "count": {"min": 8}},
 "limits": {"max_hourly_price_usd": "40.00", "launch_cap_usd": "300.00", "max_runtime_seconds": 14400},
 "steps": [
   {"name": "spot-overnight", "providers": ["gcp", "nebius"], "billing": "spot",
    "max_hourly_price_usd": "18.00", "when": {"utc_time": {"from": "22:00", "to": "06:00"}}},
   {"name": "on-demand", "providers": ["coreweave", "aws"], "max_hourly_price_usd": "40.00",
    "advance_on": ["capacity"], "ask_first": true}]}
```


sh:

```
$ xpumesh template check agent-training.json     # zero writes, zero provider calls
$ xpumesh template save agent-training.json
$ xpumesh launch --launch-template agent-training
```

Guardrails: hourly ceiling, launch cap, daily and monthly caps, runtime ceiling, per-key policy, ask-first approvals. Humans set them. Agents can only narrow.

## Leases: status, access, release


sh:

```
$ xpumesh lease list --json
$ xpumesh lease status <lease-id> --refresh --json
$ xpumesh lease access <lease-id> --json          # SSH, Jupyter, files
$ xpumesh notebook --gpu 1xh100 --on-demand --max '$8/hr' --launch-cap 40 --max-runtime 7200
$ xpumesh lease release <lease-id> --confirm <lease-id> --json
```


release result:

```
{"lease_id": "lease-…", "state": "released",
 "deletion": {"deletion_confirmed": true, "evidence_ref": "…"}}
```

Release needs an exact ID echo. It never waits on caps, prices or billing.
Every lease ends at the first of: max runtime, launch cap, idle timeout, provider-side time limit, on-machine power-off.

## Give it to your agent


local, stdio:

```
$ xpumesh agent setup claude-code   # codex | cursor | devin | vscode | gemini | windsurf
$ xpumesh agent doctor
```


hosted, OAuth, nothing to install:

```
https://YOUR-XPUMESH-HOST/v1/mcp
```

- Scopes: `leases:view`, `leases:create`, `leases:scale`, `leases:teardown`
- Human-only: `admin:budgets`, `admin:keys`
- Start here: `account_status`, `plan_launch`
- Then: `launch`, `lease_status`, `lease_access`, `lease_release`, `spend_report`
Schemas reject credential-like parameters. The full tool and refusal tables are on the agents view.

## Mesh: many machines, and your own


demand:

```
$ xpumesh mesh launch --count 4 --gpu 8xh100 --billing on-demand \
    --max '$60/hr' --launch-cap 2000 --max-runtime-seconds 14400
$ xpumesh mesh status
$ xpumesh mesh teardown --mesh-lease-id <mesh-…>
```

- Pool: per-node fallback across clouds, one private WireGuard overlay, one inventory
- Atomic: staged privately, published complete, or rolled back
- Caps: hourly, launch and monthly limits apply to the mesh, not per node
- Supply: owners enrol nodes with a signed agent, publish priced offers and windows
- Isolation: one tenant per host, full VM, no host access, owner can reclaim
- Settlement: signed metering records; payouts or instance-hour credits

## Self-host, or use the hosted API


self-host:

```
$ git clone <repo> && cd xpumesh
$ docker compose up        # control plane; your keys stay in your HashiCorp Vault
```


hosted API:

```
POST /v1/launch         GET /v1/leases              DELETE /v1/leases/{lease_id}
POST /v1/launch/check   GET /v1/finder/list-offers  GET    /v1/billing/balance
GET  /v1/guardrails     GET /v1/launch-templates    POST   /v1/approvals/{id}/approve
POST /v1/mcp
Authorization: Bearer $XPUMESH_API_KEY
```

Prices are exact decimal strings, never floats. Local and hosted caps are separate ledgers: send every caller that should share a cap to one workspace.
Local policy files are not tamper-proof against an agent with your OS permissions. Use hosted keys for a hard boundary.
