@tinify-ai/mcp-server 1.3.0 → 1.4.1
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 +37 -8
- package/dist/api/auth.d.ts +1 -1
- package/dist/api/auth.d.ts.map +1 -1
- package/dist/api/auth.js +2 -9
- package/dist/api/auth.js.map +1 -1
- package/dist/api/client.d.ts +6 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +15 -0
- package/dist/api/client.js.map +1 -1
- package/dist/api/process.d.ts +3 -2
- package/dist/api/process.d.ts.map +1 -1
- package/dist/api/process.js.map +1 -1
- package/dist/auth/anonymous.d.ts +10 -0
- package/dist/auth/anonymous.d.ts.map +1 -0
- package/dist/auth/anonymous.js +37 -0
- package/dist/auth/anonymous.js.map +1 -0
- package/dist/auth/context.d.ts +13 -0
- package/dist/auth/context.d.ts.map +1 -0
- package/dist/auth/context.js +10 -0
- package/dist/auth/context.js.map +1 -0
- package/dist/auth/jwt.d.ts +7 -0
- package/dist/auth/jwt.d.ts.map +1 -0
- package/dist/auth/jwt.js +35 -0
- package/dist/auth/jwt.js.map +1 -0
- package/dist/auth/resolver.d.ts +11 -0
- package/dist/auth/resolver.d.ts.map +1 -0
- package/dist/auth/resolver.js +35 -0
- package/dist/auth/resolver.js.map +1 -0
- package/dist/index.js +195 -178
- package/dist/index.js.map +1 -1
- package/dist/tools/login.js +1 -1
- package/dist/tools/login.js.map +1 -1
- package/dist/tools/optimize.d.ts +9 -2
- package/dist/tools/optimize.d.ts.map +1 -1
- package/dist/tools/optimize.js +35 -8
- package/dist/tools/optimize.js.map +1 -1
- package/dist/tools/status.d.ts.map +1 -1
- package/dist/tools/status.js +3 -6
- package/dist/tools/status.js.map +1 -1
- package/dist/transport/http.d.ts +8 -0
- package/dist/transport/http.d.ts.map +1 -0
- package/dist/transport/http.js +151 -0
- package/dist/transport/http.js.map +1 -0
- package/package.json +11 -5
package/dist/index.js
CHANGED
|
@@ -8,184 +8,201 @@ import { logoutTool } from "./tools/logout.js";
|
|
|
8
8
|
import { statusTool } from "./tools/status.js";
|
|
9
9
|
import { upgradeTool } from "./tools/upgrade.js";
|
|
10
10
|
import { formatErrorForMcp } from "./errors.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
11
|
+
function createServer() {
|
|
12
|
+
const server = new McpServer({
|
|
13
|
+
name: "tinify",
|
|
14
|
+
version: "1.3.0",
|
|
15
|
+
});
|
|
16
|
+
server.registerTool("optimize_image", {
|
|
17
|
+
title: "Optimize Image",
|
|
18
|
+
description: "Optimize an image: smart lossy compression (typically 60-80% size reduction), optional resize/upscale/format conversion, and AI-generated SEO metadata. " +
|
|
19
|
+
"Accepts absolute local file paths or remote URLs. In remote/API mode, only remote URLs are supported. Supported input formats: JPG, PNG, WebP, AVIF, GIF, SVG, ICO, HEIC, TIFF, BMP (max 50 MB). Supported output formats: JPG, PNG, WebP, AVIF, GIF, SVG, ICO. " +
|
|
20
|
+
"Each call costs 3 credits + 1 if SEO tags enabled. Animated GIFs are processed frame-by-frame (each frame optimized individually). " +
|
|
21
|
+
"Cost = frames × per-frame operations. Use confirm_gif_cost: true after reviewing the cost warning. " +
|
|
22
|
+
"Free tier: 20 credits/day, no signup. Log in with the login tool for more credits. Use status tool to check remaining credits before batch processing.",
|
|
23
|
+
inputSchema: {
|
|
24
|
+
input: z
|
|
25
|
+
.string()
|
|
26
|
+
.describe("Absolute local file path or remote URL of the image to optimize. Note: in remote/API mode, only remote URLs are supported (no local file paths). Supported inputs: JPG, PNG, WebP, AVIF, GIF (animated supported), HEIC, TIFF, BMP (max 50 MB). Tinify supports high-quality conversion between any input and output format."),
|
|
27
|
+
output_path: z
|
|
28
|
+
.string()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Where to save. Accepts a file path (/tmp/out.webp) or directory ending in / (/tmp/images/). " +
|
|
31
|
+
"If omitted: saves next to original, named with SEO slug when SEO is enabled or .tinified suffix otherwise. URLs save to current working directory."),
|
|
32
|
+
output_format: z
|
|
33
|
+
.enum(["original", "jpg", "png", "webp", "avif", "gif", "svg", "ico"])
|
|
34
|
+
.optional()
|
|
35
|
+
.describe("Output format. Defaults to 'original' (keep input format). Animated GIFs stay animated when output is 'gif'; converting to other formats preserves only the first frame. SVG output from raster input uses vector tracing. ICO output generates a favicon set (16, 24, 32, 48, 256px) unless a specific size is given."),
|
|
36
|
+
output_width_px: z
|
|
37
|
+
.number()
|
|
38
|
+
.int()
|
|
39
|
+
.positive()
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("Target width in pixels. Set only width for proportional resize. Set both width and height for exact output dimensions (see output_resize_behavior)."),
|
|
42
|
+
output_height_px: z
|
|
43
|
+
.number()
|
|
44
|
+
.int()
|
|
45
|
+
.positive()
|
|
46
|
+
.optional()
|
|
47
|
+
.describe("Target height in pixels. Set only height for proportional resize. Set both width and height for exact output dimensions (see output_resize_behavior)."),
|
|
48
|
+
output_upscale_factor: z
|
|
49
|
+
.union([z.literal(2), z.literal(4)])
|
|
50
|
+
.optional()
|
|
51
|
+
.describe("AI upscale factor: 2 (2×) or 4 (4×). Uses Real-ESRGAN for high-quality upscaling."),
|
|
52
|
+
output_resize_behavior: z
|
|
53
|
+
.enum(["pad", "crop"])
|
|
54
|
+
.optional()
|
|
55
|
+
.describe("When both width and height are set and aspect ratio differs: " +
|
|
56
|
+
"'pad' adds white padding (default), 'crop' smart-crops to fill exact dimensions"),
|
|
57
|
+
output_seo_tag_gen: z
|
|
58
|
+
.boolean()
|
|
59
|
+
.optional()
|
|
60
|
+
.describe("Generate SEO metadata (alt text, keywords, filename) and rename output file to SEO slug. Costs 1 extra credit. Default: true."),
|
|
61
|
+
output_file_size_limit: z
|
|
62
|
+
.number()
|
|
63
|
+
.int()
|
|
64
|
+
.positive()
|
|
65
|
+
.optional()
|
|
66
|
+
.describe("Target maximum output file size in bytes. The server will attempt to meet this limit through additional compression. Not guaranteed."),
|
|
67
|
+
confirm_gif_cost: z
|
|
68
|
+
.boolean()
|
|
69
|
+
.optional()
|
|
70
|
+
.describe("Set to true to proceed with animated GIF processing after seeing cost warning. Required for animated GIFs to prevent unexpected credit consumption."),
|
|
71
|
+
gif_frame_limit: z
|
|
72
|
+
.number()
|
|
73
|
+
.int()
|
|
74
|
+
.min(1)
|
|
75
|
+
.max(100)
|
|
76
|
+
.optional()
|
|
77
|
+
.describe("Maximum frames to process for animated GIFs (1-100, default 100). Reduces cost by sampling fewer frames while preserving animation."),
|
|
78
|
+
_gif_temp_file_id: z
|
|
79
|
+
.string()
|
|
80
|
+
.optional()
|
|
81
|
+
.describe("Internal: temp file ID from a previous GIF cost warning. Skips re-upload."),
|
|
82
|
+
},
|
|
83
|
+
outputSchema: {
|
|
84
|
+
output_path: z.string().describe("Absolute path where the optimized file was saved"),
|
|
85
|
+
output_size_bytes: z.number().describe("File size of the optimized image in bytes"),
|
|
86
|
+
output_width_px: z.number().nullable().describe("Width of the output image in pixels"),
|
|
87
|
+
output_height_px: z.number().nullable().describe("Height of the output image in pixels"),
|
|
88
|
+
output_format: z.string().nullable().describe("Output format: jpg, png, webp, avif, or gif"),
|
|
89
|
+
compression_ratio: z.number().nullable().describe("Output-to-input size ratio, e.g. 0.35 means 65% smaller"),
|
|
90
|
+
seo_alt_text: z.string().nullable().describe("AI-generated image alt text for accessibility and SEO"),
|
|
91
|
+
seo_keywords: z.array(z.string()).nullable().describe("AI-generated keywords describing the image"),
|
|
92
|
+
seo_filename: z.string().nullable().describe("AI-generated SEO filename slug without extension"),
|
|
93
|
+
},
|
|
94
|
+
}, async (params) => {
|
|
95
|
+
try {
|
|
96
|
+
const result = await optimizeImage({
|
|
97
|
+
input: params.input,
|
|
98
|
+
output_path: params.output_path,
|
|
99
|
+
output_format: params.output_format,
|
|
100
|
+
output_width_px: params.output_width_px,
|
|
101
|
+
output_height_px: params.output_height_px,
|
|
102
|
+
output_upscale_factor: params.output_upscale_factor,
|
|
103
|
+
output_resize_behavior: params.output_resize_behavior,
|
|
104
|
+
output_seo_tag_gen: params.output_seo_tag_gen,
|
|
105
|
+
output_file_size_limit: params.output_file_size_limit,
|
|
106
|
+
confirm_gif_cost: params.confirm_gif_cost,
|
|
107
|
+
gif_frame_limit: params.gif_frame_limit,
|
|
108
|
+
_gif_temp_file_id: params._gif_temp_file_id,
|
|
109
|
+
});
|
|
110
|
+
// Handle GIF cost warning (not a real result)
|
|
111
|
+
if (result._gif_warning) {
|
|
112
|
+
return { content: [{ type: "text", text: result._gif_warning }] };
|
|
113
|
+
}
|
|
114
|
+
const summary = [
|
|
115
|
+
`Optimized: ${result.output_path}`,
|
|
116
|
+
`Size: ${(result.output_size_bytes / 1024).toFixed(1)} KB`,
|
|
117
|
+
result.compression_ratio !== null
|
|
118
|
+
? `Compression: ${(result.compression_ratio * 100).toFixed(0)}%`
|
|
119
|
+
: null,
|
|
120
|
+
result.output_format ? `Format: ${result.output_format}` : null,
|
|
121
|
+
result.output_width_px && result.output_height_px
|
|
122
|
+
? `Dimensions: ${result.output_width_px}x${result.output_height_px}`
|
|
123
|
+
: null,
|
|
124
|
+
result.seo_alt_text ? `Alt text: ${result.seo_alt_text}` : null,
|
|
125
|
+
]
|
|
126
|
+
.filter(Boolean)
|
|
127
|
+
.join("\n");
|
|
128
|
+
return {
|
|
129
|
+
content: [{ type: "text", text: summary }],
|
|
130
|
+
structuredContent: result,
|
|
131
|
+
};
|
|
107
132
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
catch (error) {
|
|
144
|
-
return formatErrorForMcp(error);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
server.registerTool("logout", {
|
|
148
|
-
title: "Log Out",
|
|
149
|
-
description: "Log out of your Tinify account. Reverts to guest session (20 free credits/day). " +
|
|
150
|
-
"Your web app account is not affected.",
|
|
151
|
-
inputSchema: {},
|
|
152
|
-
}, async () => {
|
|
153
|
-
try {
|
|
154
|
-
const message = await logoutTool();
|
|
155
|
-
return { content: [{ type: "text", text: message }] };
|
|
156
|
-
}
|
|
157
|
-
catch (error) {
|
|
158
|
-
return formatErrorForMcp(error);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
server.registerTool("status", {
|
|
162
|
-
title: "Account Status",
|
|
163
|
-
description: "Check your Tinify account status: login state, tier, credits remaining, and credit reset time. " +
|
|
164
|
-
"Use this before batch processing to verify sufficient credits.",
|
|
165
|
-
inputSchema: {},
|
|
166
|
-
}, async () => {
|
|
167
|
-
try {
|
|
168
|
-
const message = await statusTool();
|
|
169
|
-
return { content: [{ type: "text", text: message }] };
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
return formatErrorForMcp(error);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
server.registerTool("upgrade", {
|
|
176
|
-
title: "Upgrade Plan",
|
|
177
|
-
description: "Open the Tinify pricing page in your browser to upgrade your plan for more credits. " +
|
|
178
|
-
"Plans: Free (50/day), Pro (3,000/month), Max (10,000/month).",
|
|
179
|
-
inputSchema: {},
|
|
180
|
-
}, async () => {
|
|
181
|
-
try {
|
|
182
|
-
const message = await upgradeTool();
|
|
183
|
-
return { content: [{ type: "text", text: message }] };
|
|
184
|
-
}
|
|
185
|
-
catch (error) {
|
|
186
|
-
return formatErrorForMcp(error);
|
|
133
|
+
catch (error) {
|
|
134
|
+
return formatErrorForMcp(error);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
if (process.env.MCP_TRANSPORT !== "http") {
|
|
138
|
+
server.registerTool("login", {
|
|
139
|
+
title: "Log In",
|
|
140
|
+
description: "Log in to your Tinify account via browser to unlock more credits. " +
|
|
141
|
+
"Opens a browser window where you complete login (Google, Facebook, or email). " +
|
|
142
|
+
"After login, MCP automatically picks up your account with shared credits across web and MCP. " +
|
|
143
|
+
"Free: 50 credits/day. Pro: 3,000/month. Max: 10,000/month.",
|
|
144
|
+
inputSchema: {},
|
|
145
|
+
}, async () => {
|
|
146
|
+
try {
|
|
147
|
+
const message = await loginTool();
|
|
148
|
+
return { content: [{ type: "text", text: message }] };
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
return formatErrorForMcp(error);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
server.registerTool("logout", {
|
|
155
|
+
title: "Log Out",
|
|
156
|
+
description: "Log out of your Tinify account. Reverts to guest session (20 free credits/day). " +
|
|
157
|
+
"Your web app account is not affected.",
|
|
158
|
+
inputSchema: {},
|
|
159
|
+
}, async () => {
|
|
160
|
+
try {
|
|
161
|
+
const message = await logoutTool();
|
|
162
|
+
return { content: [{ type: "text", text: message }] };
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
return formatErrorForMcp(error);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
187
168
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
169
|
+
server.registerTool("status", {
|
|
170
|
+
title: "Account Status",
|
|
171
|
+
description: "Check your Tinify account status: login state, tier, credits remaining, and credit reset time. " +
|
|
172
|
+
"Use this before batch processing to verify sufficient credits.",
|
|
173
|
+
inputSchema: {},
|
|
174
|
+
}, async () => {
|
|
175
|
+
try {
|
|
176
|
+
const message = await statusTool();
|
|
177
|
+
return { content: [{ type: "text", text: message }] };
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
return formatErrorForMcp(error);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
server.registerTool("upgrade", {
|
|
184
|
+
title: "Upgrade Plan",
|
|
185
|
+
description: "Open the Tinify pricing page in your browser to upgrade your plan for more credits. " +
|
|
186
|
+
"Plans: Free (50/day), Pro (3,000/month), Max (10,000/month).",
|
|
187
|
+
inputSchema: {},
|
|
188
|
+
}, async () => {
|
|
189
|
+
try {
|
|
190
|
+
const message = await upgradeTool();
|
|
191
|
+
return { content: [{ type: "text", text: message }] };
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
return formatErrorForMcp(error);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
return server;
|
|
198
|
+
}
|
|
199
|
+
if (process.env.MCP_TRANSPORT === "http") {
|
|
200
|
+
const { startHttpServer } = await import("./transport/http.js");
|
|
201
|
+
await startHttpServer(createServer);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
const server = createServer();
|
|
205
|
+
const transport = new StdioServerTransport();
|
|
206
|
+
await server.connect(transport);
|
|
207
|
+
}
|
|
191
208
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"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/dist/tools/login.js
CHANGED
|
@@ -10,7 +10,7 @@ export async function loginTool() {
|
|
|
10
10
|
// If already logged in, return current status
|
|
11
11
|
const existingToken = sessionManager.getMcpToken();
|
|
12
12
|
if (existingToken) {
|
|
13
|
-
const status = await getAccountStatus(baseUrl, existingToken
|
|
13
|
+
const status = await getAccountStatus(baseUrl, { Authorization: `Bearer ${existingToken}` });
|
|
14
14
|
if (status.logged_in) {
|
|
15
15
|
return `Already logged in as ${status.email} (${status.tier} tier, ${status.credits_remaining.toLocaleString()} credits remaining).`;
|
|
16
16
|
}
|
package/dist/tools/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/tools/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEtC,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,gBAAgB,CAAC;IAE/D,8CAA8C;IAC9C,MAAM,aAAa,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;IACnD,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/tools/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,c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A6C,CAAC;AACvD,CAAC;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,eAAe,CAAC,SAAiB;IACxC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;IACjC,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;QAClC,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,IAAI;QACZ,YAAY,EAAE,OAAO;QACrB,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,SAAS;KAChB,CAAC,CAAC;AACL,CAAC"}
|
package/dist/tools/optimize.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import { resolveInput as resolveInputUtil } from "../utils/input.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the input path/URL, with a guard for HTTP mode (remote URLs only).
|
|
4
|
+
* Exported for testing.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveInput(input: string): ReturnType<typeof resolveInputUtil>;
|
|
1
7
|
export interface OptimizeImageParams {
|
|
2
8
|
input: string;
|
|
3
9
|
output_path?: string;
|
|
4
|
-
output_format?: "original" | "jpg" | "png" | "webp" | "avif" | "gif";
|
|
10
|
+
output_format?: "original" | "jpg" | "png" | "webp" | "avif" | "gif" | "svg" | "ico";
|
|
5
11
|
output_width_px?: number;
|
|
6
12
|
output_height_px?: number;
|
|
7
|
-
output_upscale_factor?:
|
|
13
|
+
output_upscale_factor?: 2 | 4;
|
|
8
14
|
output_resize_behavior?: "pad" | "crop";
|
|
9
15
|
output_seo_tag_gen?: boolean;
|
|
16
|
+
output_file_size_limit?: number;
|
|
10
17
|
confirm_gif_cost?: boolean;
|
|
11
18
|
gif_frame_limit?: number;
|
|
12
19
|
_gif_temp_file_id?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimize.d.ts","sourceRoot":"","sources":["../../src/tools/optimize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"optimize.d.ts","sourceRoot":"","sources":["../../src/tools/optimize.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErE;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAK/E;AAKD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;IACrF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qBAAqB,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAC9B,sBAAsB,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACxC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC9B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CAsK9B"}
|
package/dist/tools/optimize.js
CHANGED
|
@@ -4,17 +4,26 @@ import { uploadFile } from "../api/upload.js";
|
|
|
4
4
|
import { triggerProcessing } from "../api/process.js";
|
|
5
5
|
import { waitForCompletion } from "../api/status.js";
|
|
6
6
|
import { downloadFile } from "../api/download.js";
|
|
7
|
-
import { resolveInput } from "../utils/input.js";
|
|
7
|
+
import { resolveInput as resolveInputUtil } from "../utils/input.js";
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the input path/URL, with a guard for HTTP mode (remote URLs only).
|
|
10
|
+
* Exported for testing.
|
|
11
|
+
*/
|
|
12
|
+
export function resolveInput(input) {
|
|
13
|
+
if (process.env.MCP_TRANSPORT === "http" && !input.startsWith("http://") && !input.startsWith("https://")) {
|
|
14
|
+
throw new Error("Local file paths are not supported in remote mode. Please provide a URL (https://...).");
|
|
15
|
+
}
|
|
16
|
+
return resolveInputUtil(input);
|
|
17
|
+
}
|
|
8
18
|
import { resolveUniqueOutputPath } from "../utils/output.js";
|
|
19
|
+
import { DEFAULT_BASE_URL, getAuthHeaders } from "../api/client.js";
|
|
9
20
|
import { SessionManager } from "../session/manager.js";
|
|
10
|
-
import { DEFAULT_BASE_URL } from "../api/client.js";
|
|
11
21
|
export async function optimizeImage(params) {
|
|
12
22
|
const baseUrl = params.baseUrl ?? DEFAULT_BASE_URL;
|
|
13
|
-
const sessionManager = new SessionManager();
|
|
14
23
|
// 1. Resolve input (read file or fetch URL)
|
|
15
24
|
const input = await resolveInput(params.input);
|
|
16
25
|
// 2. Upload to backend (skip if reusing from GIF cost warning)
|
|
17
|
-
const authHeaders =
|
|
26
|
+
const authHeaders = getAuthHeaders();
|
|
18
27
|
let uploadResult;
|
|
19
28
|
if (params._gif_temp_file_id && params.confirm_gif_cost) {
|
|
20
29
|
// Reuse the upload from a previous GIF cost warning — no re-upload needed
|
|
@@ -33,9 +42,9 @@ export async function optimizeImage(params) {
|
|
|
33
42
|
filename: input.filename,
|
|
34
43
|
authHeaders,
|
|
35
44
|
});
|
|
36
|
-
// Persist new session token if returned (for guest sessions)
|
|
37
|
-
if (uploadResult.session_token) {
|
|
38
|
-
|
|
45
|
+
// Persist new session token if returned (for guest sessions, stdio mode only)
|
|
46
|
+
if (uploadResult.session_token && process.env.MCP_TRANSPORT !== "http") {
|
|
47
|
+
new SessionManager().saveToken(uploadResult.session_token);
|
|
39
48
|
}
|
|
40
49
|
}
|
|
41
50
|
// Check if animated GIF needs cost confirmation
|
|
@@ -94,6 +103,9 @@ export async function optimizeImage(params) {
|
|
|
94
103
|
if (params.output_width_px !== undefined || params.output_height_px !== undefined) {
|
|
95
104
|
settings.output_resize_behavior = params.output_resize_behavior ?? "pad";
|
|
96
105
|
}
|
|
106
|
+
if (params.output_file_size_limit !== undefined) {
|
|
107
|
+
settings.output_file_size_limit = params.output_file_size_limit;
|
|
108
|
+
}
|
|
97
109
|
if (params.gif_frame_limit !== undefined) {
|
|
98
110
|
settings.gif_frame_limit = params.gif_frame_limit;
|
|
99
111
|
}
|
|
@@ -114,7 +126,22 @@ export async function optimizeImage(params) {
|
|
|
114
126
|
jobId: job.id,
|
|
115
127
|
timeoutMs: params.timeoutMs ?? 60000,
|
|
116
128
|
});
|
|
117
|
-
// 6.
|
|
129
|
+
// 6. In HTTP mode: return download URL (no local disk write)
|
|
130
|
+
if (process.env.MCP_TRANSPORT === "http") {
|
|
131
|
+
const downloadUrl = `${baseUrl}/download/${job.id}`;
|
|
132
|
+
return {
|
|
133
|
+
output_path: downloadUrl,
|
|
134
|
+
output_size_bytes: completedJob.processed_size ?? 0,
|
|
135
|
+
output_width_px: completedJob.processed_width ?? null,
|
|
136
|
+
output_height_px: completedJob.processed_height ?? null,
|
|
137
|
+
output_format: completedJob.processed_format ?? null,
|
|
138
|
+
compression_ratio: completedJob.processed_compression_ratio ?? null,
|
|
139
|
+
seo_alt_text: completedJob.seo_alt_text ?? null,
|
|
140
|
+
seo_keywords: completedJob.seo_keywords ?? null,
|
|
141
|
+
seo_filename: completedJob.seo_filename ?? null,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// stdio mode: download to local disk (existing code)
|
|
118
145
|
const downloadResult = await downloadFile({ baseUrl, jobId: job.id });
|
|
119
146
|
// 7. Resolve output path and save
|
|
120
147
|
const outputPath = resolveUniqueOutputPath({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimize.js","sourceRoot":"","sources":["../../src/tools/optimize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAA2B,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"optimize.js","sourceRoot":"","sources":["../../src/tools/optimize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAA2B,MAAM,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,YAAY,CAAC,gBAAgB,IAAI,IAAI;QACpD,iBAAiB,EAAE,YAAY,CAAC,2BAA2B,IAAI,IAAI;QACnE,YAAY,EAAE,YAAY,CAAC,YAAY,IAAI,IAAI;QAC/C,YAAY,EAAE,YAAY,CAAC,YAAY,IAAI,IAAI;QAC/C,YAAY,EAAE,YAAY,CAAC,YAAY,IAAI,IAAI;KAChD,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/tools/status.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/tools/status.ts"],"names":[],"mappings":"AAIA,wBAAsB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CA2BlD"}
|
package/dist/tools/status.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DEFAULT_BASE_URL } from "../api/client.js";
|
|
1
|
+
import { DEFAULT_BASE_URL, getAuthHeaders } from "../api/client.js";
|
|
3
2
|
import { getAccountStatus } from "../api/auth.js";
|
|
4
3
|
import { isX402Configured, getWalletAddress } from "../x402/client.js";
|
|
5
4
|
export async function statusTool() {
|
|
6
|
-
const sessionManager = new SessionManager();
|
|
7
5
|
const baseUrl = process.env.TINIFY_API_URL ?? DEFAULT_BASE_URL;
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const status = await getAccountStatus(baseUrl, mcpToken, sessionToken);
|
|
6
|
+
const authHeaders = getAuthHeaders();
|
|
7
|
+
const status = await getAccountStatus(baseUrl, authHeaders);
|
|
11
8
|
const x402Status = isX402Configured()
|
|
12
9
|
? `Pay As You Go: Enabled (wallet: ${await getWalletAddress()})`
|
|
13
10
|
: "Pay As You Go: Not configured (set TINIFY_X402_PRIVATE_KEY)";
|