@latens/mcp-server 1.3.0 → 1.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
@@ -75,8 +75,8 @@ Set `LATENS_WALLET` to an EVM wallet holding `$LTNS` (`0x6c29b040f7d139c93d22f8d
75
75
 
76
76
  ## Security Invariants
77
77
 
78
- 1. **Zero Spend Authority**: All exposed tools carry `readOnlyHint: true` and `destructiveHint: false`. The server cannot provision instances, sign transactions, or spend funds.
79
- 2. **Confidentiality Isolation**: This server communicates exclusively with the public stateless `/api/v1/agent/*` and `/api/token/standing` surfaces and has zero access to encrypted Private Compute Desk RFQs or wallet sessions.
78
+ 1. **Zero Wallet Custody**: The MCP server never holds private keys or signs transactions. Read-only discovery tools carry `readOnlyHint: true`, while `x402` execution tools (`latens_x402_request_quote`, `latens_x402_settle_execution`) enforce explicit `max_spend_usd` caps and require a caller-broadcast Robinhood Chain (`4663`) `tx_hash`.
79
+ 2. **Confidentiality Isolation**: This server communicates exclusively with `/api/v1/agent/*` and `/api/token/standing` and has zero access to encrypted Private Compute Desk RFQs or browser sessions.
80
80
  3. **Zero Runtime Dependencies**: Pure Node.js ESM with no third-party dependencies.
81
81
 
82
82
  ## MCP Client Configuration (Primary: `npx`)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@latens/mcp-server",
3
- "version": "1.3.0",
4
- "description": "Read-only Model Context Protocol (MCP) stdio server for autonomous AI agents querying paginated GPU supply, genuine 15-minute GPU price history, LLM VRAM sizing, deterministic multi-offer TCO comparison, and $LTNS holder standing on LATENS.",
3
+ "version": "1.4.0",
4
+ "description": "Model Context Protocol (MCP) stdio server for autonomous AI agents querying GPU supply across 8 clouds, 15-minute GPU price history, LLM VRAM sizing, multi-offer TCO comparison, $LTNS standing, and HTTP 402 (x402) payment-gated GPU execution on Robinhood Chain (4663).",
5
5
  "type": "module",
6
6
  "publishConfig": {
7
7
  "access": "public"
package/src/server.mjs CHANGED
@@ -285,6 +285,71 @@ export const TOOLS = [
285
285
  },
286
286
  },
287
287
  },
288
+ {
289
+ name: "latens_x402_request_quote",
290
+ description:
291
+ "Request an HTTP 402 (x402) payment-gated GPU execution quote on Robinhood Chain (4663) in $LTNS, USDG, or native ETH with hard maxSpendUsd ceiling protection. Does not move funds on its own.",
292
+ annotations: {
293
+ readOnlyHint: false,
294
+ destructiveHint: false,
295
+ openWorldHint: true,
296
+ },
297
+ inputSchema: {
298
+ type: "object",
299
+ required: ["ssh_public_key"],
300
+ properties: {
301
+ wallet_address: {
302
+ type: "string",
303
+ description: "Agent EVM wallet address (0x...) on Robinhood Chain 4663.",
304
+ },
305
+ offer_id: { type: "string", description: "Optional Vast.ai offer ID (e.g. vast:12345)." },
306
+ gpu_model: { type: "string", description: "Desired GPU model if offer_id is omitted (e.g. RTX 4090, A100, H100)." },
307
+ gpu_count: { type: "integer", minimum: 1, default: 1 },
308
+ duration_hours: { type: "integer", minimum: 1, maximum: 168, default: 2 },
309
+ disk_gb: { type: "integer", minimum: 20, maximum: 500, default: 80 },
310
+ payment_asset: { type: "string", enum: ["LTNS", "USDG", "ETH"], default: "LTNS" },
311
+ ssh_public_key: { type: "string", description: "OpenSSH Ed25519 or RSA public key." },
312
+ max_spend_usd: { type: "number", default: 25 },
313
+ },
314
+ },
315
+ },
316
+ {
317
+ name: "latens_x402_settle_execution",
318
+ description:
319
+ "Submit a confirmed Robinhood Chain (4663) transaction hash via X-Payment header to verify settlement and provision the dedicated SSH GPU container.",
320
+ annotations: {
321
+ readOnlyHint: false,
322
+ destructiveHint: false,
323
+ openWorldHint: true,
324
+ },
325
+ inputSchema: {
326
+ type: "object",
327
+ required: ["quote_id", "tx_hash"],
328
+ properties: {
329
+ quote_id: { type: "string" },
330
+ tx_hash: { type: "string" },
331
+ wallet_address: { type: "string" },
332
+ },
333
+ },
334
+ },
335
+ {
336
+ name: "latens_x402_get_rental_status",
337
+ description:
338
+ "Poll live SSH host, port, and container status for an x402-provisioned GPU lease using its Bearer rentalAccessToken.",
339
+ annotations: {
340
+ readOnlyHint: true,
341
+ destructiveHint: false,
342
+ openWorldHint: true,
343
+ },
344
+ inputSchema: {
345
+ type: "object",
346
+ required: ["rental_id", "rental_access_token"],
347
+ properties: {
348
+ rental_id: { type: "string" },
349
+ rental_access_token: { type: "string" },
350
+ },
351
+ },
352
+ },
288
353
  ];
289
354
 
290
355
  function buildOffersParams(args, overrides = {}) {
@@ -465,7 +530,60 @@ export async function executeTool(name, args = {}, fetchImpl = fetch) {
465
530
  return res.json();
466
531
  }
467
532
 
468
- throw new Error(`Unknown read-only tool: ${name}`);
533
+ if (name === "latens_x402_request_quote") {
534
+ const wallet = String(args.wallet_address || DEFAULT_WALLET || "").trim();
535
+ const payload = {
536
+ walletAddress: wallet || undefined,
537
+ offerId: args.offer_id,
538
+ gpuModel: args.gpu_model,
539
+ gpuCount: args.gpu_count ?? 1,
540
+ durationHours: args.duration_hours ?? 2,
541
+ diskGb: args.disk_gb ?? 80,
542
+ paymentAsset: args.payment_asset ?? "LTNS",
543
+ sshPublicKey: args.ssh_public_key,
544
+ maxSpendUsd: args.max_spend_usd ?? 25,
545
+ };
546
+ const res = await fetchImpl(`${BASE_URL}/api/v1/agent/execute`, {
547
+ method: "POST",
548
+ headers: buildHeaders({ "Content-Type": "application/json" }, wallet),
549
+ body: JSON.stringify(payload),
550
+ });
551
+ return res.json();
552
+ }
553
+
554
+ if (name === "latens_x402_settle_execution") {
555
+ const wallet = String(args.wallet_address || DEFAULT_WALLET || "").trim();
556
+ const xPayment = Buffer.from(
557
+ JSON.stringify({
558
+ quoteId: args.quote_id,
559
+ txHash: args.tx_hash,
560
+ payer: wallet || undefined,
561
+ }),
562
+ "utf8"
563
+ ).toString("base64");
564
+ const res = await fetchImpl(`${BASE_URL}/api/v1/agent/execute`, {
565
+ method: "POST",
566
+ headers: buildHeaders(
567
+ { "Content-Type": "application/json", "X-Payment": xPayment },
568
+ wallet
569
+ ),
570
+ body: JSON.stringify({}),
571
+ });
572
+ return res.json();
573
+ }
574
+
575
+ if (name === "latens_x402_get_rental_status") {
576
+ const token = String(args.rental_access_token || "").replace(/^Bearer\s+/i, "").trim();
577
+ const res = await fetchImpl(
578
+ `${BASE_URL}/api/v1/agent/rentals/${encodeURIComponent(String(args.rental_id))}`,
579
+ {
580
+ headers: buildHeaders({ Authorization: `Bearer ${token}` }),
581
+ }
582
+ );
583
+ return res.json();
584
+ }
585
+
586
+ throw new Error(`Unknown tool: ${name}`);
469
587
  }
470
588
 
471
589
  function sendJsonRpc(message) {
@@ -496,7 +614,7 @@ export function startStdioServer() {
496
614
  result: {
497
615
  protocolVersion: "2024-11-05",
498
616
  capabilities: { tools: {} },
499
- serverInfo: { name: "latens-readonly-mcp", version: "1.3.0" },
617
+ serverInfo: { name: "latens-mcp", version: "1.4.0" },
500
618
  },
501
619
  });
502
620
  return;