@runpod/mcp-server 1.1.0 → 1.3.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/index.js DELETED
@@ -1,638 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
- // If the importer is in node compatibility mode or this is not an ESM
19
- // file that has been converted to a CommonJS file using a Babel-
20
- // compatible transform (i.e. "__esModule" has not been set), then set
21
- // "default" to the CommonJS "module.exports" for node compatibility.
22
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
- mod
24
- ));
25
-
26
- // src/index.ts
27
- var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
28
- var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
29
- var import_zod = require("zod");
30
- var import_node_fetch = __toESM(require("node-fetch"), 1);
31
- var API_BASE_URL = "https://rest.runpod.io/v1";
32
- var API_KEY = process.env.RUNPOD_API_KEY;
33
- if (!API_KEY) {
34
- console.error("RUNPOD_API_KEY environment variable is required");
35
- process.exit(1);
36
- }
37
- var server = new import_mcp.McpServer({
38
- name: "RunPod API Server",
39
- version: "1.0.0",
40
- capabilities: {
41
- resources: {},
42
- tools: {}
43
- }
44
- });
45
- async function runpodRequest(endpoint, method = "GET", body) {
46
- const url = `${API_BASE_URL}${endpoint}`;
47
- const headers = {
48
- Authorization: `Bearer ${API_KEY}`,
49
- "Content-Type": "application/json"
50
- };
51
- const options = {
52
- method,
53
- headers
54
- };
55
- if (body && (method === "POST" || method === "PATCH")) {
56
- options.body = JSON.stringify(body);
57
- }
58
- try {
59
- const response = await (0, import_node_fetch.default)(url, options);
60
- if (!response.ok) {
61
- const errorText = await response.text();
62
- throw new Error(`RunPod API Error: ${response.status} - ${errorText}`);
63
- }
64
- const contentType = response.headers.get("content-type");
65
- if (contentType && contentType.includes("application/json")) {
66
- return await response.json();
67
- }
68
- return { success: true, status: response.status };
69
- } catch (error) {
70
- console.error("Error calling RunPod API:", error);
71
- throw error;
72
- }
73
- }
74
- server.tool(
75
- "list-pods",
76
- {
77
- computeType: import_zod.z.enum(["GPU", "CPU"]).optional().describe("Filter to only GPU or only CPU Pods"),
78
- gpuTypeId: import_zod.z.array(import_zod.z.string()).optional().describe("Filter to Pods with any of the listed GPU types"),
79
- dataCenterId: import_zod.z.array(import_zod.z.string()).optional().describe("Filter to Pods in any of the provided data centers"),
80
- name: import_zod.z.string().optional().describe("Filter to Pods with the provided name"),
81
- includeMachine: import_zod.z.boolean().optional().describe("Include information about the machine"),
82
- includeNetworkVolume: import_zod.z.boolean().optional().describe("Include information about attached network volumes")
83
- },
84
- async (params) => {
85
- const queryParams = new URLSearchParams();
86
- if (params.computeType)
87
- queryParams.append("computeType", params.computeType);
88
- if (params.gpuTypeId)
89
- params.gpuTypeId.forEach((type) => queryParams.append("gpuTypeId", type));
90
- if (params.dataCenterId)
91
- params.dataCenterId.forEach(
92
- (dc) => queryParams.append("dataCenterId", dc)
93
- );
94
- if (params.name) queryParams.append("name", params.name);
95
- if (params.includeMachine)
96
- queryParams.append("includeMachine", params.includeMachine.toString());
97
- if (params.includeNetworkVolume)
98
- queryParams.append(
99
- "includeNetworkVolume",
100
- params.includeNetworkVolume.toString()
101
- );
102
- const queryString = queryParams.toString() ? `?${queryParams.toString()}` : "";
103
- const result = await runpodRequest(`/pods${queryString}`);
104
- return {
105
- content: [
106
- {
107
- type: "text",
108
- text: JSON.stringify(result, null, 2)
109
- }
110
- ]
111
- };
112
- }
113
- );
114
- server.tool(
115
- "get-pod",
116
- {
117
- podId: import_zod.z.string().describe("ID of the pod to retrieve"),
118
- includeMachine: import_zod.z.boolean().optional().describe("Include information about the machine"),
119
- includeNetworkVolume: import_zod.z.boolean().optional().describe("Include information about attached network volumes")
120
- },
121
- async (params) => {
122
- const queryParams = new URLSearchParams();
123
- if (params.includeMachine)
124
- queryParams.append("includeMachine", params.includeMachine.toString());
125
- if (params.includeNetworkVolume)
126
- queryParams.append(
127
- "includeNetworkVolume",
128
- params.includeNetworkVolume.toString()
129
- );
130
- const queryString = queryParams.toString() ? `?${queryParams.toString()}` : "";
131
- const result = await runpodRequest(`/pods/${params.podId}${queryString}`);
132
- return {
133
- content: [
134
- {
135
- type: "text",
136
- text: JSON.stringify(result, null, 2)
137
- }
138
- ]
139
- };
140
- }
141
- );
142
- server.tool(
143
- "create-pod",
144
- {
145
- name: import_zod.z.string().optional().describe("Name for the pod"),
146
- imageName: import_zod.z.string().describe("Docker image to use"),
147
- cloudType: import_zod.z.enum(["SECURE", "COMMUNITY"]).optional().describe("SECURE or COMMUNITY cloud"),
148
- gpuTypeIds: import_zod.z.array(import_zod.z.string()).optional().describe("List of acceptable GPU types"),
149
- gpuCount: import_zod.z.number().optional().describe("Number of GPUs"),
150
- containerDiskInGb: import_zod.z.number().optional().describe("Container disk size in GB"),
151
- volumeInGb: import_zod.z.number().optional().describe("Volume size in GB"),
152
- volumeMountPath: import_zod.z.string().optional().describe("Path to mount the volume"),
153
- ports: import_zod.z.array(import_zod.z.string()).optional().describe("Ports to expose (e.g., '8888/http', '22/tcp')"),
154
- env: import_zod.z.record(import_zod.z.string()).optional().describe("Environment variables"),
155
- dataCenterIds: import_zod.z.array(import_zod.z.string()).optional().describe("List of data centers")
156
- },
157
- async (params) => {
158
- const result = await runpodRequest("/pods", "POST", params);
159
- return {
160
- content: [
161
- {
162
- type: "text",
163
- text: JSON.stringify(result, null, 2)
164
- }
165
- ]
166
- };
167
- }
168
- );
169
- server.tool(
170
- "update-pod",
171
- {
172
- podId: import_zod.z.string().describe("ID of the pod to update"),
173
- name: import_zod.z.string().optional().describe("New name for the pod"),
174
- imageName: import_zod.z.string().optional().describe("New Docker image"),
175
- containerDiskInGb: import_zod.z.number().optional().describe("New container disk size in GB"),
176
- volumeInGb: import_zod.z.number().optional().describe("New volume size in GB"),
177
- volumeMountPath: import_zod.z.string().optional().describe("New path to mount the volume"),
178
- ports: import_zod.z.array(import_zod.z.string()).optional().describe("New ports to expose"),
179
- env: import_zod.z.record(import_zod.z.string()).optional().describe("New environment variables")
180
- },
181
- async (params) => {
182
- const { podId, ...updateParams } = params;
183
- const result = await runpodRequest(`/pods/${podId}`, "PATCH", updateParams);
184
- return {
185
- content: [
186
- {
187
- type: "text",
188
- text: JSON.stringify(result, null, 2)
189
- }
190
- ]
191
- };
192
- }
193
- );
194
- server.tool(
195
- "start-pod",
196
- {
197
- podId: import_zod.z.string().describe("ID of the pod to start")
198
- },
199
- async (params) => {
200
- const result = await runpodRequest(`/pods/${params.podId}/start`, "POST");
201
- return {
202
- content: [
203
- {
204
- type: "text",
205
- text: JSON.stringify(result, null, 2)
206
- }
207
- ]
208
- };
209
- }
210
- );
211
- server.tool(
212
- "stop-pod",
213
- {
214
- podId: import_zod.z.string().describe("ID of the pod to stop")
215
- },
216
- async (params) => {
217
- const result = await runpodRequest(`/pods/${params.podId}/stop`, "POST");
218
- return {
219
- content: [
220
- {
221
- type: "text",
222
- text: JSON.stringify(result, null, 2)
223
- }
224
- ]
225
- };
226
- }
227
- );
228
- server.tool(
229
- "delete-pod",
230
- {
231
- podId: import_zod.z.string().describe("ID of the pod to delete")
232
- },
233
- async (params) => {
234
- const result = await runpodRequest(`/pods/${params.podId}`, "DELETE");
235
- return {
236
- content: [
237
- {
238
- type: "text",
239
- text: JSON.stringify(result, null, 2)
240
- }
241
- ]
242
- };
243
- }
244
- );
245
- server.tool(
246
- "list-endpoints",
247
- {
248
- includeTemplate: import_zod.z.boolean().optional().describe("Include template information"),
249
- includeWorkers: import_zod.z.boolean().optional().describe("Include information about workers")
250
- },
251
- async (params) => {
252
- const queryParams = new URLSearchParams();
253
- if (params.includeTemplate)
254
- queryParams.append("includeTemplate", params.includeTemplate.toString());
255
- if (params.includeWorkers)
256
- queryParams.append("includeWorkers", params.includeWorkers.toString());
257
- const queryString = queryParams.toString() ? `?${queryParams.toString()}` : "";
258
- const result = await runpodRequest(`/endpoints${queryString}`);
259
- return {
260
- content: [
261
- {
262
- type: "text",
263
- text: JSON.stringify(result, null, 2)
264
- }
265
- ]
266
- };
267
- }
268
- );
269
- server.tool(
270
- "get-endpoint",
271
- {
272
- endpointId: import_zod.z.string().describe("ID of the endpoint to retrieve"),
273
- includeTemplate: import_zod.z.boolean().optional().describe("Include template information"),
274
- includeWorkers: import_zod.z.boolean().optional().describe("Include information about workers")
275
- },
276
- async (params) => {
277
- const queryParams = new URLSearchParams();
278
- if (params.includeTemplate)
279
- queryParams.append("includeTemplate", params.includeTemplate.toString());
280
- if (params.includeWorkers)
281
- queryParams.append("includeWorkers", params.includeWorkers.toString());
282
- const queryString = queryParams.toString() ? `?${queryParams.toString()}` : "";
283
- const result = await runpodRequest(
284
- `/endpoints/${params.endpointId}${queryString}`
285
- );
286
- return {
287
- content: [
288
- {
289
- type: "text",
290
- text: JSON.stringify(result, null, 2)
291
- }
292
- ]
293
- };
294
- }
295
- );
296
- server.tool(
297
- "create-endpoint",
298
- {
299
- name: import_zod.z.string().optional().describe("Name for the endpoint"),
300
- templateId: import_zod.z.string().describe("Template ID to use"),
301
- computeType: import_zod.z.enum(["GPU", "CPU"]).optional().describe("GPU or CPU endpoint"),
302
- gpuTypeIds: import_zod.z.array(import_zod.z.string()).optional().describe("List of acceptable GPU types"),
303
- gpuCount: import_zod.z.number().optional().describe("Number of GPUs per worker"),
304
- workersMin: import_zod.z.number().optional().describe("Minimum number of workers"),
305
- workersMax: import_zod.z.number().optional().describe("Maximum number of workers"),
306
- dataCenterIds: import_zod.z.array(import_zod.z.string()).optional().describe("List of data centers")
307
- },
308
- async (params) => {
309
- const result = await runpodRequest("/endpoints", "POST", params);
310
- return {
311
- content: [
312
- {
313
- type: "text",
314
- text: JSON.stringify(result, null, 2)
315
- }
316
- ]
317
- };
318
- }
319
- );
320
- server.tool(
321
- "update-endpoint",
322
- {
323
- endpointId: import_zod.z.string().describe("ID of the endpoint to update"),
324
- name: import_zod.z.string().optional().describe("New name for the endpoint"),
325
- workersMin: import_zod.z.number().optional().describe("New minimum number of workers"),
326
- workersMax: import_zod.z.number().optional().describe("New maximum number of workers"),
327
- idleTimeout: import_zod.z.number().optional().describe("New idle timeout in seconds"),
328
- scalerType: import_zod.z.enum(["QUEUE_DELAY", "REQUEST_COUNT"]).optional().describe("Scaler type"),
329
- scalerValue: import_zod.z.number().optional().describe("Scaler value")
330
- },
331
- async (params) => {
332
- const { endpointId, ...updateParams } = params;
333
- const result = await runpodRequest(
334
- `/endpoints/${endpointId}`,
335
- "PATCH",
336
- updateParams
337
- );
338
- return {
339
- content: [
340
- {
341
- type: "text",
342
- text: JSON.stringify(result, null, 2)
343
- }
344
- ]
345
- };
346
- }
347
- );
348
- server.tool(
349
- "delete-endpoint",
350
- {
351
- endpointId: import_zod.z.string().describe("ID of the endpoint to delete")
352
- },
353
- async (params) => {
354
- const result = await runpodRequest(
355
- `/endpoints/${params.endpointId}`,
356
- "DELETE"
357
- );
358
- return {
359
- content: [
360
- {
361
- type: "text",
362
- text: JSON.stringify(result, null, 2)
363
- }
364
- ]
365
- };
366
- }
367
- );
368
- server.tool("list-templates", {}, async () => {
369
- const result = await runpodRequest("/templates");
370
- return {
371
- content: [
372
- {
373
- type: "text",
374
- text: JSON.stringify(result, null, 2)
375
- }
376
- ]
377
- };
378
- });
379
- server.tool(
380
- "get-template",
381
- {
382
- templateId: import_zod.z.string().describe("ID of the template to retrieve")
383
- },
384
- async (params) => {
385
- const result = await runpodRequest(`/templates/${params.templateId}`);
386
- return {
387
- content: [
388
- {
389
- type: "text",
390
- text: JSON.stringify(result, null, 2)
391
- }
392
- ]
393
- };
394
- }
395
- );
396
- server.tool(
397
- "create-template",
398
- {
399
- name: import_zod.z.string().describe("Name for the template"),
400
- imageName: import_zod.z.string().describe("Docker image to use"),
401
- isServerless: import_zod.z.boolean().optional().describe("Is this a serverless template"),
402
- ports: import_zod.z.array(import_zod.z.string()).optional().describe("Ports to expose"),
403
- dockerEntrypoint: import_zod.z.array(import_zod.z.string()).optional().describe("Docker entrypoint commands"),
404
- dockerStartCmd: import_zod.z.array(import_zod.z.string()).optional().describe("Docker start commands"),
405
- env: import_zod.z.record(import_zod.z.string()).optional().describe("Environment variables"),
406
- containerDiskInGb: import_zod.z.number().optional().describe("Container disk size in GB"),
407
- volumeInGb: import_zod.z.number().optional().describe("Volume size in GB"),
408
- volumeMountPath: import_zod.z.string().optional().describe("Path to mount the volume"),
409
- readme: import_zod.z.string().optional().describe("README content in markdown format")
410
- },
411
- async (params) => {
412
- const result = await runpodRequest("/templates", "POST", params);
413
- return {
414
- content: [
415
- {
416
- type: "text",
417
- text: JSON.stringify(result, null, 2)
418
- }
419
- ]
420
- };
421
- }
422
- );
423
- server.tool(
424
- "update-template",
425
- {
426
- templateId: import_zod.z.string().describe("ID of the template to update"),
427
- name: import_zod.z.string().optional().describe("New name for the template"),
428
- imageName: import_zod.z.string().optional().describe("New Docker image"),
429
- ports: import_zod.z.array(import_zod.z.string()).optional().describe("New ports to expose"),
430
- env: import_zod.z.record(import_zod.z.string()).optional().describe("New environment variables"),
431
- readme: import_zod.z.string().optional().describe("New README content in markdown format")
432
- },
433
- async (params) => {
434
- const { templateId, ...updateParams } = params;
435
- const result = await runpodRequest(
436
- `/templates/${templateId}`,
437
- "PATCH",
438
- updateParams
439
- );
440
- return {
441
- content: [
442
- {
443
- type: "text",
444
- text: JSON.stringify(result, null, 2)
445
- }
446
- ]
447
- };
448
- }
449
- );
450
- server.tool(
451
- "delete-template",
452
- {
453
- templateId: import_zod.z.string().describe("ID of the template to delete")
454
- },
455
- async (params) => {
456
- const result = await runpodRequest(
457
- `/templates/${params.templateId}`,
458
- "DELETE"
459
- );
460
- return {
461
- content: [
462
- {
463
- type: "text",
464
- text: JSON.stringify(result, null, 2)
465
- }
466
- ]
467
- };
468
- }
469
- );
470
- server.tool("list-network-volumes", {}, async () => {
471
- const result = await runpodRequest("/networkvolumes");
472
- return {
473
- content: [
474
- {
475
- type: "text",
476
- text: JSON.stringify(result, null, 2)
477
- }
478
- ]
479
- };
480
- });
481
- server.tool(
482
- "get-network-volume",
483
- {
484
- networkVolumeId: import_zod.z.string().describe("ID of the network volume to retrieve")
485
- },
486
- async (params) => {
487
- const result = await runpodRequest(
488
- `/networkvolumes/${params.networkVolumeId}`
489
- );
490
- return {
491
- content: [
492
- {
493
- type: "text",
494
- text: JSON.stringify(result, null, 2)
495
- }
496
- ]
497
- };
498
- }
499
- );
500
- server.tool(
501
- "create-network-volume",
502
- {
503
- name: import_zod.z.string().describe("Name for the network volume"),
504
- size: import_zod.z.number().describe("Size in GB (1-4000)"),
505
- dataCenterId: import_zod.z.string().describe("Data center ID")
506
- },
507
- async (params) => {
508
- const result = await runpodRequest("/networkvolumes", "POST", params);
509
- return {
510
- content: [
511
- {
512
- type: "text",
513
- text: JSON.stringify(result, null, 2)
514
- }
515
- ]
516
- };
517
- }
518
- );
519
- server.tool(
520
- "update-network-volume",
521
- {
522
- networkVolumeId: import_zod.z.string().describe("ID of the network volume to update"),
523
- name: import_zod.z.string().optional().describe("New name for the network volume"),
524
- size: import_zod.z.number().optional().describe("New size in GB (must be larger than current)")
525
- },
526
- async (params) => {
527
- const { networkVolumeId, ...updateParams } = params;
528
- const result = await runpodRequest(
529
- `/networkvolumes/${networkVolumeId}`,
530
- "PATCH",
531
- updateParams
532
- );
533
- return {
534
- content: [
535
- {
536
- type: "text",
537
- text: JSON.stringify(result, null, 2)
538
- }
539
- ]
540
- };
541
- }
542
- );
543
- server.tool(
544
- "delete-network-volume",
545
- {
546
- networkVolumeId: import_zod.z.string().describe("ID of the network volume to delete")
547
- },
548
- async (params) => {
549
- const result = await runpodRequest(
550
- `/networkvolumes/${params.networkVolumeId}`,
551
- "DELETE"
552
- );
553
- return {
554
- content: [
555
- {
556
- type: "text",
557
- text: JSON.stringify(result, null, 2)
558
- }
559
- ]
560
- };
561
- }
562
- );
563
- server.tool("list-container-registry-auths", {}, async () => {
564
- const result = await runpodRequest("/containerregistryauth");
565
- return {
566
- content: [
567
- {
568
- type: "text",
569
- text: JSON.stringify(result, null, 2)
570
- }
571
- ]
572
- };
573
- });
574
- server.tool(
575
- "get-container-registry-auth",
576
- {
577
- containerRegistryAuthId: import_zod.z.string().describe("ID of the container registry auth to retrieve")
578
- },
579
- async (params) => {
580
- const result = await runpodRequest(
581
- `/containerregistryauth/${params.containerRegistryAuthId}`
582
- );
583
- return {
584
- content: [
585
- {
586
- type: "text",
587
- text: JSON.stringify(result, null, 2)
588
- }
589
- ]
590
- };
591
- }
592
- );
593
- server.tool(
594
- "create-container-registry-auth",
595
- {
596
- name: import_zod.z.string().describe("Name for the container registry auth"),
597
- username: import_zod.z.string().describe("Registry username"),
598
- password: import_zod.z.string().describe("Registry password")
599
- },
600
- async (params) => {
601
- const result = await runpodRequest(
602
- "/containerregistryauth",
603
- "POST",
604
- params
605
- );
606
- return {
607
- content: [
608
- {
609
- type: "text",
610
- text: JSON.stringify(result, null, 2)
611
- }
612
- ]
613
- };
614
- }
615
- );
616
- server.tool(
617
- "delete-container-registry-auth",
618
- {
619
- containerRegistryAuthId: import_zod.z.string().describe("ID of the container registry auth to delete")
620
- },
621
- async (params) => {
622
- const result = await runpodRequest(
623
- `/containerregistryauth/${params.containerRegistryAuthId}`,
624
- "DELETE"
625
- );
626
- return {
627
- content: [
628
- {
629
- type: "text",
630
- text: JSON.stringify(result, null, 2)
631
- }
632
- ]
633
- };
634
- }
635
- );
636
- var transport = new import_stdio.StdioServerTransport();
637
- server.connect(transport);
638
- //# sourceMappingURL=index.js.map