@imageconvertit/mcp-server 0.3.1 → 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 +7 -3
- package/package.json +1 -1
- package/src/authorize.js +17 -5
- package/src/lib/batch.js +4 -3
package/README.md
CHANGED
|
@@ -85,11 +85,13 @@ Also: `mcp_status`, legacy `batch_resize_compress` / `batch_amazon_prep`.
|
|
|
85
85
|
| Codex / ChatGPT desktop | `~/.codex/config.toml` | `[mcp_servers.imageconvertit]` |
|
|
86
86
|
| Gemini CLI | `~/.gemini/settings.json` | `mcpServers` JSON |
|
|
87
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
|
+
|
|
88
90
|
```json
|
|
89
91
|
{
|
|
90
92
|
"mcpServers": {
|
|
91
93
|
"imageconvertit": {
|
|
92
|
-
"command": "npx",
|
|
94
|
+
"command": "npx.cmd",
|
|
93
95
|
"args": ["-y", "@imageconvertit/mcp-server"],
|
|
94
96
|
"env": {
|
|
95
97
|
"ICI_LICENSE_KEY": "YOUR_LEMONSQUEEZY_LICENSE_KEY",
|
|
@@ -100,13 +102,15 @@ Also: `mcp_status`, legacy `batch_resize_compress` / `batch_amazon_prep`.
|
|
|
100
102
|
}
|
|
101
103
|
```
|
|
102
104
|
|
|
105
|
+
On macOS / Linux, change `"command"` to `"npx"`. Prefer **Account → MCP** on imageconvertit.com — it emits the OS-correct snippet.
|
|
106
|
+
|
|
103
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.
|
|
104
108
|
|
|
105
|
-
Codex / ChatGPT desktop TOML:
|
|
109
|
+
Codex / ChatGPT desktop TOML (Windows shown; use `npx` on macOS / Linux):
|
|
106
110
|
|
|
107
111
|
```toml
|
|
108
112
|
[mcp_servers.imageconvertit]
|
|
109
|
-
command = "npx"
|
|
113
|
+
command = "npx.cmd"
|
|
110
114
|
args = ["-y", "@imageconvertit/mcp-server"]
|
|
111
115
|
|
|
112
116
|
[mcp_servers.imageconvertit.env]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imageconvertit/mcp-server",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
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
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/authorize.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Call ImageConvertIt /api/mcp/authorize before each Core batch.
|
|
3
3
|
* Supports charge (default), status, and refund (failed files after charge).
|
|
4
|
+
* Refunds require charge_id from the matching charge response.
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
const DEFAULT_BASE = 'https://imageconvertit.com';
|
|
@@ -11,6 +12,7 @@ const DEFAULT_BASE = 'https://imageconvertit.com';
|
|
|
11
12
|
* fileCount?: number,
|
|
12
13
|
* apiBase?: string,
|
|
13
14
|
* action?: 'charge'|'status'|'refund',
|
|
15
|
+
* chargeId?: string,
|
|
14
16
|
* }} opts
|
|
15
17
|
* @returns {Promise<{
|
|
16
18
|
* allowed: boolean,
|
|
@@ -20,6 +22,7 @@ const DEFAULT_BASE = 'https://imageconvertit.com';
|
|
|
20
22
|
* plan?: string,
|
|
21
23
|
* used?: number,
|
|
22
24
|
* month?: string,
|
|
25
|
+
* charge_id?: string,
|
|
23
26
|
* }>}
|
|
24
27
|
*/
|
|
25
28
|
export async function authorizeBatch({
|
|
@@ -27,22 +30,30 @@ export async function authorizeBatch({
|
|
|
27
30
|
fileCount = 1,
|
|
28
31
|
apiBase = DEFAULT_BASE,
|
|
29
32
|
action = 'charge',
|
|
33
|
+
chargeId,
|
|
30
34
|
}) {
|
|
31
35
|
if (!licenseKey || typeof licenseKey !== 'string') {
|
|
32
36
|
return { allowed: false, error: 'ICI_LICENSE_KEY is required (MCP plan).' };
|
|
33
37
|
}
|
|
34
38
|
const base = (apiBase || DEFAULT_BASE).replace(/\/$/, '');
|
|
35
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
|
+
}
|
|
36
43
|
let res;
|
|
37
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
|
+
}
|
|
38
53
|
res = await fetch(`${base}/api/mcp/authorize`, {
|
|
39
54
|
method: 'POST',
|
|
40
55
|
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
41
|
-
body: JSON.stringify(
|
|
42
|
-
license_key: licenseKey.trim(),
|
|
43
|
-
action: act,
|
|
44
|
-
file_count: Math.min(50, Math.max(1, Number(fileCount) || 1)),
|
|
45
|
-
}),
|
|
56
|
+
body: JSON.stringify(body),
|
|
46
57
|
});
|
|
47
58
|
} catch (e) {
|
|
48
59
|
return { allowed: false, error: `Network error: ${e?.message ?? e}` };
|
|
@@ -70,5 +81,6 @@ export async function authorizeBatch({
|
|
|
70
81
|
plan: json.plan,
|
|
71
82
|
month: json.month,
|
|
72
83
|
used: json.used,
|
|
84
|
+
charge_id: typeof json.charge_id === 'string' ? json.charge_id : undefined,
|
|
73
85
|
};
|
|
74
86
|
}
|
package/src/lib/batch.js
CHANGED
|
@@ -70,7 +70,7 @@ export async function runFolderBatch(env, opts) {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
let auth = { allowed: true, remaining: null, limit: null, plan: null };
|
|
73
|
+
let auth = { allowed: true, remaining: null, limit: null, plan: null, charge_id: null };
|
|
74
74
|
if (!opts.skipAuthorize) {
|
|
75
75
|
auth = await authorizeBatch({
|
|
76
76
|
licenseKey: env.ICI_LICENSE_KEY,
|
|
@@ -102,15 +102,16 @@ export async function runFolderBatch(env, opts) {
|
|
|
102
102
|
const ok = results.filter((r) => r && r.out);
|
|
103
103
|
const failed = results.filter((r) => r && r.error);
|
|
104
104
|
|
|
105
|
-
// Refund meter for files that failed after charge-first authorize
|
|
105
|
+
// Refund meter for files that failed after charge-first authorize (requires charge_id)
|
|
106
106
|
let remaining = auth.remaining;
|
|
107
|
-
if (!opts.skipAuthorize && failed.length > 0) {
|
|
107
|
+
if (!opts.skipAuthorize && failed.length > 0 && auth.charge_id) {
|
|
108
108
|
try {
|
|
109
109
|
const refund = await authorizeBatch({
|
|
110
110
|
licenseKey: env.ICI_LICENSE_KEY,
|
|
111
111
|
fileCount: failed.length,
|
|
112
112
|
apiBase: env.ICI_API_BASE,
|
|
113
113
|
action: 'refund',
|
|
114
|
+
chargeId: auth.charge_id,
|
|
114
115
|
});
|
|
115
116
|
if (refund.allowed && typeof refund.remaining === 'number') {
|
|
116
117
|
remaining = refund.remaining;
|