@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/dist/stdio.cjs CHANGED
@@ -646,7 +646,7 @@ function restV1Base(env) {
646
646
  return env.RUNPOD_REST_API_URL ?? "https://rest.runpod.io/v1";
647
647
  }
648
648
  function restV2Base(env) {
649
- return env.RUNPOD_REST_V2_API_URL ?? "https://v2-rest.runpod.io/v2";
649
+ return env.RUNPOD_REST_V2_API_URL ?? "https://api.runpod.io/v2";
650
650
  }
651
651
  function serverlessBase(env) {
652
652
  return env.RUNPOD_SERVERLESS_API_URL ?? "https://api.runpod.ai/v2";
@@ -868,27 +868,176 @@ function resolveBackend(opts) {
868
868
 
869
869
  // src/server.ts
870
870
  var SERVER_NAME = "Runpod API Server";
871
- var SERVER_VERSION = true ? "3.1.0" : "dev";
871
+ var SERVER_VERSION = true ? "3.2.0" : "dev";
872
+ var SERVER_INSTRUCTIONS = `These tools cover common Runpod operations, but they are curated projections: the underlying APIs expose more fields and parameters than the tools surface.
873
+
874
+ When you need data or capability beyond these tools, consult the full API contracts directly. The REST v2 API lives at https://api.runpod.io/v2 \u2014 the same host these tools call \u2014 and is machine-readable at https://api.runpod.io/v2/openapi.json (fetch and search it to enumerate every path, parameter, and response schema). REST v1 at https://rest.runpod.io/v1 is deprecated; prefer v2. The REST version these tools are actually configured for is reported in the serverInfo.version string of the initialize response, e.g. "[RUNPOD_REST_VERSION=v2]". The GraphQL API at https://api.runpod.io/graphql may expose data the REST API does not yet cover; its schema is documented at https://graphql-spec.runpod.io/, and introspection is disabled in production, so use that reference rather than __schema queries. Both APIs take Bearer auth with a Runpod API key: use the key this client is already configured with \u2014 do not search the environment or filesystem for a credential.`;
872
875
  function createServer(version = SERVER_VERSION) {
873
- return new import_mcp.McpServer({
874
- name: SERVER_NAME,
875
- version: `${version} [${restVersionSummary(process.env)}]`,
876
- capabilities: {
877
- resources: {},
878
- tools: {}
876
+ return new import_mcp.McpServer(
877
+ {
878
+ name: SERVER_NAME,
879
+ version: `${version} [${restVersionSummary(process.env)}]`
880
+ },
881
+ {
882
+ // Only advertise capabilities the server implements. It registers
883
+ // tools and no resources — advertising `resources` would invite
884
+ // `resources/list` calls that answer -32601.
885
+ capabilities: {
886
+ tools: {}
887
+ },
888
+ instructions: SERVER_INSTRUCTIONS
879
889
  }
880
- });
890
+ );
881
891
  }
882
892
 
883
893
  // src/tools/runtime.ts
884
894
  var import_node_fetch = __toESM(require("node-fetch"), 1);
885
895
  var import_node_crypto = require("crypto");
886
896
 
897
+ // src/_shared/rate-limit.ts
898
+ var GENERIC_RATE_LIMIT_HINT = "rate limited \u2014 back off before retrying, and pace bulk operations";
899
+ var MAX_PLAUSIBLE_WAIT_S = 7 * 86400;
900
+ function remainingRequests(raw) {
901
+ const value = raw?.trim();
902
+ return value && /^\d+$/.test(value) ? Number(value) : null;
903
+ }
904
+ function waitSeconds(raw) {
905
+ const value = raw?.trim();
906
+ if (!value || !/^\d+$/.test(value)) return null;
907
+ const seconds = Number(value);
908
+ return seconds <= MAX_PLAUSIBLE_WAIT_S ? seconds : null;
909
+ }
910
+ var WINDOW_NAME_RE = /^(?:"([\x20-\x21\x23-\x5b\x5d-\x7e]{1,32})"|([A-Za-z*][A-Za-z0-9!#$%&'*+.^_`|~:/-]{0,31}))$/;
911
+ function windowName(raw) {
912
+ const match = WINDOW_NAME_RE.exec(raw.trim());
913
+ return match ? match[1] ?? match[2] : null;
914
+ }
915
+ var QUOTED_VALUE_RE = /^"(?:[\x20-\x21\x23-\x5b\x5d-\x7e]|\\["\\])*"$/;
916
+ var DISPLAY_VALUE_RE = /^%"(?:[\x20-\x21\x23-\x24\x26-\x5b\x5d-\x7e]|\\|%[0-9a-f]{2})*"$/;
917
+ function isWellFormedParam(param) {
918
+ const eq = param.indexOf("=");
919
+ const key = (eq === -1 ? param : param.slice(0, eq)).trim();
920
+ if (key.includes('"')) return false;
921
+ if (eq === -1) return true;
922
+ const value = param.slice(eq + 1).trim();
923
+ if (value.startsWith('"')) return QUOTED_VALUE_RE.test(value);
924
+ if (value.startsWith('%"')) return DISPLAY_VALUE_RE.test(value);
925
+ return !/[\s"]/.test(value);
926
+ }
927
+ function splitOutsideStrings(input, sep) {
928
+ const parts = [];
929
+ let current = "";
930
+ let inString = false;
931
+ let inDisplay = false;
932
+ let escaped = false;
933
+ let prev = "";
934
+ for (const ch of input) {
935
+ if (escaped) escaped = false;
936
+ else if (inString && !inDisplay && ch === "\\") escaped = true;
937
+ else if (ch === '"') {
938
+ if (!inString) inDisplay = prev === "%";
939
+ inString = !inString;
940
+ } else if (ch === sep && !inString) {
941
+ parts.push(current);
942
+ current = "";
943
+ prev = ch;
944
+ continue;
945
+ }
946
+ current += ch;
947
+ prev = ch;
948
+ }
949
+ parts.push(current);
950
+ return parts;
951
+ }
952
+ function readParams(params) {
953
+ const values = /* @__PURE__ */ new Map();
954
+ let unreadable = false;
955
+ let valuelessAt = -1;
956
+ for (const [index, param] of params.entries()) {
957
+ const eq = param.indexOf("=");
958
+ const key = (eq === -1 ? param : param.slice(0, eq)).trim().toLowerCase();
959
+ if (!key) continue;
960
+ if (eq === -1) {
961
+ if (key === "r") unreadable = true;
962
+ if (key === "t") values.delete("t");
963
+ valuelessAt = index;
964
+ continue;
965
+ }
966
+ if ((key === "r" || key === "t") && (values.has(key) || valuelessAt !== -1 && index > valuelessAt)) {
967
+ unreadable = true;
968
+ }
969
+ values.set(key, param.slice(eq + 1));
970
+ }
971
+ return { values, unreadable };
972
+ }
973
+ function parseExhaustedWindows(header) {
974
+ if (!header) return { windows: [], dropped: false };
975
+ const windows = [];
976
+ let dropped = false;
977
+ for (const item of splitOutsideStrings(header, ",")) {
978
+ if (item.trim() === "") continue;
979
+ const [rawName, ...params] = splitOutsideStrings(item, ";");
980
+ if (!params.every(isWellFormedParam)) {
981
+ dropped = true;
982
+ continue;
983
+ }
984
+ const { values, unreadable } = readParams(params);
985
+ if (unreadable) {
986
+ dropped = true;
987
+ continue;
988
+ }
989
+ const remaining = remainingRequests(values.get("r"));
990
+ if (remaining === null) {
991
+ dropped = true;
992
+ continue;
993
+ }
994
+ if (remaining !== 0) continue;
995
+ windows.push({
996
+ window: windowName(rawName),
997
+ resetS: waitSeconds(values.get("t"))
998
+ });
999
+ }
1000
+ return { windows, dropped };
1001
+ }
1002
+ function humanWait(seconds) {
1003
+ if (seconds < 120) return `~${seconds}s`;
1004
+ if (seconds < 3600)
1005
+ return `~${Math.ceil(seconds / 60)} minutes (${seconds}s)`;
1006
+ if (seconds < 2 * 86400) {
1007
+ const hours = Math.ceil(seconds / 3600);
1008
+ return `~${hours} hour${hours === 1 ? "" : "s"} (${seconds}s)`;
1009
+ }
1010
+ return `~${Math.ceil(seconds / 86400)} days (${seconds}s)`;
1011
+ }
1012
+ function rateLimitHint(rateLimitHeader, retryAfterHeader) {
1013
+ const { windows, dropped } = parseExhaustedWindows(rateLimitHeader);
1014
+ windows.sort((a, b) => (b.resetS ?? -1) - (a.resetS ?? -1));
1015
+ const longestWindow = windows[0];
1016
+ const waitCandidates = [
1017
+ waitSeconds(retryAfterHeader),
1018
+ longestWindow?.resetS
1019
+ ].filter((n) => typeof n === "number" && n > 0);
1020
+ const waitS = waitCandidates.length ? Math.max(...waitCandidates) : null;
1021
+ const retryAfterUnreadable = typeof retryAfterHeader === "string" && retryAfterHeader.trim() !== "" && waitSeconds(retryAfterHeader) === null;
1022
+ if (!longestWindow && waitS === null) {
1023
+ if (!retryAfterUnreadable) return GENERIC_RATE_LIMIT_HINT;
1024
+ }
1025
+ const namedClause = longestWindow?.window ? `the ${longestWindow.window} quota is exhausted` : "";
1026
+ if (waitS === null) {
1027
+ const cause = namedClause ? `${namedClause}, but the response gave no usable reset time` : "the response gave no usable reset time";
1028
+ return `rate limited \u2014 ${cause}; back off substantially before retrying, and pace bulk operations`;
1029
+ }
1030
+ const hedge = dropped || retryAfterUnreadable || windows.some((w) => w.resetS === null) ? "at least " : "";
1031
+ const wait = `wait ${hedge}${humanWait(waitS)} before retrying, and pace bulk operations`;
1032
+ return `rate limited \u2014 ${namedClause ? `${namedClause}; ` : ""}${wait}`;
1033
+ }
1034
+
887
1035
  // src/_shared/http.ts
1036
+ 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";
888
1037
  var HttpError = class extends Error {
889
- constructor(prefix, status, body) {
890
- const hint = status === 401 ? " (the Runpod API rejected the credential \u2014 the API key may be expired or revoked; re-authenticate or update RUNPOD_API_KEY)" : "";
891
- super(`${prefix}: ${status} - ${body}${hint}`);
1038
+ constructor(prefix, status, body, hint) {
1039
+ const shownBody = body.length > 2048 ? `${body.slice(0, 2048)}\u2026 [truncated ${body.length - 2048} chars]` : body;
1040
+ super(`${prefix}: ${status} - ${shownBody}${hint ? ` (${hint})` : ""}`);
892
1041
  this.name = "HttpError";
893
1042
  this.status = status;
894
1043
  this.body = body;
@@ -923,7 +1072,11 @@ function createHttpClient(deps) {
923
1072
  throw new HttpError(
924
1073
  deps.errorPrefix,
925
1074
  response.status,
926
- await response.text()
1075
+ await response.text(),
1076
+ response.status === 429 ? rateLimitHint(
1077
+ response.headers.get("ratelimit"),
1078
+ response.headers.get("retry-after")
1079
+ ) : response.status === 401 ? EXPIRED_CREDENTIAL_HINT : void 0
927
1080
  );
928
1081
  }
929
1082
  return isJsonContentType(response.headers.get("content-type")) ? response.json() : { success: true, status: response.status };
@@ -982,7 +1135,15 @@ async function readSseSnapshot(fetchImpl, url, headers, opts) {
982
1135
  throw new HttpError(
983
1136
  "Runpod API Error",
984
1137
  res.status,
985
- await res.text().catch(() => "")
1138
+ await res.text().catch(() => ""),
1139
+ // This throw bypasses createHttpClient, so the status hints are built
1140
+ // here too or these two tools alone return a bare 429/401. The 401
1141
+ // hint applies: this request always carries Authorization (see the
1142
+ // headers bound in runtime.ts streamSse).
1143
+ res.status === 429 ? rateLimitHint(
1144
+ res.headers.get("ratelimit"),
1145
+ res.headers.get("retry-after")
1146
+ ) : res.status === 401 ? EXPIRED_CREDENTIAL_HINT : void 0
986
1147
  );
987
1148
  }
988
1149
  for await (const chunk of res.body ?? []) {
@@ -1045,7 +1206,7 @@ async function streamLogsReply(rt, tool, params) {
1045
1206
  }
1046
1207
 
1047
1208
  // src/tools/runtime.ts
1048
- var MCP_SERVER_VERSION = true ? "3.1.0" : "dev";
1209
+ var MCP_SERVER_VERSION = true ? "3.2.0" : "dev";
1049
1210
  var SESSION_ID = (0, import_node_crypto.randomUUID)();
1050
1211
  function trackingHeaders(server, ctx) {
1051
1212
  const info = server.server.getClientVersion();
@@ -1095,6 +1256,36 @@ async function graphqlRequest(query, tracking, fetchImpl, url, options) {
1095
1256
  ...options?.variables ? { variables: options.variables } : {}
1096
1257
  })
1097
1258
  });
1259
+ if (!response.ok) {
1260
+ const bodyText = await response.text();
1261
+ let gqlErrors;
1262
+ try {
1263
+ gqlErrors = JSON.parse(bodyText).errors;
1264
+ } catch {
1265
+ }
1266
+ if (Array.isArray(gqlErrors) && gqlErrors.length > 0 && response.status !== 401 && response.status !== 429) {
1267
+ throw new HttpError(
1268
+ "Runpod GraphQL Error",
1269
+ response.status,
1270
+ gqlErrors.map((e) => String(e?.message ?? JSON.stringify(e))).join(", ")
1271
+ );
1272
+ }
1273
+ throw new HttpError(
1274
+ "Runpod GraphQL Error",
1275
+ response.status,
1276
+ bodyText,
1277
+ response.status === 429 ? rateLimitHint(
1278
+ response.headers.get("ratelimit"),
1279
+ response.headers.get("retry-after")
1280
+ ) : (
1281
+ // Only when this request actually carried the caller's API key: the
1282
+ // public path sends no Authorization header, so a 401 from that
1283
+ // host (WAF, misconfigured RUNPOD_PUBLIC_GRAPHQL_URL) says nothing
1284
+ // about the credential — same rationale as observeUnauthorized.
1285
+ response.status === 401 && options?.apiKey ? EXPIRED_CREDENTIAL_HINT : void 0
1286
+ )
1287
+ );
1288
+ }
1098
1289
  const result = await response.json();
1099
1290
  if (result.errors && result.errors.length > 0) {
1100
1291
  throw new Error(
@@ -1511,6 +1702,178 @@ function registerCatalogTools(server, rt) {
1511
1702
  return jsonReply2(result);
1512
1703
  }
1513
1704
  );
1705
+ server.tool(
1706
+ "get-capacity",
1707
+ "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.",
1708
+ {
1709
+ ...listPaginationParams,
1710
+ cudaVersions: import_zod3.z.array(import_zod3.z.string().regex(/^\d{1,2}\.\d{1,2}$/)).min(1).max(12).optional().describe(
1711
+ '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.'
1712
+ ),
1713
+ includeUnavailable: import_zod3.z.boolean().optional().describe(
1714
+ '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.'
1715
+ ),
1716
+ gpuTypeIds: import_zod3.z.array(import_zod3.z.string()).optional().describe(
1717
+ "Filter to GPU types matching any of these ids or display names (case-insensitive substring, e.g. ['NVIDIA GeForce RTX 4090'] or ['4090', 'H200'])."
1718
+ ),
1719
+ gpuCount: import_zod3.z.number().int().min(1).max(8).optional().describe("GPUs per worker/pod to check stock for (default 1)."),
1720
+ secureCloudOnly: import_zod3.z.boolean().optional().describe("Restrict the stock lookup to Secure Cloud hosts.")
1721
+ },
1722
+ { title: "Get GPU capacity by CUDA version", ...READ_ONLY },
1723
+ async (params) => {
1724
+ const gpuCount = Math.min(
1725
+ 8,
1726
+ Math.max(1, Math.floor(Number(params.gpuCount)) || 1)
1727
+ );
1728
+ const secureArg = params.secureCloudOnly ? ", secureCloud: true" : "";
1729
+ const filterTerms = (params.gpuTypeIds ?? []).filter((t) => typeof t === "string" && t.trim().length > 0).map((t) => t.toLowerCase());
1730
+ const matchesFilter = (gpu) => {
1731
+ if (filterTerms.length === 0) return true;
1732
+ const id = gpu.id.toLowerCase();
1733
+ const name = gpu.displayName.toLowerCase();
1734
+ return filterTerms.some(
1735
+ (term) => id.includes(term) || name.includes(term)
1736
+ );
1737
+ };
1738
+ const stockPriority = {
1739
+ High: 3,
1740
+ Medium: 2,
1741
+ Low: 1
1742
+ };
1743
+ if (!params.cudaVersions?.length) {
1744
+ const data = await graphql(`
1745
+ query {
1746
+ gpuTypes {
1747
+ id
1748
+ displayName
1749
+ memoryInGb
1750
+ secureCloud
1751
+ communityCloud
1752
+ lowestPrice(input: { gpuCount: ${gpuCount}${secureArg} }) {
1753
+ stockStatus
1754
+ uninterruptablePrice
1755
+ gpuTypeCudaVersions {
1756
+ cudaVersion
1757
+ availability
1758
+ }
1759
+ }
1760
+ }
1761
+ }
1762
+ `);
1763
+ let rows2 = data.gpuTypes.filter((gpu) => gpu.id !== "unknown" && matchesFilter(gpu)).map((gpu) => {
1764
+ const cuda = {};
1765
+ for (const c of gpu.lowestPrice?.gpuTypeCudaVersions ?? []) {
1766
+ cuda[c.cudaVersion] = c.availability;
1767
+ }
1768
+ return {
1769
+ id: gpu.id,
1770
+ displayName: gpu.displayName,
1771
+ memoryGb: gpu.memoryInGb,
1772
+ secureCloud: gpu.secureCloud,
1773
+ communityCloud: gpu.communityCloud,
1774
+ stockStatus: gpu.lowestPrice?.stockStatus || "unavailable",
1775
+ pricePerHr: gpu.lowestPrice?.uninterruptablePrice ?? null,
1776
+ cudaVersions: cuda
1777
+ };
1778
+ });
1779
+ const availableCount = (r) => Object.values(r.cudaVersions).filter((a) => a === "AVAILABLE").length;
1780
+ if (params.includeUnavailable === false)
1781
+ rows2 = rows2.filter((r) => availableCount(r) > 0);
1782
+ rows2.sort((a, b) => {
1783
+ const diff = availableCount(b) - availableCount(a);
1784
+ if (diff !== 0) return diff;
1785
+ const stockDiff = (stockPriority[b.stockStatus] || 0) - (stockPriority[a.stockStatus] || 0);
1786
+ if (stockDiff !== 0) return stockDiff;
1787
+ return b.memoryGb - a.memoryGb;
1788
+ });
1789
+ return capListResult(rows2, {
1790
+ limit: params.limit,
1791
+ cursor: params.cursor
1792
+ });
1793
+ }
1794
+ const versions = [...new Set(params.cudaVersions)].slice(0, 12);
1795
+ const invalid = versions.filter((v) => !/^\d{1,2}\.\d{1,2}$/.test(v));
1796
+ if (invalid.length > 0) {
1797
+ return jsonReply2({
1798
+ error: `Invalid CUDA version format: ${invalid.join(", ")}. Use "major.minor" strings like "12.8".`,
1799
+ status: 400
1800
+ });
1801
+ }
1802
+ const perVersion = await Promise.allSettled(
1803
+ versions.map(
1804
+ (v) => graphql(`
1805
+ query {
1806
+ gpuTypes {
1807
+ id
1808
+ displayName
1809
+ memoryInGb
1810
+ secureCloud
1811
+ communityCloud
1812
+ lowestPrice(input: { gpuCount: ${gpuCount}, allowedCudaVersions: ["${v}"]${secureArg} }) {
1813
+ stockStatus
1814
+ uninterruptablePrice
1815
+ }
1816
+ }
1817
+ }
1818
+ `)
1819
+ )
1820
+ );
1821
+ const probeErrors = {};
1822
+ const byId = /* @__PURE__ */ new Map();
1823
+ versions.forEach((v, i) => {
1824
+ const settled = perVersion[i];
1825
+ if (settled.status === "rejected") {
1826
+ probeErrors[v] = settled.reason instanceof Error ? settled.reason.message : String(settled.reason);
1827
+ return;
1828
+ }
1829
+ for (const gpu of settled.value.gpuTypes) {
1830
+ if (gpu.id === "unknown" || !matchesFilter(gpu)) continue;
1831
+ let row = byId.get(gpu.id);
1832
+ if (!row) {
1833
+ row = {
1834
+ id: gpu.id,
1835
+ displayName: gpu.displayName,
1836
+ memoryGb: gpu.memoryInGb,
1837
+ secureCloud: gpu.secureCloud,
1838
+ communityCloud: gpu.communityCloud,
1839
+ cudaVersions: {}
1840
+ };
1841
+ byId.set(gpu.id, row);
1842
+ }
1843
+ const stock = gpu.lowestPrice?.stockStatus;
1844
+ row.cudaVersions[v] = !stock || stock === "Out" ? { stock: "Out", pricePerHr: null } : {
1845
+ stock,
1846
+ pricePerHr: gpu.lowestPrice?.uninterruptablePrice ?? null
1847
+ };
1848
+ }
1849
+ });
1850
+ let rows = [...byId.values()];
1851
+ const inStockCount = (r) => Object.values(r.cudaVersions).filter((c) => c.stock !== "Out").length;
1852
+ if (params.includeUnavailable === false)
1853
+ rows = rows.filter((r) => inStockCount(r) > 0);
1854
+ rows.sort((a, b) => {
1855
+ const diff = inStockCount(b) - inStockCount(a);
1856
+ if (diff !== 0) return diff;
1857
+ const best = (r) => Math.max(
1858
+ 0,
1859
+ ...Object.values(r.cudaVersions).map(
1860
+ (c) => stockPriority[c.stock] || 0
1861
+ )
1862
+ );
1863
+ const bestDiff = best(b) - best(a);
1864
+ if (bestDiff !== 0) return bestDiff;
1865
+ return b.memoryGb - a.memoryGb;
1866
+ });
1867
+ return capListResult(
1868
+ rows,
1869
+ { limit: params.limit, cursor: params.cursor },
1870
+ {
1871
+ probedCudaVersions: versions,
1872
+ ...Object.keys(probeErrors).length > 0 ? { probeErrors } : {}
1873
+ }
1874
+ );
1875
+ }
1876
+ );
1514
1877
  server.tool(
1515
1878
  "get-data-center",
1516
1879
  "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).",
@@ -2195,7 +2558,9 @@ function registerPodTools(server, rt) {
2195
2558
  "create-pod",
2196
2559
  '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.',
2197
2560
  {
2198
- name: import_zod7.z.string().optional().describe("Name for the pod"),
2561
+ name: import_zod7.z.string().optional().describe(
2562
+ "Name for the pod. Required on v2 unless deploying from a templateId (the template supplies its name as the default)."
2563
+ ),
2199
2564
  imageName: import_zod7.z.string().optional().describe("Docker image to use. Optional when templateId is provided."),
2200
2565
  templateId: import_zod7.z.string().optional().describe(
2201
2566
  "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."
@@ -2254,6 +2619,12 @@ function registerPodTools(server, rt) {
2254
2619
  status: 400
2255
2620
  });
2256
2621
  }
2622
+ if (!wantsCpu && !params.name && !params.templateId) {
2623
+ return jsonReply2({
2624
+ error: "Provide a name for the pod (deploying from a templateId inherits the template name).",
2625
+ status: 400
2626
+ });
2627
+ }
2257
2628
  if (wantsCpu) {
2258
2629
  if (params.templateId) {
2259
2630
  return jsonReply2({