@paraloncloud/mcp 0.0.0-stage → 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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +147 -2
  3. package/package.json +43 -4
  4. package/server.js +470 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ParalonCloud
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,148 @@
1
- # Temporary Holding Version
1
+ # ParalonCloud MCP server
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Rent GPUs from inside your AI agent, and, if you provide GPUs, run your own nodes from it.
4
+ This is an [MCP](https://modelcontextprotocol.io) server for the
5
+ [ParalonCloud Rental API](https://paraloncloud.com/docs/rental-api) and
6
+ [Provider API](https://paraloncloud.com/docs/provider-api): it lets Claude Code, Claude
7
+ Desktop, Cursor, or any MCP client
8
+
9
+ - **rent**: browse GPUs, start a rental, get its connection URL, and stop it;
10
+ - **provide**: list your nodes with live GPU load and temperature, add a node and get its
11
+ install command, take a node off the market and back, set its price, reclaim a spot
12
+ node, and read your earnings,
13
+
14
+ using natural language.
15
+
16
+ > One key for everything: the same `prlc_` key powers ParalonCloud's
17
+ > [OpenAI-compatible inference API](https://paraloncloud.com/docs/inference-api). Build an
18
+ > agent that calls a model **and** rents the GPU to run the heavy job.
19
+
20
+ > Formerly `@paraloncloud/mcp-rentals`. That package is deprecated: switch your config to `@paraloncloud/mcp`.
21
+
22
+ ## Tools
23
+
24
+ ### Renting (key needs the `rental` scope)
25
+
26
+ | Tool | What it does | Cost |
27
+ | --- | --- | --- |
28
+ | `list_gpus` | List rentable GPUs with price, VRAM, compute capability, country | free |
29
+ | `get_balance` | Your credit balance | free |
30
+ | `create_rental` | Start a Jupyter rental (async → poll) | **spends credits** |
31
+ | `get_rental` | Status + connection URL once running | free |
32
+ | `list_rentals` | Your active rentals (`status: "all"` for history) | free |
33
+ | `destroy_rental` | Stop a rental and stop billing | — |
34
+
35
+ ### Your nodes, for GPU providers (key needs the `nodes` scope)
36
+
37
+ | Tool | What it does |
38
+ | --- | --- |
39
+ | `list_my_nodes` | Your nodes: state (available, rented, paused, offline, …), GPUs, price and its allowed range, the current rental, live per-GPU load, temperature, power and memory |
40
+ | `get_my_node` | One node, same fields |
41
+ | `add_node` | Add a node; returns the docker command that installs the agent (it holds the node's token) |
42
+ | `get_node_install_command` | The install command of an existing node, again |
43
+ | `set_node_available` | Take a node off the market, or put it back; a running rental goes on to its end |
44
+ | `set_node_price` | Set the price in USD per hour for the node, or `null` for the default |
45
+ | `update_node` | Change name, spot, availability and price in one call |
46
+ | `reclaim_spot_node` | Take a spot node back for your own use; a spot rental on it stops in 2 minutes |
47
+ | `get_node_access` | Who can rent a node: everyone, or only the people, domains and organizations listed |
48
+ | `set_node_access` | Keep a node private for chosen renters (email, domain, organization), or open it to everyone (`[]`) |
49
+ | `get_earnings` | Earnings by day (rentals per node, inference per account) and the withdrawable balance |
50
+
51
+ Payouts are not reachable from the API or this server. Deleting a node stays on the site.
52
+
53
+ ## Setup
54
+
55
+ ### 1. Get a key with the right scope
56
+
57
+ 1. Create an API key in the [Console](https://paraloncloud.com/console).
58
+ 2. To rent, turn on **GPU rentals** for that key (rentals are opt-in), and optionally set
59
+ **Max rentals running at once** as a safety cap.
60
+ 3. To manage your own nodes, turn on **My nodes**. One key can have both.
61
+
62
+ Use a **dedicated key** for the agent, not your production key.
63
+
64
+ ### 2. Add it to your MCP client
65
+
66
+ The client passes your key via the `PARALON_API_KEY` env var — you never edit the server.
67
+
68
+ **Claude Desktop** — `claude_desktop_config.json`:
69
+
70
+ ```json
71
+ {
72
+ "mcpServers": {
73
+ "paraloncloud": {
74
+ "command": "npx",
75
+ "args": ["-y", "@paraloncloud/mcp"],
76
+ "env": {
77
+ "PARALON_API_KEY": "prlc_your_key_here"
78
+ }
79
+ }
80
+ }
81
+ }
82
+ ```
83
+
84
+ **Claude Code** — one command:
85
+
86
+ ```bash
87
+ claude mcp add paraloncloud \
88
+ --env PARALON_API_KEY=prlc_your_key_here \
89
+ -- npx -y @paraloncloud/mcp
90
+ ```
91
+
92
+ **Cursor** — `.cursor/mcp.json` (same shape as Claude Desktop above).
93
+
94
+ Optional env: `PARALON_BASE_URL` (defaults to `https://paraloncloud.com/api/v1`).
95
+
96
+ ### 3. Try it
97
+
98
+ > "List the cheapest GPUs I can rent, then start a 2-hour Jupyter rental on one with at least 24GB of VRAM."
99
+
100
+ The agent calls `list_gpus`, picks a node, and calls `create_rental` with `hours: 2`. It then
101
+ polls `get_rental` for the Jupyter URL. Say "stop it" and it calls `destroy_rental`.
102
+
103
+ As a provider:
104
+
105
+ > "How are my nodes doing? Is any GPU running hot?"
106
+
107
+ > "Take rig-2 off the market for the afternoon, and set rig-1 to $0.60 an hour."
108
+
109
+ > "How much did I earn this week, and from which node?"
110
+
111
+ ## Safety
112
+
113
+ - `create_rental` and `destroy_rental` change what you're billed — your MCP client will ask you
114
+ to approve them (Claude Code/Desktop confirm tool calls by default). Keep that on.
115
+ - `create_rental` auto-generates an idempotency key, so a retried call never starts a second GPU.
116
+ - Pass `hours` so a rental auto-stops even if the agent forgets to.
117
+ - The key's `max_active_rentals` limit (set in the Console) caps concurrency regardless.
118
+ - The node tools that change something (`add_node`, `set_node_available`, `set_node_price`,
119
+ `update_node`, `reclaim_spot_node`, `set_node_access`) tell the agent to confirm with you first;
120
+ `reclaim_spot_node` stops a renter's spot rental two minutes later.
121
+ - `add_node` and `get_node_install_command` return a command with the node's secret token:
122
+ keep it private.
123
+ - Give the agent a key with only the scopes it needs.
124
+
125
+ ## Test
126
+
127
+ ```bash
128
+ npm install
129
+ PARALON_API_KEY=prlc_your_key_here node smoke-test.mjs
130
+ ```
131
+
132
+ It calls the read-only tools, and the node tools only on a node that does not exist, so it
133
+ changes nothing.
134
+
135
+ ## Run locally (dev)
136
+
137
+ ```bash
138
+ PARALON_API_KEY=prlc_your_key_here node server.js
139
+ ```
140
+
141
+ ## Links
142
+
143
+ - Rental API docs: https://paraloncloud.com/docs/rental-api
144
+ - Provider API docs: https://paraloncloud.com/docs/provider-api
145
+ - Console (create keys): https://paraloncloud.com/console
146
+ - Inference API: https://paraloncloud.com/docs/inference-api
147
+
148
+ MIT
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "@paraloncloud/mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.3.0",
4
+ "mcpName": "io.github.ParalonCloud/paralon-mcp",
5
+ "description": "ParalonCloud MCP server: rent GPUs, and as a GPU provider manage your own nodes, prices and earnings, from an AI agent.",
6
+ "license": "MIT",
7
+ "author": "ParalonCloud",
8
+ "homepage": "https://github.com/ParalonCloud/paralon-mcp#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/ParalonCloud/paralon-mcp.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/ParalonCloud/paralon-mcp/issues"
15
+ },
16
+ "type": "module",
17
+ "bin": {
18
+ "paralon-mcp": "server.js"
19
+ },
20
+ "main": "server.js",
21
+ "files": [
22
+ "server.js",
23
+ "README.md"
24
+ ],
25
+ "scripts": {
26
+ "start": "node server.js"
27
+ },
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "keywords": [
32
+ "mcp",
33
+ "model-context-protocol",
34
+ "gpu",
35
+ "gpu-rental",
36
+ "paraloncloud",
37
+ "claude",
38
+ "ai-agent",
39
+ "gpu-provider",
40
+ "node-management"
41
+ ],
42
+ "dependencies": {
43
+ "@modelcontextprotocol/sdk": "^1.0.0"
44
+ }
45
+ }
package/server.js ADDED
@@ -0,0 +1,470 @@
1
+ #!/usr/bin/env node
2
+ // MCP server for the ParalonCloud Rental API and Provider API.
3
+ //
4
+ // Exposes the REST API (https://paraloncloud.com/api/v1) as MCP tools so an AI
5
+ // agent can browse GPUs, rent one, poll it for a connection URL, and stop it;
6
+ // and, for a GPU provider, manage their own nodes: list them with live GPU
7
+ // load and temperature, add one and get its install command, take it off the
8
+ // market and back, set its price, reclaim a spot node, and read earnings.
9
+ //
10
+ // Config lives in the MCP client, not here. The server reads two env vars:
11
+ // PARALON_API_KEY (required) a prlc_ key: the 'rental' scope for the
12
+ // rental tools, the 'nodes' scope for the
13
+ // provider tools (both can be on one key)
14
+ // PARALON_BASE_URL (optional) defaults to https://paraloncloud.com/api/v1
15
+ //
16
+ // Safety notes baked into the tool descriptions: create_rental and
17
+ // destroy_rental move money (per-minute billing), so the client should confirm
18
+ // them with the user. Renting is asynchronous — create returns a pending
19
+ // rental_id; call get_rental until status is "running" for the connection URL.
20
+
21
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
22
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
23
+ import {
24
+ CallToolRequestSchema,
25
+ ListToolsRequestSchema,
26
+ } from "@modelcontextprotocol/sdk/types.js";
27
+ import { randomUUID } from "node:crypto";
28
+
29
+ const BASE_URL = (process.env.PARALON_BASE_URL || "https://paraloncloud.com/api/v1").replace(/\/$/, "");
30
+ const API_KEY = process.env.PARALON_API_KEY || "";
31
+
32
+ // One thin REST helper. Returns { ok, status, data } — never throws on HTTP
33
+ // errors, so a tool can surface the API's own error message to the agent.
34
+ async function api(method, path, { body, headers } = {}) {
35
+ if (!API_KEY) {
36
+ return {
37
+ ok: false,
38
+ status: 0,
39
+ data: {
40
+ error: "missing_api_key",
41
+ message:
42
+ "Set PARALON_API_KEY in your MCP client config: a prlc_ key with the 'rental' scope for rentals, or the 'nodes' scope (My nodes) for your own nodes (create one at https://paraloncloud.com/console).",
43
+ },
44
+ };
45
+ }
46
+ try {
47
+ const res = await fetch(`${BASE_URL}${path}`, {
48
+ method,
49
+ headers: {
50
+ Authorization: `Bearer ${API_KEY}`,
51
+ ...(body ? { "Content-Type": "application/json" } : {}),
52
+ ...headers,
53
+ },
54
+ ...(body ? { body: JSON.stringify(body) } : {}),
55
+ });
56
+ let data = null;
57
+ try {
58
+ data = await res.json();
59
+ } catch {
60
+ data = {};
61
+ }
62
+ return { ok: res.ok, status: res.status, data };
63
+ } catch (e) {
64
+ return { ok: false, status: 0, data: { error: "network_error", message: String(e) } };
65
+ }
66
+ }
67
+
68
+ // Wrap a result as an MCP text response. Non-OK responses are flagged isError
69
+ // so the agent knows the call failed, with the API's message included.
70
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
71
+
72
+ function reply(result, note) {
73
+ let data = result.data;
74
+ // A key without the scope: say how to fix it, not just "forbidden".
75
+ if (!result.ok && data && data.error === "insufficient_scope") {
76
+ data = {
77
+ ...data,
78
+ how_to_fix:
79
+ "In https://paraloncloud.com/console → API keys, open this key's settings and turn on the scope it names: 'GPU rentals' for the rental tools, 'My nodes' for the node and earnings tools.",
80
+ };
81
+ }
82
+ const payload = note ? { note, ...data } : data;
83
+ return {
84
+ content: [{ type: "text", text: JSON.stringify(payload, null, 2) }],
85
+ isError: !result.ok,
86
+ };
87
+ }
88
+
89
+ const server = new Server(
90
+ { name: "paraloncloud", version: "1.3.0" },
91
+ { capabilities: { tools: {} } }
92
+ );
93
+
94
+ const TOOLS = [
95
+ {
96
+ name: "list_gpus",
97
+ description:
98
+ "List GPU nodes available to rent right now, with price per hour, GPU model, VRAM, CUDA compute capability, and country. Rent by the returned node_id. reserved_for_you: true marks a node its provider keeps for this key's person or organization: such nodes come first and nobody else sees them. Read-only, no cost. For modern LLM work prefer compute_cap >= 8.9 (FP8).",
99
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
100
+ },
101
+ {
102
+ name: "get_balance",
103
+ description:
104
+ "Get the account's credit balance (rentals are billed per minute against it). Read-only, no cost.",
105
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
106
+ },
107
+ {
108
+ name: "create_rental",
109
+ description:
110
+ "Start renting a GPU. SPENDS CREDITS (per-minute billing) — confirm with the user before calling. Asynchronous: returns a rental_id with status 'pending'. Provisioning + the secure tunnel take ~20-40 seconds. After creating, call get_rental ONCE to fetch the connection URL — it waits internally for startup and returns when ready, so do NOT poll it in a tight loop. DURATION: the rental is open-ended by default (runs until the user stops it with destroy_rental) — use open-ended as the default. When starting one, briefly tell the user it's open-ended and bills per minute until stopped, and that they can set an 'hours' auto-stop cap instead if they prefer; only pass 'hours' when the user asks for a time limit. An idempotency key is generated automatically so accidental repeats don't start a second GPU.",
111
+ inputSchema: {
112
+ type: "object",
113
+ properties: {
114
+ node_id: { type: "string", description: "Node UUID from list_gpus." },
115
+ type: {
116
+ type: "string",
117
+ enum: ["jupyter"],
118
+ description: "Environment to start. Only 'jupyter' is supported.",
119
+ },
120
+ hours: {
121
+ type: "integer",
122
+ minimum: 1,
123
+ maximum: 720,
124
+ description: "Optional auto-stop cap: the rental stops itself after this many whole hours. Omit (the default) for an open-ended rental that runs until stopped with destroy_rental.",
125
+ },
126
+ name: { type: "string", description: "Optional label for the rental." },
127
+ },
128
+ required: ["node_id"],
129
+ additionalProperties: false,
130
+ },
131
+ },
132
+ {
133
+ name: "get_rental",
134
+ description:
135
+ "Get one rental's status and connection details (Jupyter URL + token). After create_rental, call this to get the URL. It WAITS internally (up to ~24s) for the rental to finish coming up and returns as soon as it's ready — so you usually only need ONE call, at most two. Do NOT call it repeatedly in a tight loop. Provisioning plus the secure tunnel take ~20-40 seconds total; the URL is ready when connection_pending is false. Read-only.",
136
+ inputSchema: {
137
+ type: "object",
138
+ properties: { rental_id: { type: "string" } },
139
+ required: ["rental_id"],
140
+ additionalProperties: false,
141
+ },
142
+ },
143
+ {
144
+ name: "list_rentals",
145
+ description:
146
+ "List the account's rentals. By default only active ones (what's running and billing). Pass status='all' for full history. Read-only.",
147
+ inputSchema: {
148
+ type: "object",
149
+ properties: {
150
+ status: { type: "string", enum: ["active", "all"], description: "Default: active." },
151
+ },
152
+ additionalProperties: false,
153
+ },
154
+ },
155
+ {
156
+ name: "destroy_rental",
157
+ description:
158
+ "Stop a rental — stops the GPU and STOPS BILLING. This is the money brake; safe to call twice. Confirm with the user unless they clearly asked to stop it.",
159
+ inputSchema: {
160
+ type: "object",
161
+ properties: { rental_id: { type: "string" } },
162
+ required: ["rental_id"],
163
+ additionalProperties: false,
164
+ },
165
+ },
166
+
167
+ // ---- Provider tools: the account's own nodes (key needs the 'nodes' scope)
168
+ {
169
+ name: "list_my_nodes",
170
+ description:
171
+ "PROVIDER: list the GPU nodes this account provides (needs a key with the 'nodes' scope). For each node: state (available, rented, paused, not_verified, not_ready, offline), GPUs and VRAM, price (default, allowed min/max, custom, what a renter pays), verification, reputation, the current rental (never the renter), and live metrics from the last minute: per-GPU load %, temperature °C, power W and VRAM, plus host CPU and memory. Read-only.",
172
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
173
+ },
174
+ {
175
+ name: "get_my_node",
176
+ description: "PROVIDER: one of the account's nodes, same fields as list_my_nodes (state, price, rental, live GPU metrics). Read-only.",
177
+ inputSchema: {
178
+ type: "object",
179
+ properties: { node_id: { type: "string", description: "Node UUID from list_my_nodes." } },
180
+ required: ["node_id"],
181
+ additionalProperties: false,
182
+ },
183
+ },
184
+ {
185
+ name: "add_node",
186
+ description:
187
+ "PROVIDER: add a new node to the account and get the docker command that installs the agent on the machine. Confirm the name and type with the user first. The returned command contains the node's secret token: show it only to the user, never paste it anywhere public. The node comes online once the command runs on the machine, then goes through the GPU check. At most 20 nodes an hour per key.",
188
+ inputSchema: {
189
+ type: "object",
190
+ properties: {
191
+ name: { type: "string", description: "A label for the node, up to 100 characters." },
192
+ type: { type: "string", enum: ["gpu", "cpu", "mac"], description: "Default gpu." },
193
+ os: { type: "string", enum: ["linux", "windows"], description: "Operating system of the machine. Default linux." },
194
+ available: { type: "boolean", description: "On the market as soon as it is ready. Default true." },
195
+ spot: { type: "boolean", description: "A spot node: discounted and reclaimable (GPU only). Default false." },
196
+ },
197
+ required: ["name"],
198
+ additionalProperties: false,
199
+ },
200
+ },
201
+ {
202
+ name: "get_node_install_command",
203
+ description:
204
+ "PROVIDER: the docker command that installs the agent for an existing node (to reinstall or move it). It contains the node's secret token: show it only to the user. Read-only.",
205
+ inputSchema: {
206
+ type: "object",
207
+ properties: { node_id: { type: "string" } },
208
+ required: ["node_id"],
209
+ additionalProperties: false,
210
+ },
211
+ },
212
+ {
213
+ name: "set_node_available",
214
+ description:
215
+ "PROVIDER: take a node off the market (available=false) or put it back (available=true). Off stops new rentals at once; a rental already running goes on to its end. Use it when the owner needs the machine or it is rented on another marketplace. Confirm with the user unless they asked for exactly this.",
216
+ inputSchema: {
217
+ type: "object",
218
+ properties: {
219
+ node_id: { type: "string" },
220
+ available: { type: "boolean" },
221
+ },
222
+ required: ["node_id", "available"],
223
+ additionalProperties: false,
224
+ },
225
+ },
226
+ {
227
+ name: "set_node_price",
228
+ description:
229
+ "PROVIDER: set a node's price in US dollars per hour for the whole node (what the renter pays; the provider gets it minus the platform fee), or null to go back to the platform default. Must be within the node's price.min and price.max (50% to 300% of the default; see get_my_node). A rental already running keeps its price. Not possible on a spot node. Confirm the new price with the user first.",
230
+ inputSchema: {
231
+ type: "object",
232
+ properties: {
233
+ node_id: { type: "string" },
234
+ price_per_hour: { type: ["number", "null"], description: "USD per hour, or null for the default price." },
235
+ },
236
+ required: ["node_id", "price_per_hour"],
237
+ additionalProperties: false,
238
+ },
239
+ },
240
+ {
241
+ name: "update_node",
242
+ description:
243
+ "PROVIDER: change several things on a node at once: name, spot (true/false; refused while the node is rented, and turning spot on clears a custom price), available, price_per_hour (USD per hour or null). Send only what changes. Confirm changes with the user first.",
244
+ inputSchema: {
245
+ type: "object",
246
+ properties: {
247
+ node_id: { type: "string" },
248
+ name: { type: "string" },
249
+ spot: { type: "boolean" },
250
+ available: { type: "boolean" },
251
+ price_per_hour: { type: ["number", "null"] },
252
+ },
253
+ required: ["node_id"],
254
+ additionalProperties: false,
255
+ },
256
+ },
257
+ {
258
+ name: "reclaim_spot_node",
259
+ description:
260
+ "PROVIDER: take a spot node back for the owner's own use (\"In use\"): rentals and inference go off, and a spot rental running on it STOPS TWO MINUTES LATER (the renter is told). Only for spot nodes. Always confirm with the user first. Put the node back afterwards with set_node_available(true).",
261
+ inputSchema: {
262
+ type: "object",
263
+ properties: { node_id: { type: "string" } },
264
+ required: ["node_id"],
265
+ additionalProperties: false,
266
+ },
267
+ },
268
+ {
269
+ name: "get_node_access",
270
+ description:
271
+ "PROVIDER: who can rent a node. An empty list (private: false) means everyone; otherwise only the people (email), email domains and organizations listed see the node and can rent it. Read-only.",
272
+ inputSchema: {
273
+ type: "object",
274
+ properties: { node_id: { type: "string" } },
275
+ required: ["node_id"],
276
+ additionalProperties: false,
277
+ },
278
+ },
279
+ {
280
+ name: "set_node_access",
281
+ description:
282
+ "PROVIDER: set who can rent a node, replacing the whole list. Each entry is {kind: \"email\", value: \"ana@company.com\"}, {kind: \"domain\", value: \"company.com\"} or {kind: \"org\", value: \"<organization name or ID>\"}. A non-empty list makes the node PRIVATE: only those renters see it and can rent it, and ParalonCloud places no inference or other work on it, so it earns from their rentals only. [] opens it to everyone again. Call get_node_access first to keep existing entries. Always confirm with the user first. People and organizations added are told by email.",
283
+ inputSchema: {
284
+ type: "object",
285
+ properties: {
286
+ node_id: { type: "string" },
287
+ entries: {
288
+ type: "array",
289
+ maxItems: 50,
290
+ items: {
291
+ type: "object",
292
+ properties: {
293
+ kind: { type: "string", enum: ["email", "domain", "org"] },
294
+ value: { type: "string" },
295
+ },
296
+ required: ["kind", "value"],
297
+ additionalProperties: false,
298
+ },
299
+ },
300
+ },
301
+ required: ["node_id", "entries"],
302
+ additionalProperties: false,
303
+ },
304
+ },
305
+ {
306
+ name: "get_earnings",
307
+ description:
308
+ "PROVIDER: the account's earnings in USD by UTC day for the last `days` days (default 30, max 366): rentals per node and inference for the account, after the platform fee; the total; the balance that can be withdrawn now; and what rentals still running have billed so far. Payouts themselves are not available through the API. Read-only.",
309
+ inputSchema: {
310
+ type: "object",
311
+ properties: { days: { type: "integer", minimum: 1, maximum: 366 } },
312
+ additionalProperties: false,
313
+ },
314
+ },
315
+ ];
316
+
317
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
318
+
319
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
320
+ const { name, arguments: args = {} } = request.params;
321
+
322
+ switch (name) {
323
+ case "list_gpus":
324
+ return reply(await api("GET", "/gpus"));
325
+
326
+ case "get_balance":
327
+ return reply(await api("GET", "/balance"));
328
+
329
+ case "create_rental": {
330
+ if (!args.node_id) {
331
+ return reply({ ok: false, data: { error: "invalid_request", message: "node_id is required (see list_gpus)." } });
332
+ }
333
+ const body = { node_id: args.node_id, type: args.type || "jupyter" };
334
+ if (args.hours != null) body.hours = args.hours;
335
+ if (args.name) body.name = args.name;
336
+ const result = await api("POST", "/rentals", {
337
+ body,
338
+ headers: { "Idempotency-Key": randomUUID() },
339
+ });
340
+ return reply(
341
+ result,
342
+ result.ok
343
+ ? "Rental is provisioning. Call get_rental with this rental_id until status is 'running' to get the connection URL."
344
+ : undefined
345
+ );
346
+ }
347
+
348
+ case "get_rental": {
349
+ if (!args.rental_id) {
350
+ return reply({ ok: false, data: { error: "invalid_request", message: "rental_id is required." } });
351
+ }
352
+ const path = `/rentals/${encodeURIComponent(args.rental_id)}`;
353
+ // Provisioning + the secure tunnel take ~20-40s. Instead of returning a
354
+ // "pending" that makes the agent hammer this tool, wait here: poll every
355
+ // 3s for up to ~24s and return as soon as the connection is ready (or the
356
+ // budget runs out). One or two calls cover the whole startup.
357
+ let result = await api("GET", path);
358
+ let waited = 0;
359
+ while (result.ok && result.data && result.data.connection_pending === true && waited < 24000) {
360
+ await sleep(3000);
361
+ waited += 3000;
362
+ result = await api("GET", path);
363
+ }
364
+ return reply(result);
365
+ }
366
+
367
+ case "list_rentals": {
368
+ const q = args.status === "all" ? "?status=all" : "";
369
+ return reply(await api("GET", `/rentals${q}`));
370
+ }
371
+
372
+ case "destroy_rental": {
373
+ if (!args.rental_id) {
374
+ return reply({ ok: false, data: { error: "invalid_request", message: "rental_id is required." } });
375
+ }
376
+ return reply(await api("DELETE", `/rentals/${encodeURIComponent(args.rental_id)}`));
377
+ }
378
+
379
+ // ---- Provider tools
380
+ case "list_my_nodes":
381
+ return reply(await api("GET", "/nodes"));
382
+
383
+ case "get_my_node":
384
+ case "get_node_install_command":
385
+ case "reclaim_spot_node": {
386
+ if (!args.node_id) {
387
+ return reply({ ok: false, data: { error: "invalid_request", message: "node_id is required (see list_my_nodes)." } });
388
+ }
389
+ const id = encodeURIComponent(args.node_id);
390
+ if (name === "get_my_node") return reply(await api("GET", `/nodes/${id}`));
391
+ if (name === "get_node_install_command") return reply(await api("GET", `/nodes/${id}/command`));
392
+ const result = await api("POST", `/nodes/${id}/reclaim`);
393
+ return reply(
394
+ result,
395
+ result.ok ? "The node is in use: no new rentals or inference. Put it back with set_node_available(available=true)." : undefined
396
+ );
397
+ }
398
+
399
+ case "add_node": {
400
+ if (!args.name) {
401
+ return reply({ ok: false, data: { error: "invalid_request", message: "name is required." } });
402
+ }
403
+ const body = { name: args.name };
404
+ for (const k of ["type", "os", "available", "spot"]) if (args[k] !== undefined) body[k] = args[k];
405
+ const result = await api("POST", "/nodes", { body });
406
+ return reply(
407
+ result,
408
+ result.ok
409
+ ? "Node added. Give the user docker_command to run on the machine (it holds the node's secret token). The node shows online once it runs, then goes through the GPU check."
410
+ : undefined
411
+ );
412
+ }
413
+
414
+ case "set_node_available":
415
+ case "set_node_price":
416
+ case "update_node": {
417
+ if (!args.node_id) {
418
+ return reply({ ok: false, data: { error: "invalid_request", message: "node_id is required (see list_my_nodes)." } });
419
+ }
420
+ const body = {};
421
+ for (const k of ["name", "spot", "available", "price_per_hour"]) if (args[k] !== undefined) body[k] = args[k];
422
+ if (name === "set_node_available" && typeof args.available !== "boolean") {
423
+ return reply({ ok: false, data: { error: "invalid_request", message: "available must be true or false." } });
424
+ }
425
+ if (name === "set_node_price" && !("price_per_hour" in args)) {
426
+ return reply({ ok: false, data: { error: "invalid_request", message: "price_per_hour is required (a number in USD, or null for the default)." } });
427
+ }
428
+ if (Object.keys(body).length === 0) {
429
+ return reply({ ok: false, data: { error: "invalid_request", message: "Nothing to change: send name, spot, available or price_per_hour." } });
430
+ }
431
+ return reply(await api("PATCH", `/nodes/${encodeURIComponent(args.node_id)}`, { body }));
432
+ }
433
+
434
+ case "get_node_access":
435
+ case "set_node_access": {
436
+ if (!args.node_id) {
437
+ return reply({ ok: false, data: { error: "invalid_request", message: "node_id is required (see list_my_nodes)." } });
438
+ }
439
+ const path = `/nodes/${encodeURIComponent(args.node_id)}/access`;
440
+ if (name === "get_node_access") return reply(await api("GET", path));
441
+ if (!Array.isArray(args.entries)) {
442
+ return reply({ ok: false, data: { error: "invalid_request", message: "entries is required: the whole list, [] for everyone." } });
443
+ }
444
+ const result = await api("PUT", path, { body: { entries: args.entries } });
445
+ return reply(
446
+ result,
447
+ result.ok
448
+ ? result.data && result.data.private
449
+ ? "The node is private: only the listed renters see and rent it, and no ParalonCloud workloads run on it."
450
+ : "The node is open to everyone again."
451
+ : undefined
452
+ );
453
+ }
454
+
455
+ case "get_earnings": {
456
+ const q = args.days ? `?days=${encodeURIComponent(args.days)}` : "";
457
+ return reply(await api("GET", `/earnings${q}`));
458
+ }
459
+
460
+ default:
461
+ return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
462
+ }
463
+ });
464
+
465
+ const transport = new StdioServerTransport();
466
+ await server.connect(transport);
467
+ // Log to stderr only — stdout is the MCP protocol channel.
468
+ console.error(
469
+ `ParalonCloud MCP server running (base: ${BASE_URL}, key: ${API_KEY ? "set" : "MISSING — set PARALON_API_KEY"})`
470
+ );