@runpod/mcp-server 3.1.0 → 3.2.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/CHANGELOG.md +14 -0
- package/dist/{chunk-OM6RHPQC.mjs → chunk-WGK7D2YR.mjs} +370 -9
- package/dist/chunk-WGK7D2YR.mjs.map +1 -0
- package/dist/http.cjs +392 -17
- package/dist/http.cjs.map +1 -1
- package/dist/http.mjs +24 -10
- package/dist/http.mjs.map +1 -1
- package/dist/stdio.cjs +387 -16
- package/dist/stdio.cjs.map +1 -1
- package/dist/stdio.mjs +387 -16
- package/dist/stdio.mjs.map +1 -1
- package/dist/tools.cjs +369 -8
- package/dist/tools.cjs.map +1 -1
- package/dist/tools.d.cts +3 -0
- package/dist/tools.d.ts +3 -0
- package/dist/tools.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-OM6RHPQC.mjs.map +0 -1
package/dist/tools.cjs
CHANGED
|
@@ -38,11 +38,150 @@ module.exports = __toCommonJS(tools_exports);
|
|
|
38
38
|
var import_node_fetch = __toESM(require("node-fetch"), 1);
|
|
39
39
|
var import_node_crypto = require("crypto");
|
|
40
40
|
|
|
41
|
+
// src/_shared/rate-limit.ts
|
|
42
|
+
var GENERIC_RATE_LIMIT_HINT = "rate limited \u2014 back off before retrying, and pace bulk operations";
|
|
43
|
+
var MAX_PLAUSIBLE_WAIT_S = 7 * 86400;
|
|
44
|
+
function remainingRequests(raw) {
|
|
45
|
+
const value = raw?.trim();
|
|
46
|
+
return value && /^\d+$/.test(value) ? Number(value) : null;
|
|
47
|
+
}
|
|
48
|
+
function waitSeconds(raw) {
|
|
49
|
+
const value = raw?.trim();
|
|
50
|
+
if (!value || !/^\d+$/.test(value)) return null;
|
|
51
|
+
const seconds = Number(value);
|
|
52
|
+
return seconds <= MAX_PLAUSIBLE_WAIT_S ? seconds : null;
|
|
53
|
+
}
|
|
54
|
+
var WINDOW_NAME_RE = /^(?:"([\x20-\x21\x23-\x5b\x5d-\x7e]{1,32})"|([A-Za-z*][A-Za-z0-9!#$%&'*+.^_`|~:/-]{0,31}))$/;
|
|
55
|
+
function windowName(raw) {
|
|
56
|
+
const match = WINDOW_NAME_RE.exec(raw.trim());
|
|
57
|
+
return match ? match[1] ?? match[2] : null;
|
|
58
|
+
}
|
|
59
|
+
var QUOTED_VALUE_RE = /^"(?:[\x20-\x21\x23-\x5b\x5d-\x7e]|\\["\\])*"$/;
|
|
60
|
+
var DISPLAY_VALUE_RE = /^%"(?:[\x20-\x21\x23-\x24\x26-\x5b\x5d-\x7e]|\\|%[0-9a-f]{2})*"$/;
|
|
61
|
+
function isWellFormedParam(param) {
|
|
62
|
+
const eq = param.indexOf("=");
|
|
63
|
+
const key = (eq === -1 ? param : param.slice(0, eq)).trim();
|
|
64
|
+
if (key.includes('"')) return false;
|
|
65
|
+
if (eq === -1) return true;
|
|
66
|
+
const value = param.slice(eq + 1).trim();
|
|
67
|
+
if (value.startsWith('"')) return QUOTED_VALUE_RE.test(value);
|
|
68
|
+
if (value.startsWith('%"')) return DISPLAY_VALUE_RE.test(value);
|
|
69
|
+
return !/[\s"]/.test(value);
|
|
70
|
+
}
|
|
71
|
+
function splitOutsideStrings(input, sep) {
|
|
72
|
+
const parts = [];
|
|
73
|
+
let current = "";
|
|
74
|
+
let inString = false;
|
|
75
|
+
let inDisplay = false;
|
|
76
|
+
let escaped = false;
|
|
77
|
+
let prev = "";
|
|
78
|
+
for (const ch of input) {
|
|
79
|
+
if (escaped) escaped = false;
|
|
80
|
+
else if (inString && !inDisplay && ch === "\\") escaped = true;
|
|
81
|
+
else if (ch === '"') {
|
|
82
|
+
if (!inString) inDisplay = prev === "%";
|
|
83
|
+
inString = !inString;
|
|
84
|
+
} else if (ch === sep && !inString) {
|
|
85
|
+
parts.push(current);
|
|
86
|
+
current = "";
|
|
87
|
+
prev = ch;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
current += ch;
|
|
91
|
+
prev = ch;
|
|
92
|
+
}
|
|
93
|
+
parts.push(current);
|
|
94
|
+
return parts;
|
|
95
|
+
}
|
|
96
|
+
function readParams(params) {
|
|
97
|
+
const values = /* @__PURE__ */ new Map();
|
|
98
|
+
let unreadable = false;
|
|
99
|
+
let valuelessAt = -1;
|
|
100
|
+
for (const [index, param] of params.entries()) {
|
|
101
|
+
const eq = param.indexOf("=");
|
|
102
|
+
const key = (eq === -1 ? param : param.slice(0, eq)).trim().toLowerCase();
|
|
103
|
+
if (!key) continue;
|
|
104
|
+
if (eq === -1) {
|
|
105
|
+
if (key === "r") unreadable = true;
|
|
106
|
+
if (key === "t") values.delete("t");
|
|
107
|
+
valuelessAt = index;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if ((key === "r" || key === "t") && (values.has(key) || valuelessAt !== -1 && index > valuelessAt)) {
|
|
111
|
+
unreadable = true;
|
|
112
|
+
}
|
|
113
|
+
values.set(key, param.slice(eq + 1));
|
|
114
|
+
}
|
|
115
|
+
return { values, unreadable };
|
|
116
|
+
}
|
|
117
|
+
function parseExhaustedWindows(header) {
|
|
118
|
+
if (!header) return { windows: [], dropped: false };
|
|
119
|
+
const windows = [];
|
|
120
|
+
let dropped = false;
|
|
121
|
+
for (const item of splitOutsideStrings(header, ",")) {
|
|
122
|
+
if (item.trim() === "") continue;
|
|
123
|
+
const [rawName, ...params] = splitOutsideStrings(item, ";");
|
|
124
|
+
if (!params.every(isWellFormedParam)) {
|
|
125
|
+
dropped = true;
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const { values, unreadable } = readParams(params);
|
|
129
|
+
if (unreadable) {
|
|
130
|
+
dropped = true;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const remaining = remainingRequests(values.get("r"));
|
|
134
|
+
if (remaining === null) {
|
|
135
|
+
dropped = true;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (remaining !== 0) continue;
|
|
139
|
+
windows.push({
|
|
140
|
+
window: windowName(rawName),
|
|
141
|
+
resetS: waitSeconds(values.get("t"))
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return { windows, dropped };
|
|
145
|
+
}
|
|
146
|
+
function humanWait(seconds) {
|
|
147
|
+
if (seconds < 120) return `~${seconds}s`;
|
|
148
|
+
if (seconds < 3600)
|
|
149
|
+
return `~${Math.ceil(seconds / 60)} minutes (${seconds}s)`;
|
|
150
|
+
if (seconds < 2 * 86400) {
|
|
151
|
+
const hours = Math.ceil(seconds / 3600);
|
|
152
|
+
return `~${hours} hour${hours === 1 ? "" : "s"} (${seconds}s)`;
|
|
153
|
+
}
|
|
154
|
+
return `~${Math.ceil(seconds / 86400)} days (${seconds}s)`;
|
|
155
|
+
}
|
|
156
|
+
function rateLimitHint(rateLimitHeader, retryAfterHeader) {
|
|
157
|
+
const { windows, dropped } = parseExhaustedWindows(rateLimitHeader);
|
|
158
|
+
windows.sort((a, b) => (b.resetS ?? -1) - (a.resetS ?? -1));
|
|
159
|
+
const longestWindow = windows[0];
|
|
160
|
+
const waitCandidates = [
|
|
161
|
+
waitSeconds(retryAfterHeader),
|
|
162
|
+
longestWindow?.resetS
|
|
163
|
+
].filter((n) => typeof n === "number" && n > 0);
|
|
164
|
+
const waitS = waitCandidates.length ? Math.max(...waitCandidates) : null;
|
|
165
|
+
const retryAfterUnreadable = typeof retryAfterHeader === "string" && retryAfterHeader.trim() !== "" && waitSeconds(retryAfterHeader) === null;
|
|
166
|
+
if (!longestWindow && waitS === null) {
|
|
167
|
+
if (!retryAfterUnreadable) return GENERIC_RATE_LIMIT_HINT;
|
|
168
|
+
}
|
|
169
|
+
const namedClause = longestWindow?.window ? `the ${longestWindow.window} quota is exhausted` : "";
|
|
170
|
+
if (waitS === null) {
|
|
171
|
+
const cause = namedClause ? `${namedClause}, but the response gave no usable reset time` : "the response gave no usable reset time";
|
|
172
|
+
return `rate limited \u2014 ${cause}; back off substantially before retrying, and pace bulk operations`;
|
|
173
|
+
}
|
|
174
|
+
const hedge = dropped || retryAfterUnreadable || windows.some((w) => w.resetS === null) ? "at least " : "";
|
|
175
|
+
const wait = `wait ${hedge}${humanWait(waitS)} before retrying, and pace bulk operations`;
|
|
176
|
+
return `rate limited \u2014 ${namedClause ? `${namedClause}; ` : ""}${wait}`;
|
|
177
|
+
}
|
|
178
|
+
|
|
41
179
|
// src/_shared/http.ts
|
|
180
|
+
var EXPIRED_CREDENTIAL_HINT = "the Runpod API rejected the credential \u2014 the API key may be expired or revoked; re-authenticate or update RUNPOD_API_KEY";
|
|
42
181
|
var HttpError = class extends Error {
|
|
43
|
-
constructor(prefix, status, body) {
|
|
44
|
-
const
|
|
45
|
-
super(`${prefix}: ${status} - ${
|
|
182
|
+
constructor(prefix, status, body, hint) {
|
|
183
|
+
const shownBody = body.length > 2048 ? `${body.slice(0, 2048)}\u2026 [truncated ${body.length - 2048} chars]` : body;
|
|
184
|
+
super(`${prefix}: ${status} - ${shownBody}${hint ? ` (${hint})` : ""}`);
|
|
46
185
|
this.name = "HttpError";
|
|
47
186
|
this.status = status;
|
|
48
187
|
this.body = body;
|
|
@@ -77,7 +216,11 @@ function createHttpClient(deps) {
|
|
|
77
216
|
throw new HttpError(
|
|
78
217
|
deps.errorPrefix,
|
|
79
218
|
response.status,
|
|
80
|
-
await response.text()
|
|
219
|
+
await response.text(),
|
|
220
|
+
response.status === 429 ? rateLimitHint(
|
|
221
|
+
response.headers.get("ratelimit"),
|
|
222
|
+
response.headers.get("retry-after")
|
|
223
|
+
) : response.status === 401 ? EXPIRED_CREDENTIAL_HINT : void 0
|
|
81
224
|
);
|
|
82
225
|
}
|
|
83
226
|
return isJsonContentType(response.headers.get("content-type")) ? response.json() : { success: true, status: response.status };
|
|
@@ -136,7 +279,15 @@ async function readSseSnapshot(fetchImpl, url, headers, opts) {
|
|
|
136
279
|
throw new HttpError(
|
|
137
280
|
"Runpod API Error",
|
|
138
281
|
res.status,
|
|
139
|
-
await res.text().catch(() => "")
|
|
282
|
+
await res.text().catch(() => ""),
|
|
283
|
+
// This throw bypasses createHttpClient, so the status hints are built
|
|
284
|
+
// here too or these two tools alone return a bare 429/401. The 401
|
|
285
|
+
// hint applies: this request always carries Authorization (see the
|
|
286
|
+
// headers bound in runtime.ts streamSse).
|
|
287
|
+
res.status === 429 ? rateLimitHint(
|
|
288
|
+
res.headers.get("ratelimit"),
|
|
289
|
+
res.headers.get("retry-after")
|
|
290
|
+
) : res.status === 401 ? EXPIRED_CREDENTIAL_HINT : void 0
|
|
140
291
|
);
|
|
141
292
|
}
|
|
142
293
|
for await (const chunk of res.body ?? []) {
|
|
@@ -395,7 +546,7 @@ function restV1Base(env) {
|
|
|
395
546
|
return env.RUNPOD_REST_API_URL ?? "https://rest.runpod.io/v1";
|
|
396
547
|
}
|
|
397
548
|
function restV2Base(env) {
|
|
398
|
-
return env.RUNPOD_REST_V2_API_URL ?? "https://
|
|
549
|
+
return env.RUNPOD_REST_V2_API_URL ?? "https://api.runpod.io/v2";
|
|
399
550
|
}
|
|
400
551
|
function serverlessBase(env) {
|
|
401
552
|
return env.RUNPOD_SERVERLESS_API_URL ?? "https://api.runpod.ai/v2";
|
|
@@ -558,7 +709,7 @@ function resolveBackend(opts) {
|
|
|
558
709
|
}
|
|
559
710
|
|
|
560
711
|
// src/tools/runtime.ts
|
|
561
|
-
var MCP_SERVER_VERSION = true ? "3.
|
|
712
|
+
var MCP_SERVER_VERSION = true ? "3.2.0" : "dev";
|
|
562
713
|
var SESSION_ID = (0, import_node_crypto.randomUUID)();
|
|
563
714
|
function trackingHeaders(server, ctx) {
|
|
564
715
|
const info = server.server.getClientVersion();
|
|
@@ -608,6 +759,36 @@ async function graphqlRequest(query, tracking, fetchImpl, url, options) {
|
|
|
608
759
|
...options?.variables ? { variables: options.variables } : {}
|
|
609
760
|
})
|
|
610
761
|
});
|
|
762
|
+
if (!response.ok) {
|
|
763
|
+
const bodyText = await response.text();
|
|
764
|
+
let gqlErrors;
|
|
765
|
+
try {
|
|
766
|
+
gqlErrors = JSON.parse(bodyText).errors;
|
|
767
|
+
} catch {
|
|
768
|
+
}
|
|
769
|
+
if (Array.isArray(gqlErrors) && gqlErrors.length > 0 && response.status !== 401 && response.status !== 429) {
|
|
770
|
+
throw new HttpError(
|
|
771
|
+
"Runpod GraphQL Error",
|
|
772
|
+
response.status,
|
|
773
|
+
gqlErrors.map((e) => String(e?.message ?? JSON.stringify(e))).join(", ")
|
|
774
|
+
);
|
|
775
|
+
}
|
|
776
|
+
throw new HttpError(
|
|
777
|
+
"Runpod GraphQL Error",
|
|
778
|
+
response.status,
|
|
779
|
+
bodyText,
|
|
780
|
+
response.status === 429 ? rateLimitHint(
|
|
781
|
+
response.headers.get("ratelimit"),
|
|
782
|
+
response.headers.get("retry-after")
|
|
783
|
+
) : (
|
|
784
|
+
// Only when this request actually carried the caller's API key: the
|
|
785
|
+
// public path sends no Authorization header, so a 401 from that
|
|
786
|
+
// host (WAF, misconfigured RUNPOD_PUBLIC_GRAPHQL_URL) says nothing
|
|
787
|
+
// about the credential — same rationale as observeUnauthorized.
|
|
788
|
+
response.status === 401 && options?.apiKey ? EXPIRED_CREDENTIAL_HINT : void 0
|
|
789
|
+
)
|
|
790
|
+
);
|
|
791
|
+
}
|
|
611
792
|
const result = await response.json();
|
|
612
793
|
if (result.errors && result.errors.length > 0) {
|
|
613
794
|
throw new Error(
|
|
@@ -1024,6 +1205,178 @@ function registerCatalogTools(server, rt) {
|
|
|
1024
1205
|
return jsonReply2(result);
|
|
1025
1206
|
}
|
|
1026
1207
|
);
|
|
1208
|
+
server.tool(
|
|
1209
|
+
"get-capacity",
|
|
1210
|
+
"GPU capacity across host CUDA versions, as a matrix. Use this to choose an endpoint's allowedCudaVersions/minCudaVersion (or diagnose/widen a capacity-starved one) and to distinguish capacity problems from compatibility problems. Default mode is one call returning, per GPU type, overall stock plus AVAILABLE/UNAVAILABLE per host-reported CUDA version. Pass cudaVersions to deep-probe instead: one stock lookup per listed version, returning graded stock (High/Medium/Low/Out) and the lowest on-demand price per version; a probe that fails transiently reports a per-version error instead of failing the call. Nothing is hidden by default \u2014 set includeUnavailable:false to drop GPUs with no stock on any listed version. Credential-free public catalog data; works on both v1 and v2 APIs. Stock is live, so page cursors can shift between calls. Note: the matrix reflects host-reported versions, but endpoint allowedCudaVersions only accepts values from the platform enum \u2014 check create-endpoint/update-endpoint for the accepted list.",
|
|
1211
|
+
{
|
|
1212
|
+
...listPaginationParams,
|
|
1213
|
+
cudaVersions: import_zod3.z.array(import_zod3.z.string().regex(/^\d{1,2}\.\d{1,2}$/)).min(1).max(12).optional().describe(
|
|
1214
|
+
'Deep-probe these host CUDA versions (e.g. ["12.8", "13.0"], max 12): one stock lookup per version returns graded stock and price. Omit for the single-call AVAILABLE/UNAVAILABLE matrix across all versions the fleet currently reports.'
|
|
1215
|
+
),
|
|
1216
|
+
includeUnavailable: import_zod3.z.boolean().optional().describe(
|
|
1217
|
+
'Out-of-stock GPUs are included by default (explicit "Out" cells / all-UNAVAILABLE rows, sorted last). Set false to hide GPUs with no stock on any listed version.'
|
|
1218
|
+
),
|
|
1219
|
+
gpuTypeIds: import_zod3.z.array(import_zod3.z.string()).optional().describe(
|
|
1220
|
+
"Filter to GPU types matching any of these ids or display names (case-insensitive substring, e.g. ['NVIDIA GeForce RTX 4090'] or ['4090', 'H200'])."
|
|
1221
|
+
),
|
|
1222
|
+
gpuCount: import_zod3.z.number().int().min(1).max(8).optional().describe("GPUs per worker/pod to check stock for (default 1)."),
|
|
1223
|
+
secureCloudOnly: import_zod3.z.boolean().optional().describe("Restrict the stock lookup to Secure Cloud hosts.")
|
|
1224
|
+
},
|
|
1225
|
+
{ title: "Get GPU capacity by CUDA version", ...READ_ONLY },
|
|
1226
|
+
async (params) => {
|
|
1227
|
+
const gpuCount = Math.min(
|
|
1228
|
+
8,
|
|
1229
|
+
Math.max(1, Math.floor(Number(params.gpuCount)) || 1)
|
|
1230
|
+
);
|
|
1231
|
+
const secureArg = params.secureCloudOnly ? ", secureCloud: true" : "";
|
|
1232
|
+
const filterTerms = (params.gpuTypeIds ?? []).filter((t) => typeof t === "string" && t.trim().length > 0).map((t) => t.toLowerCase());
|
|
1233
|
+
const matchesFilter = (gpu) => {
|
|
1234
|
+
if (filterTerms.length === 0) return true;
|
|
1235
|
+
const id = gpu.id.toLowerCase();
|
|
1236
|
+
const name = gpu.displayName.toLowerCase();
|
|
1237
|
+
return filterTerms.some(
|
|
1238
|
+
(term) => id.includes(term) || name.includes(term)
|
|
1239
|
+
);
|
|
1240
|
+
};
|
|
1241
|
+
const stockPriority = {
|
|
1242
|
+
High: 3,
|
|
1243
|
+
Medium: 2,
|
|
1244
|
+
Low: 1
|
|
1245
|
+
};
|
|
1246
|
+
if (!params.cudaVersions?.length) {
|
|
1247
|
+
const data = await graphql(`
|
|
1248
|
+
query {
|
|
1249
|
+
gpuTypes {
|
|
1250
|
+
id
|
|
1251
|
+
displayName
|
|
1252
|
+
memoryInGb
|
|
1253
|
+
secureCloud
|
|
1254
|
+
communityCloud
|
|
1255
|
+
lowestPrice(input: { gpuCount: ${gpuCount}${secureArg} }) {
|
|
1256
|
+
stockStatus
|
|
1257
|
+
uninterruptablePrice
|
|
1258
|
+
gpuTypeCudaVersions {
|
|
1259
|
+
cudaVersion
|
|
1260
|
+
availability
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
`);
|
|
1266
|
+
let rows2 = data.gpuTypes.filter((gpu) => gpu.id !== "unknown" && matchesFilter(gpu)).map((gpu) => {
|
|
1267
|
+
const cuda = {};
|
|
1268
|
+
for (const c of gpu.lowestPrice?.gpuTypeCudaVersions ?? []) {
|
|
1269
|
+
cuda[c.cudaVersion] = c.availability;
|
|
1270
|
+
}
|
|
1271
|
+
return {
|
|
1272
|
+
id: gpu.id,
|
|
1273
|
+
displayName: gpu.displayName,
|
|
1274
|
+
memoryGb: gpu.memoryInGb,
|
|
1275
|
+
secureCloud: gpu.secureCloud,
|
|
1276
|
+
communityCloud: gpu.communityCloud,
|
|
1277
|
+
stockStatus: gpu.lowestPrice?.stockStatus || "unavailable",
|
|
1278
|
+
pricePerHr: gpu.lowestPrice?.uninterruptablePrice ?? null,
|
|
1279
|
+
cudaVersions: cuda
|
|
1280
|
+
};
|
|
1281
|
+
});
|
|
1282
|
+
const availableCount = (r) => Object.values(r.cudaVersions).filter((a) => a === "AVAILABLE").length;
|
|
1283
|
+
if (params.includeUnavailable === false)
|
|
1284
|
+
rows2 = rows2.filter((r) => availableCount(r) > 0);
|
|
1285
|
+
rows2.sort((a, b) => {
|
|
1286
|
+
const diff = availableCount(b) - availableCount(a);
|
|
1287
|
+
if (diff !== 0) return diff;
|
|
1288
|
+
const stockDiff = (stockPriority[b.stockStatus] || 0) - (stockPriority[a.stockStatus] || 0);
|
|
1289
|
+
if (stockDiff !== 0) return stockDiff;
|
|
1290
|
+
return b.memoryGb - a.memoryGb;
|
|
1291
|
+
});
|
|
1292
|
+
return capListResult(rows2, {
|
|
1293
|
+
limit: params.limit,
|
|
1294
|
+
cursor: params.cursor
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
const versions = [...new Set(params.cudaVersions)].slice(0, 12);
|
|
1298
|
+
const invalid = versions.filter((v) => !/^\d{1,2}\.\d{1,2}$/.test(v));
|
|
1299
|
+
if (invalid.length > 0) {
|
|
1300
|
+
return jsonReply2({
|
|
1301
|
+
error: `Invalid CUDA version format: ${invalid.join(", ")}. Use "major.minor" strings like "12.8".`,
|
|
1302
|
+
status: 400
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
const perVersion = await Promise.allSettled(
|
|
1306
|
+
versions.map(
|
|
1307
|
+
(v) => graphql(`
|
|
1308
|
+
query {
|
|
1309
|
+
gpuTypes {
|
|
1310
|
+
id
|
|
1311
|
+
displayName
|
|
1312
|
+
memoryInGb
|
|
1313
|
+
secureCloud
|
|
1314
|
+
communityCloud
|
|
1315
|
+
lowestPrice(input: { gpuCount: ${gpuCount}, allowedCudaVersions: ["${v}"]${secureArg} }) {
|
|
1316
|
+
stockStatus
|
|
1317
|
+
uninterruptablePrice
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
`)
|
|
1322
|
+
)
|
|
1323
|
+
);
|
|
1324
|
+
const probeErrors = {};
|
|
1325
|
+
const byId = /* @__PURE__ */ new Map();
|
|
1326
|
+
versions.forEach((v, i) => {
|
|
1327
|
+
const settled = perVersion[i];
|
|
1328
|
+
if (settled.status === "rejected") {
|
|
1329
|
+
probeErrors[v] = settled.reason instanceof Error ? settled.reason.message : String(settled.reason);
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
for (const gpu of settled.value.gpuTypes) {
|
|
1333
|
+
if (gpu.id === "unknown" || !matchesFilter(gpu)) continue;
|
|
1334
|
+
let row = byId.get(gpu.id);
|
|
1335
|
+
if (!row) {
|
|
1336
|
+
row = {
|
|
1337
|
+
id: gpu.id,
|
|
1338
|
+
displayName: gpu.displayName,
|
|
1339
|
+
memoryGb: gpu.memoryInGb,
|
|
1340
|
+
secureCloud: gpu.secureCloud,
|
|
1341
|
+
communityCloud: gpu.communityCloud,
|
|
1342
|
+
cudaVersions: {}
|
|
1343
|
+
};
|
|
1344
|
+
byId.set(gpu.id, row);
|
|
1345
|
+
}
|
|
1346
|
+
const stock = gpu.lowestPrice?.stockStatus;
|
|
1347
|
+
row.cudaVersions[v] = !stock || stock === "Out" ? { stock: "Out", pricePerHr: null } : {
|
|
1348
|
+
stock,
|
|
1349
|
+
pricePerHr: gpu.lowestPrice?.uninterruptablePrice ?? null
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
});
|
|
1353
|
+
let rows = [...byId.values()];
|
|
1354
|
+
const inStockCount = (r) => Object.values(r.cudaVersions).filter((c) => c.stock !== "Out").length;
|
|
1355
|
+
if (params.includeUnavailable === false)
|
|
1356
|
+
rows = rows.filter((r) => inStockCount(r) > 0);
|
|
1357
|
+
rows.sort((a, b) => {
|
|
1358
|
+
const diff = inStockCount(b) - inStockCount(a);
|
|
1359
|
+
if (diff !== 0) return diff;
|
|
1360
|
+
const best = (r) => Math.max(
|
|
1361
|
+
0,
|
|
1362
|
+
...Object.values(r.cudaVersions).map(
|
|
1363
|
+
(c) => stockPriority[c.stock] || 0
|
|
1364
|
+
)
|
|
1365
|
+
);
|
|
1366
|
+
const bestDiff = best(b) - best(a);
|
|
1367
|
+
if (bestDiff !== 0) return bestDiff;
|
|
1368
|
+
return b.memoryGb - a.memoryGb;
|
|
1369
|
+
});
|
|
1370
|
+
return capListResult(
|
|
1371
|
+
rows,
|
|
1372
|
+
{ limit: params.limit, cursor: params.cursor },
|
|
1373
|
+
{
|
|
1374
|
+
probedCudaVersions: versions,
|
|
1375
|
+
...Object.keys(probeErrors).length > 0 ? { probeErrors } : {}
|
|
1376
|
+
}
|
|
1377
|
+
);
|
|
1378
|
+
}
|
|
1379
|
+
);
|
|
1027
1380
|
server.tool(
|
|
1028
1381
|
"get-data-center",
|
|
1029
1382
|
"Get details for a single data center by id. v2-only \u2014 returns a 501 notice on the v1 API (use list-data-centers there).",
|
|
@@ -1708,7 +2061,9 @@ function registerPodTools(server, rt) {
|
|
|
1708
2061
|
"create-pod",
|
|
1709
2062
|
'Create a new GPU/CPU pod on Runpod. Pass gpuTypeIds for a GPU pod, or computeType:"CPU" for a CPU pod (CPU pods are served by the v1 API for now). Pass either imageName or templateId (templateId deploys from an existing template \u2014 its name, image, start command, ports, env, disk, volume, and registry credential are used as defaults, and any field you also pass explicitly replaces the template value for that field, e.g. passing env replaces the whole env set rather than merging; pass containerRegistryAuthId to override or supply a private-image credential, or an empty string to deploy with none). If the user specifies neither an image nor a template, recommend the "Runpod Pytorch 2.8.0" image (runpod/pytorch:1.0.2-cu1281-torch280-ubuntu2404) as the default \u2014 it has the most up-to-date CUDA and PyTorch versions.',
|
|
1710
2063
|
{
|
|
1711
|
-
name: import_zod7.z.string().optional().describe(
|
|
2064
|
+
name: import_zod7.z.string().optional().describe(
|
|
2065
|
+
"Name for the pod. Required on v2 unless deploying from a templateId (the template supplies its name as the default)."
|
|
2066
|
+
),
|
|
1712
2067
|
imageName: import_zod7.z.string().optional().describe("Docker image to use. Optional when templateId is provided."),
|
|
1713
2068
|
templateId: import_zod7.z.string().optional().describe(
|
|
1714
2069
|
"Deploy from an existing template (see list-templates / get-template). The template supplies name, image, start command, ports, env, disk, volume, and registry credential as defaults; any field you also pass replaces the template value for that field (whole-field, not a merge). Override the registry credential with containerRegistryAuthId. Requires the v2 REST API. Still pass gpuTypeIds or computeType to choose the compute \u2014 a template does not pin the pod compute."
|
|
@@ -1767,6 +2122,12 @@ function registerPodTools(server, rt) {
|
|
|
1767
2122
|
status: 400
|
|
1768
2123
|
});
|
|
1769
2124
|
}
|
|
2125
|
+
if (!wantsCpu && !params.name && !params.templateId) {
|
|
2126
|
+
return jsonReply2({
|
|
2127
|
+
error: "Provide a name for the pod (deploying from a templateId inherits the template name).",
|
|
2128
|
+
status: 400
|
|
2129
|
+
});
|
|
2130
|
+
}
|
|
1770
2131
|
if (wantsCpu) {
|
|
1771
2132
|
if (params.templateId) {
|
|
1772
2133
|
return jsonReply2({
|