productimageupscale-mcp 0.0.0-stage → 1.0.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 +125 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/batch-upscale.d.ts +20 -0
- package/dist/prompts/batch-upscale.d.ts.map +1 -0
- package/dist/prompts/batch-upscale.js +39 -0
- package/dist/prompts/batch-upscale.js.map +1 -0
- package/dist/prompts/upscale-product.d.ts +20 -0
- package/dist/prompts/upscale-product.d.ts.map +1 -0
- package/dist/prompts/upscale-product.js +36 -0
- package/dist/prompts/upscale-product.js.map +1 -0
- package/dist/resources/account-balance.d.ts +9 -0
- package/dist/resources/account-balance.d.ts.map +1 -0
- package/dist/resources/account-balance.js +14 -0
- package/dist/resources/account-balance.js.map +1 -0
- package/dist/resources/api-docs.d.ts +8 -0
- package/dist/resources/api-docs.d.ts.map +1 -0
- package/dist/resources/api-docs.js +60 -0
- package/dist/resources/api-docs.js.map +1 -0
- package/dist/server.d.ts +9 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +43 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/check-credits.d.ts +16 -0
- package/dist/tools/check-credits.d.ts.map +1 -0
- package/dist/tools/check-credits.js +50 -0
- package/dist/tools/check-credits.js.map +1 -0
- package/dist/tools/check-status.d.ts +21 -0
- package/dist/tools/check-status.d.ts.map +1 -0
- package/dist/tools/check-status.js +58 -0
- package/dist/tools/check-status.js.map +1 -0
- package/dist/tools/list-materials.d.ts +8 -0
- package/dist/tools/list-materials.d.ts.map +1 -0
- package/dist/tools/list-materials.js +19 -0
- package/dist/tools/list-materials.js.map +1 -0
- package/dist/tools/upscale-image.d.ts +26 -0
- package/dist/tools/upscale-image.d.ts.map +1 -0
- package/dist/tools/upscale-image.js +120 -0
- package/dist/tools/upscale-image.js.map +1 -0
- package/dist/types.d.ts +35 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/api-client.d.ts +36 -0
- package/dist/utils/api-client.d.ts.map +1 -0
- package/dist/utils/api-client.js +132 -0
- package/dist/utils/api-client.js.map +1 -0
- package/dist/utils/config.d.ts +7 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +19 -0
- package/dist/utils/config.js.map +1 -0
- package/package.json +38 -4
package/README.md
CHANGED
|
@@ -1,3 +1,126 @@
|
|
|
1
|
-
#
|
|
1
|
+
# productimageupscale-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Official [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for **[ProductImageUpscale AI](https://productimageupscale.com)** — AI-powered e-commerce image upscaling, detail restoration, and catalog zoom compliance directly inside Claude Desktop, Cursor, ChatGPT, and AI agent frameworks.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/productimageupscale-mcp)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## ⚡ Quick Start
|
|
11
|
+
|
|
12
|
+
### 1. Claude Desktop / Antigravity IDE
|
|
13
|
+
|
|
14
|
+
Add the server to your `claude_desktop_config.json`:
|
|
15
|
+
|
|
16
|
+
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
17
|
+
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"mcpServers": {
|
|
22
|
+
"productimageupscale": {
|
|
23
|
+
"command": "npx",
|
|
24
|
+
"args": ["-y", "productimageupscale-mcp@latest"],
|
|
25
|
+
"env": {
|
|
26
|
+
"PRODUCTIMAGEUPSCALE_API_KEY": "your_api_key_here"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
> **Where do I get an API key?**
|
|
34
|
+
> Generate your API key in seconds from your [ProductImageUpscale Integrations Dashboard](https://productimageupscale.com/app/integrations).
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
### 2. Cursor / Windsurf IDE
|
|
39
|
+
|
|
40
|
+
In your IDE Settings → **MCP Servers** → **Add New MCP Server**:
|
|
41
|
+
- **Name:** `productimageupscale`
|
|
42
|
+
- **Type:** `command`
|
|
43
|
+
- **Command:** `npx -y productimageupscale-mcp@latest`
|
|
44
|
+
- **Environment Variables:** `PRODUCTIMAGEUPSCALE_API_KEY=your_api_key_here`
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 🛠️ Available MCP Tools
|
|
49
|
+
|
|
50
|
+
### `upscale_image`
|
|
51
|
+
Upscales a product image to high resolution (2x, 4x, or 8x) with AI preservation of typography, materials, and logos.
|
|
52
|
+
- **`imageUrl`** *(string, required)*: Public HTTPS URL of the image (JPEG, PNG, WebP).
|
|
53
|
+
- **`scale`** *(enum: "2" | "4" | "8", default: "4")*: Scaling multiplier.
|
|
54
|
+
- **`materialType`** *(enum, default: "general")*: Texture preservation preset (`general`, `model`, `fabric`, `leather`).
|
|
55
|
+
|
|
56
|
+
### `check_credits`
|
|
57
|
+
Inspects remaining credits, subscription tier, and storage metrics.
|
|
58
|
+
- Returns current balance, max monthly credits, plan tier (`free`, `starter`, `pro`), and storage usage.
|
|
59
|
+
|
|
60
|
+
### `check_upscale_status`
|
|
61
|
+
Polls the result of an asynchronous processing job using its `imageId`.
|
|
62
|
+
- **`imageId`** *(string, required)*: Job identifier returned when an upscale request is queued.
|
|
63
|
+
|
|
64
|
+
### `list_material_types`
|
|
65
|
+
Returns a catalog of supported material presets and texture restoration guidelines.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 📚 MCP Resources
|
|
70
|
+
|
|
71
|
+
- **`account://balance`** — Live JSON payload of credit balance, tier, and storage limits.
|
|
72
|
+
- **`docs://api-guide`** — Comprehensive API documentation and marketplace compliance guidelines (Amazon 1,600 px zoom, Shopify 2,048 px square).
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 💡 MCP Prompts
|
|
77
|
+
|
|
78
|
+
- **`upscale-product-image`** — Guided single-product upscale workflow with credit check and preset recommendation.
|
|
79
|
+
- **`batch-upscale-catalog`** — Multi-product catalog batch workflow with pre-execution credit checks and summary tables.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 💰 Pricing & Unit Economics
|
|
84
|
+
|
|
85
|
+
| Plan | Monthly Price | Monthly Credits | Effective Cost / Upscale | Storage Quota | Asset Retention |
|
|
86
|
+
| :--- | :--- | :--- | :--- | :--- | :--- |
|
|
87
|
+
| **Free** | $0 | 5 credits | Free | 100 MB | 30 days rolling |
|
|
88
|
+
| **Starter** | $9 / mo | 200 credits | $0.045 / upscale | 500 MB | Permanent |
|
|
89
|
+
| **Pro** | $19 / mo | 2,000 credits | < $0.01 / upscale | 2 GB | Permanent |
|
|
90
|
+
|
|
91
|
+
Subscribers can purchase non-expiring credit top-up packs anytime:
|
|
92
|
+
- **100 Credits:** $15 ($0.15 / credit)
|
|
93
|
+
- **500 Credits:** $35 ($0.07 / credit — Save 53%)
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 🔒 Security Architecture
|
|
98
|
+
|
|
99
|
+
1. **Authentication:** The API key is passed securely via the `PRODUCTIMAGEUPSCALE_API_KEY` environment variable on process startup. Identity is never passed through LLM prompt parameters, preventing prompt injection attacks.
|
|
100
|
+
2. **Tenant Isolation:** All operations enforce Supabase Row-Level Security (RLS) scoping credit deductions and asset queries to your account.
|
|
101
|
+
3. **Format Validation:** HTTPS URLs are required; executable payloads and animated GIFs are strictly rejected.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 💻 Local Development & Testing
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Clone the repository
|
|
109
|
+
git clone https://github.com/puskalkafle/product-image-upscale-ai.git
|
|
110
|
+
cd product-image-upscale-ai/mcp-server
|
|
111
|
+
|
|
112
|
+
# Install dependencies
|
|
113
|
+
npm install
|
|
114
|
+
|
|
115
|
+
# Build TypeScript
|
|
116
|
+
npm run build
|
|
117
|
+
|
|
118
|
+
# Run with MCP Inspector
|
|
119
|
+
npx @modelcontextprotocol/inspector node dist/index.js
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 📄 License
|
|
125
|
+
|
|
126
|
+
MIT © [ProductImageUpscale AI](https://productimageupscale.com)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { createServer } from './server.js';
|
|
4
|
+
async function main() {
|
|
5
|
+
const server = createServer();
|
|
6
|
+
const transport = new StdioServerTransport();
|
|
7
|
+
await server.connect(transport);
|
|
8
|
+
console.error('[ProductImageUpscale MCP] Server running on stdio');
|
|
9
|
+
}
|
|
10
|
+
main().catch((error) => {
|
|
11
|
+
console.error('[ProductImageUpscale MCP] Fatal error:', error);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAE7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;AACrE,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;IAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const batchUpscalePromptSchema: {
|
|
3
|
+
imageUrls: z.ZodString;
|
|
4
|
+
scale: z.ZodOptional<z.ZodEnum<["2", "4", "8"]>>;
|
|
5
|
+
materialType: z.ZodOptional<z.ZodString>;
|
|
6
|
+
};
|
|
7
|
+
export declare function handleBatchUpscalePrompt(args: {
|
|
8
|
+
imageUrls: string;
|
|
9
|
+
scale?: '2' | '4' | '8';
|
|
10
|
+
materialType?: string;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
messages: {
|
|
13
|
+
role: "user";
|
|
14
|
+
content: {
|
|
15
|
+
type: "text";
|
|
16
|
+
text: string;
|
|
17
|
+
};
|
|
18
|
+
}[];
|
|
19
|
+
}>;
|
|
20
|
+
//# sourceMappingURL=batch-upscale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-upscale.d.ts","sourceRoot":"","sources":["../../src/prompts/batch-upscale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,wBAAwB;;;;CAYpC,CAAC;AAEF,wBAAsB,wBAAwB,CAAC,IAAI,EAAE;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;;;;;;;;GAyBA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const batchUpscalePromptSchema = {
|
|
3
|
+
imageUrls: z
|
|
4
|
+
.string()
|
|
5
|
+
.describe('Comma or newline separated list of public image URLs to upscale'),
|
|
6
|
+
scale: z
|
|
7
|
+
.enum(['2', '4', '8'])
|
|
8
|
+
.optional()
|
|
9
|
+
.describe('Desired scaling factor for the batch (default: 4)'),
|
|
10
|
+
materialType: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe('Common material preset for all items, or leave blank to auto-detect per image'),
|
|
14
|
+
};
|
|
15
|
+
export async function handleBatchUpscalePrompt(args) {
|
|
16
|
+
const chosenScale = args.scale || '4';
|
|
17
|
+
const presetContext = args.materialType ? `\n- Material Preset: ${args.materialType}` : '';
|
|
18
|
+
return {
|
|
19
|
+
messages: [
|
|
20
|
+
{
|
|
21
|
+
role: 'user',
|
|
22
|
+
content: {
|
|
23
|
+
type: 'text',
|
|
24
|
+
text: `Please batch-upscale the following e-commerce product catalog images using ProductImageUpscale AI:\n\n` +
|
|
25
|
+
`Target Images:\n${args.imageUrls}\n\n` +
|
|
26
|
+
`Settings:\n- Scale Factor: ${chosenScale}x${presetContext}\n\n` +
|
|
27
|
+
`Execution Plan:\n` +
|
|
28
|
+
`1. Count the number of images to upscale.\n` +
|
|
29
|
+
`2. Call 'check_credits' to ensure the account has enough credits for the entire batch.\n` +
|
|
30
|
+
`3. If credits are insufficient, stop immediately, alert me with my current balance vs required, and provide the upgrade link.\n` +
|
|
31
|
+
`4. Iterate through each image URL and trigger 'upscale_image'. For any asynchronous processing jobs, poll 'check_upscale_status' until finished.\n` +
|
|
32
|
+
`5. Generate a final markdown table summarizing:\n` +
|
|
33
|
+
` | Original Image | Status | Scale | Upscaled Download URL | Notes |`,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=batch-upscale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-upscale.js","sourceRoot":"","sources":["../../src/prompts/batch-upscale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,QAAQ,CAAC,iEAAiE,CAAC;IAC9E,KAAK,EAAE,CAAC;SACL,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;SACrB,QAAQ,EAAE;SACV,QAAQ,CAAC,mDAAmD,CAAC;IAChE,YAAY,EAAE,CAAC;SACZ,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,+EAA+E,CAAC;CAC7F,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IAI9C;IACC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC;IACtC,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,wBAAwB,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3F,OAAO;QACL,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAe;gBACrB,OAAO,EAAE;oBACP,IAAI,EAAE,MAAe;oBACrB,IAAI,EACF,wGAAwG;wBACxG,mBAAmB,IAAI,CAAC,SAAS,MAAM;wBACvC,8BAA8B,WAAW,IAAI,aAAa,MAAM;wBAChE,mBAAmB;wBACnB,6CAA6C;wBAC7C,0FAA0F;wBAC1F,iIAAiI;wBACjI,oJAAoJ;wBACpJ,mDAAmD;wBACnD,wEAAwE;iBAC3E;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const upscaleProductPromptSchema: {
|
|
3
|
+
imageUrl: z.ZodString;
|
|
4
|
+
productType: z.ZodOptional<z.ZodString>;
|
|
5
|
+
scale: z.ZodOptional<z.ZodEnum<["2", "4", "8"]>>;
|
|
6
|
+
};
|
|
7
|
+
export declare function handleUpscaleProductPrompt(args: {
|
|
8
|
+
imageUrl: string;
|
|
9
|
+
productType?: string;
|
|
10
|
+
scale?: '2' | '4' | '8';
|
|
11
|
+
}): Promise<{
|
|
12
|
+
messages: {
|
|
13
|
+
role: "user";
|
|
14
|
+
content: {
|
|
15
|
+
type: "text";
|
|
16
|
+
text: string;
|
|
17
|
+
};
|
|
18
|
+
}[];
|
|
19
|
+
}>;
|
|
20
|
+
//# sourceMappingURL=upscale-product.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upscale-product.d.ts","sourceRoot":"","sources":["../../src/prompts/upscale-product.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,0BAA0B;;;;CAUtC,CAAC;AAEF,wBAAsB,0BAA0B,CAAC,IAAI,EAAE;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CACzB;;;;;;;;GAwBA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const upscaleProductPromptSchema = {
|
|
3
|
+
imageUrl: z.string().url().describe('HTTPS URL of the product image to upscale'),
|
|
4
|
+
productType: z
|
|
5
|
+
.string()
|
|
6
|
+
.optional()
|
|
7
|
+
.describe('Type of product (e.g. jewelry, sneakers, leather bag, cosmetics, electronics)'),
|
|
8
|
+
scale: z
|
|
9
|
+
.enum(['2', '4', '8'])
|
|
10
|
+
.optional()
|
|
11
|
+
.describe('Desired scaling factor (default: 4 for high-DPI e-commerce zoom)'),
|
|
12
|
+
};
|
|
13
|
+
export async function handleUpscaleProductPrompt(args) {
|
|
14
|
+
const chosenScale = args.scale || '4';
|
|
15
|
+
const typeContext = args.productType ? `\n- Product Category: ${args.productType}` : '';
|
|
16
|
+
return {
|
|
17
|
+
messages: [
|
|
18
|
+
{
|
|
19
|
+
role: 'user',
|
|
20
|
+
content: {
|
|
21
|
+
type: 'text',
|
|
22
|
+
text: `Please upscale this e-commerce product image using the ProductImageUpscale AI tool suite:\n\n` +
|
|
23
|
+
`- Image URL: ${args.imageUrl}${typeContext}\n` +
|
|
24
|
+
`- Desired Scale: ${chosenScale}x\n\n` +
|
|
25
|
+
`Workflow Steps:\n` +
|
|
26
|
+
`1. Call 'check_credits' first to verify that my account has at least 1 credit available.\n` +
|
|
27
|
+
`2. If human models or portraits are present, select materialType='model' (enables AI face enhancement). Otherwise, use 'general' (or 'fabric'/'leather' category presets).\n` +
|
|
28
|
+
`3. Call 'upscale_image' with the image URL, scale=${chosenScale}, and appropriate materialType.\n` +
|
|
29
|
+
`4. If the job is queued (status: processing), poll 'check_upscale_status' until completed.\n` +
|
|
30
|
+
`5. Present the final upscaled image URL and confirm compliance with Amazon/Shopify zoom standards.`,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=upscale-product.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upscale-product.js","sourceRoot":"","sources":["../../src/prompts/upscale-product.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IAChF,WAAW,EAAE,CAAC;SACX,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,+EAA+E,CAAC;IAC5F,KAAK,EAAE,CAAC;SACL,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;SACrB,QAAQ,EAAE;SACV,QAAQ,CAAC,kEAAkE,CAAC;CAChF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,IAIhD;IACC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC;IACtC,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,yBAAyB,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAExF,OAAO;QACL,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAe;gBACrB,OAAO,EAAE;oBACP,IAAI,EAAE,MAAe;oBACrB,IAAI,EACF,+FAA+F;wBAC/F,gBAAgB,IAAI,CAAC,QAAQ,GAAG,WAAW,IAAI;wBAC/C,oBAAoB,WAAW,OAAO;wBACtC,mBAAmB;wBACnB,4FAA4F;wBAC5F,8KAA8K;wBAC9K,qDAAqD,WAAW,mCAAmC;wBACnG,8FAA8F;wBAC9F,oGAAoG;iBACvG;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ProductImageUpscaleClient } from '../utils/api-client.js';
|
|
2
|
+
export declare function handleAccountBalanceResource(client: ProductImageUpscaleClient, uri: URL): Promise<{
|
|
3
|
+
contents: {
|
|
4
|
+
uri: string;
|
|
5
|
+
mimeType: string;
|
|
6
|
+
text: string;
|
|
7
|
+
}[];
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=account-balance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-balance.d.ts","sourceRoot":"","sources":["../../src/resources/account-balance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAExE,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,yBAAyB,EACjC,GAAG,EAAE,GAAG;;;;;;GAeT"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export async function handleAccountBalanceResource(client, uri) {
|
|
2
|
+
const res = await client.getAccount();
|
|
3
|
+
const payload = res.ok && res.data ? res.data : { error: res.error || 'Failed to fetch account' };
|
|
4
|
+
return {
|
|
5
|
+
contents: [
|
|
6
|
+
{
|
|
7
|
+
uri: uri.href,
|
|
8
|
+
mimeType: 'application/json',
|
|
9
|
+
text: JSON.stringify(payload, null, 2),
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=account-balance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-balance.js","sourceRoot":"","sources":["../../src/resources/account-balance.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,MAAiC,EACjC,GAAQ;IAER,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAEtC,MAAM,OAAO,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,yBAAyB,EAAE,CAAC;IAElG,OAAO;QACL,QAAQ,EAAE;YACR;gBACE,GAAG,EAAE,GAAG,CAAC,IAAI;gBACb,QAAQ,EAAE,kBAAkB;gBAC5B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;aACvC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-docs.d.ts","sourceRoot":"","sources":["../../src/resources/api-docs.ts"],"names":[],"mappings":"AAAA,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,GAAG;;;;;;GA2DnD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export async function handleApiDocsResource(uri) {
|
|
2
|
+
const markdown = `# ProductImageUpscale AI — Official API & MCP Guide
|
|
3
|
+
|
|
4
|
+
ProductImageUpscale AI provides high-resolution AI upscaling tuned specifically for e-commerce product catalogs, preserving fine packaging typography, fabric weaves, metallic specular highlights, and edge sharpness.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. Supported Formats & Resolutions
|
|
9
|
+
- **Supported Formats:** JPEG, PNG, WebP (input and output)
|
|
10
|
+
- **Unsupported Formats:** Animated GIF is strictly forbidden.
|
|
11
|
+
- **Maximum Input File Size:** 20 MB
|
|
12
|
+
- **Scaling Factors:**
|
|
13
|
+
- \`2x\`: Doubles image dimensions (fastest turnaround)
|
|
14
|
+
- \`4x\`: Quadruples dimensions (recommended for e-commerce product zooms)
|
|
15
|
+
- \`8x\`: Maximum resolution output (best for ultra-fine print and high-res banners)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 2. Marketplace Compliance Specifications
|
|
20
|
+
Output images generated by ProductImageUpscale AI conform directly to major e-commerce marketplace standards:
|
|
21
|
+
- **Amazon:** Exceeds 1,600 px requirement for interactive zoom & detail inspection.
|
|
22
|
+
- **Shopify:** Matches 2,048 × 2,048 px standard square catalog format.
|
|
23
|
+
- **Google Shopping:** High-DPI feed compliance without compression artifacts.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 3. Pricing Tiers & Unit Economics
|
|
28
|
+
- **Free:** 5 credits/month, 100 MB storage quota (30-day rolling retention).
|
|
29
|
+
- **Starter:** $9/month for 200 credits ($0.045 / upscale), 500 MB permanent storage.
|
|
30
|
+
- **Pro:** $19/month for 2,000 credits (< $0.01 / upscale), 2 GB permanent storage.
|
|
31
|
+
- **Non-Expiring Top-Up Packs (Subscribers):**
|
|
32
|
+
- 100 credits for $15 ($0.15 / credit)
|
|
33
|
+
- 500 credits for $35 ($0.07 / credit — Save 53% vs 100-pack rate)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 4. MCP Server Tools Reference
|
|
38
|
+
1. \`upscale_image\`: Accepts \`imageUrl\`, \`scale\` (2, 4, 8), and \`materialType\`. Returns upscaled URL.
|
|
39
|
+
2. \`check_credits\`: Returns live credit balance, storage usage, and plan tier.
|
|
40
|
+
3. \`check_upscale_status\`: Resolves asynchronous background jobs using \`imageId\`.
|
|
41
|
+
4. \`list_material_types\`: Enumerates all specialized texture-preservation presets.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 5. Security & Authentication
|
|
46
|
+
- All tool calls execute through secure HTTPS endpoints (\`x-api-key\` header).
|
|
47
|
+
- Identity is strictly derived from the API key, completely immune to prompt injection attacks.
|
|
48
|
+
- Account dashboard & API keys: https://productimageupscale.com/app/integrations
|
|
49
|
+
`;
|
|
50
|
+
return {
|
|
51
|
+
contents: [
|
|
52
|
+
{
|
|
53
|
+
uri: uri.href,
|
|
54
|
+
mimeType: 'text/markdown',
|
|
55
|
+
text: markdown,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=api-docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-docs.js","sourceRoot":"","sources":["../../src/resources/api-docs.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,GAAQ;IAClD,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+ClB,CAAC;IAEA,OAAO;QACL,QAAQ,EAAE;YACR;gBACE,GAAG,EAAE,GAAG,CAAC,IAAI;gBACb,QAAQ,EAAE,eAAe;gBACzB,IAAI,EAAE,QAAQ;aACf;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { type ServerConfig } from './utils/config.js';
|
|
3
|
+
import { ProductImageUpscaleClient } from './utils/api-client.js';
|
|
4
|
+
export interface CreateServerOptions {
|
|
5
|
+
config?: ServerConfig;
|
|
6
|
+
client?: ProductImageUpscaleClient;
|
|
7
|
+
}
|
|
8
|
+
export declare function createServer(options?: CreateServerOptions): McpServer;
|
|
9
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAa,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AA4BlE,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,MAAM,CAAC,EAAE,yBAAyB,CAAC;CACpC;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,SAAS,CAkFzE"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { getConfig } from './utils/config.js';
|
|
3
|
+
import { ProductImageUpscaleClient } from './utils/api-client.js';
|
|
4
|
+
import { upscaleImageToolSchema, handleUpscaleImage, } from './tools/upscale-image.js';
|
|
5
|
+
import { checkCreditsToolSchema, handleCheckCredits, } from './tools/check-credits.js';
|
|
6
|
+
import { checkStatusToolSchema, handleCheckStatus, } from './tools/check-status.js';
|
|
7
|
+
import { listMaterialsToolSchema, handleListMaterials, } from './tools/list-materials.js';
|
|
8
|
+
import { handleAccountBalanceResource } from './resources/account-balance.js';
|
|
9
|
+
import { handleApiDocsResource } from './resources/api-docs.js';
|
|
10
|
+
import { upscaleProductPromptSchema, handleUpscaleProductPrompt, } from './prompts/upscale-product.js';
|
|
11
|
+
import { batchUpscalePromptSchema, handleBatchUpscalePrompt, } from './prompts/batch-upscale.js';
|
|
12
|
+
export function createServer(options = {}) {
|
|
13
|
+
const config = options.config || getConfig();
|
|
14
|
+
const client = options.client || new ProductImageUpscaleClient({ config });
|
|
15
|
+
const server = new McpServer({
|
|
16
|
+
name: 'productimageupscale',
|
|
17
|
+
version: '1.0.0',
|
|
18
|
+
});
|
|
19
|
+
// ─── TOOLS ─────────────────────────────────────────────────────────
|
|
20
|
+
// Tool 1: upscale_image
|
|
21
|
+
server.tool('upscale_image', 'Upscale an e-commerce product image to high resolution (2x, 4x, or 8x) using AI. ' +
|
|
22
|
+
'Preserves fine text, logos, fabric weaves, and material reflections without hallucination. ' +
|
|
23
|
+
'Costs 1 credit per image. Returns the upscaled image URL.', upscaleImageToolSchema, async (args) => handleUpscaleImage(client, config.baseUrl, args));
|
|
24
|
+
// Tool 2: check_credits
|
|
25
|
+
server.tool('check_credits', 'Check your current ProductImageUpscale credit balance, active subscription tier (Free, Starter, Pro), ' +
|
|
26
|
+
'and storage usage quota.', checkCreditsToolSchema, async () => handleCheckCredits(client, config.baseUrl));
|
|
27
|
+
// Tool 3: check_upscale_status
|
|
28
|
+
server.tool('check_upscale_status', 'Poll or check the status of an asynchronous upscaling job using the imageId returned by upscale_image.', checkStatusToolSchema, async (args) => handleCheckStatus(client, args));
|
|
29
|
+
// Tool 4: list_material_types
|
|
30
|
+
server.tool('list_material_types', 'List all specialized texture and detail preservation presets (general, model, fabric, leather) and processing recommendations.', listMaterialsToolSchema, async () => handleListMaterials());
|
|
31
|
+
// ─── RESOURCES ─────────────────────────────────────────────────────
|
|
32
|
+
// Resource 1: Account Balance
|
|
33
|
+
server.resource('account-balance', 'account://balance', async (uri) => handleAccountBalanceResource(client, uri));
|
|
34
|
+
// Resource 2: API Documentation
|
|
35
|
+
server.resource('api-docs', 'docs://api-guide', async (uri) => handleApiDocsResource(uri));
|
|
36
|
+
// ─── PROMPTS ───────────────────────────────────────────────────────
|
|
37
|
+
// Prompt 1: Single image guided workflow
|
|
38
|
+
server.prompt('upscale-product-image', 'Step-by-step guided workflow for upscaling a single product image with balance verification and optimal preset selection', upscaleProductPromptSchema, async (args) => handleUpscaleProductPrompt(args));
|
|
39
|
+
// Prompt 2: Batch catalog workflow
|
|
40
|
+
server.prompt('batch-upscale-catalog', 'Multi-image catalog batch workflow with pre-check credit gating and markdown report generation', batchUpscalePromptSchema, async (args) => handleBatchUpscalePrompt(args));
|
|
41
|
+
return server;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAqB,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EACL,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,wBAAwB,EACxB,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,CAAC,MAAM,EAAE,GAAG,CAAC,CACzD,CAAC;IAEF,gCAAgC;IAChC,MAAM,CAAC,QAAQ,CACb,UAAU,EACV,kBAAkB,EAClB,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAC1C,CAAC;IAEF,sEAAsE;IAEtE,yCAAyC;IACzC,MAAM,CAAC,MAAM,CACX,uBAAuB,EACvB,0HAA0H,EAC1H,0BAA0B,EAC1B,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,0BAA0B,CAAC,IAAI,CAAC,CACjD,CAAC;IAEF,mCAAmC;IACnC,MAAM,CAAC,MAAM,CACX,uBAAuB,EACvB,gGAAgG,EAChG,wBAAwB,EACxB,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAC/C,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ProductImageUpscaleClient } from '../utils/api-client.js';
|
|
2
|
+
export declare const checkCreditsToolSchema: {};
|
|
3
|
+
export declare function handleCheckCredits(client: ProductImageUpscaleClient, baseUrl: string): Promise<{
|
|
4
|
+
content: {
|
|
5
|
+
type: "text";
|
|
6
|
+
text: string;
|
|
7
|
+
}[];
|
|
8
|
+
isError: boolean;
|
|
9
|
+
} | {
|
|
10
|
+
content: {
|
|
11
|
+
type: "text";
|
|
12
|
+
text: string;
|
|
13
|
+
}[];
|
|
14
|
+
isError?: undefined;
|
|
15
|
+
}>;
|
|
16
|
+
//# sourceMappingURL=check-credits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-credits.d.ts","sourceRoot":"","sources":["../../src/tools/check-credits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAExE,eAAO,MAAM,sBAAsB,IAAK,CAAC;AAEzC,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,yBAAyB,EACjC,OAAO,EAAE,MAAM;;;;;;;;;;;;GAyDhB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export const checkCreditsToolSchema = {};
|
|
2
|
+
export async function handleCheckCredits(client, baseUrl) {
|
|
3
|
+
const res = await client.getAccount();
|
|
4
|
+
if (!res.ok || !res.data) {
|
|
5
|
+
if (res.status === 401) {
|
|
6
|
+
return {
|
|
7
|
+
content: [
|
|
8
|
+
{
|
|
9
|
+
type: 'text',
|
|
10
|
+
text: `🔒 Authentication Error: Invalid or missing API key.\n\n` +
|
|
11
|
+
`Configure PRODUCTIMAGEUPSCALE_API_KEY with your key from ${baseUrl}/app/integrations`,
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
isError: true,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
content: [
|
|
19
|
+
{
|
|
20
|
+
type: 'text',
|
|
21
|
+
text: `❌ Failed to fetch account status (${res.status || 'Network error'}): ${res.error || 'Unknown error'}`,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
isError: true,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const { credits, maxCredits, tier, status, storageLimitBytes, storageUsedBytes } = res.data;
|
|
28
|
+
const storageUsedMB = (storageUsedBytes / (1024 * 1024)).toFixed(1);
|
|
29
|
+
const storageLimitMB = (storageLimitBytes / (1024 * 1024)).toFixed(0);
|
|
30
|
+
const retentionPolicy = tier === 'free'
|
|
31
|
+
? '30-day rolling retention'
|
|
32
|
+
: 'Permanent storage (within plan quota)';
|
|
33
|
+
return {
|
|
34
|
+
content: [
|
|
35
|
+
{
|
|
36
|
+
type: 'text',
|
|
37
|
+
text: `📊 **ProductImageUpscale Account Status**\n\n` +
|
|
38
|
+
`| Parameter | Value |\n` +
|
|
39
|
+
`| :--- | :--- |\n` +
|
|
40
|
+
`| **Plan Tier** | ${tier.toUpperCase()} |\n` +
|
|
41
|
+
`| **Credits Balance** | **${credits}** / ${maxCredits} remaining |\n` +
|
|
42
|
+
`| **Account Status** | ${status} |\n` +
|
|
43
|
+
`| **Storage Usage** | ${storageUsedMB} MB / ${storageLimitMB} MB |\n` +
|
|
44
|
+
`| **Asset Retention** | ${retentionPolicy} |\n\n` +
|
|
45
|
+
`${credits <= 10 ? `⚠️ Low balance! Top up or upgrade at ${baseUrl}/pricing\n` : ''}`,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=check-credits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-credits.js","sourceRoot":"","sources":["../../src/tools/check-credits.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAiC,EACjC,OAAe;IAEf,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAEtC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QACzB,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACvB,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EACF,0DAA0D;4BAC1D,4DAA4D,OAAO,mBAAmB;qBACzF;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,qCAAqC,GAAG,CAAC,MAAM,IAAI,eAAe,MAAM,GAAG,CAAC,KAAK,IAAI,eAAe,EAAE;iBAC7G;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;IAE5F,MAAM,aAAa,GAAG,CAAC,gBAAgB,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACpE,MAAM,cAAc,GAAG,CAAC,iBAAiB,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAEtE,MAAM,eAAe,GACnB,IAAI,KAAK,MAAM;QACb,CAAC,CAAC,0BAA0B;QAC5B,CAAC,CAAC,uCAAuC,CAAC;IAE9C,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EACF,+CAA+C;oBAC/C,yBAAyB;oBACzB,mBAAmB;oBACnB,qBAAqB,IAAI,CAAC,WAAW,EAAE,MAAM;oBAC7C,6BAA6B,OAAO,QAAQ,UAAU,gBAAgB;oBACtE,0BAA0B,MAAM,MAAM;oBACtC,yBAAyB,aAAa,SAAS,cAAc,SAAS;oBACtE,2BAA2B,eAAe,QAAQ;oBAClD,GAAG,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,wCAAwC,OAAO,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE;aACxF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ProductImageUpscaleClient } from '../utils/api-client.js';
|
|
3
|
+
export declare const checkStatusToolSchema: {
|
|
4
|
+
imageId: z.ZodString;
|
|
5
|
+
};
|
|
6
|
+
export declare function handleCheckStatus(client: ProductImageUpscaleClient, args: {
|
|
7
|
+
imageId: string;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
content: {
|
|
10
|
+
type: "text";
|
|
11
|
+
text: string;
|
|
12
|
+
}[];
|
|
13
|
+
isError: boolean;
|
|
14
|
+
} | {
|
|
15
|
+
content: {
|
|
16
|
+
type: "text";
|
|
17
|
+
text: string;
|
|
18
|
+
}[];
|
|
19
|
+
isError?: undefined;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=check-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-status.d.ts","sourceRoot":"","sources":["../../src/tools/check-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAExE,eAAO,MAAM,qBAAqB;;CAKjC,CAAC;AAEF,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,yBAAyB,EACjC,IAAI,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;GA0D1B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const checkStatusToolSchema = {
|
|
3
|
+
imageId: z
|
|
4
|
+
.string()
|
|
5
|
+
.min(1)
|
|
6
|
+
.describe('Job ID returned when upscale_image queued an image for asynchronous processing.'),
|
|
7
|
+
};
|
|
8
|
+
export async function handleCheckStatus(client, args) {
|
|
9
|
+
const res = await client.getUpscaleStatus(args.imageId);
|
|
10
|
+
if (!res.ok || !res.data) {
|
|
11
|
+
return {
|
|
12
|
+
content: [
|
|
13
|
+
{
|
|
14
|
+
type: 'text',
|
|
15
|
+
text: `❌ Failed to query job status (${res.status || 'Network error'}): ${res.error || 'Job not found'}`,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
isError: true,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const data = res.data;
|
|
22
|
+
if (data.status === 'succeeded' && data.outputUrl) {
|
|
23
|
+
return {
|
|
24
|
+
content: [
|
|
25
|
+
{
|
|
26
|
+
type: 'text',
|
|
27
|
+
text: `✅ Upscale completed successfully!\n\n` +
|
|
28
|
+
`• Job ID: ${args.imageId}\n` +
|
|
29
|
+
`• Upscaled URL: ${data.outputUrl}\n\n` +
|
|
30
|
+
`The upscaled image is ready for download or production use.`,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (data.status === 'processing') {
|
|
36
|
+
return {
|
|
37
|
+
content: [
|
|
38
|
+
{
|
|
39
|
+
type: 'text',
|
|
40
|
+
text: `⏳ Job ${args.imageId} is still processing on GPU.\n\n` +
|
|
41
|
+
`Upscaling typically takes 3–8 seconds depending on image resolution. Please check again shortly.`,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
content: [
|
|
48
|
+
{
|
|
49
|
+
type: 'text',
|
|
50
|
+
text: `❌ Upscaling job ${args.imageId} failed.\n\n` +
|
|
51
|
+
`Reason: ${data.error || data.message || 'Processing aborted'}\n` +
|
|
52
|
+
`Note: On definitive failures, the credit deduction is automatically refunded.`,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
isError: true,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=check-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-status.js","sourceRoot":"","sources":["../../src/tools/check-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,iFAAiF,CAAC;CAC/F,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAiC,EACjC,IAAyB;IAEzB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAExD,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QACzB,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,iCAAiC,GAAG,CAAC,MAAM,IAAI,eAAe,MAAM,GAAG,CAAC,KAAK,IAAI,eAAe,EAAE;iBACzG;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IAEtB,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QAClD,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EACF,uCAAuC;wBACvC,aAAa,IAAI,CAAC,OAAO,IAAI;wBAC7B,mBAAmB,IAAI,CAAC,SAAS,MAAM;wBACvC,6DAA6D;iBAChE;aACF;SACF,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;QACjC,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EACF,SAAS,IAAI,CAAC,OAAO,kCAAkC;wBACvD,kGAAkG;iBACrG;aACF;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EACF,mBAAmB,IAAI,CAAC,OAAO,cAAc;oBAC7C,WAAW,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,IAAI,oBAAoB,IAAI;oBACjE,+EAA+E;aAClF;SACF;QACD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-materials.d.ts","sourceRoot":"","sources":["../../src/tools/list-materials.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,IAAK,CAAC;AAE1C,wBAAsB,mBAAmB;;;;;GAmBxC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MATERIAL_TYPES, MATERIAL_DESCRIPTIONS } from '../types.js';
|
|
2
|
+
export const listMaterialsToolSchema = {};
|
|
3
|
+
export async function handleListMaterials() {
|
|
4
|
+
const rows = MATERIAL_TYPES.map((type) => `| \`${type}\` | ${MATERIAL_DESCRIPTIONS[type]} |`).join('\n');
|
|
5
|
+
return {
|
|
6
|
+
content: [
|
|
7
|
+
{
|
|
8
|
+
type: 'text',
|
|
9
|
+
text: `🎨 **ProductImageUpscale Processing Modes & Presets**\n\n` +
|
|
10
|
+
`Select the appropriate \`materialType\` when calling \`upscale_image\`:\n\n` +
|
|
11
|
+
`| Mode / Preset | Best For & Processing Optimization |\n` +
|
|
12
|
+
`| :--- | :--- |\n` +
|
|
13
|
+
`${rows}\n\n` +
|
|
14
|
+
`*Note: For standard product packshots without human faces, use \`general\` (or leave empty).*`,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=list-materials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-materials.js","sourceRoot":"","sources":["../../src/tools/list-materials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpE,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAC7B,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,QAAQ,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAC7D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EACF,2DAA2D;oBAC3D,6EAA6E;oBAC7E,0DAA0D;oBAC1D,mBAAmB;oBACnB,GAAG,IAAI,MAAM;oBACb,+FAA+F;aAClG;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ProductImageUpscaleClient } from '../utils/api-client.js';
|
|
3
|
+
import { type MaterialType } from '../types.js';
|
|
4
|
+
export declare const upscaleImageToolSchema: {
|
|
5
|
+
imageUrl: z.ZodString;
|
|
6
|
+
scale: z.ZodDefault<z.ZodEnum<["2", "4", "8"]>>;
|
|
7
|
+
materialType: z.ZodDefault<z.ZodEnum<["general", "model", "fabric", "leather"]>>;
|
|
8
|
+
};
|
|
9
|
+
export declare function handleUpscaleImage(client: ProductImageUpscaleClient, baseUrl: string, args: {
|
|
10
|
+
imageUrl: string;
|
|
11
|
+
scale?: '2' | '4' | '8';
|
|
12
|
+
materialType?: MaterialType;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
content: {
|
|
15
|
+
type: "text";
|
|
16
|
+
text: string;
|
|
17
|
+
}[];
|
|
18
|
+
isError: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
content: {
|
|
21
|
+
type: "text";
|
|
22
|
+
text: string;
|
|
23
|
+
}[];
|
|
24
|
+
isError?: undefined;
|
|
25
|
+
}>;
|
|
26
|
+
//# sourceMappingURL=upscale-image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upscale-image.d.ts","sourceRoot":"","sources":["../../src/tools/upscale-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhE,eAAO,MAAM,sBAAsB;;;;CAmBlC,CAAC;AAEF,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,yBAAyB,EACjC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;IACJ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACxB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;;;;;;;;;;;;GAqHF"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { MATERIAL_TYPES } from '../types.js';
|
|
3
|
+
export const upscaleImageToolSchema = {
|
|
4
|
+
imageUrl: z
|
|
5
|
+
.string()
|
|
6
|
+
.url()
|
|
7
|
+
.describe('Public HTTPS URL of the image to upscale. Must be JPEG, PNG, or WebP. GIF is not supported.'),
|
|
8
|
+
scale: z
|
|
9
|
+
.enum(['2', '4', '8'])
|
|
10
|
+
.default('4')
|
|
11
|
+
.describe('Upscaling factor. 2x doubles resolution, 4x quadruples (recommended for e-commerce), 8x for maximum resolution. Default: 4'),
|
|
12
|
+
materialType: z
|
|
13
|
+
.enum(MATERIAL_TYPES)
|
|
14
|
+
.default('general')
|
|
15
|
+
.describe('Processing mode: general (standard e-commerce product packshots: electronics, shoes, cosmetics, jewelry), model (activates AI face restoration for lifestyle photos with human models), fabric (apparel category preset), leather (leather goods category preset). Default: general'),
|
|
16
|
+
};
|
|
17
|
+
export async function handleUpscaleImage(client, baseUrl, args) {
|
|
18
|
+
const scaleNum = Number(args.scale || '4');
|
|
19
|
+
const materialType = args.materialType || 'general';
|
|
20
|
+
const res = await client.upscaleImage({
|
|
21
|
+
imageUrl: args.imageUrl,
|
|
22
|
+
scale: scaleNum,
|
|
23
|
+
materialType,
|
|
24
|
+
});
|
|
25
|
+
if (!res.ok) {
|
|
26
|
+
if (res.status === 402) {
|
|
27
|
+
return {
|
|
28
|
+
content: [
|
|
29
|
+
{
|
|
30
|
+
type: 'text',
|
|
31
|
+
text: `⚠️ Insufficient credits remaining.\n\n` +
|
|
32
|
+
`Your ProductImageUpscale credit balance has been exhausted.\n\n` +
|
|
33
|
+
`Options to continue:\n` +
|
|
34
|
+
`• Upgrade to Starter ($9/mo for 200 credits, $0.045/image)\n` +
|
|
35
|
+
`• Upgrade to Pro ($19/mo for 2,000 credits, < $0.01/image)\n` +
|
|
36
|
+
`• Purchase top-up pack (100 credits for $15, 500 credits for $35)\n\n` +
|
|
37
|
+
`Upgrade link: ${baseUrl}/pricing\n` +
|
|
38
|
+
`Check current balance using tool: check_credits`,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
isError: true,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (res.status === 401) {
|
|
45
|
+
return {
|
|
46
|
+
content: [
|
|
47
|
+
{
|
|
48
|
+
type: 'text',
|
|
49
|
+
text: `🔒 Authentication Error: Invalid or missing API key.\n\n` +
|
|
50
|
+
`Please ensure the PRODUCTIMAGEUPSCALE_API_KEY environment variable is configured with a valid key.\n` +
|
|
51
|
+
`Find or create keys at: ${baseUrl}/app/integrations`,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
isError: true,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (res.status === 451) {
|
|
58
|
+
return {
|
|
59
|
+
content: [
|
|
60
|
+
{
|
|
61
|
+
type: 'text',
|
|
62
|
+
text: `🚫 Moderation Error: Image rejected.\n\n` +
|
|
63
|
+
`The provided image violates acceptable use policies (NSFW / sensitive content). Upscaling was aborted and no credits were deducted.`,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
isError: true,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
content: [
|
|
71
|
+
{
|
|
72
|
+
type: 'text',
|
|
73
|
+
text: `❌ Upscale failed (${res.status || 'Network error'}): ${res.error || 'Unknown error occurred'}`,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
isError: true,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const data = res.data;
|
|
80
|
+
const outputUrl = data?.outputUrl || data?.output;
|
|
81
|
+
if (outputUrl && (data?.status === 'succeeded' || !data?.status)) {
|
|
82
|
+
return {
|
|
83
|
+
content: [
|
|
84
|
+
{
|
|
85
|
+
type: 'text',
|
|
86
|
+
text: `✅ Image upscaled successfully!\n\n` +
|
|
87
|
+
`• Upscaled URL: ${outputUrl}\n` +
|
|
88
|
+
`• Scale: ${data?.scale || scaleNum}x\n` +
|
|
89
|
+
`• Material Preset: ${materialType}\n` +
|
|
90
|
+
`${data?.note ? `• Note: ${data.note}\n` : ''}\n` +
|
|
91
|
+
`The high-resolution image is ready for download or direct embedding into your store catalog.`,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (data?.status === 'processing' && data?.imageId) {
|
|
97
|
+
return {
|
|
98
|
+
content: [
|
|
99
|
+
{
|
|
100
|
+
type: 'text',
|
|
101
|
+
text: `⏳ Image queued and currently processing on GPU.\n\n` +
|
|
102
|
+
`• Job ID: ${data.imageId}\n` +
|
|
103
|
+
`• Scale: ${scaleNum}x\n` +
|
|
104
|
+
`• Preset: ${materialType}\n\n` +
|
|
105
|
+
`Use the check_upscale_status tool with imageId: "${data.imageId}" to retrieve the final URL once ready.`,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
content: [
|
|
112
|
+
{
|
|
113
|
+
type: 'text',
|
|
114
|
+
text: `⚠️ Unexpected response from upscaling engine: ${JSON.stringify(data)}`,
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
isError: true,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=upscale-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upscale-image.js","sourceRoot":"","sources":["../../src/tools/upscale-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAqB,MAAM,aAAa,CAAC;AAEhE,MAAM,CA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;QACnD,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EACF,qDAAqD;wBACrD,aAAa,IAAI,CAAC,OAAO,IAAI;wBAC7B,YAAY,QAAQ,KAAK;wBACzB,aAAa,YAAY,MAAM;wBAC/B,oDAAoD,IAAI,CAAC,OAAO,yCAAyC;iBAC5G;aACF;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,iDAAiD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;aAC9E;SACF;QACD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type PlanTier = 'free' | 'starter' | 'pro';
|
|
2
|
+
export interface AccountResponse {
|
|
3
|
+
credits: number;
|
|
4
|
+
maxCredits: number;
|
|
5
|
+
tier: PlanTier;
|
|
6
|
+
status: string;
|
|
7
|
+
storageLimitBytes: number;
|
|
8
|
+
storageUsedBytes: number;
|
|
9
|
+
error?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface UpscaleResponse {
|
|
12
|
+
success?: boolean;
|
|
13
|
+
imageId?: string | null;
|
|
14
|
+
status?: 'succeeded' | 'processing' | 'failed';
|
|
15
|
+
replicate_id?: string | null;
|
|
16
|
+
outputUrl?: string | null;
|
|
17
|
+
output?: string | null;
|
|
18
|
+
scale?: number;
|
|
19
|
+
note?: string;
|
|
20
|
+
message?: string;
|
|
21
|
+
error?: string;
|
|
22
|
+
code?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface UpscaleStatusResponse {
|
|
25
|
+
success?: boolean;
|
|
26
|
+
imageId?: string;
|
|
27
|
+
status?: 'succeeded' | 'processing' | 'failed';
|
|
28
|
+
outputUrl?: string | null;
|
|
29
|
+
error?: string;
|
|
30
|
+
message?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare const MATERIAL_TYPES: readonly ["general", "model", "fabric", "leather"];
|
|
33
|
+
export type MaterialType = typeof MATERIAL_TYPES[number];
|
|
34
|
+
export declare const MATERIAL_DESCRIPTIONS: Record<MaterialType, string>;
|
|
35
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,CAAC;AAElD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,QAAQ,CAAC;IAC/C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,QAAQ,CAAC;IAC/C,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,cAAc,oDAKjB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;AAEzD,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAK9D,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const MATERIAL_TYPES = [
|
|
2
|
+
'general',
|
|
3
|
+
'model',
|
|
4
|
+
'fabric',
|
|
5
|
+
'leather',
|
|
6
|
+
];
|
|
7
|
+
export const MATERIAL_DESCRIPTIONS = {
|
|
8
|
+
general: 'Default / General Packshot — standard super-resolution for all e-commerce products (electronics, cosmetics, jewelry, shoes, packshots)',
|
|
9
|
+
model: 'Model / Lifestyle — activates GFPGAN AI face restoration for clothing on human models and portrait photography (at 2x and 4x)',
|
|
10
|
+
fabric: 'Fabric & Apparel — category preset for clothing and soft goods (runs standard super-resolution with apparel defaults)',
|
|
11
|
+
leather: 'Leather Goods — category preset for footwear, bags, and leather accessories (runs standard super-resolution with leather defaults)',
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAmCA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,SAAS;IACT,OAAO;IACP,QAAQ;IACR,SAAS;CACD,CAAC;AAIX,MAAM,CAAC,MAAM,qBAAqB,GAAiC;IACjE,OAAO,EAAE,wIAAwI;IACjJ,KAAK,EAAE,+HAA+H;IACtI,MAAM,EAAE,uHAAuH;IAC/H,OAAO,EAAE,oIAAoI;CAC9I,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ServerConfig } from './config.js';
|
|
2
|
+
import type { AccountResponse, UpscaleResponse, UpscaleStatusResponse, MaterialType } from '../types.js';
|
|
3
|
+
export interface ApiClientOptions {
|
|
4
|
+
config: ServerConfig;
|
|
5
|
+
fetchFn?: typeof fetch;
|
|
6
|
+
}
|
|
7
|
+
export declare class ProductImageUpscaleClient {
|
|
8
|
+
private config;
|
|
9
|
+
private fetch;
|
|
10
|
+
constructor(options: ApiClientOptions);
|
|
11
|
+
private getHeaders;
|
|
12
|
+
getAccount(): Promise<{
|
|
13
|
+
ok: boolean;
|
|
14
|
+
status: number;
|
|
15
|
+
data?: AccountResponse;
|
|
16
|
+
error?: string;
|
|
17
|
+
}>;
|
|
18
|
+
upscaleImage(params: {
|
|
19
|
+
imageUrl: string;
|
|
20
|
+
scale?: number;
|
|
21
|
+
materialType?: MaterialType;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
ok: boolean;
|
|
24
|
+
status: number;
|
|
25
|
+
data?: UpscaleResponse;
|
|
26
|
+
error?: string;
|
|
27
|
+
code?: string;
|
|
28
|
+
}>;
|
|
29
|
+
getUpscaleStatus(imageId: string): Promise<{
|
|
30
|
+
ok: boolean;
|
|
31
|
+
status: number;
|
|
32
|
+
data?: UpscaleStatusResponse;
|
|
33
|
+
error?: string;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=api-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/utils/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA0B,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,YAAY,EACb,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;CACxB;AAED,qBAAa,yBAAyB;IACpC,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,KAAK,CAAe;gBAEhB,OAAO,EAAE,gBAAgB;IAKrC,OAAO,CAAC,UAAU;IASZ,UAAU,IAAI,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,eAAe,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAgC9F,YAAY,CAAC,MAAM,EAAE;QACzB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,YAAY,CAAC;KAC7B,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,eAAe,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IA0D7F,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAC/C,EAAE,EAAE,OAAO,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,qBAAqB,CAAC;QAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CAgCH"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { assertApiKeyConfigured } from './config.js';
|
|
2
|
+
export class ProductImageUpscaleClient {
|
|
3
|
+
config;
|
|
4
|
+
fetch;
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.config = options.config;
|
|
7
|
+
this.fetch = options.fetchFn || globalThis.fetch.bind(globalThis);
|
|
8
|
+
}
|
|
9
|
+
getHeaders() {
|
|
10
|
+
assertApiKeyConfigured(this.config.apiKey);
|
|
11
|
+
return {
|
|
12
|
+
'Content-Type': 'application/json',
|
|
13
|
+
'x-api-key': this.config.apiKey,
|
|
14
|
+
'User-Agent': 'ProductImageUpscale-MCP-Server/1.0.0',
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async getAccount() {
|
|
18
|
+
try {
|
|
19
|
+
const headers = this.getHeaders();
|
|
20
|
+
const response = await this.fetch(`${this.config.baseUrl}/api/v1/account`, {
|
|
21
|
+
method: 'GET',
|
|
22
|
+
headers,
|
|
23
|
+
});
|
|
24
|
+
const body = (await response.json());
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
return {
|
|
27
|
+
ok: false,
|
|
28
|
+
status: response.status,
|
|
29
|
+
error: body.error || `HTTP error ${response.status}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
ok: true,
|
|
34
|
+
status: response.status,
|
|
35
|
+
data: body,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
return {
|
|
40
|
+
ok: false,
|
|
41
|
+
status: 0,
|
|
42
|
+
error: err.message || 'Network request failed',
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async upscaleImage(params) {
|
|
47
|
+
try {
|
|
48
|
+
const headers = this.getHeaders();
|
|
49
|
+
// Client-side quick validation to fail fast before burning network calls
|
|
50
|
+
const cleanUrl = params.imageUrl.split('?')[0].toLowerCase();
|
|
51
|
+
if (cleanUrl.endsWith('.gif')) {
|
|
52
|
+
return {
|
|
53
|
+
ok: false,
|
|
54
|
+
status: 400,
|
|
55
|
+
code: 'UNSUPPORTED_FORMAT',
|
|
56
|
+
error: 'GIF images are not supported for AI upscaling. Please provide a JPEG, PNG, or WebP image.',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
let normalizedMaterialType = undefined;
|
|
60
|
+
if (params.materialType) {
|
|
61
|
+
const lower = params.materialType.toLowerCase();
|
|
62
|
+
if (lower === 'model')
|
|
63
|
+
normalizedMaterialType = 'Model';
|
|
64
|
+
else if (lower === 'fabric')
|
|
65
|
+
normalizedMaterialType = 'Fabric';
|
|
66
|
+
else if (lower === 'leather')
|
|
67
|
+
normalizedMaterialType = 'Leather';
|
|
68
|
+
}
|
|
69
|
+
const response = await this.fetch(`${this.config.baseUrl}/api/v1/upscale`, {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers,
|
|
72
|
+
body: JSON.stringify({
|
|
73
|
+
imageUrl: params.imageUrl,
|
|
74
|
+
scale: params.scale || 4,
|
|
75
|
+
...(normalizedMaterialType ? { materialType: normalizedMaterialType } : {}),
|
|
76
|
+
}),
|
|
77
|
+
});
|
|
78
|
+
const body = (await response.json());
|
|
79
|
+
if (!response.ok) {
|
|
80
|
+
return {
|
|
81
|
+
ok: false,
|
|
82
|
+
status: response.status,
|
|
83
|
+
code: body.code,
|
|
84
|
+
error: body.error || body.message || `HTTP error ${response.status}`,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
ok: true,
|
|
89
|
+
status: response.status,
|
|
90
|
+
data: body,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
return {
|
|
95
|
+
ok: false,
|
|
96
|
+
status: 0,
|
|
97
|
+
error: err.message || 'Network request failed',
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async getUpscaleStatus(imageId) {
|
|
102
|
+
try {
|
|
103
|
+
const headers = this.getHeaders();
|
|
104
|
+
const response = await this.fetch(`${this.config.baseUrl}/api/v1/upscale-status`, {
|
|
105
|
+
method: 'POST',
|
|
106
|
+
headers,
|
|
107
|
+
body: JSON.stringify({ imageId }),
|
|
108
|
+
});
|
|
109
|
+
const body = (await response.json());
|
|
110
|
+
if (!response.ok) {
|
|
111
|
+
return {
|
|
112
|
+
ok: false,
|
|
113
|
+
status: response.status,
|
|
114
|
+
error: body.error || body.message || `HTTP error ${response.status}`,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
ok: true,
|
|
119
|
+
status: response.status,
|
|
120
|
+
data: body,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
return {
|
|
125
|
+
ok: false,
|
|
126
|
+
status: 0,
|
|
127
|
+
error: err.message || 'Network request failed',
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=api-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/utils/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAanE,MAAM,OAAO,yBAAyB;IAC5B,MAAM,CAAe;IACrB,KAAK,CAAe;IAE5B,YAAY,OAAyB;QACnC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpE,CAAC;IAEO,UAAU;QAChB,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3C,OAAO;YACL,cAAc,EAAE,kBAAkB;YAClC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;YAC/B,YAAY,EAAE,sCAAsC;SACrD,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YAClC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,iBAAiB,EAAE;gBACzE,MAAM,EAAE,KAAK;gBACb,OAAO;aACR,CAAC,CAAC;YAEH,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAoB,CAA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|
+
export function getConfig() {
|
|
2
|
+
const apiKey = process.env.PRODUCTIMAGEUPSCALE_API_KEY ||
|
|
3
|
+
process.env.PRODUCT_IMAGE_UPSCALE_API_KEY ||
|
|
4
|
+
'';
|
|
5
|
+
const baseUrl = (process.env.PRODUCTIMAGEUPSCALE_API_URL ||
|
|
6
|
+
process.env.PRODUCT_IMAGE_UPSCALE_API_URL ||
|
|
7
|
+
'https://productimageupscale.com').replace(/\/+$/, '');
|
|
8
|
+
return {
|
|
9
|
+
apiKey,
|
|
10
|
+
baseUrl,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function assertApiKeyConfigured(apiKey) {
|
|
14
|
+
if (!apiKey || apiKey.trim().length === 0) {
|
|
15
|
+
throw new Error('Missing ProductImageUpscale API key. Please configure the PRODUCTIMAGEUPSCALE_API_KEY environment variable. ' +
|
|
16
|
+
'You can obtain your API key from https://productimageupscale.com/app/integrations');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,SAAS;IACvB,MAAM,MAAM,GACV,OAAO,CAAC,GAAG,CAAC,2BAA2B;QACvC,OAAO,CAAC,GAAG,CAAC,6BAA6B;QACzC,EAAE,CAAC;IAEL,MAAM,OAAO,GAAG,CACd,OAAO,CAAC,GAAG,CAAC,2BAA2B;QACvC,OAAO,CAAC,GAAG,CAAC,6BAA6B;QACzC,iCAAiC,CAClC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAEtB,OAAO;QACL,MAAM;QACN,OAAO;KACR,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACnD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CACb,8GAA8G;YAC9G,mFAAmF,CACpF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "productimageupscale-mcp",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Official MCP server for ProductImageUpscale AI — upscale e-commerce product images via AI agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"productimageupscale-mcp": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"dev": "tsx src/index.ts",
|
|
17
|
+
"start": "node dist/index.js",
|
|
18
|
+
"test": "vitest run"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"mcp",
|
|
22
|
+
"model-context-protocol",
|
|
23
|
+
"image-upscaling",
|
|
24
|
+
"ai",
|
|
25
|
+
"ecommerce",
|
|
26
|
+
"product-photography",
|
|
27
|
+
"claude",
|
|
28
|
+
"cursor"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
32
|
+
"zod": "^3.23.8"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^22.13.0",
|
|
36
|
+
"tsx": "^4.19.2",
|
|
37
|
+
"typescript": "^5.7.0",
|
|
38
|
+
"vitest": "^3.0.0"
|
|
39
|
+
}
|
|
40
|
+
}
|