cloudgpu-mcp 0.14.1 → 0.15.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
@@ -379,3 +379,13 @@ Ask your connected Agent: “Compare compatible GPUs for this task, include prep
379
379
  Can one GPU serve several Agent tasks? Yes: sequential approved `run_command` calls can use the same running rental, within its original budget, deadline and idle limit. Check `list_instances` / `get_status` first. Independent `run_job` calls and “rerun” each provision separately; they do not share an instance. Do not extend limits or keep an idle GPU merely because an hour was charged. Save outputs before stopping; Workspace is explicit persistence, not a disk snapshot.
380
380
 
381
381
  MCP clients must install or upgrade this package and restart their local MCP process. The account connection link authorizes a supported client; it cannot install tools into any arbitrary AI service.
382
+
383
+ ### Several tasks, one GPU allocation (0.15.0)
384
+
385
+ `prepare_task_pipeline` prepares 1–8 reviewed commands to run sequentially as one Job. They share the GPU and filesystem; each step has a new shell, so shell variables and in-memory model processes do not persist between steps. A nonzero step exit stops subsequent steps. Dependencies and any required models must already be prepared; this is not application-quality or GPU-model acceptance.
386
+
387
+ Preparation makes no API request or reservation. Review the returned command, obtain a compatible Job quote and explicit total GPU budget/deadline approval, then call `run_job` once. Retain that submission's idempotency key if its response is lost. The manifest fingerprint is informational, not a server-enforced approval or submission key. Independent Jobs still use independent allocations; this is not the durable batch coordinator.
388
+
389
+ For an existing rental, the reviewed command can instead be passed to `run_command` in the approved working directory, within its original limits. Apply a Workspace separately when needed. The draft never stops or extends an existing rental. Whole-hour sources remain usable through the existing explicitly approved rental path; this release does not remove their current automatic-Job compatibility gate.
390
+
391
+ With `persist_summary=true`, the Job draft explicitly collects only `pipeline-summary.json` through the existing output collector, using current storage quota/retention and `accept_storage_charges=false`. The summary contains step IDs, exit codes and state, not raw logs, commands or arbitrary task results. Result-file persistence must be configured and approved separately. The summary must not already exist; missing output collection or a conflicting file aborts before commands run.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudgpu-mcp",
3
- "version": "0.14.1",
3
+ "version": "0.15.0",
4
4
  "mcpName": "io.github.cloudgpu-app/cloudgpu-mcp",
5
5
  "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.",
6
6
  "type": "module",
package/rules/cloudgpu.md CHANGED
@@ -21,7 +21,7 @@ Copy this file into your project as `AGENTS.md`, `.cursor/rules/cloudgpu.md` or
21
21
  - Always set `max_spend_usd` and `max_hours`. CloudGPU's servers destroy the instance when either is reached, even if you have disconnected.
22
22
  - Keep `idle_minutes` on (default 60). Raise it if setup will take long, because installing packages and downloading models leave the GPU idle.
23
23
  - Call `get_status` at intervals, not in a tight loop, until the instance is `running`.
24
- - `failed` instances are not charged. Tell the user, then offer another GPU.
24
+ - On failure, inspect actual charges and independent release evidence. A failed platform status is not proof of release or zero cost; do not automatically create a replacement.
25
25
 
26
26
  ## Working on the instance
27
27
 
@@ -52,7 +52,7 @@ Call `connect_account` with a name for yourself and the spending limit the user
52
52
  2. Call `stop_instance`.
53
53
  3. Tell the user what ran, where the results are on their computer, and the final cost from `stop_instance`.
54
54
 
55
- If anything goes wrong mid-way, do not leave the instance running. Download whatever exists, stop the instance, then explain what happened.
55
+ For an instance created specifically for this approved task, preserve results and request release if it fails. An existing user instance keeps its original lifecycle: failure to apply files or run one step does not authorize stopping it. Inspect and ask the owner before changing its lifecycle.
56
56
 
57
57
  ## Only need a model, not a GPU?
58
58
 
@@ -67,3 +67,7 @@ Application recipes reuse prepared environments. ComfyUI protocol fixtures and L
67
67
  ## Reuse a GPU across tasks
68
68
 
69
69
  A running rental can execute multiple approved commands sequentially using its instance ID and `run_command`; check status, ownership, available memory/disk and remaining original budget/deadline first. Do not use another team or personal account's resource. This does not extend its existing limits. Separate `run_job` calls and `prepare_job_rerun` do not reuse that rental. Persist results, stop when finished and reconcile release; do not retain idle GPUs just because an hour was charged. Crossing the next started hour incurs a further full-hour charge. No warm pool is promised.
70
+
71
+ ## Shared-allocation task drafts
72
+
73
+ Use `prepare_task_pipeline` to review up to eight sequential commands for one Job, with one overall approved budget and deadline, stopping later steps after failure. It is read-only preparation, not a paid submission or automatic retry. Independent Jobs still provision separately. Optional pipeline-summary.json collection does not collect arbitrary task results; approve their persistence separately. No installed dependencies, model quality, or whole-hour Job compatibility are inferred.
@@ -93,3 +93,7 @@ Sequential approved `run_command` calls may reuse a running rental within its or
93
93
  ## Connect with an approval link
94
94
 
95
95
  In a configured MCP client, call `connect_account`, show the owner its link, then `finish_connect` after approval. No password or API key is pasted in chat. The link grants scoped access; it does not automatically install an MCP server in arbitrary AI products.
96
+
97
+ ## Several steps on one allocation
98
+
99
+ If installed, `prepare_task_pipeline` prepares up to eight reviewed sequential commands for one Job, or for `run_command` on an approved existing rental. It creates nothing. Commands share the filesystem and GPU but use separate shells; they do not share exported shell variables or a resident model process. Failure stops later steps. Python 3, bash and prepared dependencies are required. Review the returned command, obtain a compatible quote and explicit total budget/deadline approval, then submit one Job with a stable idempotency key. Preserve the original request on a lost response. The fingerprint is informational, not approval. Optional collection saves only pipeline-summary.json, never arbitrary results or logs; approve actual result persistence separately. Existing user instance limits and lifecycle remain unchanged.
package/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {rentalBilling} from "./rental-billing.js";
3
3
  import {registerComputePlanningTools} from './compute-planning.js';
4
+ import {registerTaskPipelineTools} from './task-pipelines.js';
4
5
  import {registerBatchTools} from './job-batches.js';
5
6
  import {jobInputShape} from './job-input.js';
6
7
  import {registerTaskTemplateTools} from './task-templates.js';
@@ -37,7 +38,7 @@ import {
37
38
  shq,
38
39
  } from "./guards.js";
39
40
 
40
- const VERSION = "0.14.1";
41
+ const VERSION = "0.15.0";
41
42
  const HERE = path.dirname(fileURLToPath(import.meta.url));
42
43
  const RULES = fs.readFileSync(path.join(HERE, "..", "rules", "cloudgpu.md"), "utf8");
43
44
 
@@ -65,6 +66,7 @@ const session = new Map();
65
66
  const INSTRUCTIONS = `CloudGPU (cloudgpu.app) provides GPU compute scheduling for AI agents from a prepaid balance. Billing is source-specific: per-minute or minimum one hour with each started hour charged in full. Never infer the period from an hourly price label.
66
67
  Planning: compare_compute_costs compares billed GPU cost for explicit candidates and duration; it is not a benchmark or creation approval. Check existing list_instances before renting: multiple approved commands can use the same running rental within its existing budget, time and idle limits. Separate run_job calls each provision and release independently; prepare_job_rerun does not reuse a live GPU. Never extend limits or keep idle GPUs merely to consume prepaid time.
67
68
  Batches: prepare_job_batch reviews up to eight individually quoted Jobs and their combined GPU budget. run_job_batch requires an exact approved plan hash; partial submission is possible. Retain the manifest and stable batch key to reconcile lost responses. No automatic execution retries; get_job_batch never proves independent supplier release. Storage charges are additional to GPU caps.
69
+ Shared allocation: prepare_task_pipeline prepares 1–8 reviewed sequential commands as a single Job draft, or for an approved existing rental. It creates nothing. Independent run_job calls do not share a GPU. Pipeline summary persistence is explicit and does not save arbitrary results or authorize storage charges.
68
70
  Task recipes: list_task_templates and prepare_task_template return local read-only drafts, never a paid submission. Check prerequisites, quote and obtain explicit approval before run_job. Prefer local CPU processing when a GPU is unnecessary.
69
71
  Workflow: get_account and list_gpus -> estimate_cost -> show the quote to the user and get an explicit yes -> create_instance -> get_status until running -> upload -> run_command (background for long jobs) -> tail_logs -> download results -> stop_instance -> report the actual cost.
70
72
  Rules: never rent without the user's yes on a quote; always set a budget and time limit (the platform shuts the instance down when either is hit); download results before stop_instance because destroying an instance erases its disk; never change passwords, SSH config, the firewall or the platform's monitoring agent on the instance; if anything fails, download what exists and stop the instance rather than leaving it running.
@@ -75,6 +77,7 @@ The same API key also works for the OpenAI-compatible model API at ${cfg.baseUrl
75
77
  const server = new McpServer({ name: "cloudgpu", version: VERSION }, { instructions: INSTRUCTIONS });
76
78
  registerTaskTemplateTools(server, {wrap, ok});
77
79
  registerComputePlanningTools(server,{api,wrap,ok});
80
+ registerTaskPipelineTools(server,{cfg,wrap,ok});
78
81
  registerBatchTools(server,{api,cfg,wrap,ok});
79
82
  registerStorageTools(server, { api, wrap, ok, fail, readOnly: cfg.readOnly, expandHome });
80
83
  registerJobResultTools(server, { api, wrap, ok, readOnly: cfg.readOnly });
@@ -0,0 +1,41 @@
1
+ import os, pathlib, subprocess, sys
2
+
3
+ report={'pipeline_sha256':options['pipeline_sha256'],'state':'running','steps':[]}
4
+ fd=None
5
+ if options['persist_summary']:
6
+ root=os.environ.get('CLOUDGPU_OUTPUT_DIR')
7
+ if not root: raise RuntimeError('Explicit output collection directory is required')
8
+ target=pathlib.Path(root)/'pipeline-summary.json'
9
+ fd=os.open(str(target),os.O_WRONLY|os.O_CREAT|os.O_EXCL|getattr(os,'O_NOFOLLOW',0),0o600)
10
+
11
+ def record():
12
+ if fd is not None:
13
+ data=json.dumps(report,sort_keys=True).encode('utf-8')
14
+ os.lseek(fd,0,os.SEEK_SET)
15
+ os.ftruncate(fd,0)
16
+ view=memoryview(data)
17
+ while view:
18
+ written=os.write(fd,view)
19
+ if written<=0: raise RuntimeError('Summary could not be recorded')
20
+ view=view[written:]
21
+ os.fsync(fd)
22
+
23
+ exit_code=0
24
+ try:
25
+ record()
26
+ for step in options['steps']:
27
+ result=subprocess.run(['bash','-e','-o','pipefail','-c',step['command']],check=False)
28
+ report['steps'].append({'id':step['id'],'exit_code':result.returncode})
29
+ if result.returncode:
30
+ report['state']='failed'
31
+ exit_code=result.returncode if 0<result.returncode<256 else 1
32
+ record()
33
+ break
34
+ record()
35
+ else:
36
+ report['state']='succeeded'
37
+ record()
38
+ finally:
39
+ if fd is not None: os.close(fd)
40
+ print(json.dumps(report,sort_keys=True))
41
+ sys.exit(exit_code)
@@ -0,0 +1,39 @@
1
+ import fs from 'node:fs';
2
+ import {createHash} from 'node:crypto';
3
+ import {z} from 'zod';
4
+ import {checkCommand} from './guards.js';
5
+ import {checkedTail} from './job-results.js';
6
+
7
+ const input=z.object({
8
+ steps:z.array(z.object({id:z.string().regex(/^[a-z][a-z0-9_-]{0,39}$/).refine(v=>v.trim()===v),command:z.string().min(1).max(4096)}).strict()).min(1).max(8),
9
+ workspace_version_id:z.string().regex(/^wsv_[a-f0-9]{32}$/).refine(v=>v.trim()===v).optional(),
10
+ persist_summary:z.boolean().default(false),
11
+ }).strict();
12
+ const program=fs.readFileSync(new URL('./recipes/task-pipeline.py',import.meta.url),'utf8');
13
+ export function prepareTaskPipeline(raw,apiKey='') {
14
+ const p=input.parse(raw);
15
+ if(new Set(p.steps.map(s=>s.id)).size!==p.steps.length)throw Error('Pipeline step IDs must be unique.');
16
+ for(const step of p.steps) {
17
+ if(!step.command.trim()||step.command.includes('\0'))throw Error('Pipeline commands must be nonempty and contain no NUL.');
18
+ const refused=checkCommand(step.command);if(refused)throw Error(refused);
19
+ try{checkedTail(step.command,apiKey);}catch{throw Error('Pipeline command may contain credentials or a queried URL. Remove sensitive input before preparation.');}
20
+ }
21
+ const fingerprint=createHash('sha256').update(JSON.stringify(p)).digest('hex');
22
+ const options={...p,pipeline_sha256:fingerprint};
23
+ const command="python3 - <<'CGPU_PIPELINE'\nimport json\noptions=json.loads("+JSON.stringify(JSON.stringify(options))+")\n"+program+'\nCGPU_PIPELINE';
24
+ if(Buffer.byteLength(command)>32768)throw Error('Combined pipeline exceeds the execution size limit.');
25
+ return {requirements:['Python 3','bash','Reviewed commands and prepared dependencies'],preparation_only:true,starts_gpu:false,pipeline_sha256:fingerprint,steps:p.steps,
26
+ run_job_draft:{command,...(p.workspace_version_id?{workspace_version_id:p.workspace_version_id}:{}),...(p.persist_summary?{outputs:{files:['pipeline-summary.json'],max_bytes:1048576,accept_storage_charges:false}}:{})},
27
+ execution:'Sequential child shells in one GPU allocation. Shared filesystem and GPU; shell variables and in-memory model processes do not persist between steps. First failure stops later steps. No execution retry.',
28
+ next:'Review every command and prerequisites. Obtain a fresh compatible Job quote and explicit GPU/budget/time approval, then call run_job once with a stable idempotency key. Preserve that key on a lost response. This fingerprint is not server approval or an idempotency key.',
29
+ existing_rental:'The command can instead run with run_command on an owned, ready, explicitly approved existing rental within its original limits. Apply any Workspace separately and use its returned working directory. This preparation never applies files, extends limits or stops an existing user instance. With persist_summary=true, use the Job output collector; preparation does not configure an output directory on an existing rental.',
30
+ storage_note:p.persist_summary?'Summary persists only through enabled automatic output collection and existing quota/retention/fees. It contains step IDs, exit codes and state, not commands or output. No other results are collected by this draft; declare and approve result persistence separately.':'No persistent output collection requested. Save results explicitly before release.',
31
+ };
32
+ }
33
+ export function registerTaskPipelineTools(server,{wrap,ok,cfg}) {
34
+ server.registerTool('prepare_task_pipeline',{
35
+ title:'Prepare sequential tasks for one GPU allocation',
36
+ description:'Local read-only preparation of 1–8 reviewed commands for one bounded Job or an approved existing rental. Reuses GPU and disk across steps; stops on the first error. Does not create, retry, install dependencies, approve spending or change an instance lifecycle. Summary persistence is optional and never implies paid-storage consent.',
37
+ inputSchema:input.shape,annotations:{readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false},
38
+ },wrap(async p=>ok(prepareTaskPipeline(p,cfg.apiKey))));
39
+ }