Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ The server also provides a `train_on_cloudgpu` prompt.
- **Bounded local MCP inputs.** A tool call may contain at most 10,000 combined array entries and object members, including nested values. Larger calls are rejected before tool-schema validation or API/SSH handlers. This includes inline ComfyUI workflows; simplify oversized workflows rather than splitting a paid operation or silently dropping fields. The stdio transport also retains its 10 MiB buffered-input limit. These are local MCP limits, not a claim about the remote service.

- **A quote first.** `create_instance` only takes a `quote_id` from `estimate_cost` and `user_confirmed=true`.
- **Restoring a Workspace on a new rental.** Set `workspace_restore_required: true` in `estimate_cost` and use its confirmed quote for `create_instance`. A `workspace_route_unavailable` response means review another configuration or region before renting. Transfer rates vary by route. Managed Jobs bind this requirement automatically when given `workspace_version_id`.
- **Server-side limits.** Every instance is created with `max_spend_usd`, `max_hours` and an idle limit (60 minutes by default). CloudGPU's servers check them and destroy the instance when one is hit, even if your client has disconnected or your laptop is asleep.
- **Your own ceiling.** `CLOUDGPU_MAX_SPEND_USD` and `CLOUDGPU_MAX_HOURS` cap what the agent may set.
- **Results before shutdown.** After commands have run, `stop_instance` refuses until something has been downloaded, unless the user confirms `force=true`.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cloudgpu-mcp",
"version": "0.16.6",
"version": "0.16.7",
"mcpName": "io.github.cloudgpu-app/cloudgpu-mcp",
"description": "MCP server and command-line tool for cloudgpu.app: let Claude Code, Cursor, Cline, opencode, goose and other MCP clients (or you, from a terminal) rent a GPU with explicit billing quotes, run a job, fetch the results and shut it down, with spending limits the platform enforces.",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions server.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"url": "https://github.com/cloudgpu-app/cloudgpu-mcp",
"source": "github"
},
"version": "0.16.6",
"version": "0.16.7",
"packages": [
{
"registryType": "npm",
"registryBaseUrl": "https://registry.npmjs.org",
"identifier": "cloudgpu-mcp",
"version": "0.16.6",
"version": "0.16.7",
"runtimeHint": "npx",
"transport": {
"type": "stdio"
Expand Down
11 changes: 8 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
shq,
} from "./guards.js";

const VERSION = "0.16.6";
const VERSION = "0.16.7";
const HERE = path.dirname(fileURLToPath(import.meta.url));
const RULES = fs.readFileSync(path.join(HERE, "..", "rules", "cloudgpu.md"), "utf8");

Expand Down Expand Up @@ -239,11 +239,12 @@ server.registerTool(
gpu_model: z.string().describe("GPU model exactly as list_gpus returns it"),
gpu_count: z.number().int().min(1).max(8).default(1),
hours: z.number().positive().describe("Expected run time in hours"),
workspace_restore_required: z.boolean().optional().describe("Reserve a rental for restoring a saved Workspace. Excludes suppliers with known impaired restore routes."),
template: z.string().optional().describe("Template id from list_templates; omit for a plain GPU with Python and CUDA"),
},
annotations: { readOnlyHint: true, openWorldHint: true },
},
wrap(async ({ gpu_model, gpu_count = 1, hours, template, continent }) => {
wrap(async ({ gpu_model, gpu_count = 1, hours, template, continent, workspace_restore_required }) => {
const [offers, account] = await Promise.all([api.offers(), api.account().catch(() => null)]);
const offer = offers.find((o) => String(o.gpu_model).toLowerCase() === gpu_model.toLowerCase());
if (!offer) {
Expand All @@ -252,7 +253,10 @@ server.registerTool(
if (gpu_count < (offer.min_gpu_count || 1)) {
return fail(`${offer.gpu_model} is rented in groups of at least ${offer.min_gpu_count} GPUs.`);
}
const billing = await api.rentalBillingQuote({gpuModel:offer.gpu_model,gpuCount:gpu_count,...(continent?{continent}:{}),...(template?{templateId:template}:{})});
const billing = await api.rentalBillingQuote({gpuModel:offer.gpu_model,gpuCount:gpu_count,...(continent?{continent}:{}),...(template?{templateId:template}:{}),...(workspace_restore_required?{workspaceRestoreRequired:true}:{})});
if (workspace_restore_required && billing.workspaceRestoreRequired !== true) {
return fail("workspace_route_unavailable: Select another configuration or region before renting for this Workspace.");
}
if(continent&&billing.continent!==continent)return fail("The billing quote did not bind the requested continent. No rental was started.");
const {hourly,increment,estimate}=rentalBilling(billing,hours);
const balance = account ? Number(account.balance_usd) : null;
Expand All @@ -267,6 +271,7 @@ server.registerTool(
const quote_id = quotes.put({ continent, gpu_model: offer.gpu_model, gpu_count, template, hourly, hours, estimate, billingQuoteId:billing.billingQuoteId, billingExpiresAt:billing.expiresAt, minimumChargeUsd:Number(billing.minimumChargeUsd), billingIncrementSeconds:increment });
return ok({
quote_id,
...(workspace_restore_required?{workspace_restore_required:true}:{}),
continent:continent||null,
gpu_model: offer.gpu_model,
gpu_count,
Expand Down
82 changes: 82 additions & 0 deletions test/workspace-rental.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import assert from "node:assert/strict";
import http from "node:http";
import { once } from "node:events";
import test from "node:test";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";

test("MCP offers a Workspace rental only with a server-bound billing quote", async () => {
const quotes = [];
const creates = [];
let workspaceAware = false;
const server = http.createServer(async (request, response) => {
const reply = (body) => {
response.setHeader("content-type", "application/json");
response.end(JSON.stringify(body));
};
const readBody = async () => {
const chunks = [];
for await (const chunk of request) chunks.push(chunk);
return JSON.parse(Buffer.concat(chunks).toString());
};
switch (request.url) {
case "/v1/gpu/offers":
return reply({ data: [{ gpu_model: "RTX 4090", available: "yes" }] });
case "/v1/gpu/account":
return reply({ balance_usd: 10 });
case "/v1/gpu/billing-quote":
quotes.push(await readBody());
return reply({
billingQuoteId: "server-workspace-quote", expiresAt: Date.now() + 60000, currency: "USD",
hourlyTotalUsd: 0.6, minimumChargeUsd: 0.01, preauthorizedUsd: 0.6,
incrementSeconds: 60, minimumSeconds: 60,
...(workspaceAware ? { workspaceRestoreRequired: true } : {}),
});
case "/v1/gpu/instances":
creates.push(await readBody());
return reply({ id: "synthetic-instance", status: "creating" });
default:
response.writeHead(404).end();
}
}).listen(0, "127.0.0.1");
await once(server, "listening");
const transport = new StdioClientTransport({
command: process.execPath,
args: ["src/index.js"],
env: {
...process.env,
CLOUDGPU_READ_ONLY: "0",
CLOUDGPU_API_KEY: "synthetic-key",
CLOUDGPU_BASE_URL: `http://127.0.0.1:${server.address().port}`,
},
});
const client = new Client({ name: "workspace-rental-test", version: "1" });
const call = (name, args) => client.callTool({ name, arguments: args });
const requirements = { gpu_model: "RTX 4090", hours: 1, workspace_restore_required: true };
try {
await client.connect(transport);
const legacy = await call("estimate_cost", requirements);
assert.equal(legacy.isError, true);
assert.match(legacy.content[0].text, /workspace_route_unavailable/);
assert.equal(creates.length, 0);
workspaceAware = true;
const result = await call("estimate_cost", requirements);
assert.ok(!result.isError, result.content[0].text);
const quote = JSON.parse(result.content[0].text);
assert.equal(quote.workspace_restore_required, true);
assert.equal(quotes.length, 2);
for (const request of quotes) assert.equal(request.workspaceRestoreRequired, true);
const create = await call("create_instance", {
quote_id: quote.quote_id, user_confirmed: true, max_spend_usd: 1, max_hours: 1,
});
assert.ok(!create.isError, create.content[0].text);
assert.equal(creates.length, 1);
assert.equal(creates[0].billing_quote_id, "server-workspace-quote");
assert.equal(creates[0].billing_accepted, true);
} finally {
await client.close();
await transport.close();
server.closeAllConnections();
await new Promise((resolve) => server.close(resolve));
}
});
Loading