image-tiler-mcp-server 1.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Keiver Hernandez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,359 @@
1
+ # image-tiler-mcp-server
2
+
3
+ Split large images into optimally-sized tiles so LLM vision models see every detail — no downscaling, no lost text.
4
+
5
+ <p align="center">
6
+ <img src="assets/preview.webp" alt="Preview of image tiling grid for veguitas.com" width="100%" />
7
+ </p>
8
+
9
+ ## Why tiling matters
10
+
11
+ LLM vision systems have a **maximum input resolution**. When you send an image larger than that limit, the model silently downscales it before processing. A 3600×22810 full-page screenshot gets shrunk to ~247×1568 by Claude — text becomes unreadable, UI details disappear, and the model can't analyze what it can't see.
12
+
13
+ **Tiling solves this.** This MCP server:
14
+
15
+ 1. Reads the image dimensions and the target model's vision config
16
+ 2. Calculates an optimal grid that keeps every tile within the model's sweet spot
17
+ 3. Extracts tiles as individual PNGs and saves them to disk
18
+ 4. Returns metadata (grid layout, file paths, estimated token cost)
19
+ 5. Serves tiles back as base64 in paginated batches for the LLM to analyze
20
+
21
+ Each tile is processed at **full resolution** — no downscaling — preserving text, UI elements, and fine detail across the entire image.
22
+
23
+ See [sample of generated tiles here.](https://github.com/keiver/image-tiler-mcp-server/tree/main/assets/tiles/)
24
+
25
+ ### Supported Models
26
+
27
+ | Model | Default tile | Tokens/tile | Max tile | ID |
28
+ |-------|-------------|-------------|----------|-----|
29
+ | Claude (default) | 1092px | 1590 | 1568px | `claude` |
30
+ | OpenAI (GPT-4o/o-series) | 768px | 765 | 2048px | `openai` |
31
+ | Gemini | 768px | 258 | 768px | `gemini` |
32
+ | Gemini 3 | 1536px | 1120 | 3072px | `gemini3` |
33
+
34
+ > **OpenAI note:** The `openai` config targets the GPT-4o / o-series vision pipeline (512px tile patches). GPT-4.1 uses a fundamentally different pipeline (32x32 pixel patches) and is not currently supported — it would require a separate model config with a different calculation approach.
35
+
36
+ > **Gemini 3 note:** Gemini 3 uses a fixed token budget per image (1120 tokens regardless of dimensions). Tiling increases total token cost but preserves fine detail. For cases where detail isn't critical, consider sending a single image instead.
37
+
38
+ ## Tools
39
+
40
+ ### `tiler_tile_image`
41
+
42
+ Splits a large image into tiles and saves them to disk.
43
+
44
+ | Parameter | Type | Required | Default | Description |
45
+ |---|---|---|---|---|
46
+ | `filePath` | string | yes | — | Absolute or relative path to the image file |
47
+ | `model` | string | no | `"claude"` | Target vision model: `"claude"`, `"openai"`, `"gemini"`, `"gemini3"` |
48
+ | `tileSize` | number | no | Model default | Tile size in pixels. Clamped to model min/max with a warning if out of bounds. |
49
+ | `outputDir` | string | no | `tiles/{name}` subfolder next to source | Directory to save tiles |
50
+
51
+ Returns JSON metadata with grid dimensions, tile count, model used, estimated token cost, and per-tile file paths.
52
+
53
+ ### `tiler_get_tiles`
54
+
55
+ Returns tile images as base64 in batches of 5 for the LLM to see directly.
56
+
57
+ | Parameter | Type | Required | Default | Description |
58
+ |---|---|---|---|---|
59
+ | `tilesDir` | string | yes | — | Path to tiles directory (from `tiler_tile_image`) |
60
+ | `start` | number | no | 0 | Start tile index (0-based, inclusive) |
61
+ | `end` | number | no | start + 4 | End tile index (0-based, inclusive) |
62
+
63
+ Returns text labels + image content blocks. Includes pagination hint for the next batch.
64
+
65
+ ## Installation
66
+
67
+ ### Claude Code
68
+
69
+ ```bash
70
+ claude mcp add image-tiler -- npx -y image-tiler-mcp-server
71
+ ```
72
+
73
+ > `image-tiler` is a local alias — you can name it anything you like. `image-tiler-mcp-server` is the npm package that gets downloaded and run.
74
+
75
+ See [Claude Code MCP docs](https://docs.anthropic.com/en/docs/claude-code/mcp) for more info.
76
+
77
+ ### Claude Desktop
78
+
79
+ Add to your Claude Desktop config file:
80
+
81
+ - **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
82
+ - **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
83
+ - **Linux:** `~/.config/Claude/claude_desktop_config.json`
84
+
85
+ ```json
86
+ {
87
+ "mcpServers": {
88
+ "image-tiler": {
89
+ "command": "npx",
90
+ "args": ["-y", "image-tiler-mcp-server"]
91
+ }
92
+ }
93
+ }
94
+ ```
95
+
96
+ Restart Claude Desktop after editing.
97
+
98
+ ### VS Code (Cline / Continue)
99
+
100
+ Add to your VS Code MCP settings:
101
+
102
+ ```json
103
+ {
104
+ "image-tiler": {
105
+ "command": "npx",
106
+ "args": ["-y", "image-tiler-mcp-server"]
107
+ }
108
+ }
109
+ ```
110
+
111
+ ### Cursor
112
+
113
+ Add to `~/.cursor/mcp.json`:
114
+
115
+ ```json
116
+ {
117
+ "mcpServers": {
118
+ "image-tiler": {
119
+ "command": "npx",
120
+ "args": ["-y", "image-tiler-mcp-server"]
121
+ }
122
+ }
123
+ }
124
+ ```
125
+
126
+ ### Global Install (faster startup)
127
+
128
+ ```bash
129
+ npm install -g image-tiler-mcp-server
130
+ ```
131
+
132
+ Then use the simpler config in any client:
133
+
134
+ ```json
135
+ {
136
+ "command": "image-tiler-mcp-server"
137
+ }
138
+ ```
139
+
140
+ ### From Source
141
+
142
+ ```bash
143
+ git clone https://github.com/keiver/image-tiler-mcp-server.git
144
+ cd image-tiler-mcp-server
145
+ npm install
146
+ npm run build
147
+ ```
148
+
149
+ Then point your MCP config to the built file:
150
+
151
+ ```json
152
+ {
153
+ "command": "node",
154
+ "args": ["/absolute/path/to/image-tiler-mcp-server/dist/index.js"]
155
+ }
156
+ ```
157
+
158
+ ## Usage
159
+
160
+ ### In Claude Code
161
+
162
+ ```
163
+ > Tile the screenshot at ./screenshots/full-page.png and analyze the layout
164
+
165
+ Claude will:
166
+ 1. Call tiler_tile_image(filePath="./screenshots/full-page.png")
167
+ 2. See: "Tiled 3600x22810 image → 4x21 grid = 84 tiles"
168
+ 3. Call tiler_get_tiles(tilesDir="./screenshots/tiles/full-page", start=0, end=4)
169
+ 4. Analyze tiles 0-4, then continue with start=5...
170
+ ```
171
+
172
+ ### With Other Models
173
+
174
+ ```
175
+ > Tile this image for GPT-4o analysis
176
+
177
+ Claude will:
178
+ 1. Call tiler_tile_image(filePath="./image.png", model="openai")
179
+ 2. Tiles sized at 768px for OpenAI's vision pipeline
180
+ ```
181
+
182
+ ### Typical Workflow
183
+
184
+ 1. Capture full-page screenshot with your browser extension
185
+ 2. Ask Claude: _"Tile `/path/to/screencapture-localhost-3000.png` and review all sections"_
186
+ 3. Claude pages through tiles automatically, analyzing each batch
187
+
188
+ ## Tile Output Structure
189
+
190
+ Example: `assets/landscape.png` (7680x4032) tiled with the default Claude config (1092px tiles) produces an 8x4 grid of 32 tiles (~50,880 tokens).
191
+
192
+ **Grid layout** — tiles are numbered `tile_ROW_COL.png`, extracted left-to-right, top-to-bottom:
193
+
194
+ ```
195
+ 7680px
196
+ ┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬────────┐
197
+ │ 000_000 │ 000_001 │ 000_002 │ 000_003 │ 000_004 │ 000_005 │ 000_006 │ 000_007│
198
+ │ 1092x1092│ 1092x1092│ 1092x1092│ 1092x1092│ 1092x1092│ 1092x1092│ 1092x1092│ 36x1092│ 4032px
199
+ ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼────────┤
200
+ │ 001_000 │ 001_001 │ 001_002 │ 001_003 │ 001_004 │ 001_005 │ 001_006 │ 001_007│
201
+ │ 1092x1092│ 1092x1092│ 1092x1092│ 1092x1092│ 1092x1092│ 1092x1092│ 1092x1092│ 36x1092│
202
+ ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼────────┤
203
+ │ 002_000 │ 002_001 │ 002_002 │ 002_003 │ 002_004 │ 002_005 │ 002_006 │ 002_007│
204
+ │ 1092x1092│ 1092x1092│ 1092x1092│ 1092x1092│ 1092x1092│ 1092x1092│ 1092x1092│ 36x1092│
205
+ ├──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼────────┤
206
+ │ 003_000 │ 003_001 │ 003_002 │ 003_003 │ 003_004 │ 003_005 │ 003_006 │ 003_007│
207
+ │ 1092x756 │ 1092x756 │ 1092x756 │ 1092x756 │ 1092x756 │ 1092x756 │ 1092x756 │ 36x756 │
208
+ └──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴────────┘
209
+ ```
210
+
211
+ Edge tiles are smaller: the rightmost column is 36px wide (7680 - 7×1092 = 36), and the bottom row is 756px tall (4032 - 3×1092 = 756).
212
+
213
+ **Output directory:**
214
+
215
+ ```
216
+ assets/tiles/landscape/
217
+ ├── tile_000_000.png # Row 0, Col 0 — 1092x1092
218
+ ├── tile_000_001.png # Row 0, Col 1 — 1092x1092
219
+ ├── tile_000_002.png # ...
220
+ ├── ...
221
+ ├── tile_000_007.png # Row 0, Col 7 — 36x1092 (right edge)
222
+ ├── tile_001_000.png # Row 1, Col 0
223
+ ├── ...
224
+ ├── tile_003_006.png # Row 3, Col 6 — 1092x756 (bottom edge)
225
+ └── tile_003_007.png # Row 3, Col 7 — 36x756 (corner)
226
+ ```
227
+
228
+ **JSON metadata** returned by `tiler_tile_image`:
229
+
230
+ ```json
231
+ {
232
+ "model": "claude",
233
+ "sourceImage": {
234
+ "width": 7680,
235
+ "height": 4032,
236
+ "format": "png",
237
+ "fileSize": 12345678,
238
+ "channels": 4
239
+ },
240
+ "grid": {
241
+ "cols": 8,
242
+ "rows": 4,
243
+ "totalTiles": 32,
244
+ "tileSize": 1092,
245
+ "estimatedTokens": 50880
246
+ },
247
+ "outputDir": "/path/to/assets/tiles/landscape",
248
+ "tiles": [
249
+ { "index": 0, "row": 0, "col": 0, "position": "0,0", "dimensions": "1092×1092", "filePath": "/path/to/assets/tiles/landscape/tile_000_000.png" },
250
+ { "index": 1, "row": 0, "col": 1, "position": "1092,0", "dimensions": "1092×1092", "filePath": "/path/to/assets/tiles/landscape/tile_000_001.png" },
251
+ "... 30 more tiles"
252
+ ],
253
+ "previewPath": "/path/to/assets/tiles/landscape/preview.html"
254
+ }
255
+ ```
256
+
257
+ ### Portrait example
258
+
259
+ `assets/portrait.png` (3600x22810) tiled with Claude defaults produces a 4x21 grid of 84 tiles (~133,560 tokens).
260
+
261
+ **Grid layout:**
262
+
263
+ ```
264
+ 3600px
265
+ ┌──────────┬──────────┬──────────┬─────────┐
266
+ │ 000_000 │ 000_001 │ 000_002 │ 000_003 │
267
+ │ 1092x1092│ 1092x1092│ 1092x1092│ 324x1092│
268
+ ├──────────┼──────────┼──────────┼─────────┤
269
+ │ 001_000 │ 001_001 │ 001_002 │ 001_003 │
270
+ │ 1092x1092│ 1092x1092│ 1092x1092│ 324x1092│ 22810px
271
+ ├──────────┼──────────┼──────────┼─────────┤
272
+ │ ... │ ... │ ... │ ... │ (21 rows)
273
+ ├──────────┼──────────┼──────────┼─────────┤
274
+ │ 020_000 │ 020_001 │ 020_002 │ 020_003 │
275
+ │ 1092x970 │ 1092x970 │ 1092x970 │ 324x970 │
276
+ └──────────┴──────────┴──────────┴─────────┘
277
+ ```
278
+
279
+ Edge tiles: rightmost column is 324px wide (3600 - 3×1092 = 324), bottom row is 970px tall (22810 - 20×1092 = 970).
280
+
281
+ ## Token Cost Reference
282
+
283
+ Costs vary by model. Formula: `tokens = totalTiles x tokensPerTile`
284
+
285
+ ### Claude (1092px tiles, 1590 tokens/tile)
286
+
287
+ | Image Dimensions | Tiles | Estimated Tokens |
288
+ |---|---|---|
289
+ | 1440x3000 | 6 | ~9,540 |
290
+ | 3600x5000 | 20 | ~31,800 |
291
+ | 3600x22810 | 84 | ~133,560 |
292
+
293
+ ### OpenAI — GPT-4o/o-series (768px tiles, 765 tokens/tile)
294
+
295
+ | Image Dimensions | Tiles | Estimated Tokens |
296
+ |---|---|---|
297
+ | 1440x3000 | 8 | ~6,120 |
298
+ | 3600x5000 | 35 | ~26,775 |
299
+ | 3600x22810 | 150 | ~114,750 |
300
+
301
+ ### Gemini (768px tiles, 258 tokens/tile)
302
+
303
+ | Image Dimensions | Tiles | Estimated Tokens |
304
+ |---|---|---|
305
+ | 1440x3000 | 8 | ~2,064 |
306
+ | 3600x5000 | 35 | ~9,030 |
307
+ | 3600x22810 | 150 | ~38,700 |
308
+
309
+ ### Gemini 3 (1536px tiles, 1120 tokens/tile)
310
+
311
+ | Image Dimensions | Tiles | Estimated Tokens |
312
+ |---|---|---|
313
+ | 1440x3000 | 2 | ~2,240 |
314
+ | 3600x5000 | 12 | ~13,440 |
315
+ | 3600x22810 | 45 | ~50,400 |
316
+
317
+ > **Note:** Gemini 3 uses a fixed 1120 tokens per image regardless of dimensions. More tiles = more total tokens but better detail preservation.
318
+
319
+ ## Supported Formats
320
+
321
+ PNG, JPEG, WebP, TIFF, GIF
322
+
323
+ ## Technical Details
324
+
325
+ - **Image processing:** Sharp (libvips) — demand-driven pipeline, streams tiles without full decompression
326
+ - **Memory usage:** ~350-400MB peak for 30MB+ PNGs
327
+ - **Transport:** stdio (local, single-session)
328
+ - **Tile naming:** `tile_ROW_COL.png` (zero-padded, e.g., `tile_000_003.png`)
329
+ - **Grid order:** Left-to-right, top-to-bottom
330
+ - **Batch limit:** 5 tiles per `tiler_get_tiles` call to stay within MCP response limits
331
+
332
+ ## Troubleshooting
333
+
334
+ **"Command not found"** — Make sure Node.js 18+ is installed: `node --version`
335
+
336
+ **"File not found"** — Use absolute paths. Relative paths resolve from the MCP server's working directory.
337
+
338
+ **"MCP tools not available"** — Restart your MCP client after config changes. In Claude Code, run `/mcp` to check server status.
339
+
340
+ ## Security
341
+
342
+ This is a **local MCP server** that runs on your machine via stdio. It operates with the same filesystem permissions as the MCP client process that spawns it. File paths provided to the tools are resolved and accessed directly — there is no sandboxing or path restriction beyond your OS-level permissions.
343
+
344
+ This is by design: MCP tools run in the user's security context, same as any CLI tool. No network access, no remote connections, no data sent externally.
345
+
346
+ ## Requirements
347
+
348
+ - Node.js 18+
349
+ - Compatible MCP client (Claude Code, Claude Desktop, Cursor, VS Code with MCP extension)
350
+
351
+ ## License
352
+
353
+ MIT
354
+
355
+ ## Links
356
+
357
+ - [GitHub Repository](https://github.com/keiver/image-tiler-mcp-server)
358
+ - [NPM Package](https://www.npmjs.com/package/image-tiler-mcp-server)
359
+ - [Report Issues](https://github.com/keiver/image-tiler-mcp-server/issues)
@@ -0,0 +1,21 @@
1
+ export declare const VISION_MODELS: readonly ["claude", "openai", "gemini", "gemini3"];
2
+ export type VisionModel = (typeof VISION_MODELS)[number];
3
+ export interface ModelVisionConfig {
4
+ defaultTileSize: number;
5
+ minTileSize: number;
6
+ maxTileSize: number;
7
+ tokensPerTile: number;
8
+ label: string;
9
+ }
10
+ export declare const MODEL_CONFIGS: Record<VisionModel, ModelVisionConfig>;
11
+ export declare const DEFAULT_MODEL: VisionModel;
12
+ export declare const DEFAULT_TILE_SIZE: number;
13
+ export declare const MAX_TILE_SIZE: number;
14
+ export declare const MIN_TILE_SIZE: number;
15
+ export declare const TOKENS_PER_TILE: number;
16
+ export declare const MAX_IMAGE_DIMENSION = 65536;
17
+ export declare const MAX_TOTAL_TILES = 10000;
18
+ export declare const MAX_TILES_PER_BATCH = 5;
19
+ export declare const SUPPORTED_FORMATS: readonly ["png", "jpeg", "jpg", "webp", "tiff", "gif"];
20
+ export declare const PNG_COMPRESSION_LEVEL = 6;
21
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,oDAAqD,CAAC;AAChF,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,WAAW,EAAE,iBAAiB,CA6BhE,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,WAAsB,CAAC;AAGnD,eAAO,MAAM,iBAAiB,QAAuC,CAAC;AACtE,eAAO,MAAM,aAAa,QAAmC,CAAC;AAC9D,eAAO,MAAM,aAAa,QAAmC,CAAC;AAC9D,eAAO,MAAM,eAAe,QAAqC,CAAC;AAElE,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AACzC,eAAO,MAAM,eAAe,QAAQ,CAAC;AACrC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,iBAAiB,wDAAyD,CAAC;AACxF,eAAO,MAAM,qBAAqB,IAAI,CAAC"}
@@ -0,0 +1,43 @@
1
+ export const VISION_MODELS = ["claude", "openai", "gemini", "gemini3"];
2
+ export const MODEL_CONFIGS = {
3
+ claude: {
4
+ defaultTileSize: 1092,
5
+ minTileSize: 256,
6
+ maxTileSize: 1568,
7
+ tokensPerTile: 1590,
8
+ label: "Claude",
9
+ },
10
+ openai: {
11
+ defaultTileSize: 768,
12
+ minTileSize: 256,
13
+ maxTileSize: 2048,
14
+ tokensPerTile: 765,
15
+ label: "OpenAI",
16
+ },
17
+ gemini: {
18
+ defaultTileSize: 768,
19
+ minTileSize: 256,
20
+ maxTileSize: 768,
21
+ tokensPerTile: 258,
22
+ label: "Gemini",
23
+ },
24
+ gemini3: {
25
+ defaultTileSize: 1536,
26
+ minTileSize: 384,
27
+ maxTileSize: 3072,
28
+ tokensPerTile: 1120,
29
+ label: "Gemini 3",
30
+ },
31
+ };
32
+ export const DEFAULT_MODEL = "claude";
33
+ // Backward-compatible aliases (point to Claude config)
34
+ export const DEFAULT_TILE_SIZE = MODEL_CONFIGS.claude.defaultTileSize;
35
+ export const MAX_TILE_SIZE = MODEL_CONFIGS.claude.maxTileSize;
36
+ export const MIN_TILE_SIZE = MODEL_CONFIGS.claude.minTileSize;
37
+ export const TOKENS_PER_TILE = MODEL_CONFIGS.claude.tokensPerTile;
38
+ export const MAX_IMAGE_DIMENSION = 65536;
39
+ export const MAX_TOTAL_TILES = 10000;
40
+ export const MAX_TILES_PER_BATCH = 5;
41
+ export const SUPPORTED_FORMATS = ["png", "jpeg", "jpg", "webp", "tiff", "gif"];
42
+ export const PNG_COMPRESSION_LEVEL = 6;
43
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC;AAWhF,MAAM,CAAC,MAAM,aAAa,GAA2C;IACnE,MAAM,EAAE;QACN,eAAe,EAAE,IAAI;QACrB,WAAW,EAAE,GAAG;QAChB,WAAW,EAAE,IAAI;QACjB,aAAa,EAAE,IAAI;QACnB,KAAK,EAAE,QAAQ;KAChB;IACD,MAAM,EAAE;QACN,eAAe,EAAE,GAAG;QACpB,WAAW,EAAE,GAAG;QAChB,WAAW,EAAE,IAAI;QACjB,aAAa,EAAE,GAAG;QAClB,KAAK,EAAE,QAAQ;KAChB;IACD,MAAM,EAAE;QACN,eAAe,EAAE,GAAG;QACpB,WAAW,EAAE,GAAG;QAChB,WAAW,EAAE,GAAG;QAChB,aAAa,EAAE,GAAG;QAClB,KAAK,EAAE,QAAQ;KAChB;IACD,OAAO,EAAE;QACP,eAAe,EAAE,IAAI;QACrB,WAAW,EAAE,GAAG;QAChB,WAAW,EAAE,IAAI;QACjB,aAAa,EAAE,IAAI;QACnB,KAAK,EAAE,UAAU;KAClB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAgB,QAAQ,CAAC;AAEnD,uDAAuD;AACvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC,MAAM,CAAC,eAAe,CAAC;AACtE,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC;AAC9D,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC;AAC9D,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC;AAElE,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AACzC,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AACrC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AACrC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAU,CAAC;AACxF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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,30 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
3
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import { registerTileImageTool } from "./tools/tile-image.js";
6
+ import { registerGetTilesTool } from "./tools/get-tiles.js";
7
+ const require = createRequire(import.meta.url);
8
+ const { version } = require("../package.json");
9
+ const server = new McpServer({
10
+ name: "image-tiler-mcp-server",
11
+ version,
12
+ });
13
+ registerTileImageTool(server);
14
+ registerGetTilesTool(server);
15
+ async function runStdio() {
16
+ const transport = new StdioServerTransport();
17
+ await server.connect(transport);
18
+ console.error("image-tiler-mcp-server running on stdio");
19
+ }
20
+ async function shutdown() {
21
+ await server.close();
22
+ process.exit(0);
23
+ }
24
+ process.on("SIGINT", shutdown);
25
+ process.on("SIGTERM", shutdown);
26
+ runStdio().catch((error) => {
27
+ console.error("Server error:", error);
28
+ process.exit(1);
29
+ });
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AAEtE,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAC3B,IAAI,EAAE,wBAAwB;IAC9B,OAAO;CACR,CAAC,CAAC;AAEH,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAC9B,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAE7B,KAAK,UAAU,QAAQ;IACrB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;AAC3D,CAAC;AAED,KAAK,UAAU,QAAQ;IACrB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAEhC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAClC,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ export declare const TileImageInputSchema: {
3
+ filePath: z.ZodString;
4
+ model: z.ZodDefault<z.ZodEnum<["claude", "openai", "gemini", "gemini3"]>>;
5
+ tileSize: z.ZodOptional<z.ZodNumber>;
6
+ outputDir: z.ZodOptional<z.ZodString>;
7
+ };
8
+ export declare const GetTilesInputSchema: {
9
+ tilesDir: z.ZodString;
10
+ start: z.ZodDefault<z.ZodNumber>;
11
+ end: z.ZodOptional<z.ZodNumber>;
12
+ };
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,eAAO,MAAM,oBAAoB;;;;;CA6BhC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;CAqB/B,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { z } from "zod";
2
+ import { MAX_IMAGE_DIMENSION, MAX_TILES_PER_BATCH, VISION_MODELS, DEFAULT_MODEL, MODEL_CONFIGS, } from "../constants.js";
3
+ const modelDescriptions = VISION_MODELS.map((m) => `"${m}" (${MODEL_CONFIGS[m].defaultTileSize}px tiles, ~${MODEL_CONFIGS[m].tokensPerTile} tokens/tile)`).join(", ");
4
+ const defaultDescriptions = VISION_MODELS.map((m) => `${MODEL_CONFIGS[m].label}: ${MODEL_CONFIGS[m].defaultTileSize}`).join(", ");
5
+ export const TileImageInputSchema = {
6
+ filePath: z
7
+ .string()
8
+ .min(1, "File path cannot be empty")
9
+ .describe("Absolute or relative path to the image file to tile"),
10
+ model: z
11
+ .enum(VISION_MODELS)
12
+ .default(DEFAULT_MODEL)
13
+ .describe(`Target vision model: ${modelDescriptions}. Default: "${DEFAULT_MODEL}"`),
14
+ tileSize: z
15
+ .number()
16
+ .int()
17
+ .min(1, "Tile size must be a positive integer")
18
+ .max(MAX_IMAGE_DIMENSION, `Tile size must not exceed ${MAX_IMAGE_DIMENSION}px`)
19
+ .optional()
20
+ .describe(`Tile size in pixels. If omitted, uses the model's optimal default (${defaultDescriptions}). Values outside the model's supported range are automatically clamped with a warning.`),
21
+ outputDir: z
22
+ .string()
23
+ .optional()
24
+ .describe("Directory to save tiles. Defaults to a 'tiles' subfolder next to the source image"),
25
+ };
26
+ export const GetTilesInputSchema = {
27
+ tilesDir: z
28
+ .string()
29
+ .min(1, "Tiles directory path cannot be empty")
30
+ .describe("Path to the tiles directory (returned by tiler_tile_image as outputDir)"),
31
+ start: z
32
+ .number()
33
+ .int()
34
+ .min(0, "Start index must be >= 0")
35
+ .default(0)
36
+ .describe("Start tile index (0-based, inclusive)"),
37
+ end: z
38
+ .number()
39
+ .int()
40
+ .min(0, "End index must be >= 0")
41
+ .optional()
42
+ .describe(`End tile index (0-based, inclusive). Defaults to start + ${MAX_TILES_PER_BATCH - 1}. Max ${MAX_TILES_PER_BATCH} tiles per batch to stay within MCP response limits`),
43
+ };
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,aAAa,GACd,MAAM,iBAAiB,CAAC;AAEzB,MAAM,iBAAiB,GAAG,aAAa,CAAC,GAAG,CACzC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,aAAa,CAAC,CAAC,CAAC,CAAC,eAAe,cAAc,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,eAAe,CAC9G,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,mBAAmB,GAAG,aAAa,CAAC,GAAG,CAC3C,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,aAAa,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,CACxE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,2BAA2B,CAAC;SACnC,QAAQ,CAAC,qDAAqD,CAAC;IAClE,KAAK,EAAE,CAAC;SACL,IAAI,CAAC,aAAa,CAAC;SACnB,OAAO,CAAC,aAAa,CAAC;SACtB,QAAQ,CACP,wBAAwB,iBAAiB,eAAe,aAAa,GAAG,CACzE;IACH,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,EAAE,sCAAsC,CAAC;SAC9C,GAAG,CACF,mBAAmB,EACnB,6BAA6B,mBAAmB,IAAI,CACrD;SACA,QAAQ,EAAE;SACV,QAAQ,CACP,sEAAsE,mBAAmB,yFAAyF,CACnL;IACH,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,mFAAmF,CACpF;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,sCAAsC,CAAC;SAC9C,QAAQ,CACP,yEAAyE,CAC1E;IACH,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,EAAE,0BAA0B,CAAC;SAClC,OAAO,CAAC,CAAC,CAAC;SACV,QAAQ,CAAC,uCAAuC,CAAC;IACpD,GAAG,EAAE,CAAC;SACH,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC;SAChC,QAAQ,EAAE;SACV,QAAQ,CACP,4DAA4D,mBAAmB,GAAG,CAAC,SAAS,mBAAmB,qDAAqD,CACrK;CACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ImageMetadata, TileGridInfo, TileImageResult } from "../types.js";
2
+ export declare function getImageMetadata(filePath: string): Promise<ImageMetadata>;
3
+ export declare function calculateGrid(width: number, height: number, tileSize: number, tokensPerTile?: number): TileGridInfo;
4
+ export declare function tileImage(filePath: string, tileSize: number, outputDir: string, tokensPerTile?: number): Promise<TileImageResult>;
5
+ export declare function readTileAsBase64(tilePath: string): Promise<string>;
6
+ export declare function listTilesInDirectory(tilesDir: string): Promise<string[]>;
7
+ //# sourceMappingURL=image-processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-processor.d.ts","sourceRoot":"","sources":["../../src/services/image-processor.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAY,eAAe,EAAE,MAAM,aAAa,CAAC;AAK1F,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,aAAa,CAAC,CAwBxB;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,aAAa,GAAE,MAAwB,GACtC,YAAY,CAYd;AAED,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,aAAa,GAAE,MAAwB,GACtC,OAAO,CAAC,eAAe,CAAC,CA4E1B;AAED,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGxE;AAED,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,EAAE,CAAC,CAuBnB"}