@runpod/mcp-server 2.0.0 → 3.1.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 CHANGED
@@ -1,5 +1,100 @@
1
1
  # @runpod/mcp-server
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 259241d: Enforce PKCE (S256) in every hosted OAuth flow. `/authorize` rejects missing, malformed, or non-S256 challenges before issuing a code and forwards a valid challenge to the flash backend. `/token` requires a valid, matching `code_verifier` before returning the minted key; missing PKCE state, `plain`, and non-matching verifiers are rejected.
8
+
9
+ Requires the backend `codeChallenge` / `codeChallengeMethod` fields on `createFlashAuthRequest` / `flashAuthRequestStatus` (runpod/RunPod, DR-1398) to be deployed.
10
+
11
+ - f6208cd: Diagnose stuck queued jobs instead of leaving them ambiguous. A job that stays IN_QUEUE has two very different causes that its status alone cannot distinguish: no host has the endpoint's GPU available (capacity), or a worker spun up and is crash-looping — the platform marks it UNHEALTHY while the job stays queued indefinitely, and agents reliably misread that as a capacity shortage. `get-job-status` now best-effort attaches the endpoint's worker summary (`workerHealth`) and a plain-language `hint` whenever the job is IN_QUEUE (v2 only; the extra lookup never fails the status call, and the diagnosis is cached ~15s per endpoint so polling loops do not amplify into repeated worker-list fetches): UNHEALTHY workers → crash-loop guidance naming the worker ids to inspect with `stream-worker-logs`; zero workers → capacity guidance; throttled/initializing → wait guidance. The `get-job-status`, `endpoint-health`, `list-endpoint-workers`, and `stream-worker-logs` descriptions now cross-reference each other so agents are routed from a stuck job to the worker logs without prior knowledge of the platform's queueing behavior.
12
+ - f36f191: Send the reshaped v2 Serverless write schema, and support load-balancing endpoints.
13
+
14
+ `/v2/serverless` changed its create/update contract: endpoint `type` (`QUEUE` or
15
+ `LOAD_BALANCER`) is now required on create, the autoscaling object moved from a flat
16
+ `{type, value, idleTimeout}` to a per-scaler `{type, queueDelay}` / `{type, requestCount}`,
17
+ and `idleTimeout` moved under `workers`. `create-endpoint` and `update-endpoint` now emit
18
+ that shape; previously they sent the older one and were rejected with a `422`.
19
+
20
+ `create-endpoint` gains `endpointType` for queue-based (default) versus load-balancing
21
+ request routing. `scalerType` defaults per endpoint type, `scalerValue` defaults to `4`, and
22
+ passing `scalerValue` alone on `update-endpoint` keeps the endpoint's current scaler, so
23
+ existing calls keep working unchanged. Responses carry `type` and `requestUrls`, and
24
+ `get-endpoint` / `list-endpoints` now point at `requestUrls` as the source for an endpoint's
25
+ URLs.
26
+
27
+ **This requires a Runpod API host serving the new schema.** Against a host still on the older
28
+ one, endpoint create/update return a `422` naming `queueDelay`/`requestCount`/`idleTimeout` as
29
+ not allowed. `RUNPOD_REST_VERSION=v1` remains available for the legacy template-based model.
30
+
31
+ ## 3.0.0
32
+
33
+ ### Major Changes
34
+
35
+ - 119f633: Resync the tool surface with the current v2 REST spec.
36
+
37
+ **Breaking:** removes the seven tag tools (`list-tags`, `get-tag`, `create-tag`, `update-tag`,
38
+ `delete-tag`, `attach-tag`, `detach-tag`). `/v2/tags` no longer exists — it returns
39
+ `404 "The requested path was not found."` on both the production and dev hosts — so the tools
40
+ could not succeed for any caller.
41
+
42
+ **New:** three AWS ECR delegation tools (`list-registry-delegations`,
43
+ `create-registry-delegation`, `delete-registry-delegation`) for `/v2/registries/delegations`.
44
+ Unlike `create-container-registry-auth`, this stores no credentials: you register an ECR
45
+ repository ARN and Runpod is granted scoped pull access. v2-only.
46
+
47
+ **New:** `create-network-volume` gains `volumeType` (`STANDARD` | `HIGH_PERFORMANCE`). The
48
+ field was in the spec but no tool exposed it, so high-performance volumes could not be created
49
+ here. Omit it for the data center default. Its documented size range is also corrected to
50
+ 10–4096 GB (was 1–4000).
51
+
52
+ **Enabled:** `list-endpoint-releases` was implemented but left unregistered because
53
+ `GET /v2/serverless/{id}/releases` used to be dev-only. It now returns 200 on production.
54
+
55
+ `create-template` no longer sends `category: NVIDIA` when the caller omits it — v2 made the
56
+ field optional with that same server-side default, so the value is no longer invented
57
+ client-side. An explicit `category` still passes through.
58
+
59
+ ### Minor Changes
60
+
61
+ - fbcf9b7: Add `RUNPOD_AUTHED_GRAPHQL_URL` to override the GraphQL host used by authenticated operations that have no REST equivalent (`deploy-hub-repo`, `set-endpoint-gpus`). These calls send the caller's API key as a Bearer token, so they no longer follow `RUNPOD_PUBLIC_GRAPHQL_URL` — that variable stays the credential-free discovery override, safe to point at a stub.
62
+ - 00e6ec2: Surface dead credentials as a proper HTTP 401 on the HTTP server so OAuth-capable MCP clients re-authenticate automatically.
63
+
64
+ Previously, when a bearer token was revoked mid-session (e.g. an OAuth-minted key), every upstream Runpod call failed with a 401 that the MCP SDK wrapped into a 200 JSON-RPC tool error — the client never saw an HTTP 401, never re-ran its auth flow, and the user was stuck with bare "Unauthorized" tool errors until they manually reconnected. The request handler now pre-flight verifies the bearer (one `myself` GraphQL query, cached ~60s valid / ~30s invalid by token hash, never the raw token) and answers `401` + `WWW-Authenticate` with the protected-resource metadata when the credential is dead. `WWW-Authenticate` is exposed via CORS so browser clients can read it, and a rejected credential carries `error="invalid_token"` to distinguish it from a request that sent none (RFC 6750 §3.1). `ToolContext` gains an optional `onUnauthorized` callback, invoked when an outbound call returns 401, which drops the cached verdict so the next request re-checks.
65
+
66
+ The check is deliberately conservative so it can never reject a working key:
67
+ - It fails **open** on anything indeterminate — auth-backend errors, 5xx, 403 (this host sits behind a WAF, and a block is not a revocation), a slow backend (time-bound), and a GraphQL response carrying an `errors` array (a resolver blip returns `myself: null` for everyone at once; treating that as invalid would 401 every valid key). Failing closed on any of these would make OAuth clients re-run the flow, minting a new API key per attempt — an unrecoverable loop.
68
+ - It runs only for the requests the transport would actually run a tool for: a `POST` whose `Content-Type` the SDK treats as JSON and whose body invokes a method (including inside a batch). Everything else is passed through unchecked.
69
+ - It self-disables (logging `skip_env_mismatch`) when the REST/Serverless hosts and the auth-GraphQL host disagree about environment in either direction, since it would otherwise validate a key against the wrong backend.
70
+ - Request bodies are capped at 4 MB (matching the SDK) on hosts that do not pre-parse them.
71
+ - The verdict cache is safe under load: eviction never disowns an in-flight check, and TTLs use a monotonic clock, so a burst of distinct tokens or a wall-clock adjustment cannot let a since-revoked key linger as `valid`.
72
+
73
+ Set `MCP_SKIP_CREDENTIAL_CHECK=true` to disable the pre-flight entirely.
74
+
75
+ Notes for consumers of the published `./http` export (not only the hosted deployment): the pre-flight adds one outbound `myself` call to the Runpod GraphQL host per checked request, and a new dependency on that host being reachable (it fails open if not). This does **not** close the pre-existing key-validity oracle — a caller who speaks MCP can still learn 401-vs-not for a token, one upstream call each, with no rate limiting; closing that needs rate limiting, which this does not add.
76
+
77
+ - f3b226b: Add a `deploy-hub-repo` tool that deploys a Runpod Hub repo's listed release as a new Serverless endpoint — the same operation as clicking Deploy on the Hub. Identify the repo by `repo` ("owner/name") or `hubReleaseId` (both from `list-hub-repos`); the release supplies the prebuilt image, container disk, CUDA constraints, and env-var defaults, with caller overrides for env vars, GPU pools, worker counts, scaling, and FlashBoot. Required env vars without a default fail fast with an actionable message before anything is created, as do POD listings and releases without a GPU pool when none is provided. Uses the authenticated GraphQL `saveEndpoint` mutation (Hub deploys have no REST home yet), so it behaves identically on v1 and v2. The tool runtime gains a `graphqlAuthed` helper (API-key Bearer + variables) to support it.
78
+ - 725b6cd: Surface realtime GPU availability on the v2 catalog. `list-gpu-types` now requests `?include=AVAILABILITY` by default, so each GPU carries an `availability` summary (HIGH/MEDIUM/LOW/NONE) and results are sorted highest-stock-first. The full catalog is still returned by default — nothing is hidden — so the tool stays complete for discovery and capacity/price surveys. `includeUnavailable` is now an opt-in _hide_: pass `includeUnavailable: false` to drop out-of-stock GPUs and list only currently-deployable ones. A new `includeAvailability` param (default true) can opt out of the stock lookup entirely. `get-gpu-type` returns the per-datacenter availability breakdown (and URL-encodes ids, which contain spaces) so callers can pick a `dataCenterIds` with stock before creating a pod. Falls back gracefully when the backend doesn't populate availability.
79
+
80
+ The v2 path also drops the `"unknown"` sentinel GPU (matching the v1 path) so it doesn't leak into the now-unhidden default list.
81
+
82
+ Behavior change to note: `list-gpu-types` still returns every GPU by default, but results are now sorted highest-stock-first rather than in a stable order. Nothing is hidden by default.
83
+
84
+ - 546a40f: Add a `list-hub-repos` tool for discovering the Runpod Hub catalog (prebuilt Serverless workers and Pod templates such as vLLM, ComfyUI, and Axolotl). Served by the public GraphQL endpoint — no auth required — and available on both v1 and v2. Each result includes the repo metadata (stars, deploys, category, tags) plus the currently listed release with its `hubReleaseId` and prebuilt `imageName`, the two values a Hub deploy is pinned to. Supports `searchTerm`, `category`, `type` (SERVERLESS/POD), and `repoOwner` filters (applied client-side), and an opt-in `includeConfig` that returns the release's parsed hardware/env-var config from `.runpod/hub.json`. Results are sorted most-deployed first and use the shared pagination envelope.
85
+ - e4fabd1: Add a `list-public-endpoints` tool for discovering Runpod Public Endpoints — the managed, pay-per-use model APIs (text, image, video, audio) that require no deployment. Served by the public GraphQL endpoint — no auth required — and available on both v1 and v2. Each result includes the `endpointId` to call with `run-endpoint`/`runsync-endpoint` (or directly at `https://api.runpod.ai/v2/{endpointId}`), plus the model name, modality, owner, and pricing parsed from the catalog metadata. Only live endpoints are listed by default (`includeOffline:true` to include the rest), with `searchTerm`, `modality`, and `owner` filters and the shared pagination envelope.
86
+ - cc0966c: Enable pod and serverless worker log streaming (v2). `stream-pod-logs` (GET /v2/pods/{id}/logs) is now registered — it was previously implemented but disabled while the endpoint was dev-only, and it is now live on prod. A new `stream-worker-logs` tool (GET /v2/serverless/{id}/workers/{workerId}/logs) streams a single worker's logs; get the workerId from `list-endpoint-workers`. Both read a bounded snapshot of the Server-Sent-Events stream (container and/or system) and support `source`, `tail`, `since`, and `maxWaitMs`; both return a 501 notice on the v1 API.
87
+ - 466a9d8: Add a `set-endpoint-gpus` tool that sets which GPUs any Serverless endpoint's workers run on — including pinning specific GPU SKUs, which the REST API cannot express (its pool-level `gpuPoolIds` has no exclusion concept). Callers pass either a raw `gpuIds` string or `pools` plus `excludeGpuTypeIds` (GPU type ids from `list-gpu-types`) and the exclusion string is built automatically; excluding all but one SKU in a pool pins that SKU exactly. Because the GraphQL `saveEndpoint` mutation resets omitted endpoint-level fields to server defaults (verified live), the tool reads the endpoint's current settings first and echoes every field back with only the GPU selection changed — workers, scaling, timeouts, FlashBoot, locations, network volumes, and the template are all preserved.
88
+ - d1f3719: create-pod template deploy improvements. Added a `containerRegistryAuthId` param to `create-pod` (private-image registry credential, a valid v2 ContainerConfig field). When deploying from a `templateId`, the template's registry credential is inherited as a default so a private-image template pulls correctly, `containerRegistryAuthId` overrides it, and passing an empty string opts out entirely (emits `registry: null`, which v2 accepts, clearing the template's credential). The template is fetched from v2 explicitly, so a split per-resource version override (e.g. templates pinned to v1) can't yield a v1-shaped template merged into a v2 pod body. Tool descriptions now state that template fields are applied whole-field as defaults (an explicitly-passed field replaces the template value rather than merging).
89
+ - 0b49b91: Fix two template gaps from the same ticket (API-385 / E-3717).
90
+ 1. `create-template`/`update-template` were dropping the container start command on the v2 REST API. `dockerStartCmd` is now mapped to the v2 template's `args` field (a single string; a multi-element array is space-joined) instead of being discarded, so a template's startup command is persisted. `update-template` accepts `dockerStartCmd` now too. (v2 has no separate entrypoint field, so `dockerEntrypoint` is still not persisted on v2 — documented in the tool.)
91
+ 2. `create-pod` can now deploy from a template. v2 `CreatePodRequest` has no `templateId`, so `create-pod` accepts a `templateId`, fetches the template, and spreads its container config (image, start command, ports, env, disk, volume, registry credential) into the pod body as defaults — any field you also pass explicitly overrides the template. `imageName` is now optional when `templateId` is given. Template-based deploy requires the v2 REST API and (for now) a GPU pod; clear errors are returned for v1, CPU, or when neither image nor template is supplied.
92
+
93
+ ### Patch Changes
94
+
95
+ - e50409d: URL-encode the resource ids interpolated into the log-streaming request paths (`stream-pod-logs`, `stream-worker-logs`) so an id containing a URL-special character can't corrupt the request path. Opaque Runpod ids are unaffected in practice; this is defensive hardening.
96
+ - fb76883: Surface the configured `RUNPOD_REST_VERSION` in the MCP `serverInfo` version, e.g. `2.0.0 [RUNPOD_REST_VERSION=v2]` (or `RUNPOD_REST_VERSION unset (default v2)`). A plain `initialize` handshake now reveals whether a deployment is running v1 or v2 without inspecting the environment, and flags any per-resource overrides.
97
+
3
98
  ## 2.0.0
4
99
 
5
100
  ### Major Changes
@@ -65,7 +160,7 @@
65
160
 
66
161
  ### Minor Changes
67
162
 
68
- - 3e6dedf: Add HTTP transport for hosted MCP server deployments. The package now exports three entrypoints: `@runpod/mcp-server` (stdio, unchanged), `@runpod/mcp-server/http` (streamable HTTP with per-request auth), and `@runpod/mcp-server/tools` (shared tool definitions). This enables deploying the MCP server on Vercel or any HTTP-capable host where each request carries its own RunPod API key via the Authorization header. Existing stdio users are unaffected.
163
+ - 3e6dedf: Add HTTP transport for hosted MCP server deployments. The package now exports three entrypoints: `@runpod/mcp-server` (stdio, unchanged), `@runpod/mcp-server/http` (streamable HTTP with per-request auth), and `@runpod/mcp-server/tools` (shared tool definitions). This enables deploying the MCP server on Vercel or any HTTP-capable host where each request carries its own Runpod API key via the Authorization header. Existing stdio users are unaffected.
69
164
  - 3e6dedf: Add a "Sign in with Runpod" OAuth flow to the hosted HTTP server so it can act as the authorization server for Claude's MCP connector. When `MCP_OAUTH_ENABLED=true`, the server advertises itself in the OAuth discovery metadata and exposes `GET /authorize` and `POST /token`. The flow reuses the Runpod flash auth backend: `/authorize` creates a guest `createFlashAuthRequest` and hands off to the Runpod console for approval, and `/token` polls `flashAuthRequestStatus` and returns the minted Runpod API key as the access token, which the server then forwards to the Runpod API. The backend endpoint and console base URL are configurable via `RUNPOD_GRAPHQL_URL` and `CONSOLE_BASE_URL`.
70
165
  - 3e6dedf: Complete the hosted OAuth flow for real MCP clients. Add an OAuth 2.0 Dynamic Client Registration endpoint (`POST /register`, RFC 7591) and advertise it as `registration_endpoint`, so clients like Claude can register before signing in. Make the Runpod REST and Serverless API hosts configurable via `RUNPOD_REST_API_URL` and `RUNPOD_SERVERLESS_API_URL` so a deployment authenticating with non-production keys can target the matching environment. The console handoff path is `/integrations/mcp/login`.
71
166
  - 3e6dedf: Validate the OAuth `redirect_uri` against an allowlist. Because the authorization code redeems into a real Runpod API key, `/authorize` and `/token` now reject any `redirect_uri` that is not an allowlisted client callback, preventing an attacker from crafting an authorize link that delivers the code (and key) to a host they control. Loopback addresses (`http://localhost` / `127.0.0.1` / `::1`, any port) are always allowed per RFC 8252; the hosted client callbacks default to Claude's, and the list is extendable via `MCP_ALLOWED_REDIRECT_URIS` (comma-separated).
@@ -102,4 +197,4 @@
102
197
 
103
198
  ### Minor Changes
104
199
 
105
- - c49b2cc: Add npx support for running the MCP server directly without installation. Includes bin field in package.json, shebang in build output, and updated README with npx command. Also fixes branding consistency (RunPod -> Runpod) and adds development conventions documentation.
200
+ - c49b2cc: Add npx support for running the MCP server directly without installation. Includes bin field in package.json, shebang in build output, and updated README with npx command. Also fixes branding consistency (Runpod -> Runpod) and adds development conventions documentation.
package/README.md CHANGED
@@ -2,32 +2,56 @@
2
2
 
3
3
  [![smithery badge](https://smithery.ai/badge/@runpod/runpod-mcp-ts)](https://smithery.ai/server/@runpod/runpod-mcp-ts)
4
4
 
5
- This is the official Runpod Model Context Protocol (MCP) server, published to npm as `@runpod/mcp-server`. It lets MCP clients such as Claude Code, Claude Desktop, Cursor, Windsurf, and VS Code manage your Runpod Pods, Serverless endpoints, templates, network volumes, and more.
5
+ The official Runpod Model Context Protocol (MCP) server. It lets MCP clients such as Claude Code, Claude Desktop, Cursor, Windsurf, and VS Code manage your Runpod Pods, Serverless endpoints, templates, network volumes, and more.
6
+
7
+ **We host it for you at [`https://mcp.getrunpod.io/`](https://mcp.getrunpod.io/)** — point your client at that URL and sign in with Runpod. Nothing to install, no API key on disk. Or run it locally from npm as [`@runpod/mcp-server`](https://www.npmjs.com/package/@runpod/mcp-server).
6
8
 
7
9
  ## Quick start
8
10
 
9
- The fastest way to get connected is the guided installer pointed at the **hosted Runpod MCP server at `https://mcp.getrunpod.io/`**. The installer detects the agents you have installed, asks which ones to configure, and writes the configuration for you:
11
+ The guided installer detects the clients you have installed, asks which to configure, and writes the config for you:
10
12
 
11
13
  ```bash
12
14
  npx @runpod/mcp-server@latest add
13
15
  ```
14
16
 
15
- It supports **Claude Code, Claude Desktop, Cursor, Windsurf, and Visual Studio Code**, and offers two connection modes:
17
+ It offers two connection modes:
16
18
 
17
- - **Hosted (recommended).** Points the agent at the hosted server and authenticates with the **"Sign in with Runpod"** OAuth flow, so **no API key is stored on disk**.
18
- - **Local.** Runs the server through `npx` and stores a `RUNPOD_API_KEY` in the agent's config.
19
+ - **Hosted (recommended)** — points the client at the hosted server and authenticates with "Sign in with Runpod" (OAuth). No API key is stored on disk.
20
+ - **Local** — runs the server through `npx` and stores a `RUNPOD_API_KEY` in the client's config.
19
21
 
20
- To undo the changes later, run:
22
+ To undo later:
21
23
 
22
24
  ```bash
23
25
  npx @runpod/mcp-server@latest remove
24
26
  ```
25
27
 
26
- ### Connect to the hosted server manually
28
+ ### Or install the whole Runpod plugin
29
+
30
+ For the full agent setup, the [official plugin marketplace](https://github.com/runpod/runpod-plugins-official) bundles this server with a router skill plus five more — `runpod-mcp`, `runpodctl`, `flash`, `runpod-usage`, and `companion-clis`:
31
+
32
+ ```bash
33
+ npx skills add runpod/runpod-plugins-official
34
+ ```
35
+
36
+ That works in Claude Code, Codex, Cursor, Copilot, Windsurf, Cline, Gemini, opencode, and 17+ other agents, and installs the skills — pair it with `npx @runpod/mcp-server@latest add` above for the control-plane tools.
27
37
 
28
- If you'd rather configure your client by hand, point it at the hosted server over HTTP (no local process, no API key stored).
38
+ In **Claude Code**, the native plugin route also wires up the hosted MCP server for you (OAuth included), so no separate setup is needed:
29
39
 
30
- **Claude Code** — add it as an HTTP server:
40
+ ```
41
+ /plugin marketplace add runpod/runpod-plugins-official
42
+ /plugin install runpod@runpod
43
+ ```
44
+
45
+ ### Requirements
46
+
47
+ - Node.js 18 or higher.
48
+ - A Runpod account and [API key](https://www.runpod.io/console/user/settings).
49
+
50
+ ## Connect to the hosted server
51
+
52
+ To configure a client by hand, point it at the hosted server over HTTP (no local process, no API key stored).
53
+
54
+ **Claude Code:**
31
55
 
32
56
  ```bash
33
57
  claude mcp add --transport http runpod -s user https://mcp.getrunpod.io/
@@ -45,34 +69,29 @@ claude mcp add --transport http runpod -s user https://mcp.getrunpod.io/
45
69
  }
46
70
  ```
47
71
 
48
- The hosted server uses the "Sign in with Runpod" OAuth flow for authentication, so no API key is stored. An OAuth-capable client starts the sign-in flow automatically on first connect. See [Sign in with Runpod (authorize flow)](#sign-in-with-runpod-authorize-flow) for details.
72
+ An OAuth-capable client starts the "Sign in with Runpod" flow automatically on first connect: it opens a browser, you log in to the Runpod console and approve, and the server obtains a Runpod API key scoped to your session. Nothing is stored on disk.
49
73
 
50
- > Prefer your own API key instead of OAuth? Append `--header "Authorization: Bearer YOUR_API_KEY"` to the `claude mcp add` command (or add a `headers` block in the JSON), and the server forwards that key to the Runpod API directly.
51
-
52
- ### Requirements
53
-
54
- - Node.js 18 or higher.
55
- - A Runpod account and API key: https://www.runpod.io/console/user/settings
74
+ > Prefer your own API key over OAuth? Append `--header "Authorization: Bearer YOUR_API_KEY"` to the `claude mcp add` command (or add a `headers` block in the JSON). The server forwards that key to the Runpod API directly.
56
75
 
57
76
  ## Run locally with `npx`
58
77
 
59
- To run the server as a local `stdio` process with your own API key:
78
+ Run the server as a local `stdio` process with your own API key:
60
79
 
61
80
  ```bash
62
81
  RUNPOD_API_KEY=YOUR_API_KEY npx -y @runpod/mcp-server@latest
63
82
  ```
64
83
 
65
- ### Install via Smithery
84
+ Or install via [Smithery](https://smithery.ai/server/@runpod/runpod-mcp-ts):
66
85
 
67
86
  ```bash
68
87
  npx -y @smithery/cli install @runpod/runpod-mcp-ts --client claude
69
88
  ```
70
89
 
71
- ## Local MCP client setup
90
+ ### Local client setup
72
91
 
73
- Local MCP clients should use the default package entrypoint, which is the `stdio` server. The caller sets `RUNPOD_API_KEY` in the environment, and the server forwards it directly to the Runpod API.
92
+ Local clients launch the `stdio` server and set `RUNPOD_API_KEY` in the environment.
74
93
 
75
- ### Claude Code
94
+ **Claude Code:**
76
95
 
77
96
  ```bash
78
97
  claude mcp add runpod -s user \
@@ -80,27 +99,9 @@ claude mcp add runpod -s user \
80
99
  -- npx -y @runpod/mcp-server@latest
81
100
  ```
82
101
 
83
- For a project-local server:
102
+ Use `-s project` for a project-local server. Verify with `claude mcp list`; in a session, `/mcp` reconnects.
84
103
 
85
- ```bash
86
- claude mcp add runpod -s project \
87
- -e RUNPOD_API_KEY=YOUR_API_KEY \
88
- -- npx -y @runpod/mcp-server@latest
89
- ```
90
-
91
- Verify with `claude mcp list`. In an active session, use `/mcp` to reconnect.
92
-
93
- ### Claude Desktop
94
-
95
- Local MCP servers in Claude Desktop still use `claude_desktop_config.json`.
96
-
97
- macOS:
98
-
99
- `~/Library/Application Support/Claude/claude_desktop_config.json`
100
-
101
- Windows:
102
-
103
- `%APPDATA%\\Claude\\claude_desktop_config.json`
104
+ **Claude Desktop, Cursor, VS Code, Windsurf, and other clients** — use the same command in the client's MCP config:
104
105
 
105
106
  ```json
106
107
  {
@@ -116,152 +117,38 @@ Windows:
116
117
  }
117
118
  ```
118
119
 
119
- Restart Claude Desktop after saving.
120
-
121
- For remote clients such as Claude's connector, use the hosted HTTP server instead (the [Quick start](#quick-start) above). The client then runs the OAuth "Sign in with Runpod" flow, and the resulting Runpod API key is forwarded to the Runpod API on each request.
122
-
123
- ### Cursor
124
-
125
- Add this to `.cursor/mcp.json` in your project or `~/.cursor/mcp.json` globally:
126
-
127
- ```json
128
- {
129
- "mcpServers": {
130
- "runpod": {
131
- "command": "npx",
132
- "args": ["-y", "@runpod/mcp-server@latest"],
133
- "env": {
134
- "RUNPOD_API_KEY": "YOUR_API_KEY"
135
- }
136
- }
137
- }
138
- }
139
- ```
140
-
141
- ### VS Code, Windsurf, Cline, JetBrains, and other local clients
142
-
143
- Use the same pattern:
144
-
145
- - command: `npx`
146
- - args: `["-y", "@runpod/mcp-server@latest"]`
147
- - env: `RUNPOD_API_KEY=YOUR_API_KEY`
148
-
149
- For a broader list of MCP clients, see https://modelcontextprotocol.io/clients
120
+ Claude Desktop's config lives at `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows); restart the app after saving. For a broader list of clients, see the [MCP clients directory](https://modelcontextprotocol.io/clients).
150
121
 
151
122
  ## Usage examples
152
123
 
153
- ### List all Pods
124
+ Ask your MCP client in natural language:
154
125
 
155
126
  ```text
156
- Can you list all my Runpod Pods?
127
+ List all my Runpod Pods.
157
128
  ```
158
129
 
159
- ### Create a new Pod
160
-
161
130
  ```text
162
- Create a new Runpod Pod with the following specifications:
163
- - Name: test-pod
164
- - Image: runpod/pytorch:2.1.0-py3.10-cuda11.8.0-devel-ubuntu22.04
165
- - GPU Type: NVIDIA GeForce RTX 4090
166
- - GPU Count: 1
131
+ Create a Runpod Pod named test-pod with image
132
+ runpod/pytorch:2.1.0-py3.10-cuda11.8.0-devel-ubuntu22.04,
133
+ GPU type NVIDIA GeForce RTX 4090, 1 GPU.
167
134
  ```
168
135
 
169
- ### Create a Serverless endpoint
170
-
171
136
  ```text
172
- Create a Runpod Serverless endpoint with the following configuration:
173
- - Name: my-endpoint
174
- - Image: runpod/test-output:0.0.1
175
- - GPU pool: AMPERE_80 (a "pool" value from list-gpu-types)
176
- - Minimum workers: 0
177
- - Maximum workers: 3
137
+ Create a Serverless endpoint named my-endpoint with image
138
+ runpod/test-output:0.0.1, GPU pool AMPERE_80, 0 min workers, 3 max workers.
178
139
  ```
179
140
 
180
- On the v2 API (the default) endpoints are image-based — pass an image and a GPU
181
- pool, not a template. To use the legacy template-based model, pin
182
- `RUNPOD_REST_VERSION=v1` and provide a `Template ID` instead.
183
-
184
- ## Hosted HTTP deployment
185
-
186
- The package also exports a Streamable HTTP entrypoint at `@runpod/mcp-server/http`, and this repo includes a Vercel function in `api/index.ts`. This is what powers the hosted server at `https://mcp.getrunpod.io/`.
141
+ On the v2 API (the default), endpoints are image-based — pass an image and a GPU pool (a `pool` value from `list-gpu-types`), not a template.
187
142
 
188
- The hosted transport is stateless:
143
+ See [`docs/configuration.md`](docs/configuration.md) for REST v1/v2 selection and the `templateId` migration note, private image pull (registry credentials vs ECR delegation), and large-output handling.
189
144
 
190
- - Each request creates a fresh MCP server instance.
191
- - The caller must send `Authorization: Bearer <token>`.
192
- - No credentials are cached or shared server-side.
145
+ ## Security
193
146
 
194
- ### Hosted auth
147
+ This server acts with the full permissions of the supplied API key.
195
148
 
196
- The server forwards the caller's Bearer token directly to the Runpod API as the credential for that request. There is no server-side or shared key.
197
-
198
- The token can be either:
199
-
200
- - a Runpod API key the caller configured manually, or
201
- - a Runpod API key obtained through the OAuth "Sign in with Runpod" flow (see below).
202
-
203
- An unauthenticated request receives a `401` with a `WWW-Authenticate` header pointing at the protected-resource metadata, which tells an OAuth-capable client (such as Claude) to start the sign-in flow. A caller that brings its own API key as the bearer token never hits that path.
204
-
205
- ### Sign in with Runpod (authorize flow)
206
-
207
- In OAuth mode the hosted server is itself the authorization server for Claude's connector. It advertises itself in `/.well-known/oauth-protected-resource` and `/.well-known/oauth-authorization-server`, pointing `authorization_endpoint` at its own `GET /authorize`, `token_endpoint` at its own `POST /token`, and `registration_endpoint` at its own `POST /register`.
208
-
209
- The flow reuses the Runpod flash auth backend and mints a real Runpod API key:
210
-
211
- 1. The client registers via `POST /register` (OAuth Dynamic Client Registration, RFC 7591) to obtain a `client_id`. This is a public client; no client secret is used.
212
- 2. `GET /authorize` calls the guest `createFlashAuthRequest` mutation to get a request id (which serves as the OAuth authorization code), then `302`-redirects the browser to the console handoff page (`/integrations/mcp/login`), carrying the request id plus the client's `redirect_uri` and `state`.
213
- 3. The user logs in and approves the request in the console. On approval the backend mints a Runpod API key for the request.
214
- 4. The console returns the browser to the client's `redirect_uri` with `code=<request id>`.
215
- 5. `POST /token` polls the guest `flashAuthRequestStatus` query for that id; once `APPROVED`, it returns the minted `apiKey` as the `access_token`. The client then sends that key as its bearer token on every MCP request, and the server forwards it to the Runpod API.
216
-
217
- This flow uses these environment variables:
218
-
219
- - `RUNPOD_GRAPHQL_URL`: flash auth backend endpoint (default `https://api.runpod.io/graphql`).
220
- - `CONSOLE_BASE_URL`: base URL of the console that hosts the handoff login page (default `https://console.runpod.io`).
221
- - `RUNPOD_REST_API_URL` / `RUNPOD_SERVERLESS_API_URL`: override the REST and Serverless API hosts so a deployment authenticating with non-production keys can target the matching environment.
222
- - `RUNPOD_API_KEY_NAME`: name for the minted key as shown in the user's dashboard. Defaults to `runpod-mcp`. Set it to `""` to omit the name for a backend that does not support the `apiKeyName` argument (such backends reject the request when it is sent).
223
- - `MCP_ALLOWED_REDIRECT_URIS`: comma-separated extra `redirect_uri` values to allow, in addition to the built-in Claude callbacks. Loopback addresses (`localhost`/`127.0.0.1`/`::1`, any port) are always allowed. `/authorize` and `/token` reject any `redirect_uri` not on this list, since the authorization code redeems into a real API key.
224
-
225
- You can verify the entire flow end to end with `MCP_SERVER_URL=<deployment-url> npx tsx scripts/oauth-e2e.ts` (the harness uses a loopback callback).
226
-
227
- Notes and current limitations:
228
-
229
- - PKCE is not supported: `code_challenge` is neither advertised nor enforced (the flash flow has no place to bind it). Security relies on the `redirect_uri` allowlist and the single-use, short-lived flash approval.
230
- - The minted key is named via `RUNPOD_API_KEY_NAME` (default `runpod-mcp`), which requires a flash backend that supports the `apiKeyName` argument. Against a backend without it, set `RUNPOD_API_KEY_NAME=""`.
231
-
232
- ### Vercel
233
-
234
- This repo already contains `vercel.json` and the Vercel handler.
235
-
236
- Deploy with the Vercel CLI:
237
-
238
- ```bash
239
- vercel
240
- vercel --prod
241
- ```
242
-
243
- After deploy, test the endpoint:
244
-
245
- ```bash
246
- curl -i https://YOUR-DEPLOYMENT.vercel.app/
247
- ```
248
-
249
- Unauthenticated requests should return `401`.
250
-
251
- ### Hosted smoke test
252
-
253
- ```bash
254
- MCP_SERVER_URL=https://YOUR-DEPLOYMENT.vercel.app \
255
- RUNPOD_API_KEY=YOUR_API_KEY \
256
- pnpm smoke:http
257
- ```
258
-
259
- This validates:
260
-
261
- - MCP initialization.
262
- - `tools/list`.
263
- - A public GraphQL-backed tool call.
264
- - An authenticated REST-backed tool call.
149
+ - Never share your API key.
150
+ - Be deliberate with destructive tools.
151
+ - Each request authenticates with its own caller-supplied token, which is forwarded to the Runpod API and **never persisted server-side**. The server never holds a credential of its own and never shares one across users.
265
152
 
266
153
  ## Local development
267
154
 
@@ -278,153 +165,16 @@ Run the local build directly:
278
165
  RUNPOD_API_KEY=YOUR_API_KEY node dist/stdio.mjs
279
166
  ```
280
167
 
281
- Or point a client at your local build:
282
-
283
- ```json
284
- {
285
- "command": "node",
286
- "args": ["/absolute/path/to/runpod-mcp/dist/stdio.mjs"],
287
- "env": {
288
- "RUNPOD_API_KEY": "YOUR_API_KEY"
289
- }
290
- }
291
- ```
292
-
293
- ### Local smoke test
294
-
295
- ```bash
296
- RUNPOD_API_KEY=YOUR_API_KEY pnpm build
297
- RUNPOD_API_KEY=YOUR_API_KEY pnpm smoke:stdio
298
- ```
299
-
300
- ## Contributing
301
-
302
- The source is now split by responsibility:
303
-
304
- - `src/stdio.ts`: local `stdio` entrypoint (runs the v2 probe at startup for `auto` mode).
305
- - `src/http.ts`: bearer-token extraction and the per-request MCP session for the Streamable HTTP transport.
306
- - `src/tools.ts`: thin orchestrator — builds the shared runtime and calls each per-resource registrar.
307
- - `src/tools/<resource>.ts`: the tools for one resource (`pods`, `endpoints`, `jobs`, `templates`, `network-volumes`, `registries`, `catalog`), each with a description + MCP annotations.
308
- - `src/tools/runtime.ts`: the shared per-server runtime (caller-tracking, the authenticated REST/Serverless/GraphQL clients, the v1/v2 backend resolver) threaded into every registrar.
309
- - `src/server.ts`: shared server metadata and construction.
310
- - `src/_shared/backend.ts`: v1/v2 routing adapter — version resolution, per-resource paths, list-envelope unwrap, and the v2 probe.
311
- - `src/_shared/http.ts`: unified authenticated JSON client + `HttpError`.
312
- - `src/_shared/tracking.ts`: caller-tracking header construction.
313
- - `src/_shared/mappers.ts`: v1→v2 request-body mappers.
314
- - `api/index.ts`: Vercel adapter and the OAuth authorization-server routes (`/.well-known/*`, `/register`, `/authorize`, `/token`).
315
-
316
168
  After changes:
317
169
 
318
170
  ```bash
319
171
  pnpm type-check
320
172
  pnpm lint
321
- pnpm test
173
+ pnpm test # offline unit suite — no network or API key required
322
174
  pnpm build
323
175
  ```
324
176
 
325
- `pnpm test` runs the offline unit suite (outbound-request goldens, adapter, mappers, http client) — no network or API key required.
326
-
327
- ### v2 spec parity gate
328
-
329
- `tests/spec-parity.test.ts` walks every operation in the vendored v2 OpenAPI spec (`tests/fixtures/v2-openapi.yaml`) and fails if a v2 endpoint has no MCP tool covering it (and isn't explicitly allowlisted) — the drift gate that flags when the API grows an endpoint we don't expose yet. It also runs the reverse check (no tool is left unaccounted for). It's part of `pnpm test`, hermetic (parses the committed spec; no network, no API key).
330
-
331
- Refresh the vendored spec when the v2 API changes:
332
-
333
- ```bash
334
- pnpm tsx scripts/fetch-v2-spec.ts # re-fetch tests/fixtures/v2-openapi.yaml
335
- pnpm test # parity test shows any newly-uncovered endpoint
336
- ```
337
-
338
- The serverless runtime tools (`run-endpoint`, `get-job-status`, …) target `api.runpod.ai/v2`, which is a different service from the v2 REST control plane, so they are allowlisted as intentionally spec-unmapped. The spec has no logs/artifacts endpoints, so there are no such tools.
339
-
340
- An optional live shape check (skipped by default) verifies the live endpoints still return the envelopes the list tools unwrap; run it with `MCP_LIVE_V2_KEY=<dev-key> pnpm test` (optionally `MCP_LIVE_V2_BASE`).
341
-
342
- For transport validation:
343
-
344
- ```bash
345
- pnpm smoke:stdio
346
- pnpm smoke:http
347
- ```
348
-
349
- To exercise a real create→get→delete lifecycle against a **dev account** (free resources only — templates and registry auths — with fail-closed teardown):
350
-
351
- ```bash
352
- RUNPOD_API_KEY=YOUR_DEV_KEY \
353
- RUNPOD_REST_V2_API_URL=https://v2-rest.runpod.dev/v2 \
354
- pnpm smoke:crud v1 v2
355
- ```
356
-
357
- This project uses [changesets](https://github.com/changesets/changesets) for versioning and npm publishing. Every PR with user-facing changes needs a changeset file at `.changeset/DESCRIPTIVE_NAME.md`.
358
-
359
- See `CLAUDE.md` and `docs/context.md` for contributor guidance.
360
-
361
- ## Reference
362
-
363
- ### Deployment modes
364
-
365
- The server supports two deployment modes:
366
-
367
- - Local `stdio` for Claude Desktop, Claude Code, Cursor, VS Code, and other MCP clients that launch a local process. The caller sets `RUNPOD_API_KEY` in the environment.
368
- - Hosted Streamable HTTP for Vercel or other HTTP-capable platforms. Each request carries its own `Authorization: Bearer <token>`, which the server forwards directly to the Runpod API. The token can be a Runpod API key or one obtained through the OAuth "Sign in with Runpod" flow.
369
-
370
- The server never holds a credential of its own and never shares one across users.
371
-
372
- ### REST API version (v1 / v2)
373
-
374
- The server can target either the v1 REST API (`rest.runpod.io/v1`) or the newer v2 REST API (`v2-rest.runpod.io/v2`). It **defaults to v2**; set `RUNPOD_REST_VERSION=v1` to pin the previous v1 behavior. These environment variables are read once at startup:
375
-
376
- | Variable | Values | Default | Effect |
377
- | -------------------------------- | ---------------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------- |
378
- | `RUNPOD_REST_VERSION` | `v1` \| `v2` \| `auto` | `v2` | Version used for all resources. |
379
- | `RUNPOD_REST_VERSION_<RESOURCE>` | `v1` \| `v2` \| `auto` | — | Per-resource override (e.g. `RUNPOD_REST_VERSION_PODS=v2`). Takes precedence over the global setting. |
380
- | `RUNPOD_REST_V2_API_URL` | URL | `https://v2-rest.runpod.io/v2` | v2 base URL. Override to target a non-prod host. |
381
- | `RUNPOD_REST_API_URL` | URL | `https://rest.runpod.io/v1` | v1 base URL. |
382
- | `RUNPOD_SERVERLESS_API_URL` | URL | `https://api.runpod.ai/v2` | Serverless runtime base URL. |
383
-
384
- Notes:
385
-
386
- - **Default is v2** — with nothing set, every control-plane resource uses the v2 REST API. Set `RUNPOD_REST_VERSION=v1` to pin the previous v1 behavior.
387
- - **Pinning a deployment** — the env var is read once at startup, so set `RUNPOD_REST_VERSION` (`v1` or `v2`) in the host's environment (e.g. a Vercel project env var) and redeploy; no code change. Hosted HTTP honors this default like any other transport.
388
- - **What `auto` does:** it probes v2 once at startup and falls back to v1 — but **only on the `stdio` transport** (one process = one key). On hosted HTTP `auto` resolves to **v1**, because a warm instance serves many users and a cached probe verdict could leak across them. `auto` is a stdio-only convenience; on HTTP, rely on the default or pin the version explicitly.
389
- - `jobs` (serverless runtime) always uses v1 regardless of the setting — it has no v2 REST home (it targets `api.runpod.ai/v2`, a different service).
390
- - The v2-only tools (`list-cpu-types`, `get-gpu-type`, `restart-pod`) return a clear "v2 only" notice when called under v1.
391
-
392
- > **⚠️ Migration note — `create-endpoint` / `update-endpoint` changed shape in v2.** Serverless endpoints now use the v2 API (`/v2/serverless`) with an **inline config** instead of a `templateId`. On v2, `create-endpoint` requires `imageName` + `gpuPoolIds` (GPU **pool** names from `list-gpu-types` — the `pool` field, e.g. `AMPERE_80`), plus optional `workersMin`/`workersMax`, `scalerType`/`scalerValue`/`idleTimeout`, `containerDiskInGb`, `env`, `flashboot`, etc. It no longer accepts `templateId`. **If you previously called `create-endpoint` with `{ templateId }` and have no `RUNPOD_REST_VERSION` set, that call now returns a clean `400` after upgrading** — switch to the inline fields, or pin `RUNPOD_REST_VERSION=v1` to keep the legacy template-based model.
393
-
394
- - `create-pod` for a **CPU pod** (`computeType: "CPU"`) on v2 is transparently served by the **v1** API — v2 has no CPU pods yet — and the reply is flagged `_servedBy: "v1"`. Because that fallback hits the **v1 base**, set `RUNPOD_REST_API_URL` to match your environment when running v2 against a non-prod host (otherwise CPU creates land on v1 **prod**). On v2 a create with neither `gpuTypeIds` nor `computeType` is rejected — absence is never silently turned into a CPU pod.
395
-
396
- Example (stdio client config) — v2 against prod:
397
-
398
- ```json
399
- "env": {
400
- "RUNPOD_API_KEY": "YOUR_API_KEY",
401
- "RUNPOD_REST_VERSION": "v2"
402
- }
403
- ```
404
-
405
- Targeting a **non-prod (dev) environment** — point **both** bases at it (the v1 base matters even in v2 mode, for the CPU-pod fallback above):
406
-
407
- ```json
408
- "env": {
409
- "RUNPOD_API_KEY": "YOUR_DEV_KEY",
410
- "RUNPOD_REST_VERSION": "v2",
411
- "RUNPOD_REST_V2_API_URL": "https://v2-rest.runpod.dev/v2",
412
- "RUNPOD_REST_API_URL": "https://rest.runpod.dev/v1"
413
- }
414
- ```
415
-
416
- ### Large tool output
417
-
418
- Resource **lists** are paginated (default 20 items, `nextCursor`), so a big account can't flood the agent's context. But **serverless job output** — `run-endpoint`, `runsync-endpoint`, `get-job-status`, and especially `stream-job` (which accumulates every chunk) — is returned **as-is and is not size-capped**. It's a single opaque payload, not a list, so there's no cursor to page. A very large or long-streaming result can exceed the context window. If output may be huge, have the agent **write it to a file** instead of returning it inline, or set `s3Config` on the job so large outputs go to object storage.
419
-
420
- ## Security considerations
421
-
422
- This server acts with the full permissions of the supplied `RUNPOD_API_KEY`.
423
-
424
- - Never share your API key.
425
- - Be deliberate about destructive tools.
426
- - Treat hosted deployments as sensitive infrastructure.
427
- - Each request authenticates with its own caller-supplied token, which is forwarded to the Runpod API and never persisted server-side.
177
+ This project uses [changesets](https://github.com/changesets/changesets) for versioning and npm publishing; every PR with user-facing changes needs a changeset. See `CLAUDE.md` and `docs/context.md` for full contributor guidance, architecture, and the test suite.
428
178
 
429
179
  ## License
430
180