@tinify-ai/mcp-server 1.0.3 → 1.0.5
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 +111 -36
- package/dist/api/process.d.ts +1 -1
- package/dist/api/process.d.ts.map +1 -1
- package/dist/index.js +21 -23
- package/dist/index.js.map +1 -1
- package/dist/tools/optimize.d.ts +1 -2
- package/dist/tools/optimize.d.ts.map +1 -1
- package/dist/tools/optimize.js +10 -4
- package/dist/tools/optimize.js.map +1 -1
- package/dist/utils/output.d.ts +1 -0
- package/dist/utils/output.d.ts.map +1 -1
- package/dist/utils/output.js +7 -4
- package/dist/utils/output.js.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://modelcontextprotocol.io)
|
|
6
6
|
|
|
7
|
-
MCP server for [
|
|
7
|
+
MCP server for [tinify.ai](https://tinify.ai) image optimization. AI-powered upscaling, resizing/cropping, compression, and SEO tag generation — all in one tool.
|
|
8
8
|
|
|
9
9
|
## Quick Start
|
|
10
10
|
|
|
@@ -15,7 +15,7 @@ Add to your MCP client config:
|
|
|
15
15
|
"mcpServers": {
|
|
16
16
|
"tinify": {
|
|
17
17
|
"command": "npx",
|
|
18
|
-
"args": ["-y", "@tinify-ai/mcp-server"]
|
|
18
|
+
"args": ["-y", "@tinify-ai/mcp-server@latest"]
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -35,7 +35,7 @@ Edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) o
|
|
|
35
35
|
"mcpServers": {
|
|
36
36
|
"tinify": {
|
|
37
37
|
"command": "npx",
|
|
38
|
-
"args": ["-y", "@tinify-ai/mcp-server"]
|
|
38
|
+
"args": ["-y", "@tinify-ai/mcp-server@latest"]
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -46,7 +46,7 @@ Edit `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) o
|
|
|
46
46
|
<summary><strong>Claude Code</strong></summary>
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
claude mcp add tinify -- npx -y @tinify-ai/mcp-server
|
|
49
|
+
claude mcp add tinify -- npx -y @tinify-ai/mcp-server@latest
|
|
50
50
|
```
|
|
51
51
|
</details>
|
|
52
52
|
|
|
@@ -60,7 +60,7 @@ Add to `.cursor/mcp.json` in your project root:
|
|
|
60
60
|
"mcpServers": {
|
|
61
61
|
"tinify": {
|
|
62
62
|
"command": "npx",
|
|
63
|
-
"args": ["-y", "@tinify-ai/mcp-server"]
|
|
63
|
+
"args": ["-y", "@tinify-ai/mcp-server@latest"]
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -77,7 +77,7 @@ Edit `~/.codeium/windsurf/mcp_config.json`:
|
|
|
77
77
|
"mcpServers": {
|
|
78
78
|
"tinify": {
|
|
79
79
|
"command": "npx",
|
|
80
|
-
"args": ["-y", "@tinify-ai/mcp-server"]
|
|
80
|
+
"args": ["-y", "@tinify-ai/mcp-server@latest"]
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -86,48 +86,86 @@ Edit `~/.codeium/windsurf/mcp_config.json`:
|
|
|
86
86
|
|
|
87
87
|
## Tool: `optimize_image`
|
|
88
88
|
|
|
89
|
-
Optimizes an image with smart
|
|
89
|
+
Optimizes an image with smart lossy compression (typically 60-80% size reduction), optional resize/upscale/format conversion, and AI-generated SEO metadata. Accepts absolute local file paths or remote URLs.
|
|
90
90
|
|
|
91
91
|
### Parameters
|
|
92
92
|
|
|
93
93
|
| Parameter | Type | Required | Default | Description |
|
|
94
94
|
|-----------|------|----------|---------|-------------|
|
|
95
|
-
| `input` | string | Yes | — |
|
|
96
|
-
| `output_path` | string | No | auto |
|
|
97
|
-
| `output_format` | string | No | original | jpeg
|
|
95
|
+
| `input` | string | Yes | — | Absolute local file path or remote URL |
|
|
96
|
+
| `output_path` | string | No | auto | File path or directory (ending in `/`). If omitted: saves next to original with SEO slug or `.tinified` suffix |
|
|
97
|
+
| `output_format` | string | No | original | `jpeg`, `png`, `webp`, or `original` |
|
|
98
98
|
| `output_width_px` | int | No | — | Target width in pixels |
|
|
99
99
|
| `output_height_px` | int | No | — | Target height in pixels |
|
|
100
|
-
| `output_upscale_factor` | float | No | — |
|
|
101
|
-
| `output_resize_mode` | string | No | pad | pad or crop |
|
|
102
|
-
| `
|
|
103
|
-
|
|
100
|
+
| `output_upscale_factor` | float | No | — | AI upscale factor (e.g. 2.0, 4.0) |
|
|
101
|
+
| `output_resize_mode` | string | No | pad | `pad` (white padding) or `crop` (smart crop). Only used when both width and height are set |
|
|
102
|
+
| `output_seo_tag_gen` | bool | No | true | Generate SEO metadata and rename file to SEO slug. Costs 1 extra credit |
|
|
103
|
+
|
|
104
|
+
### Resize Behavior
|
|
105
|
+
|
|
106
|
+
| Dimensions provided | Behavior | `output_resize_mode` |
|
|
107
|
+
|---|---|---|
|
|
108
|
+
| Width only | Proportional scale | N/A |
|
|
109
|
+
| Height only | Proportional scale | N/A |
|
|
110
|
+
| Width + Height | Exact dimensions, white padding | `pad` (default) |
|
|
111
|
+
| Width + Height | Exact dimensions, smart crop | `crop` |
|
|
104
112
|
|
|
105
113
|
### Examples
|
|
106
114
|
|
|
107
|
-
**Basic
|
|
108
|
-
|
|
115
|
+
**Basic compression** — just compress, keep format and dimensions:
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{ "input": "/Users/me/photos/hero.png" }
|
|
119
|
+
```
|
|
109
120
|
|
|
110
121
|
**Convert to WebP:**
|
|
111
|
-
> "Optimize hero.png as webp"
|
|
112
122
|
|
|
113
|
-
|
|
114
|
-
|
|
123
|
+
```json
|
|
124
|
+
{ "input": "/Users/me/hero.png", "output_format": "webp" }
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Resize proportionally** — set one dimension, the other scales:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{ "input": "/Users/me/hero.png", "output_width_px": 1200 }
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Exact dimensions with padding** — white bars fill the gap:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{ "input": "/Users/me/hero.png", "output_width_px": 1080, "output_height_px": 1080 }
|
|
137
|
+
```
|
|
115
138
|
|
|
116
|
-
**
|
|
117
|
-
> "Upscale logo.png by 4x"
|
|
139
|
+
**Exact dimensions with smart crop:**
|
|
118
140
|
|
|
119
|
-
|
|
120
|
-
|
|
141
|
+
```json
|
|
142
|
+
{ "input": "/Users/me/hero.png", "output_width_px": 1080, "output_height_px": 1080, "output_resize_mode": "crop" }
|
|
143
|
+
```
|
|
121
144
|
|
|
122
|
-
**
|
|
123
|
-
> "Optimize https://example.com/photo.jpg"
|
|
145
|
+
**AI upscale 4x:**
|
|
124
146
|
|
|
125
|
-
|
|
147
|
+
```json
|
|
148
|
+
{ "input": "/Users/me/icon.png", "output_upscale_factor": 4 }
|
|
149
|
+
```
|
|
126
150
|
|
|
127
|
-
|
|
151
|
+
**From URL, save to directory:**
|
|
128
152
|
|
|
153
|
+
```json
|
|
154
|
+
{ "input": "https://example.com/photo.jpg", "output_path": "/Users/me/assets/" }
|
|
129
155
|
```
|
|
130
|
-
|
|
156
|
+
|
|
157
|
+
**Skip SEO to save 1 credit:**
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{ "input": "/Users/me/hero.png", "output_seo_tag_gen": false }
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Output
|
|
164
|
+
|
|
165
|
+
Returns a text summary and structured metadata:
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
Optimized: /Users/me/photos/modern-office-workspace.webp
|
|
131
169
|
Size: 142.3 KB
|
|
132
170
|
Compression: 73%
|
|
133
171
|
Format: webp
|
|
@@ -135,15 +173,35 @@ Dimensions: 1920x1080
|
|
|
135
173
|
Alt text: Modern office workspace with laptop and coffee cup on wooden desk
|
|
136
174
|
```
|
|
137
175
|
|
|
138
|
-
Structured
|
|
176
|
+
**Structured output fields:**
|
|
177
|
+
|
|
178
|
+
```json
|
|
179
|
+
{
|
|
180
|
+
"output_path": "/Users/me/photos/modern-office-workspace.webp",
|
|
181
|
+
"output_size_bytes": 145715,
|
|
182
|
+
"output_width_px": 1920,
|
|
183
|
+
"output_height_px": 1080,
|
|
184
|
+
"output_format": "webp",
|
|
185
|
+
"compression_ratio": 0.27,
|
|
186
|
+
"seo_alt_text": "Modern office workspace with laptop and coffee cup on wooden desk",
|
|
187
|
+
"seo_keywords": ["office", "workspace", "laptop", "desk", "modern"],
|
|
188
|
+
"seo_filename": "modern-office-workspace"
|
|
189
|
+
}
|
|
190
|
+
```
|
|
139
191
|
|
|
140
192
|
## Supported Formats
|
|
141
193
|
|
|
142
194
|
| Format | Input | Output |
|
|
143
195
|
|--------|-------|--------|
|
|
144
|
-
|
|
|
196
|
+
| JPG | Yes | Yes |
|
|
145
197
|
| PNG | Yes | Yes |
|
|
146
198
|
| WebP | Yes | Yes |
|
|
199
|
+
| AVIF | Yes | Yes |
|
|
200
|
+
| HEIC/HEIF | Yes* | No |
|
|
201
|
+
| TIFF | Yes* | No |
|
|
202
|
+
| BMP | Yes* | No |
|
|
203
|
+
|
|
204
|
+
*Automatically converted to JPG at upload time.
|
|
147
205
|
|
|
148
206
|
Max file size: 50 MB.
|
|
149
207
|
|
|
@@ -152,11 +210,11 @@ Max file size: 50 MB.
|
|
|
152
210
|
```
|
|
153
211
|
Local file or URL
|
|
154
212
|
→ Upload to Tinify API
|
|
155
|
-
→ Smart compression (
|
|
213
|
+
→ Smart compression (lossy, typically 60-80% reduction)
|
|
156
214
|
→ AI SEO tag generation (alt text, keywords, filename)
|
|
157
215
|
→ Optional: resize, upscale, format conversion
|
|
158
216
|
→ Download optimized file
|
|
159
|
-
→ Save
|
|
217
|
+
→ Save with SEO filename slug (or .tinified suffix if SEO disabled)
|
|
160
218
|
```
|
|
161
219
|
|
|
162
220
|
All processing happens server-side via the [Tinify API](https://tinify.ai). The MCP server is a thin client that orchestrates the pipeline.
|
|
@@ -166,24 +224,41 @@ All processing happens server-side via the [Tinify API](https://tinify.ai). The
|
|
|
166
224
|
| | Free Tier |
|
|
167
225
|
|---|-----------|
|
|
168
226
|
| Credits/day | 20 |
|
|
169
|
-
| Images/day | 5 (with default settings) |
|
|
170
|
-
| Cost per image |
|
|
227
|
+
| Images/day | ~5 (with default settings) |
|
|
228
|
+
| Cost per image | 3 credits + 1 if SEO tags enabled (default) |
|
|
171
229
|
| Signup required | No |
|
|
172
230
|
|
|
173
231
|
Session tokens are stored locally at `~/.tinify/session.json` and persist across invocations.
|
|
174
232
|
|
|
175
233
|
Need more credits? See plans at [tinify.ai](https://tinify.ai/#pricing).
|
|
176
234
|
|
|
235
|
+
## Tips for AI Agents
|
|
236
|
+
|
|
237
|
+
Paste this into your `CLAUDE.md` or system prompt to help agents use the tool effectively:
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
## Tinify MCP — optimize_image
|
|
241
|
+
|
|
242
|
+
- Each call costs 3 credits + 1 if SEO enabled (default). Free tier: 20 credits/day.
|
|
243
|
+
- Always use absolute file paths, not relative.
|
|
244
|
+
- Set only width OR height for proportional resize. Set both for exact dimensions.
|
|
245
|
+
- When both dimensions are set, use output_resize_mode: "crop" for photos, "pad" for logos/icons.
|
|
246
|
+
- output_seo_tag_gen (default true) renames the file to an SEO slug and generates alt text + keywords.
|
|
247
|
+
- Set output_seo_tag_gen: false to save 1 credit when SEO metadata is not needed.
|
|
248
|
+
- HEIC, TIFF, BMP inputs are auto-converted to JPG.
|
|
249
|
+
- For batch processing, call optimize_image once per file.
|
|
250
|
+
```
|
|
251
|
+
|
|
177
252
|
## Troubleshooting
|
|
178
253
|
|
|
179
254
|
**Server not appearing in tool list:**
|
|
180
255
|
- Restart your MCP client after editing the config
|
|
181
256
|
- Ensure Node.js >= 18 is installed: `node --version`
|
|
182
|
-
- Try running directly: `npx -y @tinify-ai/mcp-server` (should start without errors)
|
|
257
|
+
- Try running directly: `npx -y @tinify-ai/mcp-server@latest` (should start without errors)
|
|
183
258
|
|
|
184
259
|
**"Insufficient credits" error:**
|
|
185
260
|
- Free tier allows 20 credits/day (resets daily)
|
|
186
|
-
- Each image costs 4 credits
|
|
261
|
+
- Each image costs 3-4 credits depending on settings
|
|
187
262
|
- Disable SEO tags (`output_seo_tag_gen: false`) to reduce to 3 credits/image
|
|
188
263
|
|
|
189
264
|
**File not found:**
|
package/dist/api/process.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/api/process.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,aAAa,CAAC,EAAE,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/api/process.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,aAAa,CAAC,EAAE,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IAC7D,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kBAAkB,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACpC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,UAAU,aAAa;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,UAAU,OAAO;IACf,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAiCrF"}
|
package/dist/index.js
CHANGED
|
@@ -10,17 +10,18 @@ const server = new McpServer({
|
|
|
10
10
|
});
|
|
11
11
|
server.registerTool("optimize_image", {
|
|
12
12
|
title: "Optimize Image",
|
|
13
|
-
description: "Optimize an image
|
|
14
|
-
"Accepts local file paths or remote URLs.
|
|
13
|
+
description: "Optimize an image: smart lossy compression (typically 60-80% size reduction), optional resize/upscale/format conversion, and AI-generated SEO metadata. " +
|
|
14
|
+
"Accepts absolute local file paths or remote URLs. Supported formats: JPG, PNG, WebP, AVIF, HEIC, TIFF, BMP (max 50 MB). " +
|
|
15
|
+
"Each call costs 3 credits + 1 if SEO tags enabled. Free tier: 20 credits/day, no signup.",
|
|
15
16
|
inputSchema: {
|
|
16
17
|
input: z
|
|
17
18
|
.string()
|
|
18
|
-
.describe("
|
|
19
|
+
.describe("Absolute local file path or remote URL of the image to optimize. Supported: JPG, PNG, WebP, AVIF, HEIC, TIFF, BMP (max 50 MB)."),
|
|
19
20
|
output_path: z
|
|
20
21
|
.string()
|
|
21
22
|
.optional()
|
|
22
|
-
.describe("Where to save
|
|
23
|
-
"with
|
|
23
|
+
.describe("Where to save. Accepts a file path (/tmp/out.webp) or directory ending in / (/tmp/images/). " +
|
|
24
|
+
"If omitted: saves next to original, named with SEO slug when SEO is enabled or .tinified suffix otherwise. URLs save to current working directory."),
|
|
24
25
|
output_format: z
|
|
25
26
|
.enum(["original", "jpeg", "png", "webp"])
|
|
26
27
|
.optional()
|
|
@@ -30,13 +31,13 @@ server.registerTool("optimize_image", {
|
|
|
30
31
|
.int()
|
|
31
32
|
.positive()
|
|
32
33
|
.optional()
|
|
33
|
-
.describe("Target width in pixels.
|
|
34
|
+
.describe("Target width in pixels. Set only width for proportional resize. Set both width and height for exact output dimensions (see output_resize_mode)."),
|
|
34
35
|
output_height_px: z
|
|
35
36
|
.number()
|
|
36
37
|
.int()
|
|
37
38
|
.positive()
|
|
38
39
|
.optional()
|
|
39
|
-
.describe("Target height in pixels.
|
|
40
|
+
.describe("Target height in pixels. Set only height for proportional resize. Set both width and height for exact output dimensions (see output_resize_mode)."),
|
|
40
41
|
output_upscale_factor: z
|
|
41
42
|
.number()
|
|
42
43
|
.min(0.1)
|
|
@@ -46,26 +47,24 @@ server.registerTool("optimize_image", {
|
|
|
46
47
|
output_resize_mode: z
|
|
47
48
|
.enum(["pad", "crop"])
|
|
48
49
|
.optional()
|
|
49
|
-
.describe("
|
|
50
|
-
|
|
51
|
-
.
|
|
52
|
-
.optional()
|
|
53
|
-
.describe("Maintain aspect ratio during resize. Default: true."),
|
|
50
|
+
.describe("How to handle aspect ratio mismatch when both width and height are specified. " +
|
|
51
|
+
"'pad' adds white padding (default), 'crop' uses smart cropping. " +
|
|
52
|
+
"Only applies when both output_width_px and output_height_px are set."),
|
|
54
53
|
output_seo_tag_gen: z
|
|
55
54
|
.boolean()
|
|
56
55
|
.optional()
|
|
57
|
-
.describe("Generate SEO metadata (alt text, keywords, filename). Default: true."),
|
|
56
|
+
.describe("Generate SEO metadata (alt text, keywords, filename) and rename output file to SEO slug. Costs 1 extra credit. Default: true."),
|
|
58
57
|
},
|
|
59
58
|
outputSchema: {
|
|
60
|
-
output_path: z.string(),
|
|
61
|
-
output_size_bytes: z.number(),
|
|
62
|
-
output_width_px: z.number().nullable(),
|
|
63
|
-
output_height_px: z.number().nullable(),
|
|
64
|
-
output_format: z.string().nullable(),
|
|
65
|
-
compression_ratio: z.number().nullable(),
|
|
66
|
-
seo_alt_text: z.string().nullable(),
|
|
67
|
-
seo_keywords: z.array(z.string()).nullable(),
|
|
68
|
-
seo_filename: z.string().nullable(),
|
|
59
|
+
output_path: z.string().describe("Absolute path where the optimized file was saved"),
|
|
60
|
+
output_size_bytes: z.number().describe("File size of the optimized image in bytes"),
|
|
61
|
+
output_width_px: z.number().nullable().describe("Width of the output image in pixels"),
|
|
62
|
+
output_height_px: z.number().nullable().describe("Height of the output image in pixels"),
|
|
63
|
+
output_format: z.string().nullable().describe("Output format: jpg, png, webp, or avif"),
|
|
64
|
+
compression_ratio: z.number().nullable().describe("Output-to-input size ratio, e.g. 0.35 means 65% smaller"),
|
|
65
|
+
seo_alt_text: z.string().nullable().describe("AI-generated image alt text for accessibility and SEO"),
|
|
66
|
+
seo_keywords: z.array(z.string()).nullable().describe("AI-generated keywords describing the image"),
|
|
67
|
+
seo_filename: z.string().nullable().describe("AI-generated SEO filename slug without extension"),
|
|
69
68
|
},
|
|
70
69
|
}, async (params) => {
|
|
71
70
|
try {
|
|
@@ -77,7 +76,6 @@ server.registerTool("optimize_image", {
|
|
|
77
76
|
output_height_px: params.output_height_px,
|
|
78
77
|
output_upscale_factor: params.output_upscale_factor,
|
|
79
78
|
output_resize_mode: params.output_resize_mode,
|
|
80
|
-
output_aspect_lock: params.output_aspect_lock,
|
|
81
79
|
output_seo_tag_gen: params.output_seo_tag_gen,
|
|
82
80
|
});
|
|
83
81
|
const summary = [
|
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,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,GAAG,IAAI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CAAC,CAAC,IAAI;SAChE;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;YACnD,iBAAiB,EAAE,MAAM;SAC1B,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;AACH,CAAC,CACF,CAAC;AAEF,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
package/dist/tools/optimize.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export interface OptimizeImageParams {
|
|
2
2
|
input: string;
|
|
3
3
|
output_path?: string;
|
|
4
|
-
output_format?: "original" | "
|
|
4
|
+
output_format?: "original" | "jpg" | "png" | "webp" | "avif";
|
|
5
5
|
output_width_px?: number;
|
|
6
6
|
output_height_px?: number;
|
|
7
7
|
output_upscale_factor?: number;
|
|
8
8
|
output_resize_mode?: "pad" | "crop";
|
|
9
|
-
output_aspect_lock?: boolean;
|
|
10
9
|
output_seo_tag_gen?: boolean;
|
|
11
10
|
baseUrl?: string;
|
|
12
11
|
timeoutMs?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimize.d.ts","sourceRoot":"","sources":["../../src/tools/optimize.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"optimize.d.ts","sourceRoot":"","sources":["../../src/tools/optimize.ts"],"names":[],"mappings":"AAWA,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,CAAC;IAC7D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,kBAAkB,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACpC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,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,CAoG9B"}
|
package/dist/tools/optimize.js
CHANGED
|
@@ -41,11 +41,14 @@ export async function optimizeImage(params) {
|
|
|
41
41
|
if (params.output_upscale_factor !== undefined) {
|
|
42
42
|
settings.output_upscale_factor = params.output_upscale_factor;
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
// Derive aspect_lock: false only when both dimensions are specified (exact output requested)
|
|
45
|
+
// Otherwise omit (backend defaults to true = proportional scaling)
|
|
46
|
+
if (params.output_width_px !== undefined && params.output_height_px !== undefined) {
|
|
47
|
+
settings.output_aspect_lock = false;
|
|
48
|
+
settings.output_resize_mode = params.output_resize_mode ?? "pad";
|
|
46
49
|
}
|
|
47
|
-
if (params.
|
|
48
|
-
settings.
|
|
50
|
+
else if (params.output_resize_mode !== undefined) {
|
|
51
|
+
settings.output_resize_mode = params.output_resize_mode;
|
|
49
52
|
}
|
|
50
53
|
// 4. Trigger processing
|
|
51
54
|
const processResult = await triggerProcessing({
|
|
@@ -75,6 +78,9 @@ export async function optimizeImage(params) {
|
|
|
75
78
|
outputFormat: params.output_format && params.output_format !== "original"
|
|
76
79
|
? params.output_format
|
|
77
80
|
: completedJob.processed_format ?? undefined,
|
|
81
|
+
seoFilename: params.output_seo_tag_gen !== false
|
|
82
|
+
? (completedJob.seo_filename ?? undefined)
|
|
83
|
+
: undefined,
|
|
78
84
|
});
|
|
79
85
|
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
80
86
|
fs.writeFileSync(outputPath, downloadResult.buffer);
|
|
@@ -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;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,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,eAAe,IAAI,IAAI;QACrD,gBAAgB,EAAE,YAAY,CAAC,gBAAgB,IAAI,IAAI;QACvD,aAAa,EAAE,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"}
|
package/dist/utils/output.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAEA,UAAU,gBAAgB;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAEA,UAAU,gBAAgB;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA4BD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAoBlE"}
|
package/dist/utils/output.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
|
-
function getTinifiedFilename(filename, outputFormat) {
|
|
2
|
+
function getTinifiedFilename(filename, outputFormat, seoFilename) {
|
|
3
3
|
const ext = path.extname(filename);
|
|
4
|
-
const name = path.basename(filename, ext);
|
|
5
4
|
let newExt;
|
|
6
5
|
if (!outputFormat || outputFormat === "original") {
|
|
7
6
|
newExt = ext || ".png";
|
|
@@ -9,17 +8,21 @@ function getTinifiedFilename(filename, outputFormat) {
|
|
|
9
8
|
else {
|
|
10
9
|
newExt = `.${outputFormat}`;
|
|
11
10
|
}
|
|
11
|
+
if (seoFilename) {
|
|
12
|
+
return `${seoFilename}${newExt}`;
|
|
13
|
+
}
|
|
14
|
+
const name = path.basename(filename, ext);
|
|
12
15
|
return `${name}.tinified${newExt}`;
|
|
13
16
|
}
|
|
14
17
|
function isDirectoryPath(p) {
|
|
15
18
|
return p.endsWith("/") || p.endsWith(path.sep);
|
|
16
19
|
}
|
|
17
20
|
export function resolveOutputPath(params) {
|
|
18
|
-
const { inputPath, isUrl, filename, outputPath, outputFormat, cwd } = params;
|
|
21
|
+
const { inputPath, isUrl, filename, outputPath, outputFormat, seoFilename, cwd } = params;
|
|
19
22
|
if (outputPath && !isDirectoryPath(outputPath)) {
|
|
20
23
|
return path.resolve(outputPath);
|
|
21
24
|
}
|
|
22
|
-
const tinifiedName = getTinifiedFilename(filename, outputFormat);
|
|
25
|
+
const tinifiedName = getTinifiedFilename(filename, outputFormat, seoFilename);
|
|
23
26
|
if (outputPath && isDirectoryPath(outputPath)) {
|
|
24
27
|
return path.join(path.resolve(outputPath), tinifiedName);
|
|
25
28
|
}
|
package/dist/utils/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAA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AAU,CAAC,EAAE,YAAY,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,OAAO,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AAC3C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinify-ai/mcp-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "MCP server for Tinify image optimization — one tool, max optimization",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"tinify-ai-mcp-server": "dist/index.js"
|
|
7
|
+
"tinify-ai-mcp-server": "dist/index.js",
|
|
8
|
+
"mcp-server": "dist/index.js"
|
|
8
9
|
},
|
|
9
10
|
"main": "dist/index.js",
|
|
10
11
|
"files": [
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
"start": "node dist/index.js",
|
|
18
19
|
"test": "vitest run",
|
|
19
20
|
"test:watch": "vitest",
|
|
21
|
+
"test:live": "node scripts/live-test.mjs",
|
|
20
22
|
"typecheck": "tsc --noEmit",
|
|
21
23
|
"prepublishOnly": "npm run test && npm run build"
|
|
22
24
|
},
|