cloudgpu-mcp 0.8.0 → 0.9.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 +1 -1
- package/src/api.js +9 -0
- package/src/index.js +10 -4
- package/src/job-results.js +26 -4
package/README.md
CHANGED
|
@@ -295,3 +295,13 @@ This branch adds `diagnose_job` (read-only) and `save_job_output` (explicit stor
|
|
|
295
295
|
`diagnose_job` reports the error category, platform instance status and whether platform charges are final. It does not prove supplier release, infer that command failures are always user errors, or automatically rerun work. `needs_attention` requires resource reconciliation before a new task. A rerun requires a fresh quote, explicit approval and a new idempotency key.
|
|
296
296
|
|
|
297
297
|
Registry configuration allows discovery and connect-link approval without pre-entering a key. A tool-enabled MCP client is still required; a link does not install a client or grant unlimited spending. No new fixed infrastructure or model storage is introduced.
|
|
298
|
+
|
|
299
|
+
### Optional Job output collection (requires backend capability)
|
|
300
|
+
|
|
301
|
+
Call `run_job` with `outputs: {"files":["metrics.json"],"max_bytes":1048576}` and a command that writes to `"$CLOUDGPU_OUTPUT_DIR/metrics.json"`. Files are relative to this dedicated directory; the platform does not scan the disk. The server refuses unsupported backends rather than silently starting a Job without saving results. GPU download/execution/upload time shares the same time and spend limits.
|
|
302
|
+
|
|
303
|
+
After completion, inspect `get_job.output_collection`: only `succeeded` confirms collection. Each saved entry gives `file_id`, `sha256`, `size_bytes` and status; use existing file download tools. Partial failure may retain ready files, but is not overall success. Cancellation, budget exhaustion, instance loss or interrupted collection can prevent saving; GPU release still proceeds with no automatic re-run. Files follow the existing account quota, storage pricing and 30-day retention. `accept_storage_charges` defaults false and requires explicit user agreement to paid storage. The 10 MiB default/100 MiB maximum is a transfer bound, not a new user quota. File-name protections cannot guarantee that user-selected file contents contain no secrets.
|
|
304
|
+
|
|
305
|
+
### Job log snapshot safety
|
|
306
|
+
|
|
307
|
+
Version 0.8.0 still has a credential-filter gap in `save_job_output`; upgrading to 0.8.0 did not fix it. The 0.9.0 candidate rejects quoted JSON credential keys, common prefixed/aliased secret fields, authorization schemes, queried/user-info URLs and bounded common escaped representations before any storage operation. Safe logs remain byte-identical. This is a conservative recognizable-pattern check, not a guarantee that arbitrary, encrypted or unknown credentials will be detected. Save only logs you know are sanitized, with explicit user approval; no actual exposure is established by this fix.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudgpu-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"mcpName": "io.github.mrhy7176/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 per minute, run a job, fetch the results and shut it down, with spending limits the platform enforces.",
|
|
6
6
|
"type": "module",
|
package/src/api.js
CHANGED
|
@@ -106,9 +106,18 @@ export class CloudGpuApi {
|
|
|
106
106
|
// ── jobs: start a GPU, run one command, destroy the GPU (server-side) ──
|
|
107
107
|
createJob(body, idempotencyKey) {
|
|
108
108
|
if (!idempotencyKey) throw new Error("createJob needs an idempotency key");
|
|
109
|
+
if (body.outputs) return this.createOutputJob(body,idempotencyKey);
|
|
109
110
|
if (body.model_references?.length) return this.createModelJob(body,idempotencyKey);
|
|
110
111
|
return this.request("POST", "/v1/jobs", body, { idempotencyKey });
|
|
111
112
|
}
|
|
113
|
+
async createOutputJob(body,idempotencyKey) {
|
|
114
|
+
const caps=await this.request("GET","/v1/public/compute-capabilities",undefined,{noAuth:true});
|
|
115
|
+
if(caps.automatic_output_collection!==true || caps.storage!==true)
|
|
116
|
+
throw new ApiError(503,"outputs_unavailable","Automatic output collection is not enabled; no Job was submitted. Do not silently remove outputs.");
|
|
117
|
+
if(body.model_references?.length && caps.model_references!==true)
|
|
118
|
+
throw new ApiError(503,"model_references_unavailable","Pinned model loading is not enabled; no Job was submitted.");
|
|
119
|
+
return this.request("POST","/v1/jobs",body,{idempotencyKey});
|
|
120
|
+
}
|
|
112
121
|
async createModelJob(body,idempotencyKey) {
|
|
113
122
|
const caps=await this.request("GET","/v1/public/compute-capabilities",undefined,{noAuth:true});
|
|
114
123
|
if(caps.model_references!==true) throw new ApiError(503,"model_references_unavailable","Backend has not enabled pinned model loading; no Job was submitted.");
|
package/src/index.js
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
shq,
|
|
33
33
|
} from "./guards.js";
|
|
34
34
|
|
|
35
|
-
const VERSION = "0.
|
|
35
|
+
const VERSION = "0.9.0";
|
|
36
36
|
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
37
37
|
const RULES = fs.readFileSync(path.join(HERE, "..", "rules", "cloudgpu.md"), "utf8");
|
|
38
38
|
|
|
@@ -60,7 +60,7 @@ const session = new Map();
|
|
|
60
60
|
const INSTRUCTIONS = `CloudGPU (cloudgpu.app) rents GPUs billed per minute from a prepaid balance.
|
|
61
61
|
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.
|
|
62
62
|
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.
|
|
63
|
-
Jobs: for a batch task (one command that writes its results somewhere), run_job does the whole thing on CloudGPU's servers: start a GPU, run the command, destroy the GPU, with the same per-job budget and time limit. Check it with get_job. The GPU
|
|
63
|
+
Jobs: for a batch task (one command that writes its results somewhere), run_job does the whole thing on CloudGPU's servers: start a GPU, run the command, destroy the GPU, with the same per-job budget and time limit. Check it with get_job. The GPU disk is erased on release. When automatic_output_collection is enabled, declare explicit outputs and write them under $CLOUDGPU_OUTPUT_DIR; inspect output_collection and download ready file IDs afterward. Otherwise upload results yourself or print them; get_job returns the last ~4 KB of logs. Saving output shares the same GPU budget and existing storage quota/fees; never infer storage-fee acceptance.
|
|
64
64
|
No API key yet? connect_account gives the user a link to approve this assistant with a spending limit; then finish_connect stores the key on this computer.
|
|
65
65
|
The same API key also works for the OpenAI-compatible model API at ${cfg.baseUrl}/v1 (see list_models).`;
|
|
66
66
|
|
|
@@ -505,7 +505,7 @@ if (!cfg.readOnly) {
|
|
|
505
505
|
description:
|
|
506
506
|
"Costs money. CloudGPU starts a GPU, runs one bash command on it, then destroys the GPU, all on its servers, so it finishes even if this assistant disconnects. " +
|
|
507
507
|
"max_spend_usd and max_hours are enforced by the servers. Retrying with the same idempotency_key never starts a second GPU; this tool generates one if you leave it out and returns it. " +
|
|
508
|
-
"The disk is erased when the job ends
|
|
508
|
+
"The disk is erased when the job ends. When automatic_output_collection is available, declare outputs and write only those files under $CLOUDGPU_OUTPUT_DIR for persistent storage before release. Otherwise upload results yourself or print them. Storage retention and fees follow the account policy; collection consumes the same GPU budget and may fail. " +
|
|
509
509
|
"Requires the user's explicit yes on the GPU, budget and time limit.",
|
|
510
510
|
inputSchema: {
|
|
511
511
|
command: z.string().min(1).max(32768).describe("bash command or script to run on the GPU"),
|
|
@@ -515,6 +515,11 @@ if (!cfg.readOnly) {
|
|
|
515
515
|
disk_gb: z.number().int().optional().describe("Larger system disk: 100, 200 or 500; omit for the standard disk"),
|
|
516
516
|
workspace_version_id: z.string().optional().describe("Immutable Workspace version to restore before the command; requires enabled persistent storage"),
|
|
517
517
|
model_references: z.array(z.object({name:z.string(),repo_id:z.string(),revision:z.string().regex(/^[0-9a-f]{40}$/),files:z.array(z.object({path:z.string(),size_bytes:z.number().int().positive(),sha256:z.string().regex(/^[0-9a-f]{64}$/).optional()})).min(1).max(32)})).max(4).optional().describe("Pinned public model references from resolve_model_reference. Downloads into $CLOUDGPU_MODEL_DIR/<name> before the command; download time consumes the same GPU budget. No R2 cache or remote repository code execution."),
|
|
518
|
+
outputs: z.object({
|
|
519
|
+
files: z.array(z.string().min(1).max(512)).min(1).max(16),
|
|
520
|
+
max_bytes: z.number().int().min(1).max(104857600).optional(),
|
|
521
|
+
accept_storage_charges: z.boolean().optional(),
|
|
522
|
+
}).strict().optional().describe("Explicit relative output files under $CLOUDGPU_OUTPUT_DIR; no globs, symlinks, hidden or credential files. Default total limit 10 MiB, maximum 100 MiB. Only set accept_storage_charges=true after the user agrees to existing paid storage terms. Inspect output_collection after completion; the GPU is released even if saving fails."),
|
|
518
523
|
quote_id: z.string().optional().describe("Server quote from quote_compute, starting quote_; binds configuration and checks price at submission"),
|
|
519
524
|
max_spend_usd: z.number().positive().describe(`Budget for this job in USD (at most ${cfg.maxSpend})`),
|
|
520
525
|
max_hours: z.number().positive().describe(`Hard time limit in hours (at most ${cfg.maxHours})`),
|
|
@@ -523,7 +528,7 @@ if (!cfg.readOnly) {
|
|
|
523
528
|
},
|
|
524
529
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true },
|
|
525
530
|
},
|
|
526
|
-
wrap(async ({ command, gpu_model, template, gpu_count = 1, disk_gb, workspace_version_id, model_references, quote_id, max_spend_usd, max_hours, user_confirmed, idempotency_key }) => {
|
|
531
|
+
wrap(async ({ command, gpu_model, template, gpu_count = 1, disk_gb, workspace_version_id, model_references, outputs, quote_id, max_spend_usd, max_hours, user_confirmed, idempotency_key }) => {
|
|
527
532
|
if (user_confirmed !== true) {
|
|
528
533
|
return fail("Not started: tell the user the GPU, budget and time limit, wait for an explicit yes, then call again with user_confirmed=true.");
|
|
529
534
|
}
|
|
@@ -542,6 +547,7 @@ if (!cfg.readOnly) {
|
|
|
542
547
|
if (template) body.template = template;
|
|
543
548
|
if (disk_gb) body.disk_gb = disk_gb;
|
|
544
549
|
if (workspace_version_id) body.workspace_version_id = workspace_version_id;
|
|
550
|
+
if (outputs) body.outputs = outputs;
|
|
545
551
|
if (model_references?.length) body.model_references = model_references;
|
|
546
552
|
if (quote_id) body.quote_id = quote_id;
|
|
547
553
|
const job = await api.createJob(body, key);
|
package/src/job-results.js
CHANGED
|
@@ -9,11 +9,33 @@ const terminal=new Set(['succeeded','failed','cancelled']);
|
|
|
9
9
|
const idSchema=z.string().regex(/^job_[a-f0-9]{32}$/);
|
|
10
10
|
const locks=new Map();
|
|
11
11
|
function assertId(id){if(!/^job_[a-f0-9]{32}$/.test(id))throw Error('Invalid Job ID.');}
|
|
12
|
+
// Inspect bounded decoded views but preserve the original safe log byte-for-byte.
|
|
13
|
+
// This is a conservative refusal filter, not proof that arbitrary log content is secret-free.
|
|
14
|
+
const credentialField=/(?:^|[^A-Za-z0-9_])["']?[A-Za-z0-9_.-]*(?:password|passwd|pwd|passphrase|secret|client[_-]?secret|secret[_-]?(?:access[_-]?)?key|api[_-]?key|access[_-]?key(?:[_-]?id)?|aws[_-]?(?:access[_-]?key[_-]?id|secret[_-]?access[_-]?key|session[_-]?token)|(?:access|refresh|id|auth|session|csrf|xsrf)[_-]?token|token|authorization|proxy[_-]?authorization|cookie|set[_-]?cookie|x[_-]?(?:api[_-]?key|auth[_-]?token))["']?\s*[:=]\s*(?=\S)/i;
|
|
15
|
+
const credentialForms=[credentialField,/-----BEGIN [^-]*PRIVATE KEY-----/i,/\bsk-[A-Za-z0-9_-]{16,}/,/\b(?:Bearer|Basic)\s+[A-Za-z0-9_+/.=-]{8,}/i,/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/,/https?:\/\/[^\s"'<>]*\?[^\s"'<>]*/i,/https?:\/\/[^/\s"'<>@]+@/i];
|
|
16
|
+
function decodedTailView(text){
|
|
17
|
+
const named={quot:'"',apos:"'",colon:':',equals:'=',amp:'&',sol:'/',quest:'?'};
|
|
18
|
+
return text.normalize('NFKC')
|
|
19
|
+
.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g,'')
|
|
20
|
+
.replace(/[\u200b-\u200f\u202a-\u202e\u2060-\u206f\ufeff]/g,'')
|
|
21
|
+
.replace(/\\u([0-9a-f]{4})|\\x([0-9a-f]{2})|\\(["'\\/:=])/gi,(_m,u,x,c)=>u?String.fromCharCode(parseInt(u,16)):x?String.fromCharCode(parseInt(x,16)):c)
|
|
22
|
+
.replace(/(?:%[0-9a-f]{2})+/gi,part=>Buffer.from(part.replaceAll('%',''),'hex').toString('utf8'))
|
|
23
|
+
.replace(/&#(x[0-9a-f]+|[0-9]+);|&(quot|apos|colon|equals|amp|sol|quest);/gi,(_m,n,name)=>{
|
|
24
|
+
if(name)return named[name.toLowerCase()];const value=n[0].toLowerCase()==='x'?parseInt(n.slice(1),16):parseInt(n,10);
|
|
25
|
+
if(value>0x10ffff)throw Error('Output normalization is unsafe; nothing was uploaded.');return String.fromCodePoint(value);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
12
28
|
export function checkedTail(text,apiKey){
|
|
13
29
|
if(typeof text!=='string'||Buffer.byteLength(text)>16384)throw Error('Job output tail exceeds the bounded snapshot limit.');
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
30
|
+
let view=text;
|
|
31
|
+
for(let depth=0;depth<5;depth++){
|
|
32
|
+
if((apiKey&&apiKey.length>=4&&view.includes(apiKey))||credentialForms.some(re=>re.test(view)))throw Error('Output may contain credentials or a signed URL. Sanitize it before saving; nothing was uploaded.');
|
|
33
|
+
const next=decodedTailView(view);
|
|
34
|
+
if(Buffer.byteLength(next)>65536)throw Error('Output normalization exceeds the bounded snapshot limit.');
|
|
35
|
+
if(next===view)return text;
|
|
36
|
+
view=next;
|
|
37
|
+
}
|
|
38
|
+
throw Error('Output normalization is too deeply encoded; nothing was uploaded.');
|
|
17
39
|
}
|
|
18
40
|
export async function diagnoseJob(api,id){
|
|
19
41
|
assertId(id);const job=await api.job(id);const code=job.error?.code||null;
|
|
@@ -50,5 +72,5 @@ export function registerJobResultTools(server,{api,wrap,ok,readOnly}){
|
|
|
50
72
|
const storage=new PersistentStorage(api);
|
|
51
73
|
server.registerTool('diagnose_job',{title:'Inspect Job failure and cost state',description:'Read-only Job diagnosis and observed platform instance state. Never creates, stops or retries a GPU. Does not claim supplier release verification or classify every command failure as user error.',inputSchema:{job_id:idSchema},annotations:{readOnlyHint:true,openWorldHint:true}},wrap(async({job_id})=>ok(await diagnoseJob(api,job_id))));
|
|
52
74
|
if(readOnly)return;
|
|
53
|
-
server.registerTool('save_job_output',{title:'Save ended Job output tail',description:'With approval, persist the ended Job log tail as a small Artifact using existing storage quota and retention. This is not the full log or binary output collection. Refuses recognizable credentials and queried URLs. Never touches GPU resources. Reuses a matching verified snapshot when found; cross-client concurrent calls may create duplicates.',inputSchema:{job_id:idSchema,user_confirmed:z.boolean(),accept_storage_charges:z.boolean().default(false)},annotations:{readOnlyHint:false,destructiveHint:false,idempotentHint:false,openWorldHint:true}},wrap(async({job_id,user_confirmed,accept_storage_charges})=>ok(await saveJobOutput(api,storage,job_id,user_confirmed,accept_storage_charges))));
|
|
75
|
+
server.registerTool('save_job_output',{title:'Save ended Job output tail',description:'With approval, persist the ended Job log tail as a small Artifact using existing storage quota and retention. This is not the full log or binary output collection. Refuses recognizable credentials, quoted/aliased fields and bounded escaped representations or queried URLs. This is not a guarantee that arbitrary logs contain no secrets; save only logs you know are sanitized. Never touches GPU resources. Reuses a matching verified snapshot when found; cross-client concurrent calls may create duplicates.',inputSchema:{job_id:idSchema,user_confirmed:z.boolean(),accept_storage_charges:z.boolean().default(false)},annotations:{readOnlyHint:false,destructiveHint:false,idempotentHint:false,openWorldHint:true}},wrap(async({job_id,user_confirmed,accept_storage_charges})=>ok(await saveJobOutput(api,storage,job_id,user_confirmed,accept_storage_charges))));
|
|
54
76
|
}
|