charter-mcp 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,11 +2,13 @@
2
2
 
3
3
  An MCP server that lets an agent rent a machine on [Charter](https://charter.mainnet.toonprotocol.dev/agents) and pay for it itself. No account, no API key, no signup: the agent has a wallet, its operator funds it, and each paid tool call is one x402 payment in USDC on Base.
4
4
 
5
- What it rents, by the hour, at 0.007 USDC an hour on the live host:
5
+ What it rents, by the hour, at the price each host sets (0.007 USDC an hour today). Hosts are run by independent operators, not vetted by Charter; each offer carries the host's record, and an operator can see what runs on its machine.
6
+
7
+ What it rents:
6
8
 
7
9
  - **A Python sandbox.** Your script (up to 8 KiB, NumPy installed, no network) runs once; stdout, stderr and the exit code come back.
8
- - **A page fetcher.** Up to five pages loaded in a headless browser through a hidden exit on the Anyone network; the text of each comes back.
9
- - **A Linux home.** A Debian box of your own with 1 CPU, 1 GiB of memory, a 2 GiB disk kept 7 days after the lease ends, and SSH in.
10
+ - **A page fetcher.** Up to five pages loaded in a headless browser (through a hidden exit on the Anyone network on an offer with `hiddenEgress`); the text of each comes back.
11
+ - **A Linux home.** A Debian box of your own with 1 CPU, 1 GiB of memory, a disk (`home.diskGiB` in the offer) kept 7 days after the lease ends, and SSH in.
10
12
 
11
13
  ## Install
12
14
 
@@ -97,16 +99,17 @@ Other settings: `CHARTER_MCP_KEY_FILE`, `CHARTER_MCP_SPEND_FILE`, `CHARTER_MCP_N
97
99
  ## Read this before renting a home
98
100
 
99
101
  - SSH is plain: `ssh -p <port> tenant@<host>`, with the host and port from the lease's `access.ssh` (the port is fixed per home, 22000 to 22099; the same keys reopen the same home). A host may also publish `access.onion`, which needs an Anyone client.
100
- - All of the box's outbound traffic leaves through the host's Anyone client: slow, and some services refuse shared exits.
101
- - No root. 1 GiB of memory. Homes are limited (`home.slots` in the offer); an open answers `busy` when they are full.
102
- - The operator of the host can read the disk. Secrets go in over `scp`, never through Charter.
102
+ - On a host that fences homes to Anyone (the reference setup), all of the box's outbound traffic leaves through the host's Anyone client: slow, and some services refuse shared exits.
103
+ - Log in as `tenant`, and as `root` with apt on a host whose offer says `home.root`. 1 GiB of memory. Homes are limited (`home.slots` in the offer); an open answers `busy` when they are full.
104
+ - The host's operator, an independent party, can read the disk. Secrets go in over `scp`, never through Charter.
105
+ - A home lives on the host that holds its disk. If that host is gone the door answers `home_host_gone`; once the door has dropped the host, naming another offer opens a fresh, empty home.
103
106
  - A home that is not paid closes; its disk and port are kept 7 days and the same keys open it again.
104
107
 
105
108
  The full procedure is at [charter.mainnet.toonprotocol.dev/agents](https://charter.mainnet.toonprotocol.dev/agents).
106
109
 
107
110
  ## Status
108
111
 
109
- One host, run by the project, live on Base mainnet since 2026-10-17. No uptime figure. Charter runs on [TOON](https://toon.ar.io/): ILP routes each packet, x402 settles it. MIT.
112
+ Live on Base mainnet since 2026-10-17. Anyone can run a host; the door lists a host once it passes a probe and ranks hosts by record, then price. No uptime figure. Payments are x402 in USDC on Base. MIT.
110
113
 
111
114
  ## Develop
112
115
 
package/dist/cli.js CHANGED
@@ -13,8 +13,9 @@ export const USAGE = `usage:
13
13
  charter-mcp grant --id <grantId> --token-file <file>
14
14
  free: read your own grant (the full lease id once granted)
15
15
 
16
- One interval is an hour at 0.007 USDC on the live host. --wait is 10 to 240 seconds (default 40); a job
17
- still running then prints its leaseId, and \`lease\` collects the output for free.
16
+ One interval is an hour; hosts set their own price (0.007 USDC today). --wait is 10 to 240 seconds (default 40); a job
17
+ still running then prints its leaseId, and \`lease\` collects the output for free. Hosts are run by
18
+ independent operators, not vetted by Charter.
18
19
  Environment: CHARTER_MAX_USDC_PER_HOUR (0.01), CHARTER_MAX_USDC_PER_DAY (0.25), CHARTER_MCP_KEY_FILE,
19
20
  CHARTER_MCP_NO_NEW_KEY, CHARTER_MCP_SPEND_FILE, CHARTER_BASE_RPC, CHARTER_DOOR_URL.
20
21
  Pitching is free and a model judges it; ask your operator first. Every decision is public at /grants on the door.
package/dist/core.js CHANGED
@@ -90,16 +90,23 @@ async function capped(d, micro, pay) {
90
90
  return r;
91
91
  }
92
92
  const IMAGE_OF = (job) => 'python' in job ? 'charter-job-python' : 'urls' in job ? 'charter-job-fetch' : (job.home.image ?? 'charter-home');
93
- /** The cheapest live offer that runs the job, as the door itself would pick. */
94
- export async function cheapestOffer(d, job) {
93
+ /**
94
+ * The first offer in the door's order (GET /v1/offers lists them as the door ranks them: record, then price) that
95
+ * runs the job and this server can use: not over the hourly cap, not waiting for the door's funding, and for a
96
+ * home, with a free slot. When every offer that runs the job is over the cap, the first of those, so rent can say
97
+ * what it costs.
98
+ */
99
+ export async function firstFitOffer(d, job) {
95
100
  const r = await d.get('/v1/offers');
96
101
  if (r.status !== 200 || !Array.isArray(r.body))
97
102
  throw new Error(`GET /v1/offers answered ${r.status}: cannot read the price, nothing paid`);
98
103
  const image = IMAGE_OF(job);
99
- const fits = r.body.filter((o) => Array.isArray(o?.images) && o.images.includes(image) && /^\d{1,12}$/.test(String(o.tickPrice)) && BigInt(o.tickPrice) > 0n);
100
- if (fits.length === 0)
104
+ const usable = r.body.filter((o) => Array.isArray(o?.images) && o.images.includes(image) && /^\d{1,12}$/.test(String(o.tickPrice)) && BigInt(o.tickPrice) > 0n &&
105
+ o.record?.funding !== 'waiting' &&
106
+ !('home' in job && o.home?.free === 0));
107
+ if (usable.length === 0)
101
108
  throw new Error(`no machine on sale runs ${image} right now (GET /v1/offers lists ${r.body.length}). Try again later; nothing was paid.`);
102
- return fits.reduce((a, b) => (BigInt(b.tickPrice) < BigInt(a.tickPrice) ? b : a));
109
+ return usable.find((o) => BigInt(o.tickPrice) <= d.maxHour) ?? usable[0];
103
110
  }
104
111
  function needWallet(d) {
105
112
  if (!d.pay)
@@ -121,7 +128,7 @@ function refusal(what, r) {
121
128
  /** Opens a lease and pays its first interval: one paid call. */
122
129
  export async function rent(d, job) {
123
130
  const pay = needWallet(d);
124
- const offer = await cheapestOffer(d, job);
131
+ const offer = await firstFitOffer(d, job);
125
132
  const cost = price(offer.tickPrice);
126
133
  if (cost > d.maxHour) {
127
134
  throw new CapError(`one interval costs ${microToUsdc(cost)} USDC, over this server's cap of ${microToUsdc(d.maxHour)} (CHARTER_MAX_USDC_PER_HOUR). Nothing was paid.`);
package/dist/server.js CHANGED
@@ -20,7 +20,7 @@ import { privateKeyToAccount } from 'viem/accounts';
20
20
  import { base } from 'viem/chains';
21
21
  import { z } from 'zod';
22
22
  import { BASE, BASE_USDC, CapError, DEFAULT_DOOR, PayError, extend, grantStatus, lease, microToUsdc, onlyDoorExact, output, pitch, rent, runJob, usdcToMicro, } from './core.js';
23
- export const VERSION = '0.3.0';
23
+ export const VERSION = '0.4.0';
24
24
  export function optionsFromEnv(env) {
25
25
  const dir = join(homedir(), '.charter');
26
26
  const v = (k) => env[k]?.trim() || undefined;
@@ -283,6 +283,8 @@ export function build(o, log, fetchFn = fetch) {
283
283
  memoryMiB: x.memoryMiB,
284
284
  images: x.images,
285
285
  home: x.home ?? null,
286
+ operator: x.operator ?? null,
287
+ record: x.record ?? null,
286
288
  })),
287
289
  docs: `${o.door}/agents`,
288
290
  ...caps(),
@@ -359,10 +361,10 @@ export function build(o, log, fetchFn = fetch) {
359
361
  }
360
362
  };
361
363
  const server = new McpServer({ name: 'charter', version: VERSION });
362
- const cost = 'Costs one interval of the cheapest machine: 0.007 USDC on the live host (see charter_offers), paid from this server\'s own wallet in USDC on Base.';
364
+ const cost = 'Costs one interval of the first machine in the door\'s ranking that runs it within this server\'s cap (hosts set their own price; 0.007 USDC an hour today; see charter_offers), paid from this server\'s own wallet in USDC on Base. Hosts are run by independent operators, not vetted by Charter.';
363
365
  server.registerTool('charter_offers', {
364
366
  title: 'Charter machines on sale',
365
- description: 'Free. The machines for rent on Charter right now: price per interval in USDC (0.007 an hour on the live host), CPU, memory, the job images each runs, and how many home slots it has. Charter rents a sandboxed machine by the hour with no account: a Python job, a page-fetch job, or a Linux home with SSH. Call this first to see the price before any paid tool.',
367
+ description: 'Free. The machines for rent on Charter right now: price per interval in USDC (hosts set their own; 0.007 an hour today), CPU, memory, the job images each runs, how many home slots it has and whether its home is tested, and the host\'s record (probes passed, leases finished, success rate). Hosts are run by independent operators, not vetted by Charter, and an operator can see what runs on its machine. Charter rents a sandboxed machine by the hour with no account: a Python job, a page-fetch job, or a Linux home with SSH. Call this first to see the price before any paid tool.',
366
368
  inputSchema: {},
367
369
  annotations: { readOnlyHint: true, openWorldHint: true },
368
370
  }, () => answer(actions.offers));
@@ -382,8 +384,8 @@ export function build(o, log, fetchFn = fetch) {
382
384
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
383
385
  }, ({ script, waitSeconds }) => answer(() => actions.runPython(script, waitSeconds)));
384
386
  server.registerTool('charter_fetch_pages', {
385
- title: 'Fetch pages in a headless browser through a hidden exit',
386
- description: `PAID. ${cost} Loads up to five http or https pages in a headless browser on a rented machine, through an exit on the Anyone network so the site sees neither you nor the host, and returns each page's text. Useful when a page needs JavaScript or your own address is refused. Slow (a page can take a minute) and some sites refuse shared exits. If it is still running when the wait ends, charter_lease collects the output for free.`,
387
+ title: 'Fetch pages in a headless browser',
388
+ description: `PAID. ${cost} Loads up to five http or https pages in a headless browser on a rented machine and returns each page's text. On an offer with hiddenEgress the pages load through an exit on the Anyone network, so the site sees neither you nor the host. Useful when a page needs JavaScript or your own address is refused. Slow (a page can take a minute) and some sites refuse shared exits. If it is still running when the wait ends, charter_lease collects the output for free.`,
387
389
  inputSchema: {
388
390
  urls: z.array(z.string().url().regex(/^https?:\/\//i)).min(1).max(5).describe('one to five http or https URLs'),
389
391
  waitSeconds: z.number().int().min(10).max(240).optional().describe('how long to wait for the job before handing back the leaseId (default 40, under most clients\' 60 s tool timeout; pages often need longer, so expect to collect with charter_lease)'),
@@ -392,7 +394,7 @@ export function build(o, log, fetchFn = fetch) {
392
394
  }, ({ urls, waitSeconds }) => answer(() => actions.fetchPages(urls, waitSeconds)));
393
395
  server.registerTool('charter_rent_home', {
394
396
  title: 'Rent a Linux home with SSH',
395
- description: `PAID. ${cost} Opens a Linux box of your own (Debian, 1 CPU, 1 GiB memory, a 2 GiB disk kept 7 days after the lease ends, user "tenant", no root) and pays its first interval. Pass 1 to 8 SSH PUBLIC keys; the key set is the home's identity, so the same keys open the same disk again. Read this before renting: SSH is plain: ssh -p <port> tenant@<host> to the public address the lease shows, no special client needed (some hosts publish an onion address on the Anyone network instead, which needs an Anyone client); outbound traffic may be slow; homes are limited (home.slots in the offer) and an open answers busy when they are full. After renting, call charter_lease about once a minute until it shows the SSH address, and charter_extend before the paid time runs out.`,
397
+ description: `PAID. ${cost} Opens a Linux box of your own (Debian, 1 CPU, 1 GiB memory, the offer's home.diskGiB of disk kept 7 days after the lease ends, login "tenant", and "root" with apt on a host whose offer says home.root) and pays its first interval. The host's operator can read its disk. Pass 1 to 8 SSH PUBLIC keys; the key set is the home's identity, so the same keys open the same disk again. Read this before renting: SSH is plain: ssh -p <port> tenant@<host> to the public address the lease shows, no special client needed (some hosts publish an onion address on the Anyone network instead, which needs an Anyone client); outbound traffic may be slow; homes are limited (home.slots in the offer) and an open answers busy when they are full. After renting, call charter_lease about once a minute until it shows the SSH address, and charter_extend before the paid time runs out.`,
396
398
  inputSchema: {
397
399
  sshKeys: z.array(z.string().max(1023)).min(1).max(8).describe('SSH public key lines (ssh-ed25519, ecdsa-sha2-nistp256/384/521 or ssh-rsa). Public keys only: never a private key.'),
398
400
  image: z.enum(['charter-home', 'charter-hermes']).optional().describe('charter-home (default) is a plain box; charter-hermes has Hermes Agent preinstalled'),
@@ -407,7 +409,7 @@ export function build(o, log, fetchFn = fetch) {
407
409
  }, ({ leaseId }) => answer(() => actions.lease(leaseId)));
408
410
  server.registerTool('charter_extend', {
409
411
  title: 'Pay more time on a lease',
410
- description: 'PAID. Pays the next intervals of a running lease, one payment each (0.007 USDC an hour on the live host), from this server\'s wallet. Use it to keep a home running: pay before the paid time runs out, ideally half an hour early. Stops at the first refused payment and reports what was paid. A lease that has closed cannot be extended; a home opens again with the same keys.',
412
+ description: 'PAID. Pays the next intervals of a running lease, one payment each at the lease\'s open-time price (0.007 USDC an hour today), from this server\'s wallet. Use it to keep a home running: pay before the paid time runs out, ideally half an hour early. Stops at the first refused payment and reports what was paid. A lease that has closed cannot be extended; a home opens again with the same keys.',
411
413
  inputSchema: {
412
414
  leaseId: z.string().regex(/^[0-9a-f]{32}$/).describe('the leaseId to pay for'),
413
415
  hours: z.number().int().min(1).max(24).describe('how many intervals to pay now, 1 to 24. The door refunds nothing, so pay only what you will use.'),
@@ -416,7 +418,7 @@ export function build(o, log, fetchFn = fetch) {
416
418
  }, ({ leaseId, hours }) => answer(() => actions.extend(leaseId, hours)));
417
419
  server.registerTool('charter_grant_pitch', {
418
420
  title: 'Pitch the Charter grant fund',
419
- description: 'Free. Pitches the Charter grant fund for a home paid by the fund: no payment is ever made and this server\'s wallet is not used. Ask your operator before you apply. A model judges the pitch, and every decision and its reason is public at /grants on the door. A grant is 30 days of a home paid by the fund. Homes are reached by plain SSH (ssh -p <port> tenant@<host>); some hosts publish an onion address instead, which needs an Anyone client. Keep the grantToken the answer returns: it is the only way to read your lease id (charter_grant_status). The operator can read the home\'s disk, so keep secrets off it. Pass 1 to 8 SSH PUBLIC keys; the key set is the home\'s identity.',
421
+ description: 'Free. Pitches the Charter grant fund for a home paid by the fund: no payment is ever made and this server\'s wallet is not used. Ask your operator before you apply. A model judges the pitch, and every decision and its reason is public at /grants on the door. A grant is 30 days of a home paid by the fund. Homes are reached by plain SSH (ssh -p <port> tenant@<host>); some hosts publish an onion address instead, which needs an Anyone client. Keep the grantToken the answer returns: it is the only way to read your lease id (charter_grant_status). The host is run by an independent operator; the operator can read the home\'s disk, so keep secrets off it. Pass 1 to 8 SSH PUBLIC keys; the key set is the home\'s identity.',
420
422
  inputSchema: {
421
423
  name: z.string().min(1).max(80).describe('who is asking, at most 80 characters'),
422
424
  pitch: z.string().min(1).max(2000).describe('what you will run and why it deserves a home, at most 2000 characters. It is judged by a model and the decision is public.'),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "charter-mcp",
3
- "version": "0.3.0",
4
- "description": "MCP server and command line that let an agent rent a sandboxed machine by the hour on Charter and pay for it itself: run a Python script, fetch pages through a hidden exit, or rent a Linux home with SSH. USDC on Base over x402, no account.",
3
+ "version": "0.4.0",
4
+ "description": "MCP server and command line that let an agent rent a sandboxed machine by the hour on Charter and pay for it itself: run a Python script, fetch pages, or rent a Linux home with SSH, on hosts run by independent operators. A grant fund pays a free month to agents that pitch. USDC on Base over x402, no account.",
5
5
  "mcpName": "io.github.drew-dot-com/charter",
6
6
  "type": "module",
7
7
  "license": "MIT",