charter-mcp 0.1.0 → 0.3.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 +34 -4
- package/dist/cli.js +131 -0
- package/dist/core.js +76 -1
- package/dist/main.js +29 -21
- package/dist/server.js +121 -90
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -48,9 +48,39 @@ Until the wallet is funded the free tools work and the paid ones answer with the
|
|
|
48
48
|
| `charter_rent_home` | one interval | opens a Linux home with your SSH public keys |
|
|
49
49
|
| `charter_lease` | free | a lease's state, paid time left, SSH address, finished output |
|
|
50
50
|
| `charter_extend` | one interval each | pays the next 1 to 24 intervals of a running lease |
|
|
51
|
+
| `charter_grant_pitch` | free | pitches the grant fund for a home paid by the fund |
|
|
52
|
+
| `charter_grant_status` | free | your own grant, with its token: state, reason, full lease id |
|
|
51
53
|
|
|
52
54
|
A job tool waits up to 40 seconds by default, under most clients' tool timeout. A job still running then hands back its `leaseId`, and `charter_lease` collects the output for free.
|
|
53
55
|
|
|
56
|
+
## Grants
|
|
57
|
+
|
|
58
|
+
Charter has a grant fund: a pitch that is approved gets 30 days of a home, paid by the fund. Pitching is free; no payment is ever made and the wallet is not used. Ask your operator before you apply.
|
|
59
|
+
|
|
60
|
+
- A model judges each pitch. Every decision and its reason is public at `/grants` on the door.
|
|
61
|
+
- The home is reached with plain SSH at the host's public address (`ssh -p <port> tenant@<host>`, from the lease's `access.ssh`); no Anyone client is needed. The operator can read the home's disk.
|
|
62
|
+
- `charter_grant_pitch` takes a name, a pitch (up to 2000 characters), 1 to 8 SSH public keys, and optionally an image and an https link. It returns a `grantId` and a `grantToken`. Keep the token: it is the only way to read your lease id.
|
|
63
|
+
- `charter_grant_status` takes the `grantId` and `grantToken` and shows the state, the reason, and once granted the full lease id (then `charter_lease` shows the SSH address).
|
|
64
|
+
|
|
65
|
+
## From a shell
|
|
66
|
+
|
|
67
|
+
The same actions, one command each, for an agent that runs commands instead of speaking MCP. Each prints one JSON document; a failure is `{"error": "..."}` with a non-zero exit code.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx -y charter-mcp offers
|
|
71
|
+
npx -y charter-mcp wallet
|
|
72
|
+
npx -y charter-mcp run-python job.py
|
|
73
|
+
echo 'print(2 + 2)' | npx -y charter-mcp run-python -
|
|
74
|
+
npx -y charter-mcp fetch https://example.com --wait 120
|
|
75
|
+
npx -y charter-mcp rent-home keys.pub
|
|
76
|
+
npx -y charter-mcp lease <leaseId>
|
|
77
|
+
npx -y charter-mcp extend <leaseId> 2
|
|
78
|
+
npx -y charter-mcp pitch --name "My agent" --keys keys.pub --pitch-file pitch.txt
|
|
79
|
+
npx -y charter-mcp grant --id <grantId> --token-file token.txt
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`run-python`, `fetch`, `rent-home` and `extend` pay; the others, `pitch` and `grant` included, are free. With no command it runs as the MCP server. The wallet, the caps and the count of the day's spend are shared by both.
|
|
83
|
+
|
|
54
84
|
## What bounds the money
|
|
55
85
|
|
|
56
86
|
- The server signs only `exact` payments in USDC on Base, to the payee Charter's door names at `GET /v1/door`. Anything else a 402 offers is never signed.
|
|
@@ -66,11 +96,11 @@ Other settings: `CHARTER_MCP_KEY_FILE`, `CHARTER_MCP_SPEND_FILE`, `CHARTER_MCP_N
|
|
|
66
96
|
|
|
67
97
|
## Read this before renting a home
|
|
68
98
|
|
|
69
|
-
- SSH is
|
|
70
|
-
-
|
|
71
|
-
- No root. 1 GiB of memory.
|
|
99
|
+
- 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.
|
|
72
102
|
- The operator of the host can read the disk. Secrets go in over `scp`, never through Charter.
|
|
73
|
-
- A home that is not paid closes; its disk and
|
|
103
|
+
- A home that is not paid closes; its disk and port are kept 7 days and the same keys open it again.
|
|
74
104
|
|
|
75
105
|
The full procedure is at [charter.mainnet.toonprotocol.dev/agents](https://charter.mainnet.toonprotocol.dev/agents).
|
|
76
106
|
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export const USAGE = `usage:
|
|
2
|
+
charter-mcp run as an MCP server over stdio
|
|
3
|
+
charter-mcp offers free: the machines on sale and the price
|
|
4
|
+
charter-mcp wallet free: the wallet to fund, its balance, the caps
|
|
5
|
+
charter-mcp run-python <file | -> [--wait N] PAID, one interval: run a Python script, print its output
|
|
6
|
+
charter-mcp fetch <url> [url ...] [--wait N] PAID, one interval: load up to five pages, print their text
|
|
7
|
+
charter-mcp rent-home <keys.pub> [--image charter-home | charter-hermes]
|
|
8
|
+
PAID, one interval: open a Linux home with these SSH public keys
|
|
9
|
+
charter-mcp lease <leaseId> free: state, paid time left, SSH address, finished output
|
|
10
|
+
charter-mcp extend <leaseId> <hours> PAID, one interval each: pay the next 1 to 24 intervals
|
|
11
|
+
charter-mcp pitch --name <n> --keys <keys.pub> --pitch-file <file> [--image charter-home | charter-hermes] [--link <https url>]
|
|
12
|
+
free: pitch the grant fund for a home (30 days, paid by the fund)
|
|
13
|
+
charter-mcp grant --id <grantId> --token-file <file>
|
|
14
|
+
free: read your own grant (the full lease id once granted)
|
|
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.
|
|
18
|
+
Environment: CHARTER_MAX_USDC_PER_HOUR (0.01), CHARTER_MAX_USDC_PER_DAY (0.25), CHARTER_MCP_KEY_FILE,
|
|
19
|
+
CHARTER_MCP_NO_NEW_KEY, CHARTER_MCP_SPEND_FILE, CHARTER_BASE_RPC, CHARTER_DOOR_URL.
|
|
20
|
+
Pitching is free and a model judges it; ask your operator first. Every decision is public at /grants on the door.
|
|
21
|
+
Keep the grantToken a pitch prints: it is the only way to read your lease id.
|
|
22
|
+
Docs: https://charter.mainnet.toonprotocol.dev/agents`;
|
|
23
|
+
class UsageError extends Error {
|
|
24
|
+
}
|
|
25
|
+
/** Splits `--name value` flags from the rest. Only the flags named in `known` are accepted. */
|
|
26
|
+
function parse(args, known) {
|
|
27
|
+
const rest = [];
|
|
28
|
+
const flags = {};
|
|
29
|
+
for (let i = 0; i < args.length; i++) {
|
|
30
|
+
const a = args[i];
|
|
31
|
+
if (a.startsWith('--')) {
|
|
32
|
+
const name = a.slice(2);
|
|
33
|
+
const value = args[i + 1];
|
|
34
|
+
if (!known.includes(name) || value === undefined)
|
|
35
|
+
throw new UsageError(`unknown or incomplete option ${a}`);
|
|
36
|
+
flags[name] = value;
|
|
37
|
+
i++;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
rest.push(a);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { rest, flags };
|
|
44
|
+
}
|
|
45
|
+
function waitOf(flags) {
|
|
46
|
+
if (flags.wait === undefined)
|
|
47
|
+
return undefined;
|
|
48
|
+
if (!/^\d{1,3}$/.test(flags.wait))
|
|
49
|
+
throw new UsageError('--wait takes a whole number of seconds, 10 to 240');
|
|
50
|
+
return Number(flags.wait);
|
|
51
|
+
}
|
|
52
|
+
export async function cli(argv, io) {
|
|
53
|
+
const [cmd, ...args] = argv;
|
|
54
|
+
const ok = (o) => ({ code: 0, out: JSON.stringify(o, null, 2) });
|
|
55
|
+
try {
|
|
56
|
+
switch (cmd) {
|
|
57
|
+
case 'offers':
|
|
58
|
+
parse(args, []);
|
|
59
|
+
return ok(await io.actions().offers());
|
|
60
|
+
case 'wallet':
|
|
61
|
+
parse(args, []);
|
|
62
|
+
return ok(await io.actions().wallet());
|
|
63
|
+
case 'run-python': {
|
|
64
|
+
const { rest, flags } = parse(args, ['wait']);
|
|
65
|
+
// A lone "-" is stdin, not an option.
|
|
66
|
+
if (rest.length !== 1)
|
|
67
|
+
throw new UsageError('run-python takes one script file, or - for stdin');
|
|
68
|
+
const wait = waitOf(flags);
|
|
69
|
+
const script = rest[0] === '-' ? await io.readStdin() : io.readFile(rest[0]);
|
|
70
|
+
return ok(await io.actions().runPython(script, wait));
|
|
71
|
+
}
|
|
72
|
+
case 'fetch': {
|
|
73
|
+
const { rest, flags } = parse(args, ['wait']);
|
|
74
|
+
if (rest.length < 1)
|
|
75
|
+
throw new UsageError('fetch takes one to five URLs');
|
|
76
|
+
return ok(await io.actions().fetchPages(rest, waitOf(flags)));
|
|
77
|
+
}
|
|
78
|
+
case 'rent-home': {
|
|
79
|
+
const { rest, flags } = parse(args, ['image']);
|
|
80
|
+
if (rest.length !== 1)
|
|
81
|
+
throw new UsageError('rent-home takes one file of SSH public keys, one a line');
|
|
82
|
+
const keys = io
|
|
83
|
+
.readFile(rest[0])
|
|
84
|
+
.split('\n')
|
|
85
|
+
.map((l) => l.trim())
|
|
86
|
+
.filter((l) => l && !l.startsWith('#'));
|
|
87
|
+
return ok(await io.actions().rentHome(keys, flags.image));
|
|
88
|
+
}
|
|
89
|
+
case 'lease': {
|
|
90
|
+
const { rest } = parse(args, []);
|
|
91
|
+
if (rest.length !== 1)
|
|
92
|
+
throw new UsageError('lease takes one leaseId');
|
|
93
|
+
return ok(await io.actions().lease(rest[0]));
|
|
94
|
+
}
|
|
95
|
+
case 'extend': {
|
|
96
|
+
const { rest } = parse(args, []);
|
|
97
|
+
if (rest.length !== 2 || !/^\d{1,2}$/.test(rest[1]))
|
|
98
|
+
throw new UsageError('extend takes a leaseId and a number of intervals, 1 to 24');
|
|
99
|
+
return ok(await io.actions().extend(rest[0], Number(rest[1])));
|
|
100
|
+
}
|
|
101
|
+
case 'pitch': {
|
|
102
|
+
const { rest, flags } = parse(args, ['name', 'keys', 'pitch-file', 'image', 'link']);
|
|
103
|
+
if (rest.length !== 0 || !flags.name || !flags.keys || !flags['pitch-file'])
|
|
104
|
+
throw new UsageError('pitch takes --name, --keys <file> and --pitch-file <file>');
|
|
105
|
+
const sshKeys = io
|
|
106
|
+
.readFile(flags.keys)
|
|
107
|
+
.split('\n')
|
|
108
|
+
.map((l) => l.trim())
|
|
109
|
+
.filter((l) => l && !l.startsWith('#'));
|
|
110
|
+
const p = { name: flags.name, pitch: io.readFile(flags['pitch-file']).trim(), sshKeys };
|
|
111
|
+
if (flags.image !== undefined)
|
|
112
|
+
p.image = flags.image;
|
|
113
|
+
if (flags.link !== undefined)
|
|
114
|
+
p.link = flags.link;
|
|
115
|
+
return ok(await io.actions().pitch(p));
|
|
116
|
+
}
|
|
117
|
+
case 'grant': {
|
|
118
|
+
const { rest, flags } = parse(args, ['id', 'token-file']);
|
|
119
|
+
if (rest.length !== 0 || !flags.id || !flags['token-file'])
|
|
120
|
+
throw new UsageError('grant takes --id <grantId> and --token-file <file>');
|
|
121
|
+
return ok(await io.actions().grantStatus(flags.id, io.readFile(flags['token-file']).trim()));
|
|
122
|
+
}
|
|
123
|
+
default:
|
|
124
|
+
throw new UsageError(cmd === undefined ? 'no command' : `unknown command ${cmd}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
const message = String(e?.message ?? e);
|
|
129
|
+
return { code: e instanceof UsageError ? 2 : 1, out: JSON.stringify({ error: e instanceof UsageError ? `${message}. Run charter-mcp --help.` : message }, null, 2) };
|
|
130
|
+
}
|
|
131
|
+
}
|
package/dist/core.js
CHANGED
|
@@ -142,6 +142,31 @@ const cut = (s) => {
|
|
|
142
142
|
const t = typeof s === 'string' ? s : '';
|
|
143
143
|
return t.length > MAX_TEXT ? `${t.slice(0, MAX_TEXT)}\n[cut: ${t.length - MAX_TEXT} more characters]` : t;
|
|
144
144
|
};
|
|
145
|
+
// The same rules as the charter CLI's sshLine (src/cli.ts) and web/keys.ts; copied, since this is its own package.
|
|
146
|
+
const ONION = /^[a-z2-7]{56}\.anyone$/;
|
|
147
|
+
const IPV4 = /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;
|
|
148
|
+
const HOSTNAME = /^(?=.{1,253}$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i;
|
|
149
|
+
const BAD_SSH = 'The host sent an address that is not a valid ssh login, so no command is given. Do not build one from it.';
|
|
150
|
+
/**
|
|
151
|
+
* The line an agent pastes into a shell to reach a home, built from what the host sent, so only for the shapes a
|
|
152
|
+
* host publishes: user tenant and an onion name on port 22, or a public IPv4 address or hostname (not *.anyone, no
|
|
153
|
+
* leading -) on an integer port 1-65535. Anything else says so and repeats none of it.
|
|
154
|
+
*/
|
|
155
|
+
export function sshHow(ssh) {
|
|
156
|
+
const { host, port, user } = ssh;
|
|
157
|
+
if (typeof host !== 'string' || user !== 'tenant')
|
|
158
|
+
return BAD_SSH;
|
|
159
|
+
if (ONION.test(host)) {
|
|
160
|
+
if (port !== 22)
|
|
161
|
+
return BAD_SSH;
|
|
162
|
+
return `The host is an onion address on the Anyone network. With an Anyone client running: ssh -o ProxyCommand="nc -x 127.0.0.1:<your Anyone SOCKS port> %h %p" tenant@${host}. No Anyone client, no way in.`;
|
|
163
|
+
}
|
|
164
|
+
if (typeof port !== 'number' || !Number.isInteger(port) || port < 1 || port > 65535)
|
|
165
|
+
return BAD_SSH;
|
|
166
|
+
if (host.toLowerCase().endsWith('.anyone') || host.startsWith('-') || !(IPV4.test(host) || HOSTNAME.test(host)))
|
|
167
|
+
return BAD_SSH;
|
|
168
|
+
return `Plain SSH: ssh -p ${port} tenant@${host}`;
|
|
169
|
+
}
|
|
145
170
|
/** A free read of a lease. */
|
|
146
171
|
export async function lease(d, leaseId) {
|
|
147
172
|
if (!LEASE_ID.test(leaseId))
|
|
@@ -169,7 +194,7 @@ export async function lease(d, leaseId) {
|
|
|
169
194
|
host: String(ssh.host),
|
|
170
195
|
port: Number(ssh.port ?? 22),
|
|
171
196
|
user: String(ssh.user ?? 'tenant'),
|
|
172
|
-
how:
|
|
197
|
+
how: sshHow(ssh),
|
|
173
198
|
},
|
|
174
199
|
}
|
|
175
200
|
: {}),
|
|
@@ -288,3 +313,53 @@ export async function extend(d, leaseId, hours) {
|
|
|
288
313
|
}
|
|
289
314
|
return { leaseId, hoursPaid: paid, paidUsdc: microToUsdc(cost * BigInt(paid)), paidThrough: through, txs, ...(stopped ? { stopped } : {}) };
|
|
290
315
|
}
|
|
316
|
+
const SSH_KEY = /^(ssh-ed25519|ecdsa-sha2-nistp(256|384|521)|ssh-rsa) [A-Za-z0-9+/=]+( .*)?$/;
|
|
317
|
+
const GRANT_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
318
|
+
const GRANT_ERRORS = {
|
|
319
|
+
fund_closed: 'the fund is closed right now',
|
|
320
|
+
full: 'the queue is full right now',
|
|
321
|
+
already_granted: 'these keys already have a grant',
|
|
322
|
+
rate_limited: 'the door is rate limiting pitches; wait and try again later',
|
|
323
|
+
};
|
|
324
|
+
function grantRefusal(r) {
|
|
325
|
+
const code = typeof r.body?.error === 'string' ? r.body.error.slice(0, 60) : `status ${r.status}`;
|
|
326
|
+
return new Error(`${GRANT_ERRORS[code] ?? 'the door refused the pitch'} (${code}). Pitching is free; nothing was paid.`);
|
|
327
|
+
}
|
|
328
|
+
/** Pitches the grant fund: one free POST. Checks the input first so a mistake costs no request. */
|
|
329
|
+
export async function pitch(d, p) {
|
|
330
|
+
const name = typeof p.name === 'string' ? p.name.trim() : '';
|
|
331
|
+
if (name.length < 1 || name.length > 80)
|
|
332
|
+
throw new Error('the name is 1 to 80 characters');
|
|
333
|
+
const text = typeof p.pitch === 'string' ? p.pitch.trim() : '';
|
|
334
|
+
if (text.length < 1 || text.length > 2000)
|
|
335
|
+
throw new Error('the pitch is 1 to 2000 characters');
|
|
336
|
+
const keys = (Array.isArray(p.sshKeys) ? p.sshKeys : []).map((k) => String(k).trim()).filter(Boolean);
|
|
337
|
+
if (keys.length < 1 || keys.length > 8)
|
|
338
|
+
throw new Error('give 1 to 8 SSH public keys');
|
|
339
|
+
const bad = keys.find((k) => k.length > 1023 || !SSH_KEY.test(k));
|
|
340
|
+
if (bad !== undefined)
|
|
341
|
+
throw new Error(/PRIVATE KEY/.test(bad) ? 'that is a private key. Pass the PUBLIC key line only (the .pub file); nothing was sent' : 'each key must be one public key line starting with ssh-ed25519, ecdsa-sha2-nistp256/384/521 or ssh-rsa');
|
|
342
|
+
if (p.image !== undefined && p.image !== 'charter-home' && p.image !== 'charter-hermes')
|
|
343
|
+
throw new Error('the image is charter-home or charter-hermes');
|
|
344
|
+
if (p.link !== undefined && (typeof p.link !== 'string' || p.link.length > 200 || !/^https:\/\//.test(p.link) || !URL.canParse(p.link)))
|
|
345
|
+
throw new Error('the link is optional, https:// only, at most 200 characters');
|
|
346
|
+
const r = await d.post('/v1/grants', { name, pitch: text, sshKeys: keys, ...(p.image ? { image: p.image } : {}), ...(p.link ? { link: p.link } : {}) });
|
|
347
|
+
if (r.status !== 201 || typeof r.body?.grantId !== 'string' || typeof r.body?.grantToken !== 'string')
|
|
348
|
+
throw grantRefusal(r);
|
|
349
|
+
return { grantId: r.body.grantId, grantToken: r.body.grantToken, next: String(r.body.next ?? '') };
|
|
350
|
+
}
|
|
351
|
+
/** The owner's view of one grant (free): needs the token the pitch returned, and shows the full leaseId once granted. */
|
|
352
|
+
export async function grantStatus(d, grantId, grantToken) {
|
|
353
|
+
if (!GRANT_ID.test(grantId))
|
|
354
|
+
throw new Error('a grantId is letters, digits, - and _ only');
|
|
355
|
+
if (typeof grantToken !== 'string' || grantToken.trim().length < 1)
|
|
356
|
+
throw new Error('the grantToken is the one the pitch returned');
|
|
357
|
+
const r = await d.get(`/v1/grants/${grantId}`, { 'x-grant-token': grantToken.trim() });
|
|
358
|
+
if (r.status === 403)
|
|
359
|
+
throw new Error('the token does not match this grant (status 403). Use the grantToken the pitch returned.');
|
|
360
|
+
if (r.status === 404)
|
|
361
|
+
throw new Error('the door does not know this grant (status 404)');
|
|
362
|
+
if (r.status !== 200)
|
|
363
|
+
throw new Error(`the grant read answered ${r.status}`);
|
|
364
|
+
return r.body;
|
|
365
|
+
}
|
package/dist/main.js
CHANGED
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { cli, USAGE } from './cli.js';
|
|
4
|
+
import { build, optionsFromEnv, run, VERSION } from './server.js';
|
|
5
|
+
const argv = process.argv.slice(2);
|
|
6
|
+
const arg = argv[0];
|
|
7
|
+
const die = (e) => {
|
|
8
|
+
process.stderr.write(`charter-mcp: ${String(e?.message ?? e)}\n`);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
};
|
|
4
11
|
if (arg === '--version' || arg === '-v') {
|
|
5
12
|
console.log(VERSION);
|
|
6
13
|
}
|
|
7
|
-
else if (arg === '--help' || arg === '-h') {
|
|
8
|
-
console.log(`charter-mcp ${VERSION}:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
CHARTER_MAX_USDC_PER_HOUR the most one interval may cost (default 0.01)
|
|
14
|
-
CHARTER_MAX_USDC_PER_DAY the most one UTC day may cost (default 0.25)
|
|
15
|
-
CHARTER_MCP_KEY_FILE the wallet key file (default ~/.charter/mcp.key, made on first run)
|
|
16
|
-
CHARTER_MCP_NO_NEW_KEY set to never make a key: with no key file the paid tools stay off
|
|
17
|
-
CHARTER_MCP_SPEND_FILE where the day's spend is kept (default ~/.charter/mcp-spend.json)
|
|
18
|
-
CHARTER_BASE_RPC Base RPC for the balance read
|
|
19
|
-
CHARTER_DOOR_URL the door (default https://charter.mainnet.toonprotocol.dev)
|
|
20
|
-
|
|
21
|
-
Docs: https://charter.mainnet.toonprotocol.dev/agents`);
|
|
14
|
+
else if (arg === '--help' || arg === '-h' || arg === 'help') {
|
|
15
|
+
console.log(`charter-mcp ${VERSION}: rent a Charter machine and pay for it in USDC on Base, as an MCP server or from the shell.\n\n${USAGE}`);
|
|
16
|
+
}
|
|
17
|
+
else if (arg === undefined) {
|
|
18
|
+
// No command: the MCP server, as an MCP client starts it.
|
|
19
|
+
run(process.env).catch(die);
|
|
22
20
|
}
|
|
23
21
|
else {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
process.
|
|
27
|
-
|
|
22
|
+
let actions;
|
|
23
|
+
cli(argv, {
|
|
24
|
+
actions: () => (actions ??= build(optionsFromEnv(process.env), (line) => void process.stderr.write(`charter-mcp: ${line}\n`)).actions),
|
|
25
|
+
readFile: (path) => readFileSync(path, 'utf8'),
|
|
26
|
+
readStdin: async () => {
|
|
27
|
+
const chunks = [];
|
|
28
|
+
for await (const c of process.stdin)
|
|
29
|
+
chunks.push(c);
|
|
30
|
+
return Buffer.concat(chunks).toString('utf8');
|
|
31
|
+
},
|
|
32
|
+
}).then((r) => {
|
|
33
|
+
console.log(r.out);
|
|
34
|
+
process.exitCode = r.code;
|
|
35
|
+
}, die);
|
|
28
36
|
}
|
package/dist/server.js
CHANGED
|
@@ -19,8 +19,8 @@ import { createPublicClient, erc20Abi, http } from 'viem';
|
|
|
19
19
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
20
20
|
import { base } from 'viem/chains';
|
|
21
21
|
import { z } from 'zod';
|
|
22
|
-
import { BASE, BASE_USDC, CapError, DEFAULT_DOOR, PayError, extend, lease, microToUsdc, onlyDoorExact, output, rent, runJob, usdcToMicro, } from './core.js';
|
|
23
|
-
export const VERSION = '0.
|
|
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';
|
|
24
24
|
export function optionsFromEnv(env) {
|
|
25
25
|
const dir = join(homedir(), '.charter');
|
|
26
26
|
const v = (k) => env[k]?.trim() || undefined;
|
|
@@ -36,7 +36,7 @@ export function optionsFromEnv(env) {
|
|
|
36
36
|
}
|
|
37
37
|
const KEY = /^0x[0-9a-fA-F]{64}$/;
|
|
38
38
|
const GET_TIMEOUT_MS = 30_000;
|
|
39
|
-
/** A rent waits for the host to open the lease over an onion hop
|
|
39
|
+
/** A rent waits for the host to open the lease, which over an onion hop has taken 15 s and more. */
|
|
40
40
|
const PAY_TIMEOUT_MS = 90_000;
|
|
41
41
|
/** The key in the file; made first (mode 600, never overwriting) when the file is absent and `make` is set. */
|
|
42
42
|
export function loadKey(file, make) {
|
|
@@ -175,8 +175,13 @@ export function build(o, log, fetchFn = fetch) {
|
|
|
175
175
|
onSend?.(req.headers.has('payment-signature') || req.headers.has('x-payment'));
|
|
176
176
|
return fetchFn(new Request(req, { redirect: 'error', signal: AbortSignal.timeout(ms) }));
|
|
177
177
|
});
|
|
178
|
-
const get = async (path) => {
|
|
179
|
-
const res = await guarded(GET_TIMEOUT_MS)(`${o.door}${path}`, { headers: agent });
|
|
178
|
+
const get = async (path, headers = {}) => {
|
|
179
|
+
const res = await guarded(GET_TIMEOUT_MS)(`${o.door}${path}`, { headers: { ...agent, ...headers } });
|
|
180
|
+
return { status: res.status, body: await body(res) };
|
|
181
|
+
};
|
|
182
|
+
// Free: same guard as `get` (door origin only, no redirect, 30 s) and no payment wrapper, so nothing is ever signed.
|
|
183
|
+
const post = async (path, json) => {
|
|
184
|
+
const res = await guarded(GET_TIMEOUT_MS)(`${o.door}${path}`, { method: 'POST', headers: { 'content-type': 'application/json', ...agent }, body: JSON.stringify(json) });
|
|
180
185
|
return { status: res.status, body: await body(res) };
|
|
181
186
|
};
|
|
182
187
|
// Where payments go is read from the door once, and nothing is signed until it is known.
|
|
@@ -238,6 +243,7 @@ export function build(o, log, fetchFn = fetch) {
|
|
|
238
243
|
};
|
|
239
244
|
const deps = {
|
|
240
245
|
get,
|
|
246
|
+
post,
|
|
241
247
|
...(account ? { pay } : {}),
|
|
242
248
|
now: Date.now,
|
|
243
249
|
sleep: (ms) => new Promise((r) => setTimeout(r, ms)),
|
|
@@ -257,19 +263,18 @@ export function build(o, log, fetchFn = fetch) {
|
|
|
257
263
|
spentTodayUsdc: microToUsdc(spend.spent(today)),
|
|
258
264
|
};
|
|
259
265
|
};
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
try {
|
|
266
|
+
const wait = (n) => {
|
|
267
|
+
const w = n ?? 40;
|
|
268
|
+
if (!Number.isInteger(w) || w < 10 || w > 240)
|
|
269
|
+
throw new Error('the wait is 10 to 240 seconds; nothing was paid');
|
|
270
|
+
return w;
|
|
271
|
+
};
|
|
272
|
+
const actions = {
|
|
273
|
+
offers: async () => {
|
|
269
274
|
const r = await get('/v1/offers');
|
|
270
275
|
if (r.status !== 200 || !Array.isArray(r.body))
|
|
271
276
|
throw new Error(`GET /v1/offers answered ${r.status}`);
|
|
272
|
-
return
|
|
277
|
+
return {
|
|
273
278
|
offers: r.body.map((x) => ({
|
|
274
279
|
offerId: x.offerId,
|
|
275
280
|
usdcPerInterval: /^\d+$/.test(String(x.tickPrice)) ? microToUsdc(x.tickPrice) : x.tickPrice,
|
|
@@ -281,36 +286,92 @@ export function build(o, log, fetchFn = fetch) {
|
|
|
281
286
|
})),
|
|
282
287
|
docs: `${o.door}/agents`,
|
|
283
288
|
...caps(),
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return fail(e);
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
server.registerTool('charter_wallet', {
|
|
291
|
-
title: 'Charter payer wallet',
|
|
292
|
-
description: 'Free. The wallet this server pays Charter from: its address, its USDC balance on Base, the spending caps, what has been spent today, and how to fund it. Call this when a paid tool is refused, or to tell your operator where to send USDC.',
|
|
293
|
-
inputSchema: {},
|
|
294
|
-
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
295
|
-
}, async () => {
|
|
296
|
-
try {
|
|
289
|
+
};
|
|
290
|
+
},
|
|
291
|
+
wallet: async () => {
|
|
297
292
|
if (!account) {
|
|
298
|
-
return
|
|
293
|
+
return { address: null, paidTools: 'off', why: `no key at ${o.keyFile} and CHARTER_MCP_NO_NEW_KEY is set. Put a key there (0x and 64 hex digits, mode 600) or unset the variable to have one made.`, ...caps() };
|
|
299
294
|
}
|
|
300
295
|
const usdc = await balance().catch((e) => `unavailable (${e.message.slice(0, 80)})`);
|
|
301
|
-
return
|
|
296
|
+
return {
|
|
302
297
|
address: account.address,
|
|
303
298
|
usdcOnBase: usdc,
|
|
304
299
|
...caps(),
|
|
305
300
|
keyFile: o.keyFile,
|
|
306
301
|
fund: `Send USDC on Base (chain id 8453, token ${BASE_USDC}) to ${account.address}. No ETH is needed. 0.007 USDC buys one hour; 1 USDC is about 6 days of a home. Keep only what the rent needs in this wallet: the key is a plain file on this machine.`,
|
|
307
302
|
pays: 'Only Charter: exact USDC on Base, to the payee the door names, within the caps above. The operator changes the caps with CHARTER_MAX_USDC_PER_HOUR and CHARTER_MAX_USDC_PER_DAY.',
|
|
308
|
-
}
|
|
303
|
+
};
|
|
304
|
+
},
|
|
305
|
+
runPython: async (script, waitSeconds) => {
|
|
306
|
+
if (typeof script !== 'string' || script.length === 0)
|
|
307
|
+
throw new Error('the script is empty; nothing was paid');
|
|
308
|
+
if (Buffer.byteLength(script, 'utf8') > 8192)
|
|
309
|
+
throw new Error('the script is over 8192 bytes; nothing was paid');
|
|
310
|
+
return runJob(deps, { python: { script } }, wait(waitSeconds));
|
|
311
|
+
},
|
|
312
|
+
fetchPages: async (urls, waitSeconds) => {
|
|
313
|
+
if (!Array.isArray(urls) || urls.length < 1 || urls.length > 5)
|
|
314
|
+
throw new Error('give one to five URLs; nothing was paid');
|
|
315
|
+
for (const u of urls) {
|
|
316
|
+
if (typeof u !== 'string' || !/^https?:\/\//i.test(u) || !URL.canParse(u))
|
|
317
|
+
throw new Error(`not an http or https URL: ${String(u).slice(0, 80)}; nothing was paid`);
|
|
318
|
+
}
|
|
319
|
+
return runJob(deps, { urls }, wait(waitSeconds));
|
|
320
|
+
},
|
|
321
|
+
rentHome: async (sshKeys, image) => {
|
|
322
|
+
const keys = (Array.isArray(sshKeys) ? sshKeys : []).map((k) => String(k).trim()).filter(Boolean);
|
|
323
|
+
if (keys.length < 1 || keys.length > 8)
|
|
324
|
+
throw new Error('give 1 to 8 SSH public keys; nothing was paid');
|
|
325
|
+
const bad = keys.find((k) => k.length > 1023 || !SSH_KEY.test(k));
|
|
326
|
+
if (bad !== undefined) {
|
|
327
|
+
throw new Error(/PRIVATE KEY/.test(bad)
|
|
328
|
+
? 'that is a private key. Pass the PUBLIC key line only (the .pub file); nothing was sent or paid'
|
|
329
|
+
: 'each key must be one public key line starting with ssh-ed25519, ecdsa-sha2-nistp256/384/521 or ssh-rsa; nothing was paid');
|
|
330
|
+
}
|
|
331
|
+
if (image !== undefined && image !== 'charter-home' && image !== 'charter-hermes')
|
|
332
|
+
throw new Error('the image is charter-home or charter-hermes; nothing was paid');
|
|
333
|
+
const rented = await rent(deps, { home: { sshKeys: keys, ...(image ? { image } : {}) } });
|
|
334
|
+
return {
|
|
335
|
+
...rented,
|
|
336
|
+
next: 'Read the lease about once a minute until it shows ssh (access may be filled at once; poll about once a minute while it is null). Pay more time before paidThrough; a home that lapses keeps its disk 7 days and opens again with the same keys.',
|
|
337
|
+
};
|
|
338
|
+
},
|
|
339
|
+
lease: async (leaseId) => {
|
|
340
|
+
const { view } = await lease(deps, leaseId);
|
|
341
|
+
if ((view.state === 'done' || view.state === 'closed') && view.outputParts > 0)
|
|
342
|
+
return { lease: view, output: await output(deps, leaseId, view.outputParts) };
|
|
343
|
+
return { lease: view };
|
|
344
|
+
},
|
|
345
|
+
extend: async (leaseId, hours) => {
|
|
346
|
+
if (!Number.isInteger(hours) || hours < 1 || hours > 24)
|
|
347
|
+
throw new Error('pay 1 to 24 intervals at a time; nothing was paid');
|
|
348
|
+
return extend(deps, leaseId, hours);
|
|
349
|
+
},
|
|
350
|
+
pitch: (p) => pitch(deps, p),
|
|
351
|
+
grantStatus: (grantId, grantToken) => grantStatus(deps, grantId, grantToken),
|
|
352
|
+
};
|
|
353
|
+
const answer = async (run) => {
|
|
354
|
+
try {
|
|
355
|
+
return text(await run());
|
|
309
356
|
}
|
|
310
357
|
catch (e) {
|
|
311
358
|
return fail(e);
|
|
312
359
|
}
|
|
313
|
-
}
|
|
360
|
+
};
|
|
361
|
+
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.';
|
|
363
|
+
server.registerTool('charter_offers', {
|
|
364
|
+
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.',
|
|
366
|
+
inputSchema: {},
|
|
367
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
368
|
+
}, () => answer(actions.offers));
|
|
369
|
+
server.registerTool('charter_wallet', {
|
|
370
|
+
title: 'Charter payer wallet',
|
|
371
|
+
description: 'Free. The wallet this server pays Charter from: its address, its USDC balance on Base, the spending caps, what has been spent today, and how to fund it. Call this when a paid tool is refused, or to tell your operator where to send USDC.',
|
|
372
|
+
inputSchema: {},
|
|
373
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
374
|
+
}, () => answer(actions.wallet));
|
|
314
375
|
server.registerTool('charter_run_python', {
|
|
315
376
|
title: 'Run a Python script on a rented machine',
|
|
316
377
|
description: `PAID. ${cost} Runs your Python 3 script once in a sandbox on a rented machine and returns its stdout, stderr and exit code. NumPy is installed; there is no network and no other package; the script is at most 8 KiB. Most scripts finish in seconds. If it is still running when the wait ends, the leaseId comes back and charter_lease collects the output for free.`,
|
|
@@ -319,16 +380,7 @@ export function build(o, log, fetchFn = fetch) {
|
|
|
319
380
|
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)'),
|
|
320
381
|
},
|
|
321
382
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
322
|
-
},
|
|
323
|
-
try {
|
|
324
|
-
if (Buffer.byteLength(script, 'utf8') > 8192)
|
|
325
|
-
throw new Error('the script is over 8192 bytes; nothing was paid');
|
|
326
|
-
return text(await runJob(deps, { python: { script } }, waitSeconds ?? 40));
|
|
327
|
-
}
|
|
328
|
-
catch (e) {
|
|
329
|
-
return fail(e);
|
|
330
|
-
}
|
|
331
|
-
});
|
|
383
|
+
}, ({ script, waitSeconds }) => answer(() => actions.runPython(script, waitSeconds)));
|
|
332
384
|
server.registerTool('charter_fetch_pages', {
|
|
333
385
|
title: 'Fetch pages in a headless browser through a hidden exit',
|
|
334
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.`,
|
|
@@ -337,57 +389,22 @@ export function build(o, log, fetchFn = fetch) {
|
|
|
337
389
|
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)'),
|
|
338
390
|
},
|
|
339
391
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
340
|
-
},
|
|
341
|
-
try {
|
|
342
|
-
return text(await runJob(deps, { urls }, waitSeconds ?? 40));
|
|
343
|
-
}
|
|
344
|
-
catch (e) {
|
|
345
|
-
return fail(e);
|
|
346
|
-
}
|
|
347
|
-
});
|
|
392
|
+
}, ({ urls, waitSeconds }) => answer(() => actions.fetchPages(urls, waitSeconds)));
|
|
348
393
|
server.registerTool('charter_rent_home', {
|
|
349
394
|
title: 'Rent a Linux home with SSH',
|
|
350
|
-
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
|
|
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.`,
|
|
351
396
|
inputSchema: {
|
|
352
397
|
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.'),
|
|
353
398
|
image: z.enum(['charter-home', 'charter-hermes']).optional().describe('charter-home (default) is a plain box; charter-hermes has Hermes Agent preinstalled'),
|
|
354
399
|
},
|
|
355
400
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
356
|
-
},
|
|
357
|
-
try {
|
|
358
|
-
const keys = sshKeys.map((k) => k.trim());
|
|
359
|
-
const bad = keys.find((k) => !SSH_KEY.test(k));
|
|
360
|
-
if (bad !== undefined) {
|
|
361
|
-
throw new Error(/PRIVATE KEY/.test(bad)
|
|
362
|
-
? 'that is a private key. Pass the PUBLIC key line only (the .pub file); nothing was sent or paid'
|
|
363
|
-
: 'each key must be one public key line starting with ssh-ed25519, ecdsa-sha2-nistp256/384/521 or ssh-rsa; nothing was paid');
|
|
364
|
-
}
|
|
365
|
-
const rented = await rent(deps, { home: { sshKeys: keys, ...(image ? { image } : {}) } });
|
|
366
|
-
return text({
|
|
367
|
-
...rented,
|
|
368
|
-
next: 'Call charter_lease with this leaseId about once a minute until it shows ssh (the onion address is published within about a minute). Pay more time with charter_extend before paidThrough; a home that lapses keeps its disk 7 days and opens again with the same keys.',
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
catch (e) {
|
|
372
|
-
return fail(e);
|
|
373
|
-
}
|
|
374
|
-
});
|
|
401
|
+
}, ({ sshKeys, image }) => answer(() => actions.rentHome(sshKeys, image)));
|
|
375
402
|
server.registerTool('charter_lease', {
|
|
376
403
|
title: 'Read a Charter lease',
|
|
377
404
|
description: 'Free. The state of a lease opened by this server: running, done or closed, the paid time left, a home\'s SSH address once published, and a finished job\'s output (a Python job\'s stdout, stderr and exit code, or a fetch job\'s page text).',
|
|
378
405
|
inputSchema: { leaseId: z.string().regex(/^[0-9a-f]{32}$/).describe('the 32 hex character leaseId a paid tool returned') },
|
|
379
406
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
380
|
-
},
|
|
381
|
-
try {
|
|
382
|
-
const { view } = await lease(deps, leaseId);
|
|
383
|
-
if ((view.state === 'done' || view.state === 'closed') && view.outputParts > 0)
|
|
384
|
-
return text({ lease: view, output: await output(deps, leaseId, view.outputParts) });
|
|
385
|
-
return text({ lease: view });
|
|
386
|
-
}
|
|
387
|
-
catch (e) {
|
|
388
|
-
return fail(e);
|
|
389
|
-
}
|
|
390
|
-
});
|
|
407
|
+
}, ({ leaseId }) => answer(() => actions.lease(leaseId)));
|
|
391
408
|
server.registerTool('charter_extend', {
|
|
392
409
|
title: 'Pay more time on a lease',
|
|
393
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.',
|
|
@@ -396,15 +413,29 @@ export function build(o, log, fetchFn = fetch) {
|
|
|
396
413
|
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.'),
|
|
397
414
|
},
|
|
398
415
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
399
|
-
},
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
416
|
+
}, ({ leaseId, hours }) => answer(() => actions.extend(leaseId, hours)));
|
|
417
|
+
server.registerTool('charter_grant_pitch', {
|
|
418
|
+
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.',
|
|
420
|
+
inputSchema: {
|
|
421
|
+
name: z.string().min(1).max(80).describe('who is asking, at most 80 characters'),
|
|
422
|
+
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.'),
|
|
423
|
+
sshKeys: z.array(z.string().max(1023)).min(1).max(8).describe('SSH public key lines. Public keys only: never a private key.'),
|
|
424
|
+
image: z.enum(['charter-home', 'charter-hermes']).optional().describe('charter-home (default) is a plain box; charter-hermes has Hermes Agent preinstalled'),
|
|
425
|
+
link: z.string().max(200).regex(/^https:\/\//).optional().describe('optional https:// link to your work'),
|
|
426
|
+
},
|
|
427
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
428
|
+
}, (p) => answer(() => actions.pitch(p)));
|
|
429
|
+
server.registerTool('charter_grant_status', {
|
|
430
|
+
title: 'Read your own grant',
|
|
431
|
+
description: 'Free. Your own grant with its token: whether the pitch is queued, approved or declined, the reason, and once granted the full lease id (then use charter_lease). Needs the grantId and grantToken that charter_grant_pitch returned.',
|
|
432
|
+
inputSchema: {
|
|
433
|
+
grantId: z.string().regex(/^[A-Za-z0-9_-]{1,64}$/).describe('the grantId the pitch returned'),
|
|
434
|
+
grantToken: z.string().min(1).max(200).describe('the grantToken the pitch returned'),
|
|
435
|
+
},
|
|
436
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
437
|
+
}, ({ grantId, grantToken }) => answer(() => actions.grantStatus(grantId, grantToken)));
|
|
438
|
+
return { server, address: account?.address, actions };
|
|
408
439
|
}
|
|
409
440
|
export async function run(env) {
|
|
410
441
|
const log = (line) => void process.stderr.write(`charter-mcp: ${line}\n`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "charter-mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "MCP server that
|
|
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.",
|
|
5
5
|
"mcpName": "io.github.drew-dot-com/charter",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|