cloudgpu-mcp 0.14.0 → 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 +10 -0
- package/package.json +3 -2
- package/rules/cloudgpu.md +6 -2
- package/skills/cloudgpu/SKILL.md +99 -0
- package/skills/cloudgpu-model-api/SKILL.md +56 -0
- package/src/cli-core.js +3 -3
- package/src/index.js +4 -1
- package/src/recipes/task-pipeline.py +41 -0
- package/src/task-pipelines.js +39 -0
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.
|
|
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",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"rules",
|
|
15
15
|
"README.md",
|
|
16
16
|
"LICENSE",
|
|
17
|
-
"examples"
|
|
17
|
+
"examples",
|
|
18
|
+
"skills"
|
|
18
19
|
],
|
|
19
20
|
"engines": {
|
|
20
21
|
"node": ">=18.3"
|
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
|
-
-
|
|
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
|
-
|
|
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.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cloudgpu
|
|
3
|
+
description: Rent and use a cloud GPU on CloudGPU (cloudgpu.app) through the `cloudgpu` MCP tools. Use when the user wants to rent a GPU, run a training, fine-tuning, inference or ComfyUI job on a cloud GPU, or mentions CloudGPU or cloudgpu.app, and the `cloudgpu` MCP tools are available.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CloudGPU
|
|
7
|
+
|
|
8
|
+
Follow these steps whenever you rent or use a GPU on CloudGPU (cloudgpu.app) through the `cloudgpu` MCP tools.
|
|
9
|
+
|
|
10
|
+
## Before renting
|
|
11
|
+
|
|
12
|
+
1. Call `get_account` and `list_gpus`. Pick a GPU with enough VRAM for the job, and don't rent more GPU than the job needs. As a rough guide, LoRA on a 7–8B model fits in 24 GB, and a full fine-tune of the same model needs 80 GB or more.
|
|
13
|
+
2. Check existing `list_instances` before renting. A compatible running rental can run multiple approved commands inside its original limits. Optionally compare billed task costs with `compare_compute_costs`, then call `estimate_cost` with preparation/download/output time included.
|
|
14
|
+
3. Show the user a short quote before you rent anything:
|
|
15
|
+
- the GPU and how many,
|
|
16
|
+
- the price per hour,
|
|
17
|
+
- the billing increment and minimum charge: some sources charge a minimum one hour and every started hour in full, with no voluntary-stop refund of unused charged time,
|
|
18
|
+
- the estimated hours and cost,
|
|
19
|
+
- the budget and time limit you will set,
|
|
20
|
+
- their balance after the job.
|
|
21
|
+
4. Rent only after the user says yes. Pass `user_confirmed=true` only in that case.
|
|
22
|
+
|
|
23
|
+
## Renting
|
|
24
|
+
|
|
25
|
+
- Always set `max_spend_usd` and `max_hours`. CloudGPU's servers destroy the instance when either is reached, even if you have disconnected.
|
|
26
|
+
- Keep `idle_minutes` on (default 60). Include setup time when agreeing limits before creation. Never silently extend the approved budget, time or idle limits.
|
|
27
|
+
- Call `get_status` at intervals, not in a tight loop, until the instance is `running`.
|
|
28
|
+
- On failure, inspect actual charges and release status; do not promise zero charges or automatic refunds. Do not retry creation while the result or resource release is uncertain.
|
|
29
|
+
|
|
30
|
+
## Working on the instance
|
|
31
|
+
|
|
32
|
+
- Put code and data on the instance with `upload`. Do not upload credentials.
|
|
33
|
+
- Use `run_command` for short steps. For training, long installs or big downloads, use `background=true` and follow progress with `tail_logs`.
|
|
34
|
+
- Instances come with Python and CUDA, but not always PyTorch. Check first: `nvidia-smi -L` and `python -c "import torch; print(torch.__version__, torch.cuda.is_available())"`.
|
|
35
|
+
- If PyTorch is missing, plain `pip install torch` installs a current CUDA build. It is a few GB, so run it with `background=true`. Index URLs for older CUDA versions (for example `.../whl/cu124`) may have no wheel for the machine's Python, which can be very new. Only use them if the project needs that CUDA version, and then create an environment with an older Python first (`conda create -y -n work python=3.12`, then `conda activate work && ...` in each command).
|
|
36
|
+
- If `nvidia-smi` shows no GPU once the instance is running, stop and tell the user. CloudGPU detects such machines and shuts them down automatically.
|
|
37
|
+
- **Do not** change the root password, edit the SSH configuration, change the firewall, or stop the platform's monitoring agent (`cgpu-*` processes). The platform must keep its access to the instance; if that access is lost, the platform shuts the instance down. The MCP server refuses such commands.
|
|
38
|
+
- Never use the GPU for cryptocurrency mining or anything the [acceptable use policy](https://cloudgpu.app/aup) forbids. Instances that do so are shut down.
|
|
39
|
+
|
|
40
|
+
## Finishing (always)
|
|
41
|
+
|
|
42
|
+
1. Download every result: model weights, adapters, checkpoints, logs, metrics. Destroying an instance erases its disk. Workspace persists only files explicitly uploaded and ready, under its quota/retention policy. It is not an automatic disk backup. Storage fees are separate from GPU budgets.
|
|
43
|
+
2. Call `stop_instance`.
|
|
44
|
+
3. Tell the user what ran, where the results are on their computer, and the final cost from `stop_instance`.
|
|
45
|
+
|
|
46
|
+
If anything goes wrong mid-way, do not leave the instance running. Download whatever exists, stop the instance, then explain what happened.
|
|
47
|
+
|
|
48
|
+
## Balance and top-ups
|
|
49
|
+
|
|
50
|
+
- If `get_account` or `estimate_cost` shows the balance would not cover the quoted job, do not call `create_instance`. Tell the user how much is missing and ask them to top up at https://cloudgpu.app/billing (card or USDT). When they say it is done, call `estimate_cost` again before renting.
|
|
51
|
+
- `create_instance` also checks the balance. If it is below the estimate or budget plus 10%, the MCP server does not rent anything and returns an error that starts with `Not rented: balance $... is below $...` and points to https://cloudgpu.app/billing. If the CloudGPU API itself rejects the request with HTTP status 402, the error reads `CloudGPU API error 402 <code>: <message>` followed by the same billing link. Handle both the same way as above: stop, tell the user how much is missing, and do not retry.
|
|
52
|
+
- Never top up, enter card details or move money on the user's behalf. The user does that themselves on the billing page.
|
|
53
|
+
|
|
54
|
+
## Checking prices without the MCP server
|
|
55
|
+
|
|
56
|
+
If the `cloudgpu` tools are not available, read current prices from https://cloudgpu.app/gpu-prices.json (machine-readable, with an `updated_at` field) or https://cloudgpu.app/pricing. Check `updated_at` and tell the user how fresh the data is. Do not quote prices from memory.
|
|
57
|
+
|
|
58
|
+
## Optional persistence
|
|
59
|
+
|
|
60
|
+
Discover tools and `GET /v1/public/compute-capabilities` first. Persistence is
|
|
61
|
+
unavailable when that endpoint is missing or `storage` is false. Never promise
|
|
62
|
+
free storage, a retention period or automatic output collection.
|
|
63
|
+
|
|
64
|
+
When enabled, ask before saving private project files. Use `save_workspace` for
|
|
65
|
+
regular source/config/dependency-manifest files, `upload_artifact` for persistent
|
|
66
|
+
results or datasets/models, and `download_artifact` to retrieve them. Pass the
|
|
67
|
+
saved `workspace_version_id` to `run_job` to restore the files before execution.
|
|
68
|
+
The service does not restore a boot disk and does not automatically save edits;
|
|
69
|
+
the Job command must still save its results before shutdown. Do not upload secrets.
|
|
70
|
+
|
|
71
|
+
For Jobs, prefer `quote_compute` for a server quote and send its `quote_id` with
|
|
72
|
+
the chosen candidate. Its `required_starting_balance` is separate from the task
|
|
73
|
+
estimate. The original `estimate_cost` quote belongs to `create_instance`.
|
|
74
|
+
|
|
75
|
+
## Only need a model, not a GPU?
|
|
76
|
+
|
|
77
|
+
The same API key works for CloudGPU's model API at `https://cloudgpu.app/v1`. Call `list_models` to see the models. If you only need inference on a hosted model, use the API instead of renting a GPU.
|
|
78
|
+
|
|
79
|
+
## If the MCP server is not installed
|
|
80
|
+
|
|
81
|
+
If no `cloudgpu` tools are available, the MCP server needs to be set up first:
|
|
82
|
+
|
|
83
|
+
- Command: `npx -y cloudgpu-mcp`
|
|
84
|
+
- Environment variable: `CLOUDGPU_API_KEY`, with a key created at https://cloudgpu.app.
|
|
85
|
+
- Never paste the key into the chat or into files in the project. Ask the user to put it in their MCP client's configuration or environment themselves.
|
|
86
|
+
|
|
87
|
+
See the [README](https://github.com/cloudgpu-app/cloudgpu-mcp#install) for per-client setup.
|
|
88
|
+
|
|
89
|
+
## Jobs and instance reuse
|
|
90
|
+
|
|
91
|
+
Sequential approved `run_command` calls may reuse a running rental within its original budget, deadline and idle limit. Check ownership, readiness and free memory/disk first. Independent `run_job` calls and `prepare_job_rerun` provision separately, not into that live rental. Job/template support is configuration-specific; inspect `supports_jobs` and obtain a Job quote, never substitute the rental quote. Do not keep an idle GPU merely to consume a prepaid hour. Confirm result persistence and release when finished.
|
|
92
|
+
|
|
93
|
+
## Connect with an approval link
|
|
94
|
+
|
|
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.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cloudgpu-model-api
|
|
3
|
+
description: Call a hosted model through CloudGPU's OpenAI-compatible model API at https://cloudgpu.app/v1, without renting a GPU. Use when the user wants to call a hosted model (chat/completions) through CloudGPU, wire CloudGPU into an OpenAI-compatible client or agent framework (OpenAI SDK, LangChain, Cline, Roo Code, Continue, Aider, n8n, Dify), or mentions cloudgpu.app/v1.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CloudGPU model API
|
|
7
|
+
|
|
8
|
+
CloudGPU (cloudgpu.app) serves hosted models over an OpenAI-compatible API at `https://cloudgpu.app/v1`. No GPU rental is needed.
|
|
9
|
+
|
|
10
|
+
## 1. Pick a model ID
|
|
11
|
+
|
|
12
|
+
- Call the `list_models` tool, or `GET https://cloudgpu.app/v1/models` (public, no key needed).
|
|
13
|
+
- Never guess or hardcode a model ID. Use one the list returns.
|
|
14
|
+
|
|
15
|
+
## 2. Authenticate
|
|
16
|
+
|
|
17
|
+
- Send `Authorization: Bearer $CLOUDGPU_API_KEY`.
|
|
18
|
+
- Read the key from the environment. Never print it, and never write it into files that get committed.
|
|
19
|
+
- If `CLOUDGPU_API_KEY` is not set, ask the user to create a key at https://cloudgpu.app and set it themselves. Do not ask them to paste it into the chat.
|
|
20
|
+
|
|
21
|
+
## 3. Set up a client
|
|
22
|
+
|
|
23
|
+
In any OpenAI-compatible SDK, client or agent framework, set `base_url` to `https://cloudgpu.app/v1` and the API key to the value of `CLOUDGPU_API_KEY`.
|
|
24
|
+
|
|
25
|
+
Python (OpenAI SDK):
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
import os
|
|
29
|
+
from openai import OpenAI
|
|
30
|
+
|
|
31
|
+
client = OpenAI(base_url="https://cloudgpu.app/v1", api_key=os.environ["CLOUDGPU_API_KEY"])
|
|
32
|
+
resp = client.chat.completions.create(
|
|
33
|
+
model="kimi-k3", # example only: check list_models or /v1/models first
|
|
34
|
+
messages=[{"role": "user", "content": "Say hello."}],
|
|
35
|
+
)
|
|
36
|
+
print(resp.choices[0].message.content)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The same request as HTTP. Read the key from the environment; do not paste it into the request text you show the user.
|
|
40
|
+
|
|
41
|
+
- `POST https://cloudgpu.app/v1/chat/completions`
|
|
42
|
+
- `Authorization: Bearer` followed by the value of `CLOUDGPU_API_KEY`
|
|
43
|
+
- `Content-Type: application/json`
|
|
44
|
+
- Body: `{"model":"<id from the model list>","messages":[{"role":"user","content":"Say hello."}]}`
|
|
45
|
+
|
|
46
|
+
The model id in any example is only an example. Check the model list before using it.
|
|
47
|
+
|
|
48
|
+
## Prices and balance
|
|
49
|
+
|
|
50
|
+
Don't quote prices from memory. Current prices are at https://cloudgpu.app/api. The same API key and balance also cover GPU rental (see the `cloudgpu` skill).
|
|
51
|
+
|
|
52
|
+
## Errors
|
|
53
|
+
|
|
54
|
+
- **401:** the key is missing or wrong. Check that `CLOUDGPU_API_KEY` is set and valid.
|
|
55
|
+
- **404 / model not found:** the model ID is not available. Re-run `list_models` and use an ID from the list.
|
|
56
|
+
- **429:** too many requests. Back off, then retry.
|
package/src/cli-core.js
CHANGED
|
@@ -78,7 +78,7 @@ const COMMANDS = {
|
|
|
78
78
|
" output in /root/cloudgpu-setup.log on the instance",
|
|
79
79
|
"--wait poll until the instance is running or failed, then print SSH and URLs",
|
|
80
80
|
"--show-password with --wait, also print the SSH password if the API returns one",
|
|
81
|
-
"Costs money: billing is
|
|
81
|
+
"Costs money: billing is source-specific. Hourly sources require a billing quote and explicit approval through MCP; never infer billing from the hourly price label.",
|
|
82
82
|
],
|
|
83
83
|
options: {
|
|
84
84
|
...JSON_OPT,
|
|
@@ -557,7 +557,7 @@ async function cmdOffers(c) {
|
|
|
557
557
|
offers.map((o) => [o.gpu_model, o.vram_gb != null ? `${o.vram_gb} GB` : null, usd(o.hourly_usd), o.available, o.min_gpu_count]),
|
|
558
558
|
),
|
|
559
559
|
);
|
|
560
|
-
c.out("Prices and availability are live
|
|
560
|
+
c.out("Prices and availability are live and can change; billing periods vary by source. Use MCP estimate_cost for the minimum charge.\n");
|
|
561
561
|
if (tpl && tpl.recommended_gpu) c.out(`Template ${tpl.id} recommends: ${tpl.recommended_gpu}\n`);
|
|
562
562
|
return 0;
|
|
563
563
|
}
|
|
@@ -611,7 +611,7 @@ async function cmdUp(c) {
|
|
|
611
611
|
return 0;
|
|
612
612
|
}
|
|
613
613
|
c.out(`Created ${inst.id} (${gpuLabel(inst)}, status: ${inst.status}).\n`);
|
|
614
|
-
c.out(`Billing
|
|
614
|
+
c.out(`Billing follows the approved source-specific terms until destroyed. Check it with: cloudgpu status ${inst.id}\n`);
|
|
615
615
|
c.out(`Destroy it with: cloudgpu down ${inst.id}\n`);
|
|
616
616
|
return 0;
|
|
617
617
|
}
|
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.
|
|
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
|
+
}
|