@imageconvertit/mcp-server 0.0.0-stage → 0.3.2
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 +134 -3
- package/package.json +50 -6
- package/src/authorize.js +86 -0
- package/src/index.js +734 -0
- package/src/lib/batch.js +151 -0
- package/src/lib/cloudAuth.js +177 -0
- package/src/lib/imageOps.js +272 -0
- package/src/lib/rembg.js +38 -0
- package/src/lib/runAi.js +312 -0
- package/src/tools/ai.js +319 -0
- package/src/tools/core.js +7 -0
- package/src/tools/ecommerce.js +607 -0
- package/src/tools/format.js +534 -0
package/README.md
CHANGED
|
@@ -1,3 +1,134 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# @imageconvertit/mcp-server
|
|
2
|
+
|
|
3
|
+
**One** local **stdio** MCP package — two meters:
|
|
4
|
+
|
|
5
|
+
| Meter | Tools | Gate |
|
|
6
|
+
|-------|-------|------|
|
|
7
|
+
| **Core** (E-Commerce + Format) | Folder batch tools | Automation `$19` / `$29` / `$49` via `POST /api/mcp/authorize` |
|
|
8
|
+
| **Cloud AI** (12 tools) | Single-image AI tools | Same **credit wallet** as the website via `POST /api/run-ai` |
|
|
9
|
+
|
|
10
|
+
There is **not** a second MCP package. Claude / Cursor / VS Code / Codex / Gemini CLI all use this same `@imageconvertit/mcp-server`.
|
|
11
|
+
|
|
12
|
+
**Provider keys never ship to clients.** FAL / FASHN / GROQ stay on Cloudflare. MCP only uses `ICI_LICENSE_KEY` → mints `api_token` → calls our API.
|
|
13
|
+
|
|
14
|
+
Version **0.3.1**
|
|
15
|
+
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
- Node 20+
|
|
19
|
+
- `ICI_LICENSE_KEY` = LemonSqueezy key (Automation for Core batches; any key with credits / Automation Pro for Cloud AI)
|
|
20
|
+
- Optional: `ICI_DEVICE_ID` (stable seat id; auto-persisted under `~/.imageconvertit/` if omitted)
|
|
21
|
+
- First rembg call downloads ONNX models (cached)
|
|
22
|
+
|
|
23
|
+
## Tools
|
|
24
|
+
|
|
25
|
+
### Format & Conversion
|
|
26
|
+
| Product | MCP tool |
|
|
27
|
+
|---------|----------|
|
|
28
|
+
| Bulk Image Compressor | `batch_compress` |
|
|
29
|
+
| Bulk Image Cropper | `batch_crop` |
|
|
30
|
+
| Bulk Image Resizer | `batch_resize` |
|
|
31
|
+
| Bulk Image Converter | `batch_convert` |
|
|
32
|
+
| PNG to WebP Converter | `batch_png_to_webp` |
|
|
33
|
+
| HEIC → PNG / JPG / PDF | `batch_heic_convert` |
|
|
34
|
+
| Bulk Image Upscale (Lanczos) | `batch_upscale` |
|
|
35
|
+
| Bulk Image to PDF | `batch_images_to_pdf` |
|
|
36
|
+
| Bulk PDF to Image | `batch_pdf_to_images` |
|
|
37
|
+
| AI Vectorize (local potrace) | `batch_vectorize` |
|
|
38
|
+
| Bulk Black and White | `batch_grayscale` |
|
|
39
|
+
| Bulk Image Rotator | `batch_rotate` |
|
|
40
|
+
| Book Cover Bleed Checker | `batch_bleed_checker` (+ `bleed-report.json`) |
|
|
41
|
+
|
|
42
|
+
### E-Commerce & Creators
|
|
43
|
+
| Product | MCP tool |
|
|
44
|
+
|---------|----------|
|
|
45
|
+
| Bulk Background Remover | `batch_remove_background` |
|
|
46
|
+
| Amazon/Shopify White Background | `batch_white_background` |
|
|
47
|
+
| Bulk Background Colour Changer | `batch_background_color` |
|
|
48
|
+
| Bulk Catalog Watermarking | `batch_watermark` (text and/or `watermarkPath`) |
|
|
49
|
+
| Add Text to Product Photos | `batch_text_overlay` |
|
|
50
|
+
| Adjust Product Photos In Bulk | `batch_adjust` |
|
|
51
|
+
| Align Product Photos In Bulk | `batch_align_center` |
|
|
52
|
+
| Add Logo to Product Photos In Bulk | `batch_logo_overlay` |
|
|
53
|
+
| Add Reflections to Product Photos In Bulk | `batch_reflection` |
|
|
54
|
+
| Add Shadow to Product Photos | `batch_add_shadow` |
|
|
55
|
+
| Bulk Blur Background | `batch_blur_background` |
|
|
56
|
+
| Barcode & QR Code Generator | `generate_barcode_qr` |
|
|
57
|
+
|
|
58
|
+
### Cloud AI (credit-strict)
|
|
59
|
+
| Product | MCP tool | Server slug |
|
|
60
|
+
|---------|----------|-------------|
|
|
61
|
+
| AI Fashion Model | `ai_fashion_model` | `ai-fashion-model` |
|
|
62
|
+
| AI Virtual Try-On | `ai_virtual_try_on` | `ai-virtual-try-on` |
|
|
63
|
+
| AI Fashion Model Swap | `ai_fashion_model_swap` | `ai-fashion-model-swap` |
|
|
64
|
+
| AI Fashion Model Creation | `ai_fashion_model_creation` | `ai-fashion-model-creation` |
|
|
65
|
+
| AI Remove Object | `ai_remove_object` | `ai-remove-object` |
|
|
66
|
+
| AI Watermark Remover | `ai_watermark_remover` | `watermark-remover` |
|
|
67
|
+
| AI Lifestyle Product Photos | `ai_lifestyle_product_photos` | `ai-lifestyle-product-photos` |
|
|
68
|
+
| AI Product Backgrounds | `ai_product_backgrounds` | `ai-product-backgrounds` |
|
|
69
|
+
| 8K Image Upscaler | `ai_8k_upscaler` | `8k-texture-upscaler` |
|
|
70
|
+
| AI Product Beautifier | `ai_product_beautifier` | `ai-product-beautifier` |
|
|
71
|
+
| AI Image Colorizer | `ai_image_colorizer` | `image-colorizer` |
|
|
72
|
+
| AI Uncrop | `ai_uncrop` | `ai-uncrop` |
|
|
73
|
+
|
|
74
|
+
Cloud AI tools take absolute **file paths** (`inputPath` / `outputPath`). Without credits the API returns **402** — no free Cloud AI via MCP.
|
|
75
|
+
|
|
76
|
+
Also: `mcp_status`, legacy `batch_resize_compress` / `batch_amazon_prep`.
|
|
77
|
+
|
|
78
|
+
## Client setup (verified 2026-11-17)
|
|
79
|
+
|
|
80
|
+
| Client | Config file | Format |
|
|
81
|
+
|--------|-------------|--------|
|
|
82
|
+
| Claude Desktop | `claude_desktop_config.json` | `mcpServers` JSON |
|
|
83
|
+
| Cursor | `~/.cursor/mcp.json` or `.cursor/mcp.json` | `mcpServers` JSON |
|
|
84
|
+
| VS Code | `.vscode/mcp.json` | `servers` + `"type":"stdio"` |
|
|
85
|
+
| Codex / ChatGPT desktop | `~/.codex/config.toml` | `[mcp_servers.imageconvertit]` |
|
|
86
|
+
| Gemini CLI | `~/.gemini/settings.json` | `mcpServers` JSON |
|
|
87
|
+
|
|
88
|
+
**Windows GUI hosts (Claude / Cursor / VS Code):** use `npx.cmd` (not `npx`) so PATH resolves. macOS / Linux: `npx`. Node.js 20+ must be installed and on PATH for GUI apps.
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"mcpServers": {
|
|
93
|
+
"imageconvertit": {
|
|
94
|
+
"command": "npx.cmd",
|
|
95
|
+
"args": ["-y", "@imageconvertit/mcp-server"],
|
|
96
|
+
"env": {
|
|
97
|
+
"ICI_LICENSE_KEY": "YOUR_LEMONSQUEEZY_LICENSE_KEY",
|
|
98
|
+
"ICI_API_BASE": "https://imageconvertit.com"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
On macOS / Linux, change `"command"` to `"npx"`. Prefer **Account → MCP** on imageconvertit.com — it emits the OS-correct snippet.
|
|
106
|
+
|
|
107
|
+
**Do not** put `FAL_API_KEY`, `FASHN_API_KEY`, or `GROQ_API_KEY` in MCP env — they are rejected by design (unused) and must stay on the server.
|
|
108
|
+
|
|
109
|
+
Codex / ChatGPT desktop TOML (Windows shown; use `npx` on macOS / Linux):
|
|
110
|
+
|
|
111
|
+
```toml
|
|
112
|
+
[mcp_servers.imageconvertit]
|
|
113
|
+
command = "npx.cmd"
|
|
114
|
+
args = ["-y", "@imageconvertit/mcp-server"]
|
|
115
|
+
|
|
116
|
+
[mcp_servers.imageconvertit.env]
|
|
117
|
+
ICI_LICENSE_KEY = "YOUR_LEMONSQUEEZY_LICENSE_KEY"
|
|
118
|
+
ICI_API_BASE = "https://imageconvertit.com"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Dev smoke (local Core ops, no Cloud AI network)
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
cd packages/mcp-server && npm run smoke
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Notes
|
|
128
|
+
|
|
129
|
+
- **One package, two meters** — Core = Automation files; Cloud AI = credits
|
|
130
|
+
- Paths only for Core — never send image bytes through the model
|
|
131
|
+
- Cloud AI: MCP reads the file locally, POSTs to `/api/run-ai`, writes the result path
|
|
132
|
+
- Max 50 files/pages per Core authorize call · concurrency ≤ 3
|
|
133
|
+
- Publish this package to npm before relying on `npx -y`
|
|
134
|
+
- Deploy `/api/mcp/authorize` + `/api/run-ai` for live metering
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@imageconvertit/mcp-server",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@imageconvertit/mcp-server",
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"description": "ImageConvertIt local MCP — Core (E-Commerce + Format, Automation file meter) + Cloud AI (12 tools, website credit wallet). Provider keys never leave the server.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"imageconvertit-mcp": "src/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./src/index.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"start": "node ./src/index.js",
|
|
22
|
+
"smoke": "node ./scripts/smoke-ops.mjs",
|
|
23
|
+
"audit:cloud-ai": "node ./scripts/audit-cloud-ai.mjs"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@imgly/background-removal-node": "^1.4.5",
|
|
27
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
28
|
+
"@napi-rs/canvas": "^0.1.65",
|
|
29
|
+
"bwip-js": "^4.5.1",
|
|
30
|
+
"heic-convert": "^2.1.0",
|
|
31
|
+
"pdf-lib": "^1.17.1",
|
|
32
|
+
"pdfjs-dist": "^4.10.38",
|
|
33
|
+
"potrace": "^2.1.8",
|
|
34
|
+
"sharp": "^0.34.1",
|
|
35
|
+
"zod": "^3.24.2"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"mcp",
|
|
39
|
+
"imageconvertit",
|
|
40
|
+
"image",
|
|
41
|
+
"sharp",
|
|
42
|
+
"ecommerce",
|
|
43
|
+
"cloud-ai"
|
|
44
|
+
],
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/imageconvertit/imageconvertit"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/authorize.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call ImageConvertIt /api/mcp/authorize before each Core batch.
|
|
3
|
+
* Supports charge (default), status, and refund (failed files after charge).
|
|
4
|
+
* Refunds require charge_id from the matching charge response.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const DEFAULT_BASE = 'https://imageconvertit.com';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {{
|
|
11
|
+
* licenseKey: string,
|
|
12
|
+
* fileCount?: number,
|
|
13
|
+
* apiBase?: string,
|
|
14
|
+
* action?: 'charge'|'status'|'refund',
|
|
15
|
+
* chargeId?: string,
|
|
16
|
+
* }} opts
|
|
17
|
+
* @returns {Promise<{
|
|
18
|
+
* allowed: boolean,
|
|
19
|
+
* error?: string,
|
|
20
|
+
* remaining?: number,
|
|
21
|
+
* limit?: number,
|
|
22
|
+
* plan?: string,
|
|
23
|
+
* used?: number,
|
|
24
|
+
* month?: string,
|
|
25
|
+
* charge_id?: string,
|
|
26
|
+
* }>}
|
|
27
|
+
*/
|
|
28
|
+
export async function authorizeBatch({
|
|
29
|
+
licenseKey,
|
|
30
|
+
fileCount = 1,
|
|
31
|
+
apiBase = DEFAULT_BASE,
|
|
32
|
+
action = 'charge',
|
|
33
|
+
chargeId,
|
|
34
|
+
}) {
|
|
35
|
+
if (!licenseKey || typeof licenseKey !== 'string') {
|
|
36
|
+
return { allowed: false, error: 'ICI_LICENSE_KEY is required (MCP plan).' };
|
|
37
|
+
}
|
|
38
|
+
const base = (apiBase || DEFAULT_BASE).replace(/\/$/, '');
|
|
39
|
+
const act = action === 'status' || action === 'refund' ? action : 'charge';
|
|
40
|
+
if (act === 'refund' && (!chargeId || typeof chargeId !== 'string')) {
|
|
41
|
+
return { allowed: false, error: 'charge_id is required to refund MCP files.' };
|
|
42
|
+
}
|
|
43
|
+
let res;
|
|
44
|
+
try {
|
|
45
|
+
const body = {
|
|
46
|
+
license_key: licenseKey.trim(),
|
|
47
|
+
action: act,
|
|
48
|
+
file_count: Math.min(50, Math.max(1, Number(fileCount) || 1)),
|
|
49
|
+
};
|
|
50
|
+
if (act === 'refund' && chargeId) {
|
|
51
|
+
body.charge_id = String(chargeId).trim();
|
|
52
|
+
}
|
|
53
|
+
res = await fetch(`${base}/api/mcp/authorize`, {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
56
|
+
body: JSON.stringify(body),
|
|
57
|
+
});
|
|
58
|
+
} catch (e) {
|
|
59
|
+
return { allowed: false, error: `Network error: ${e?.message ?? e}` };
|
|
60
|
+
}
|
|
61
|
+
let json = null;
|
|
62
|
+
try {
|
|
63
|
+
json = await res.json();
|
|
64
|
+
} catch {
|
|
65
|
+
return { allowed: false, error: `Authorize failed (${res.status}).` };
|
|
66
|
+
}
|
|
67
|
+
if (!res.ok || !json?.allowed) {
|
|
68
|
+
return {
|
|
69
|
+
allowed: false,
|
|
70
|
+
error: json?.error ?? `Authorize denied (${res.status}).`,
|
|
71
|
+
remaining: json?.remaining,
|
|
72
|
+
limit: json?.limit,
|
|
73
|
+
plan: json?.plan,
|
|
74
|
+
used: json?.used,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
allowed: true,
|
|
79
|
+
remaining: json.remaining,
|
|
80
|
+
limit: json.limit,
|
|
81
|
+
plan: json.plan,
|
|
82
|
+
month: json.month,
|
|
83
|
+
used: json.used,
|
|
84
|
+
charge_id: typeof json.charge_id === 'string' ? json.charge_id : undefined,
|
|
85
|
+
};
|
|
86
|
+
}
|