upres-cli 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -28
- package/dist/cli.cjs +329 -232
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +331 -232
- package/dist/cli.js.map +1 -1
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/mcp.cjs +314 -0
- package/dist/mcp.cjs.map +1 -0
- package/dist/mcp.d.cts +6 -0
- package/dist/mcp.d.ts +6 -0
- package/dist/mcp.js +287 -0
- package/dist/mcp.js.map +1 -0
- package/dist/models.cjs +38 -176
- package/dist/models.cjs.map +1 -1
- package/dist/models.d.cts +2 -2
- package/dist/models.d.ts +2 -2
- package/dist/models.js +38 -176
- package/dist/models.js.map +1 -1
- package/dist/types.cjs +0 -0
- package/dist/types.js +0 -0
- package/package.json +10 -5
- package/scripts/check-mcp-registry.sh +51 -0
- package/scripts/ensure-dist.mjs +15 -0
package/dist/mcp.cjs
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/mcp.ts
|
|
22
|
+
var mcp_exports = {};
|
|
23
|
+
__export(mcp_exports, {
|
|
24
|
+
handleMessage: () => handleMessage,
|
|
25
|
+
startStdio: () => startStdio
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(mcp_exports);
|
|
28
|
+
|
|
29
|
+
// src/models.ts
|
|
30
|
+
var MODELS = [
|
|
31
|
+
{
|
|
32
|
+
id: "flare",
|
|
33
|
+
name: "Flare",
|
|
34
|
+
description: "Everyday photos, 2x-4x. Fastest and cheapest. Does not invent detail.",
|
|
35
|
+
category: "image-upscale",
|
|
36
|
+
price: "Included in plan quota",
|
|
37
|
+
inputTypes: ["image/*"],
|
|
38
|
+
params: [
|
|
39
|
+
{ name: "image", type: "string", required: true, description: "Image URL or file" },
|
|
40
|
+
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4], description: "Scale multiplier" }
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: "prism",
|
|
45
|
+
name: "Prism",
|
|
46
|
+
description: "Text, logos, screenshots and product shots. Keeps edges true, does not invent detail.",
|
|
47
|
+
category: "image-upscale",
|
|
48
|
+
price: "Included in plan quota",
|
|
49
|
+
inputTypes: ["image/*"],
|
|
50
|
+
params: [
|
|
51
|
+
{ name: "image", type: "string", required: true, description: "Image URL or file" },
|
|
52
|
+
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4], description: "Scale multiplier" }
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "lumen",
|
|
57
|
+
name: "Lumen",
|
|
58
|
+
description: "Maximum detail recovery for print, up to 8x. Slower and dearer than Flare.",
|
|
59
|
+
category: "image-upscale",
|
|
60
|
+
price: "Included in plan quota",
|
|
61
|
+
inputTypes: ["image/*"],
|
|
62
|
+
params: [
|
|
63
|
+
{ name: "image", type: "string", required: true, description: "Image URL or file" },
|
|
64
|
+
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4, 8], description: "Scale multiplier" }
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: "mirage",
|
|
69
|
+
name: "Mirage",
|
|
70
|
+
description: "Invents plausible new detail rather than recovering what was there. Most dramatic, least faithful. Good for art, wrong for documents.",
|
|
71
|
+
category: "image-enhance",
|
|
72
|
+
price: "Included in plan quota",
|
|
73
|
+
inputTypes: ["image/*"],
|
|
74
|
+
params: [
|
|
75
|
+
{ name: "image", type: "string", required: true, description: "Image URL or file" },
|
|
76
|
+
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4, 8], description: "Scale multiplier" }
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: "motion",
|
|
81
|
+
name: "Motion",
|
|
82
|
+
description: "Fast 4K finish for AI-generated video (Sora, Kling, Runway). Frame-consistent, does not invent faces.",
|
|
83
|
+
category: "video-upscale",
|
|
84
|
+
price: "Counts against monthly video minutes",
|
|
85
|
+
inputTypes: ["video/*"],
|
|
86
|
+
params: [
|
|
87
|
+
{ name: "video", type: "string", required: true, description: "Video URL or file" },
|
|
88
|
+
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4], description: "Scale multiplier" }
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: "motion-x",
|
|
93
|
+
name: "Motion X",
|
|
94
|
+
description: "Cinema-grade video upscale for film and commercials. Noticeably slower and dearer per second than Motion.",
|
|
95
|
+
category: "video-upscale",
|
|
96
|
+
price: "Counts against monthly video minutes",
|
|
97
|
+
inputTypes: ["video/*"],
|
|
98
|
+
params: [
|
|
99
|
+
{ name: "video", type: "string", required: true, description: "Video URL or file" },
|
|
100
|
+
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4], description: "Scale multiplier" }
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
];
|
|
104
|
+
var IMAGE_MODELS = MODELS.filter((m) => m.category !== "video-upscale");
|
|
105
|
+
var VIDEO_MODELS = MODELS.filter((m) => m.category === "video-upscale");
|
|
106
|
+
|
|
107
|
+
// src/mcp.ts
|
|
108
|
+
var VERSION = "0.2.0";
|
|
109
|
+
var DEFAULT_BASE_URL = "https://api.upres.ai/v1";
|
|
110
|
+
function apiKey() {
|
|
111
|
+
return process.env.UPRES_API_KEY ?? "";
|
|
112
|
+
}
|
|
113
|
+
function baseUrl() {
|
|
114
|
+
return process.env.UPRES_BASE_URL ?? DEFAULT_BASE_URL;
|
|
115
|
+
}
|
|
116
|
+
async function api(method, endpoint, body) {
|
|
117
|
+
const key = apiKey();
|
|
118
|
+
if (!key) {
|
|
119
|
+
throw new Error("UPRES_API_KEY is not set. Get a key at https://upres.ai/account/api-keys");
|
|
120
|
+
}
|
|
121
|
+
const res = await fetch(`${baseUrl()}${endpoint}`, {
|
|
122
|
+
method,
|
|
123
|
+
headers: {
|
|
124
|
+
Authorization: `Bearer ${key}`,
|
|
125
|
+
...body ? { "Content-Type": "application/json" } : {}
|
|
126
|
+
},
|
|
127
|
+
body: body ? JSON.stringify(body) : void 0
|
|
128
|
+
});
|
|
129
|
+
const data = await res.json().catch(() => ({}));
|
|
130
|
+
if (!res.ok) {
|
|
131
|
+
throw new Error(data.error ?? `HTTP ${res.status}`);
|
|
132
|
+
}
|
|
133
|
+
return data;
|
|
134
|
+
}
|
|
135
|
+
var TOOLS = [
|
|
136
|
+
{
|
|
137
|
+
name: "upres_list_models",
|
|
138
|
+
description: "List UpRes upscale models (flare, prism, lumen, mirage, motion, motion-x) with use cases.",
|
|
139
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false }
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "upres_get_credits",
|
|
143
|
+
description: "Show recent job count for the authenticated UpRes API key as a quota proxy.",
|
|
144
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false }
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "upres_upscale_image",
|
|
148
|
+
description: "Submit an image upscale job from a public URL. Models: flare, prism, lumen, mirage.",
|
|
149
|
+
inputSchema: {
|
|
150
|
+
type: "object",
|
|
151
|
+
properties: {
|
|
152
|
+
image_url: { type: "string", description: "Public HTTPS URL of the image" },
|
|
153
|
+
model: {
|
|
154
|
+
type: "string",
|
|
155
|
+
enum: ["flare", "prism", "lumen", "mirage"],
|
|
156
|
+
description: "Image model. Default flare."
|
|
157
|
+
},
|
|
158
|
+
scale: { type: "integer", enum: [2, 4, 8], description: "Scale multiplier. Default 4." }
|
|
159
|
+
},
|
|
160
|
+
required: ["image_url"],
|
|
161
|
+
additionalProperties: false
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "upres_upscale_video",
|
|
166
|
+
description: "Submit a video upscale job from a public URL. Models: motion, motion-x.",
|
|
167
|
+
inputSchema: {
|
|
168
|
+
type: "object",
|
|
169
|
+
properties: {
|
|
170
|
+
video_url: { type: "string", description: "Public HTTPS URL of the video" },
|
|
171
|
+
model: {
|
|
172
|
+
type: "string",
|
|
173
|
+
enum: ["motion", "motion-x"],
|
|
174
|
+
description: "Video model. Default motion."
|
|
175
|
+
},
|
|
176
|
+
scale: { type: "integer", enum: [2, 4], description: "Scale multiplier. Default 4." }
|
|
177
|
+
},
|
|
178
|
+
required: ["video_url"],
|
|
179
|
+
additionalProperties: false
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "upres_get_job",
|
|
184
|
+
description: "Get status and result_url of an UpRes job by id.",
|
|
185
|
+
inputSchema: {
|
|
186
|
+
type: "object",
|
|
187
|
+
properties: {
|
|
188
|
+
job_id: { type: "string", description: "Job UUID returned by an upscale tool" }
|
|
189
|
+
},
|
|
190
|
+
required: ["job_id"],
|
|
191
|
+
additionalProperties: false
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
];
|
|
195
|
+
function ok(id, result) {
|
|
196
|
+
return { jsonrpc: "2.0", id, result };
|
|
197
|
+
}
|
|
198
|
+
function fail(id, code, message) {
|
|
199
|
+
return { jsonrpc: "2.0", id, error: { code, message } };
|
|
200
|
+
}
|
|
201
|
+
function text(obj) {
|
|
202
|
+
return { content: [{ type: "text", text: JSON.stringify(obj, null, 2) }] };
|
|
203
|
+
}
|
|
204
|
+
async function callTool(name, args) {
|
|
205
|
+
switch (name) {
|
|
206
|
+
case "upres_list_models":
|
|
207
|
+
return text(
|
|
208
|
+
MODELS.map((m) => ({
|
|
209
|
+
id: m.id,
|
|
210
|
+
name: m.name,
|
|
211
|
+
category: m.category,
|
|
212
|
+
description: m.description
|
|
213
|
+
}))
|
|
214
|
+
);
|
|
215
|
+
case "upres_get_credits": {
|
|
216
|
+
const jobs = await api("GET", "/jobs?limit=100");
|
|
217
|
+
const data = jobs.data ?? [];
|
|
218
|
+
return text({
|
|
219
|
+
recent_jobs: data.length,
|
|
220
|
+
completed: data.filter((j) => j.status === "completed").length,
|
|
221
|
+
pricing: "https://upres.ai/pricing"
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
case "upres_upscale_image": {
|
|
225
|
+
const image_url = String(args.image_url ?? "");
|
|
226
|
+
if (!image_url) throw new Error("image_url is required");
|
|
227
|
+
const job = await api("POST", "/jobs", {
|
|
228
|
+
image_url,
|
|
229
|
+
model: args.model ?? "flare",
|
|
230
|
+
scale: args.scale ?? 4
|
|
231
|
+
});
|
|
232
|
+
return text(job);
|
|
233
|
+
}
|
|
234
|
+
case "upres_upscale_video": {
|
|
235
|
+
const video_url = String(args.video_url ?? "");
|
|
236
|
+
if (!video_url) throw new Error("video_url is required");
|
|
237
|
+
const job = await api("POST", "/jobs", {
|
|
238
|
+
image_url: video_url,
|
|
239
|
+
model: args.model ?? "motion",
|
|
240
|
+
scale: args.scale ?? 4
|
|
241
|
+
});
|
|
242
|
+
return text(job);
|
|
243
|
+
}
|
|
244
|
+
case "upres_get_job": {
|
|
245
|
+
const job_id = String(args.job_id ?? "");
|
|
246
|
+
if (!job_id) throw new Error("job_id is required");
|
|
247
|
+
const job = await api("GET", `/jobs/${job_id}`);
|
|
248
|
+
return text(job);
|
|
249
|
+
}
|
|
250
|
+
default:
|
|
251
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
async function handle(msg) {
|
|
255
|
+
const id = msg.id;
|
|
256
|
+
const method = String(msg.method ?? "");
|
|
257
|
+
if (msg.jsonrpc !== "2.0") return fail(id, -32600, "Invalid Request");
|
|
258
|
+
if (method === "initialize") {
|
|
259
|
+
return ok(id, {
|
|
260
|
+
protocolVersion: "2024-11-05",
|
|
261
|
+
capabilities: { tools: {} },
|
|
262
|
+
serverInfo: { name: "upres", version: VERSION }
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
if (method === "notifications/initialized" || method === "initialized") return null;
|
|
266
|
+
if (method === "ping") return ok(id, {});
|
|
267
|
+
if (method === "tools/list") return ok(id, { tools: TOOLS });
|
|
268
|
+
if (method === "tools/call") {
|
|
269
|
+
const params = msg.params ?? {};
|
|
270
|
+
const name = String(params.name ?? "");
|
|
271
|
+
const args = params.arguments ?? {};
|
|
272
|
+
try {
|
|
273
|
+
return ok(id, await callTool(name, args));
|
|
274
|
+
} catch (e) {
|
|
275
|
+
return ok(id, {
|
|
276
|
+
isError: true,
|
|
277
|
+
content: [{ type: "text", text: e.message }]
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (id === void 0) return null;
|
|
282
|
+
return fail(id, -32601, `Method not found: ${method}`);
|
|
283
|
+
}
|
|
284
|
+
async function handleMessage(msg) {
|
|
285
|
+
return handle(msg);
|
|
286
|
+
}
|
|
287
|
+
function startStdio() {
|
|
288
|
+
let buf = "";
|
|
289
|
+
process.stdin.setEncoding("utf8");
|
|
290
|
+
process.stdin.on("data", async (chunk) => {
|
|
291
|
+
buf += chunk;
|
|
292
|
+
while (true) {
|
|
293
|
+
const nl = buf.indexOf("\n");
|
|
294
|
+
if (nl < 0) break;
|
|
295
|
+
const line = buf.slice(0, nl).trim();
|
|
296
|
+
buf = buf.slice(nl + 1);
|
|
297
|
+
if (!line) continue;
|
|
298
|
+
let msg;
|
|
299
|
+
try {
|
|
300
|
+
msg = JSON.parse(line);
|
|
301
|
+
} catch {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
const reply = await handle(msg);
|
|
305
|
+
if (reply) process.stdout.write(JSON.stringify(reply) + "\n");
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
310
|
+
0 && (module.exports = {
|
|
311
|
+
handleMessage,
|
|
312
|
+
startStdio
|
|
313
|
+
});
|
|
314
|
+
//# sourceMappingURL=mcp.cjs.map
|
package/dist/mcp.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mcp.ts","../src/models.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * UpRes MCP stdio server. Speaks JSON-RPC over stdin/stdout so Claude,\n * Cursor, and Hermes can upscale without a browser.\n *\n * UPRES_API_KEY=upres_... npx upres-cli mcp\n * claude mcp add upres -- npx -y upres-cli mcp\n */\nimport { MODELS } from \"./models.js\";\n\nconst VERSION = \"0.2.0\";\nconst DEFAULT_BASE_URL = \"https://api.upres.ai/v1\";\n\ntype Json = Record<string, unknown>;\n\nfunction apiKey(): string {\n return process.env.UPRES_API_KEY ?? \"\";\n}\n\nfunction baseUrl(): string {\n return process.env.UPRES_BASE_URL ?? DEFAULT_BASE_URL;\n}\n\nasync function api<T>(method: string, endpoint: string, body?: unknown): Promise<T> {\n const key = apiKey();\n if (!key) {\n throw new Error(\"UPRES_API_KEY is not set. Get a key at https://upres.ai/account/api-keys\");\n }\n const res = await fetch(`${baseUrl()}${endpoint}`, {\n method,\n headers: {\n Authorization: `Bearer ${key}`,\n ...(body ? { \"Content-Type\": \"application/json\" } : {}),\n },\n body: body ? JSON.stringify(body) : undefined,\n });\n const data = (await res.json().catch(() => ({}))) as T & { error?: string };\n if (!res.ok) {\n throw new Error(data.error ?? `HTTP ${res.status}`);\n }\n return data;\n}\n\nconst TOOLS = [\n {\n name: \"upres_list_models\",\n description:\n \"List UpRes upscale models (flare, prism, lumen, mirage, motion, motion-x) with use cases.\",\n inputSchema: { type: \"object\", properties: {}, additionalProperties: false },\n },\n {\n name: \"upres_get_credits\",\n description: \"Show recent job count for the authenticated UpRes API key as a quota proxy.\",\n inputSchema: { type: \"object\", properties: {}, additionalProperties: false },\n },\n {\n name: \"upres_upscale_image\",\n description: \"Submit an image upscale job from a public URL. Models: flare, prism, lumen, mirage.\",\n inputSchema: {\n type: \"object\",\n properties: {\n image_url: { type: \"string\", description: \"Public HTTPS URL of the image\" },\n model: {\n type: \"string\",\n enum: [\"flare\", \"prism\", \"lumen\", \"mirage\"],\n description: \"Image model. Default flare.\",\n },\n scale: { type: \"integer\", enum: [2, 4, 8], description: \"Scale multiplier. Default 4.\" },\n },\n required: [\"image_url\"],\n additionalProperties: false,\n },\n },\n {\n name: \"upres_upscale_video\",\n description: \"Submit a video upscale job from a public URL. Models: motion, motion-x.\",\n inputSchema: {\n type: \"object\",\n properties: {\n video_url: { type: \"string\", description: \"Public HTTPS URL of the video\" },\n model: {\n type: \"string\",\n enum: [\"motion\", \"motion-x\"],\n description: \"Video model. Default motion.\",\n },\n scale: { type: \"integer\", enum: [2, 4], description: \"Scale multiplier. Default 4.\" },\n },\n required: [\"video_url\"],\n additionalProperties: false,\n },\n },\n {\n name: \"upres_get_job\",\n description: \"Get status and result_url of an UpRes job by id.\",\n inputSchema: {\n type: \"object\",\n properties: {\n job_id: { type: \"string\", description: \"Job UUID returned by an upscale tool\" },\n },\n required: [\"job_id\"],\n additionalProperties: false,\n },\n },\n];\n\nfunction ok(id: unknown, result: unknown) {\n return { jsonrpc: \"2.0\", id, result };\n}\n\nfunction fail(id: unknown, code: number, message: string) {\n return { jsonrpc: \"2.0\", id, error: { code, message } };\n}\n\nfunction text(obj: unknown) {\n return { content: [{ type: \"text\", text: JSON.stringify(obj, null, 2) }] };\n}\n\nasync function callTool(name: string, args: Json): Promise<unknown> {\n switch (name) {\n case \"upres_list_models\":\n return text(\n MODELS.map((m) => ({\n id: m.id,\n name: m.name,\n category: m.category,\n description: m.description,\n })),\n );\n case \"upres_get_credits\": {\n const jobs = await api<{ data: { status: string }[] }>(\"GET\", \"/jobs?limit=100\");\n const data = jobs.data ?? [];\n return text({\n recent_jobs: data.length,\n completed: data.filter((j) => j.status === \"completed\").length,\n pricing: \"https://upres.ai/pricing\",\n });\n }\n case \"upres_upscale_image\": {\n const image_url = String(args.image_url ?? \"\");\n if (!image_url) throw new Error(\"image_url is required\");\n const job = await api(\"POST\", \"/jobs\", {\n image_url,\n model: args.model ?? \"flare\",\n scale: args.scale ?? 4,\n });\n return text(job);\n }\n case \"upres_upscale_video\": {\n const video_url = String(args.video_url ?? \"\");\n if (!video_url) throw new Error(\"video_url is required\");\n const job = await api(\"POST\", \"/jobs\", {\n image_url: video_url,\n model: args.model ?? \"motion\",\n scale: args.scale ?? 4,\n });\n return text(job);\n }\n case \"upres_get_job\": {\n const job_id = String(args.job_id ?? \"\");\n if (!job_id) throw new Error(\"job_id is required\");\n const job = await api(\"GET\", `/jobs/${job_id}`);\n return text(job);\n }\n default:\n throw new Error(`Unknown tool: ${name}`);\n }\n}\n\nasync function handle(msg: Json): Promise<Json | null> {\n const id = msg.id;\n const method = String(msg.method ?? \"\");\n if (msg.jsonrpc !== \"2.0\") return fail(id, -32600, \"Invalid Request\");\n\n if (method === \"initialize\") {\n return ok(id, {\n protocolVersion: \"2024-11-05\",\n capabilities: { tools: {} },\n serverInfo: { name: \"upres\", version: VERSION },\n });\n }\n if (method === \"notifications/initialized\" || method === \"initialized\") return null;\n if (method === \"ping\") return ok(id, {});\n if (method === \"tools/list\") return ok(id, { tools: TOOLS });\n if (method === \"tools/call\") {\n const params = (msg.params ?? {}) as Json;\n const name = String(params.name ?? \"\");\n const args = (params.arguments ?? {}) as Json;\n try {\n return ok(id, await callTool(name, args));\n } catch (e) {\n return ok(id, {\n isError: true,\n content: [{ type: \"text\", text: (e as Error).message }],\n });\n }\n }\n if (id === undefined) return null;\n return fail(id, -32601, `Method not found: ${method}`);\n}\n\nexport async function handleMessage(msg: Json): Promise<Json | null> {\n return handle(msg);\n}\n\nexport function startStdio(): void {\n let buf = \"\";\n process.stdin.setEncoding(\"utf8\");\n process.stdin.on(\"data\", async (chunk: string) => {\n buf += chunk;\n while (true) {\n const nl = buf.indexOf(\"\\n\");\n if (nl < 0) break;\n const line = buf.slice(0, nl).trim();\n buf = buf.slice(nl + 1);\n if (!line) continue;\n let msg: Json;\n try {\n msg = JSON.parse(line) as Json;\n } catch {\n continue;\n }\n const reply = await handle(msg);\n if (reply) process.stdout.write(JSON.stringify(reply) + \"\\n\");\n }\n });\n}\n","import type { ModelDefinition } from \"./types.js\";\n\n// Synced with https://api.upres.ai/v1/openapi.json (spec v1.1.0).\n// A job names one of six models. Which backend serves a model is ours to\n// choose and can change without notice — that is how a failing vendor\n// stops being your outage.\nexport const MODELS: ModelDefinition[] = [\n {\n id: \"flare\",\n name: \"Flare\",\n description: \"Everyday photos, 2x-4x. Fastest and cheapest. Does not invent detail.\",\n category: \"image-upscale\",\n price: \"Included in plan quota\",\n inputTypes: [\"image/*\"],\n params: [\n { name: \"image\", type: \"string\", required: true, description: \"Image URL or file\" },\n { name: \"scale\", type: \"integer\", required: false, default: 4, options: [2, 4], description: \"Scale multiplier\" },\n ],\n },\n {\n id: \"prism\",\n name: \"Prism\",\n description: \"Text, logos, screenshots and product shots. Keeps edges true, does not invent detail.\",\n category: \"image-upscale\",\n price: \"Included in plan quota\",\n inputTypes: [\"image/*\"],\n params: [\n { name: \"image\", type: \"string\", required: true, description: \"Image URL or file\" },\n { name: \"scale\", type: \"integer\", required: false, default: 4, options: [2, 4], description: \"Scale multiplier\" },\n ],\n },\n {\n id: \"lumen\",\n name: \"Lumen\",\n description: \"Maximum detail recovery for print, up to 8x. Slower and dearer than Flare.\",\n category: \"image-upscale\",\n price: \"Included in plan quota\",\n inputTypes: [\"image/*\"],\n params: [\n { name: \"image\", type: \"string\", required: true, description: \"Image URL or file\" },\n { name: \"scale\", type: \"integer\", required: false, default: 4, options: [2, 4, 8], description: \"Scale multiplier\" },\n ],\n },\n {\n id: \"mirage\",\n name: \"Mirage\",\n description: \"Invents plausible new detail rather than recovering what was there. Most dramatic, least faithful. Good for art, wrong for documents.\",\n category: \"image-enhance\",\n price: \"Included in plan quota\",\n inputTypes: [\"image/*\"],\n params: [\n { name: \"image\", type: \"string\", required: true, description: \"Image URL or file\" },\n { name: \"scale\", type: \"integer\", required: false, default: 4, options: [2, 4, 8], description: \"Scale multiplier\" },\n ],\n },\n {\n id: \"motion\",\n name: \"Motion\",\n description: \"Fast 4K finish for AI-generated video (Sora, Kling, Runway). Frame-consistent, does not invent faces.\",\n category: \"video-upscale\",\n price: \"Counts against monthly video minutes\",\n inputTypes: [\"video/*\"],\n params: [\n { name: \"video\", type: \"string\", required: true, description: \"Video URL or file\" },\n { name: \"scale\", type: \"integer\", required: false, default: 4, options: [2, 4], description: \"Scale multiplier\" },\n ],\n },\n {\n id: \"motion-x\",\n name: \"Motion X\",\n description: \"Cinema-grade video upscale for film and commercials. Noticeably slower and dearer per second than Motion.\",\n category: \"video-upscale\",\n price: \"Counts against monthly video minutes\",\n inputTypes: [\"video/*\"],\n params: [\n { name: \"video\", type: \"string\", required: true, description: \"Video URL or file\" },\n { name: \"scale\", type: \"integer\", required: false, default: 4, options: [2, 4], description: \"Scale multiplier\" },\n ],\n },\n];\n\nexport const IMAGE_MODELS = MODELS.filter((m) => m.category !== \"video-upscale\");\nexport const VIDEO_MODELS = MODELS.filter((m) => m.category === \"video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K,EAAG;AACZ,YAAM,OAAO,IAAI,MAAM,GAAG,EAAE,EAAE,KAAK;AACnC,YAAM,IAAI,MAAM,KAAK,CAAC;AACtB,UAAI,CAAC,KAAM;AACX,UAAI;AACJ,UAAI;AACF,cAAM,KAAK,MAAM,IAAI;AAAA,MACvB,QAAQ;AACN;AAAA,MACF;AACA,YAAM,QAAQ,MAAM,OAAO,GAAG;AAC9B,UAAI,MAAO,SAAQ,OAAO,MAAM,KAAK,UAAU,KAAK,IAAI,IAAI;AAAA,IAC9D;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/dist/mcp.d.cts
ADDED
package/dist/mcp.d.ts
ADDED
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/models.ts
|
|
4
|
+
var MODELS = [
|
|
5
|
+
{
|
|
6
|
+
id: "flare",
|
|
7
|
+
name: "Flare",
|
|
8
|
+
description: "Everyday photos, 2x-4x. Fastest and cheapest. Does not invent detail.",
|
|
9
|
+
category: "image-upscale",
|
|
10
|
+
price: "Included in plan quota",
|
|
11
|
+
inputTypes: ["image/*"],
|
|
12
|
+
params: [
|
|
13
|
+
{ name: "image", type: "string", required: true, description: "Image URL or file" },
|
|
14
|
+
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4], description: "Scale multiplier" }
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "prism",
|
|
19
|
+
name: "Prism",
|
|
20
|
+
description: "Text, logos, screenshots and product shots. Keeps edges true, does not invent detail.",
|
|
21
|
+
category: "image-upscale",
|
|
22
|
+
price: "Included in plan quota",
|
|
23
|
+
inputTypes: ["image/*"],
|
|
24
|
+
params: [
|
|
25
|
+
{ name: "image", type: "string", required: true, description: "Image URL or file" },
|
|
26
|
+
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4], description: "Scale multiplier" }
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "lumen",
|
|
31
|
+
name: "Lumen",
|
|
32
|
+
description: "Maximum detail recovery for print, up to 8x. Slower and dearer than Flare.",
|
|
33
|
+
category: "image-upscale",
|
|
34
|
+
price: "Included in plan quota",
|
|
35
|
+
inputTypes: ["image/*"],
|
|
36
|
+
params: [
|
|
37
|
+
{ name: "image", type: "string", required: true, description: "Image URL or file" },
|
|
38
|
+
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4, 8], description: "Scale multiplier" }
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "mirage",
|
|
43
|
+
name: "Mirage",
|
|
44
|
+
description: "Invents plausible new detail rather than recovering what was there. Most dramatic, least faithful. Good for art, wrong for documents.",
|
|
45
|
+
category: "image-enhance",
|
|
46
|
+
price: "Included in plan quota",
|
|
47
|
+
inputTypes: ["image/*"],
|
|
48
|
+
params: [
|
|
49
|
+
{ name: "image", type: "string", required: true, description: "Image URL or file" },
|
|
50
|
+
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4, 8], description: "Scale multiplier" }
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "motion",
|
|
55
|
+
name: "Motion",
|
|
56
|
+
description: "Fast 4K finish for AI-generated video (Sora, Kling, Runway). Frame-consistent, does not invent faces.",
|
|
57
|
+
category: "video-upscale",
|
|
58
|
+
price: "Counts against monthly video minutes",
|
|
59
|
+
inputTypes: ["video/*"],
|
|
60
|
+
params: [
|
|
61
|
+
{ name: "video", type: "string", required: true, description: "Video URL or file" },
|
|
62
|
+
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4], description: "Scale multiplier" }
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "motion-x",
|
|
67
|
+
name: "Motion X",
|
|
68
|
+
description: "Cinema-grade video upscale for film and commercials. Noticeably slower and dearer per second than Motion.",
|
|
69
|
+
category: "video-upscale",
|
|
70
|
+
price: "Counts against monthly video minutes",
|
|
71
|
+
inputTypes: ["video/*"],
|
|
72
|
+
params: [
|
|
73
|
+
{ name: "video", type: "string", required: true, description: "Video URL or file" },
|
|
74
|
+
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4], description: "Scale multiplier" }
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
];
|
|
78
|
+
var IMAGE_MODELS = MODELS.filter((m) => m.category !== "video-upscale");
|
|
79
|
+
var VIDEO_MODELS = MODELS.filter((m) => m.category === "video-upscale");
|
|
80
|
+
|
|
81
|
+
// src/mcp.ts
|
|
82
|
+
var VERSION = "0.2.0";
|
|
83
|
+
var DEFAULT_BASE_URL = "https://api.upres.ai/v1";
|
|
84
|
+
function apiKey() {
|
|
85
|
+
return process.env.UPRES_API_KEY ?? "";
|
|
86
|
+
}
|
|
87
|
+
function baseUrl() {
|
|
88
|
+
return process.env.UPRES_BASE_URL ?? DEFAULT_BASE_URL;
|
|
89
|
+
}
|
|
90
|
+
async function api(method, endpoint, body) {
|
|
91
|
+
const key = apiKey();
|
|
92
|
+
if (!key) {
|
|
93
|
+
throw new Error("UPRES_API_KEY is not set. Get a key at https://upres.ai/account/api-keys");
|
|
94
|
+
}
|
|
95
|
+
const res = await fetch(`${baseUrl()}${endpoint}`, {
|
|
96
|
+
method,
|
|
97
|
+
headers: {
|
|
98
|
+
Authorization: `Bearer ${key}`,
|
|
99
|
+
...body ? { "Content-Type": "application/json" } : {}
|
|
100
|
+
},
|
|
101
|
+
body: body ? JSON.stringify(body) : void 0
|
|
102
|
+
});
|
|
103
|
+
const data = await res.json().catch(() => ({}));
|
|
104
|
+
if (!res.ok) {
|
|
105
|
+
throw new Error(data.error ?? `HTTP ${res.status}`);
|
|
106
|
+
}
|
|
107
|
+
return data;
|
|
108
|
+
}
|
|
109
|
+
var TOOLS = [
|
|
110
|
+
{
|
|
111
|
+
name: "upres_list_models",
|
|
112
|
+
description: "List UpRes upscale models (flare, prism, lumen, mirage, motion, motion-x) with use cases.",
|
|
113
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false }
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "upres_get_credits",
|
|
117
|
+
description: "Show recent job count for the authenticated UpRes API key as a quota proxy.",
|
|
118
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false }
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "upres_upscale_image",
|
|
122
|
+
description: "Submit an image upscale job from a public URL. Models: flare, prism, lumen, mirage.",
|
|
123
|
+
inputSchema: {
|
|
124
|
+
type: "object",
|
|
125
|
+
properties: {
|
|
126
|
+
image_url: { type: "string", description: "Public HTTPS URL of the image" },
|
|
127
|
+
model: {
|
|
128
|
+
type: "string",
|
|
129
|
+
enum: ["flare", "prism", "lumen", "mirage"],
|
|
130
|
+
description: "Image model. Default flare."
|
|
131
|
+
},
|
|
132
|
+
scale: { type: "integer", enum: [2, 4, 8], description: "Scale multiplier. Default 4." }
|
|
133
|
+
},
|
|
134
|
+
required: ["image_url"],
|
|
135
|
+
additionalProperties: false
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "upres_upscale_video",
|
|
140
|
+
description: "Submit a video upscale job from a public URL. Models: motion, motion-x.",
|
|
141
|
+
inputSchema: {
|
|
142
|
+
type: "object",
|
|
143
|
+
properties: {
|
|
144
|
+
video_url: { type: "string", description: "Public HTTPS URL of the video" },
|
|
145
|
+
model: {
|
|
146
|
+
type: "string",
|
|
147
|
+
enum: ["motion", "motion-x"],
|
|
148
|
+
description: "Video model. Default motion."
|
|
149
|
+
},
|
|
150
|
+
scale: { type: "integer", enum: [2, 4], description: "Scale multiplier. Default 4." }
|
|
151
|
+
},
|
|
152
|
+
required: ["video_url"],
|
|
153
|
+
additionalProperties: false
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: "upres_get_job",
|
|
158
|
+
description: "Get status and result_url of an UpRes job by id.",
|
|
159
|
+
inputSchema: {
|
|
160
|
+
type: "object",
|
|
161
|
+
properties: {
|
|
162
|
+
job_id: { type: "string", description: "Job UUID returned by an upscale tool" }
|
|
163
|
+
},
|
|
164
|
+
required: ["job_id"],
|
|
165
|
+
additionalProperties: false
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
];
|
|
169
|
+
function ok(id, result) {
|
|
170
|
+
return { jsonrpc: "2.0", id, result };
|
|
171
|
+
}
|
|
172
|
+
function fail(id, code, message) {
|
|
173
|
+
return { jsonrpc: "2.0", id, error: { code, message } };
|
|
174
|
+
}
|
|
175
|
+
function text(obj) {
|
|
176
|
+
return { content: [{ type: "text", text: JSON.stringify(obj, null, 2) }] };
|
|
177
|
+
}
|
|
178
|
+
async function callTool(name, args) {
|
|
179
|
+
switch (name) {
|
|
180
|
+
case "upres_list_models":
|
|
181
|
+
return text(
|
|
182
|
+
MODELS.map((m) => ({
|
|
183
|
+
id: m.id,
|
|
184
|
+
name: m.name,
|
|
185
|
+
category: m.category,
|
|
186
|
+
description: m.description
|
|
187
|
+
}))
|
|
188
|
+
);
|
|
189
|
+
case "upres_get_credits": {
|
|
190
|
+
const jobs = await api("GET", "/jobs?limit=100");
|
|
191
|
+
const data = jobs.data ?? [];
|
|
192
|
+
return text({
|
|
193
|
+
recent_jobs: data.length,
|
|
194
|
+
completed: data.filter((j) => j.status === "completed").length,
|
|
195
|
+
pricing: "https://upres.ai/pricing"
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
case "upres_upscale_image": {
|
|
199
|
+
const image_url = String(args.image_url ?? "");
|
|
200
|
+
if (!image_url) throw new Error("image_url is required");
|
|
201
|
+
const job = await api("POST", "/jobs", {
|
|
202
|
+
image_url,
|
|
203
|
+
model: args.model ?? "flare",
|
|
204
|
+
scale: args.scale ?? 4
|
|
205
|
+
});
|
|
206
|
+
return text(job);
|
|
207
|
+
}
|
|
208
|
+
case "upres_upscale_video": {
|
|
209
|
+
const video_url = String(args.video_url ?? "");
|
|
210
|
+
if (!video_url) throw new Error("video_url is required");
|
|
211
|
+
const job = await api("POST", "/jobs", {
|
|
212
|
+
image_url: video_url,
|
|
213
|
+
model: args.model ?? "motion",
|
|
214
|
+
scale: args.scale ?? 4
|
|
215
|
+
});
|
|
216
|
+
return text(job);
|
|
217
|
+
}
|
|
218
|
+
case "upres_get_job": {
|
|
219
|
+
const job_id = String(args.job_id ?? "");
|
|
220
|
+
if (!job_id) throw new Error("job_id is required");
|
|
221
|
+
const job = await api("GET", `/jobs/${job_id}`);
|
|
222
|
+
return text(job);
|
|
223
|
+
}
|
|
224
|
+
default:
|
|
225
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
async function handle(msg) {
|
|
229
|
+
const id = msg.id;
|
|
230
|
+
const method = String(msg.method ?? "");
|
|
231
|
+
if (msg.jsonrpc !== "2.0") return fail(id, -32600, "Invalid Request");
|
|
232
|
+
if (method === "initialize") {
|
|
233
|
+
return ok(id, {
|
|
234
|
+
protocolVersion: "2024-11-05",
|
|
235
|
+
capabilities: { tools: {} },
|
|
236
|
+
serverInfo: { name: "upres", version: VERSION }
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
if (method === "notifications/initialized" || method === "initialized") return null;
|
|
240
|
+
if (method === "ping") return ok(id, {});
|
|
241
|
+
if (method === "tools/list") return ok(id, { tools: TOOLS });
|
|
242
|
+
if (method === "tools/call") {
|
|
243
|
+
const params = msg.params ?? {};
|
|
244
|
+
const name = String(params.name ?? "");
|
|
245
|
+
const args = params.arguments ?? {};
|
|
246
|
+
try {
|
|
247
|
+
return ok(id, await callTool(name, args));
|
|
248
|
+
} catch (e) {
|
|
249
|
+
return ok(id, {
|
|
250
|
+
isError: true,
|
|
251
|
+
content: [{ type: "text", text: e.message }]
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (id === void 0) return null;
|
|
256
|
+
return fail(id, -32601, `Method not found: ${method}`);
|
|
257
|
+
}
|
|
258
|
+
async function handleMessage(msg) {
|
|
259
|
+
return handle(msg);
|
|
260
|
+
}
|
|
261
|
+
function startStdio() {
|
|
262
|
+
let buf = "";
|
|
263
|
+
process.stdin.setEncoding("utf8");
|
|
264
|
+
process.stdin.on("data", async (chunk) => {
|
|
265
|
+
buf += chunk;
|
|
266
|
+
while (true) {
|
|
267
|
+
const nl = buf.indexOf("\n");
|
|
268
|
+
if (nl < 0) break;
|
|
269
|
+
const line = buf.slice(0, nl).trim();
|
|
270
|
+
buf = buf.slice(nl + 1);
|
|
271
|
+
if (!line) continue;
|
|
272
|
+
let msg;
|
|
273
|
+
try {
|
|
274
|
+
msg = JSON.parse(line);
|
|
275
|
+
} catch {
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
const reply = await handle(msg);
|
|
279
|
+
if (reply) process.stdout.write(JSON.stringify(reply) + "\n");
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
export {
|
|
284
|
+
handleMessage,
|
|
285
|
+
startStdio
|
|
286
|
+
};
|
|
287
|
+
//# sourceMappingURL=mcp.js.map
|