@runpod/mcp-server 3.3.0 → 3.4.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.mjs CHANGED
@@ -31,10 +31,15 @@ function containerConfigToV2(p) {
31
31
  mounts: persistentMount(p.volumeInGb, p.volumeMountPath)
32
32
  });
33
33
  }
34
- function gpuConfigToV2(gpuTypeIds, gpuCount) {
34
+ function gpuConfigToV2(gpuTypeIds, gpuCount, allowedCudaVersions, minCudaVersion2) {
35
35
  const id = gpuTypeIds?.[0];
36
36
  if (id === void 0) return void 0;
37
- return { id, count: gpuCount ?? 1 };
37
+ return compact({
38
+ id,
39
+ count: gpuCount ?? 1,
40
+ allowedCudaVersions,
41
+ minCudaVersion: minCudaVersion2
42
+ });
38
43
  }
39
44
  function mapPodCreateToV2(params) {
40
45
  return compact({
@@ -55,7 +60,12 @@ function mapPodCreateToV2(params) {
55
60
  // singular on v2 (`gpu.id`): gpuConfigToV2 takes the first id; the
56
61
  // create-pod handler warns when more than one gpuTypeId was supplied.
57
62
  dataCenterIds: params.dataCenterIds?.length ? params.dataCenterIds : void 0,
58
- gpu: gpuConfigToV2(params.gpuTypeIds, params.gpuCount)
63
+ gpu: gpuConfigToV2(
64
+ params.gpuTypeIds,
65
+ params.gpuCount,
66
+ params.allowedCudaVersions,
67
+ params.minCudaVersion
68
+ )
59
69
  });
60
70
  }
61
71
  function mapPodUpdateToV2(params) {
@@ -72,9 +82,15 @@ function defaultScalerType(endpointType) {
72
82
  function endpointScaling(scalerType, value) {
73
83
  return scalerType === "REQUEST_COUNT" ? { type: "REQUEST_COUNT", requestCount: value } : { type: "QUEUE_DELAY", queueDelay: value };
74
84
  }
75
- function endpointGpuConfig(pools, count) {
76
- if (!pools?.length) return void 0;
77
- return compact({ pools, count });
85
+ function endpointGpuConfig(params, mode) {
86
+ const gpu = compact({
87
+ pools: params.gpuPoolIds?.length ? params.gpuPoolIds : void 0,
88
+ count: params.gpuCount,
89
+ allowedCudaVersions: params.allowedCudaVersions,
90
+ minCudaVersion: params.minCudaVersion
91
+ });
92
+ if (mode === "create" && !("pools" in gpu)) return void 0;
93
+ return Object.keys(gpu).length ? gpu : void 0;
78
94
  }
79
95
  function endpointWorkers(params) {
80
96
  const workers = compact({
@@ -84,7 +100,7 @@ function endpointWorkers(params) {
84
100
  });
85
101
  return Object.keys(workers).length ? workers : void 0;
86
102
  }
87
- function endpointCommonToV2(params) {
103
+ function endpointCommonToV2(params, mode) {
88
104
  return compact({
89
105
  name: params.name,
90
106
  image: params.imageName,
@@ -93,7 +109,7 @@ function endpointCommonToV2(params) {
93
109
  ports: params.ports,
94
110
  env: params.env,
95
111
  registry: params.containerRegistryAuthId,
96
- gpu: endpointGpuConfig(params.gpuPoolIds, params.gpuCount),
112
+ gpu: endpointGpuConfig(params, mode),
97
113
  workers: endpointWorkers(params),
98
114
  dataCenterIds: params.dataCenterIds?.length ? params.dataCenterIds : void 0,
99
115
  networkVolumes: params.networkVolumeIds?.length ? params.networkVolumeIds : void 0,
@@ -104,7 +120,7 @@ function endpointCommonToV2(params) {
104
120
  function mapEndpointCreateToV2(params) {
105
121
  const endpointType = params.endpointType ?? DEFAULT_ENDPOINT_TYPE;
106
122
  return compact({
107
- ...endpointCommonToV2(params),
123
+ ...endpointCommonToV2(params, "create"),
108
124
  type: endpointType,
109
125
  scaling: endpointScaling(
110
126
  params.scalerType ?? defaultScalerType(endpointType),
@@ -114,13 +130,28 @@ function mapEndpointCreateToV2(params) {
114
130
  }
115
131
  function mapEndpointUpdateToV2(params) {
116
132
  return compact({
117
- ...endpointCommonToV2(params),
133
+ ...endpointCommonToV2(params, "update"),
118
134
  scaling: params.scalerType ? endpointScaling(
119
135
  params.scalerType,
120
136
  params.scalerValue ?? DEFAULT_SCALER_VALUE
121
137
  ) : void 0
122
138
  });
123
139
  }
140
+ var CUDA_MAJOR_MINOR = /^\d+\.\d+$/;
141
+ function cudaConstraintError(params, opts = {}) {
142
+ const { allowedCudaVersions, minCudaVersion: minCudaVersion2 } = params;
143
+ if (allowedCudaVersions?.length && minCudaVersion2) {
144
+ return "allowedCudaVersions and minCudaVersion are mutually exclusive \u2014 pass either an exact set or an open-ended floor, not both.";
145
+ }
146
+ if (minCudaVersion2 !== void 0 && !CUDA_MAJOR_MINOR.test(minCudaVersion2) && !(opts.allowClear && minCudaVersion2 === "")) {
147
+ return `minCudaVersion must be major.minor (e.g. "12.0", not "12")${opts.allowClear ? "; an empty string clears the floor" : ""}.`;
148
+ }
149
+ const bad = allowedCudaVersions?.find((v) => !CUDA_MAJOR_MINOR.test(v));
150
+ if (bad !== void 0) {
151
+ return `allowedCudaVersions entries must be major.minor (e.g. "12.8"); got "${bad}". Discover valid values via get-capacity or list-gpu-types.`;
152
+ }
153
+ return void 0;
154
+ }
124
155
  function mapNetworkVolumeCreateToV2(params) {
125
156
  return compact({
126
157
  name: params.name,
@@ -462,7 +493,7 @@ function resolveBackend(opts) {
462
493
 
463
494
  // src/server.ts
464
495
  var SERVER_NAME = "Runpod API Server";
465
- var SERVER_VERSION = true ? "3.3.0" : "dev";
496
+ var SERVER_VERSION = true ? "3.4.0" : "dev";
466
497
  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.
467
498
 
468
499
  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.`;
@@ -843,7 +874,7 @@ async function streamLogsReply(rt, tool, params) {
843
874
  }
844
875
 
845
876
  // src/tools/runtime.ts
846
- var MCP_SERVER_VERSION = true ? "3.3.0" : "dev";
877
+ var MCP_SERVER_VERSION = true ? "3.4.0" : "dev";
847
878
  var SESSION_ID = randomUUID();
848
879
  function trackingHeaders(server, ctx) {
849
880
  const info = server.server.getClientVersion();
@@ -1173,16 +1204,47 @@ function registerCatalogTools(server, rt) {
1173
1204
  ),
1174
1205
  product: z3.enum(["POD", "CLUSTER", "SERVERLESS"]).optional().describe(
1175
1206
  "Product context for the availability lookup \u2014 the same GPU can be scarce for Pods and plentiful for Serverless. Default POD. Use SERVERLESS when picking a GPU for an endpoint, CLUSTER for Instant Clusters. Ignored when includeAvailability is false."
1207
+ ),
1208
+ minCudaVersion: z3.string().optional().describe(
1209
+ 'Scope the availability lookup to hosts at or above this CUDA version (v2 only). Integer major or major.minor \u2014 "12" means any 12.x release; unlike the create-pod/create-endpoint body fields, a bare major is accepted here because the filter only widens a read. Requires includeAvailability (the default).'
1176
1210
  )
1177
1211
  },
1178
1212
  { title: "List GPU types", ...READ_ONLY },
1179
1213
  async (params) => {
1180
1214
  const backend = backendFor("gpus");
1215
+ if (params.minCudaVersion !== void 0 && backend.version !== "v2") {
1216
+ return jsonReply2({
1217
+ error: "The minCudaVersion filter is only supported on the v2 REST API. Set RUNPOD_REST_VERSION=v2, or use get-capacity for per-CUDA-version availability.",
1218
+ status: 501
1219
+ });
1220
+ }
1181
1221
  if (backend.version === "v2") {
1182
1222
  const wantAvailability = params.includeAvailability !== false;
1183
1223
  const product = GPU_PRODUCTS.has(String(params.product)) ? String(params.product) : "POD";
1224
+ if (params.minCudaVersion !== void 0) {
1225
+ if (!wantAvailability) {
1226
+ return jsonReply2({
1227
+ error: "minCudaVersion filters the availability lookup, so it requires includeAvailability (the default). Drop includeAvailability:false or the filter.",
1228
+ status: 400
1229
+ });
1230
+ }
1231
+ if (!/^\d+(\.\d+)?$/.test(params.minCudaVersion)) {
1232
+ return jsonReply2({
1233
+ error: 'minCudaVersion must be an integer major ("12") or major.minor ("12.1").',
1234
+ status: 400
1235
+ });
1236
+ }
1237
+ }
1238
+ const query = new URLSearchParams();
1239
+ if (wantAvailability) {
1240
+ query.set("include", "AVAILABILITY");
1241
+ query.set("product", product);
1242
+ if (params.minCudaVersion !== void 0) {
1243
+ query.set("minCudaVersion", params.minCudaVersion);
1244
+ }
1245
+ }
1184
1246
  const raw = await callRestUrl(
1185
- `${backend.base}${backend.list}${wantAvailability ? `?include=AVAILABILITY&product=${product}` : ""}`
1247
+ `${backend.base}${backend.list}${query.size ? `?${query}` : ""}`
1186
1248
  );
1187
1249
  let gpus = backend.unwrap(raw);
1188
1250
  gpus = gpus.filter((g) => g.id !== "unknown");
@@ -2280,7 +2342,13 @@ function registerPodTools(server, rt) {
2280
2342
  containerRegistryAuthId: z7.string().optional().describe(
2281
2343
  "Container registry credential ID for pulling a private image (see list-container-registry-auths). When deploying from a templateId, this overrides the credential the template carries; pass an empty string to deploy with NO credential (clears a template\u2019s inherited registry)."
2282
2344
  ),
2283
- dataCenterIds: z7.array(z7.string()).optional().describe("List of data centers")
2345
+ dataCenterIds: z7.array(z7.string()).optional().describe("List of data centers"),
2346
+ allowedCudaVersions: z7.array(z7.string()).optional().describe(
2347
+ 'Acceptable host CUDA versions as major.minor, e.g. ["12.8","12.6"] (v2, GPU pods only). Exact match \u2014 discover valid values per GPU type with get-capacity. Mutually exclusive with minCudaVersion.'
2348
+ ),
2349
+ minCudaVersion: z7.string().optional().describe(
2350
+ 'Lowest acceptable host CUDA version as major.minor, e.g. "12.4" (v2, GPU pods only). A bare major like "12" is rejected. Open-ended floor; mutually exclusive with a non-empty allowedCudaVersions.'
2351
+ )
2284
2352
  },
2285
2353
  { title: "Create pod", ...WRITE },
2286
2354
  async (params) => {
@@ -2294,6 +2362,13 @@ function registerPodTools(server, rt) {
2294
2362
  sshKey = validated.key;
2295
2363
  }
2296
2364
  const sshNote = "sshPublicKey applied: PUBLIC_KEY env set and 22/tcp exposed. Full SSH (incl. SCP/SFTP/rsync) also requires an image that installs PUBLIC_KEY into authorized_keys and starts sshd (all runpod/* official images do) and a machine with a public IP \u2014 read the pod\u2019s portMappings for port 22 once it is running.";
2365
+ const hasCudaParams = params.allowedCudaVersions !== void 0 || params.minCudaVersion !== void 0;
2366
+ if (hasCudaParams && backend.version !== "v2") {
2367
+ return jsonReply2({
2368
+ error: "allowedCudaVersions/minCudaVersion are only supported on the v2 REST API. Set RUNPOD_REST_VERSION=v2.",
2369
+ status: 501
2370
+ });
2371
+ }
2297
2372
  if (params.templateId && backend.version !== "v2") {
2298
2373
  return jsonReply2({
2299
2374
  error: "Deploying a pod from a templateId is only supported on the v2 REST API. Set RUNPOD_REST_VERSION=v2, or pass imageName instead.",
@@ -2329,6 +2404,16 @@ function registerPodTools(server, rt) {
2329
2404
  status: 400
2330
2405
  });
2331
2406
  }
2407
+ if (hasCudaParams && !wantsGpu) {
2408
+ return jsonReply2({
2409
+ error: "allowedCudaVersions/minCudaVersion apply to GPU pods only \u2014 pass gpuTypeIds (see list-gpu-types).",
2410
+ status: 400
2411
+ });
2412
+ }
2413
+ if (hasCudaParams) {
2414
+ const cudaError = cudaConstraintError(params);
2415
+ if (cudaError) return jsonReply2({ error: cudaError, status: 400 });
2416
+ }
2332
2417
  if (!wantsCpu && !params.name && !params.templateId) {
2333
2418
  return jsonReply2({
2334
2419
  error: "Provide a name for the pod (deploying from a templateId inherits the template name).",
@@ -2518,6 +2603,9 @@ function registerPodTools(server, rt) {
2518
2603
  import { z as z8 } from "zod";
2519
2604
  var MIN_QUEUE_DELAY = 0.5;
2520
2605
  var MIN_REQUEST_COUNT = 1;
2606
+ function isRequestCountScaler(type) {
2607
+ return type === "REQUEST_COUNT";
2608
+ }
2521
2609
  var MIN_IDLE_TIMEOUT = 1;
2522
2610
  var MAX_IDLE_TIMEOUT = 3600;
2523
2611
  function scalerValueError(scalerType, scalerValue) {
@@ -2610,6 +2698,12 @@ function registerEndpointTools(server, rt) {
2610
2698
  'GPU pool names (v2, required). The `pool` field from list-gpu-types, e.g. ["AMPERE_80"]. NOT GPU type ids.'
2611
2699
  ),
2612
2700
  gpuCount: z8.number().optional().describe("GPUs per worker (v2)"),
2701
+ allowedCudaVersions: z8.array(z8.string()).optional().describe(
2702
+ 'Acceptable host CUDA versions for worker placement as major.minor, e.g. ["12.8"] (v2). Exact match \u2014 see get-capacity for which versions have stock. Mutually exclusive with minCudaVersion.'
2703
+ ),
2704
+ minCudaVersion: z8.string().optional().describe(
2705
+ 'Lowest acceptable host CUDA version as major.minor, e.g. "12.4" (v2). A bare major like "12" is rejected. Mutually exclusive with a non-empty allowedCudaVersions.'
2706
+ ),
2613
2707
  args: z8.string().optional().describe("Container start command/args (v2)"),
2614
2708
  containerDiskInGb: z8.number().optional().describe("Container disk size in GB (v2)"),
2615
2709
  ports: z8.array(z8.string()).optional().describe("Ports to expose (v2), e.g. ['8000/http']"),
@@ -2639,6 +2733,13 @@ function registerEndpointTools(server, rt) {
2639
2733
  { title: "Create endpoint", ...WRITE },
2640
2734
  async (params) => {
2641
2735
  const backend = backendFor("endpoints");
2736
+ const hasCudaParams = params.allowedCudaVersions !== void 0 || params.minCudaVersion !== void 0;
2737
+ if (hasCudaParams && backend.version !== "v2") {
2738
+ return jsonReply2({
2739
+ error: "allowedCudaVersions/minCudaVersion are only supported on the v2 REST API. Set RUNPOD_REST_VERSION=v2.",
2740
+ status: 501
2741
+ });
2742
+ }
2642
2743
  if (backend.version === "v2") {
2643
2744
  if (!params.name) {
2644
2745
  return jsonReply2({
@@ -2671,6 +2772,10 @@ function registerEndpointTools(server, rt) {
2671
2772
  if (scalerError) {
2672
2773
  return jsonReply2({ error: scalerError, status: 400 });
2673
2774
  }
2775
+ if (hasCudaParams) {
2776
+ const cudaError = cudaConstraintError(params);
2777
+ if (cudaError) return jsonReply2({ error: cudaError, status: 400 });
2778
+ }
2674
2779
  const body = backend.mapCreate(params);
2675
2780
  const result2 = await callRestUrl(
2676
2781
  `${backend.base}${backend.list}`,
@@ -2708,7 +2813,7 @@ function registerEndpointTools(server, rt) {
2708
2813
  );
2709
2814
  server.tool(
2710
2815
  "update-endpoint",
2711
- "Update a Serverless endpoint's config. On v2 you can change image/disk/env/ports/registry/workers/scaling/networkVolumes/timeout/flashboot; on v1, scaling fields (worker min/max, idle timeout, scaler type/value, name). Only provided fields change. An endpoint's request routing (queue vs load balancer) is fixed at creation and cannot be changed here \u2014 recreate the endpoint instead.",
2816
+ "Update a Serverless endpoint's config. On v2 you can change image/disk/env/ports/registry/workers/scaling/networkVolumes/timeout/flashboot, plus the GPU selection (gpuPoolIds/gpuCount) and its CUDA constraints (allowedCudaVersions/minCudaVersion) \u2014 CUDA-only or count-only changes do not require resending gpuPoolIds; on v1, scaling fields (worker min/max, idle timeout, scaler type/value, name). Only provided fields change. An endpoint's request routing (queue vs load balancer) is fixed at creation and cannot be changed here \u2014 recreate the endpoint instead. Note: passing gpuPoolIds replaces the GPU selection wholesale, which clears any GPU-type exclusions set elsewhere (console or set-endpoint-gpus) \u2014 the reply carries a _warning when that happens.",
2712
2817
  {
2713
2818
  endpointId: z8.string().describe("ID of the endpoint to update"),
2714
2819
  name: z8.string().optional().describe("New name for the endpoint"),
@@ -2727,6 +2832,12 @@ function registerEndpointTools(server, rt) {
2727
2832
  imageName: z8.string().optional().describe("New Docker image (v2)"),
2728
2833
  gpuPoolIds: z8.array(z8.string()).optional().describe('New GPU pool names (v2), e.g. ["AMPERE_80"]'),
2729
2834
  gpuCount: z8.number().optional().describe("New GPUs per worker (v2)"),
2835
+ allowedCudaVersions: z8.array(z8.string()).optional().describe(
2836
+ "New acceptable host CUDA versions as major.minor (v2). Changing only this does not require resending gpuPoolIds. An explicit [] clears the constraint. Mutually exclusive with minCudaVersion."
2837
+ ),
2838
+ minCudaVersion: z8.string().optional().describe(
2839
+ 'New lowest acceptable host CUDA version as major.minor (v2). An empty string clears the floor; a bare major like "12" is rejected. Mutually exclusive with a non-empty allowedCudaVersions.'
2840
+ ),
2730
2841
  args: z8.string().optional().describe("New container args (v2)"),
2731
2842
  containerDiskInGb: z8.number().optional().describe("New container disk size in GB (v2)"),
2732
2843
  ports: z8.array(z8.string()).optional().describe("New ports (v2)"),
@@ -2741,14 +2852,41 @@ function registerEndpointTools(server, rt) {
2741
2852
  const { endpointId, ...updateParams } = params;
2742
2853
  const backend = backendFor("endpoints");
2743
2854
  const url = `${backend.base}${backend.get(endpointId)}`;
2855
+ const hasCudaParams = updateParams.allowedCudaVersions !== void 0 || updateParams.minCudaVersion !== void 0;
2744
2856
  if (backend.version !== "v2") {
2857
+ if (hasCudaParams) {
2858
+ return jsonReply2({
2859
+ error: "allowedCudaVersions/minCudaVersion are only supported on the v2 REST API. Set RUNPOD_REST_VERSION=v2.",
2860
+ status: 501
2861
+ });
2862
+ }
2745
2863
  const body2 = backend.mapUpdate(updateParams);
2746
2864
  return jsonReply2(await callRestUrl(url, "PATCH", body2));
2747
2865
  }
2866
+ if (hasCudaParams) {
2867
+ const cudaError = cudaConstraintError(updateParams, {
2868
+ allowClear: true
2869
+ });
2870
+ if (cudaError) return jsonReply2({ error: cudaError, status: 400 });
2871
+ }
2872
+ if (updateParams.gpuPoolIds !== void 0 && !updateParams.gpuPoolIds.length) {
2873
+ return jsonReply2({
2874
+ error: "gpuPoolIds cannot be empty \u2014 omit it to keep the current GPU selection.",
2875
+ status: 400
2876
+ });
2877
+ }
2748
2878
  let scalerType = updateParams.scalerType;
2749
- if (scalerType === void 0 && updateParams.scalerValue !== void 0) {
2879
+ const needScalerRead = scalerType === void 0 && updateParams.scalerValue !== void 0;
2880
+ const needExclusionRead = (updateParams.gpuPoolIds?.length ?? 0) > 0;
2881
+ let clearedExclusions = [];
2882
+ if (needScalerRead || needExclusionRead) {
2750
2883
  const current = await callRestUrl(url);
2751
- scalerType = current?.scaling?.type === "REQUEST_COUNT" ? "REQUEST_COUNT" : "QUEUE_DELAY";
2884
+ if (needScalerRead) {
2885
+ scalerType = isRequestCountScaler(current?.scaling?.type) ? "REQUEST_COUNT" : "QUEUE_DELAY";
2886
+ }
2887
+ if (needExclusionRead && current?.gpu?.excludedTypes?.length) {
2888
+ clearedExclusions = current.gpu.excludedTypes;
2889
+ }
2752
2890
  }
2753
2891
  const scalerError = scalerValueError(
2754
2892
  scalerType,
@@ -2761,7 +2899,14 @@ function registerEndpointTools(server, rt) {
2761
2899
  ...updateParams,
2762
2900
  scalerType
2763
2901
  });
2764
- return jsonReply2(await callRestUrl(url, "PATCH", body));
2902
+ const result = await callRestUrl(url, "PATCH", body);
2903
+ if (clearedExclusions.length) {
2904
+ return jsonReply2({
2905
+ ...result,
2906
+ _warning: `Supplying gpuPoolIds replaced the GPU selection wholesale, clearing ${clearedExclusions.length} GPU-type exclusion(s) previously set on this endpoint: ${clearedExclusions.join(", ")}. Re-apply them with set-endpoint-gpus if still wanted.`
2907
+ });
2908
+ }
2909
+ return jsonReply2(result);
2765
2910
  }
2766
2911
  );
2767
2912
  server.tool(