imgx-mcp 1.4.0 → 1.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.1 (2026-03-05)
4
+
5
+ ### Fixed
6
+
7
+ - **Re-release of v1.5.0** — v1.5.0 was unpublished during documentation review; npm does not allow re-publishing the same version. No code changes from v1.5.0.
8
+ - **Documentation** — Added `.imgx/` directory location explanation, `output_dir`/history relationship, and updated SKILL.md tips
9
+
10
+ ## 1.5.0 (2026-03-05) [YANKED — npm does not allow re-publish]
11
+
12
+ ### Added
13
+
14
+ - **User config `projectRoot` fallback** — `findProjectRoot()` now checks `projectRoot` in user config as a final fallback when env var, MCP roots, and `.imgxrc` detection all fail
15
+ - **CLI `project-root` config key** — `imgx config set project-root /path/to/project` and `imgx config get project-root`
16
+ - 3 new tests for `projectRoot` fallback (total: 84 tests)
17
+
18
+ ### Project root configuration (3 tiers)
19
+
20
+ | Method | Scope | How to set |
21
+ |--------|-------|------------|
22
+ | `IMGX_PROJECT_ROOT` env var in client config | Per-client (highest priority) | Add to `env` in `claude_desktop_config.json`, `.mcp.json`, etc. |
23
+ | Auto-detection (MCP roots / `.imgxrc` search) | Automatic | Works on CLI agents (Claude Code, Gemini CLI). Not available on Claude Desktop |
24
+ | `imgx config set project-root` | All clients on the machine | Stored in `~/.config/imgx/config.json` or `%APPDATA%\imgx\config.json` |
25
+
26
+ Detection priority: env var → MCP roots → `.imgxrc` upward search → user config `projectRoot`
27
+
28
+ ## 1.4.1 (2026-03-04)
29
+
30
+ ### Fixed
31
+
32
+ - **MCP roots detection race condition** — `listRoots()` was called immediately after `server.connect()`, before the MCP initialization handshake completed. The request failed silently, causing `setProjectRoot()` to never execute and images to save to the fallback `~/Pictures/imgx/` instead of `<project-root>/.imgx/`. Now uses `oninitialized` callback to wait for handshake completion and checks `roots` capability before requesting.
33
+
3
34
  ## 1.4.0 (2026-03-04)
4
35
 
5
36
  ### Added
package/README.md CHANGED
@@ -1,481 +1,508 @@
1
- # imgx-mcp
2
-
3
- AI image generation and editing MCP server. Works with Claude Code, Gemini CLI, Cursor, Windsurf, and any MCP-compatible tool.
4
-
5
- Generate images from text, edit existing images with text instructions, iterate on results — all from your AI coding environment.
6
-
7
- ## Quick start
8
-
9
- Add to your tool's MCP config (`.mcp.json`, `settings.json`, etc.):
10
-
11
- ```json
12
- {
13
- "mcpServers": {
14
- "imgx": {
15
- "command": "npx",
16
- "args": ["--package=imgx-mcp", "-y", "imgx-mcp"],
17
- "env": { "GEMINI_API_KEY": "your-key" }
18
- }
19
- }
20
- }
21
- ```
22
-
23
- That's it. Your AI agent can now generate and edit images.
24
-
25
- > **Windows**: Replace `"command": "npx"` with `"command": "cmd"` and prepend `"/c"` to the args array.
26
-
27
- ## Skill (Claude Code)
28
-
29
- For Claude Code users, imgx-mcp includes an `image-generation` skill — a guided prompt that teaches Claude how to use the MCP tools effectively. With the skill installed, type `/image-generation` to start a guided workflow.
30
-
31
- ### Install the skill
32
-
33
- Copy the skill directory from the npm package or GitHub repository to your project:
34
-
35
- ```bash
36
- # From npm (after npx has cached the package)
37
- cp -r $(npm root -g)/imgx-mcp/skills .claude/skills
38
-
39
- # Or from the GitHub repository
40
- curl -sL https://raw.githubusercontent.com/somacoffeekyoto/imgx-mcp/main/skills/image-generation/SKILL.md \
41
- -o .claude/skills/image-generation/SKILL.md --create-dirs
42
- curl -sL https://raw.githubusercontent.com/somacoffeekyoto/imgx-mcp/main/skills/image-generation/references/providers.md \
43
- -o .claude/skills/image-generation/references/providers.md --create-dirs
44
- ```
45
-
46
- Or place skill files manually:
47
-
48
- ```
49
- your-project/
50
- .mcp.json ← MCP server config (Quick start above)
51
- .claude/
52
- skills/
53
- image-generation/
54
- SKILL.md ← skill prompt
55
- references/
56
- providers.md ← provider reference
57
- ```
58
-
59
- The skill files are included in the [npm package](https://www.npmjs.com/package/imgx-mcp) under `skills/` and in the [GitHub repository](https://github.com/somacoffeekyoto/imgx-mcp/tree/main/skills/image-generation).
60
-
61
- > **Personal skill** (all projects): Place in `~/.claude/skills/image-generation/` instead of `.claude/skills/`.
62
-
63
- ### Claude Desktop
64
-
65
- Claude Desktop supports skills via ZIP upload:
66
-
67
- 1. Download [`image-generation-skill.zip`](dist/image-generation-skill.zip) from the repository (or find it in the [npm package](https://www.npmjs.com/package/imgx-mcp) under `dist/`)
68
- 2. In Claude Desktop: **Settings > Profile > Customize > Skills > Add Skill**
69
- 3. Upload the ZIP
70
-
71
- > Update the skill by re-downloading and re-uploading the ZIP after new releases.
72
-
73
- ### What the skill does
74
-
75
- The skill guides Claude Code through image workflows: blog covers, iterative editing, provider comparison, icon generation. It knows the MCP tool parameters and best practices, so you get better results with less effort.
76
-
77
- ### MCP server vs Skill
78
-
79
- | | MCP server | Skill |
80
- |---|---|---|
81
- | What it does | Exposes image tools to AI agents | Guided prompt for using the tools |
82
- | Works with | Any MCP-compatible tool | Claude Code, Claude Desktop |
83
- | Install | Add to `.mcp.json` | Copy skill files to project |
84
- | Team sharing | Commit `.mcp.json` to repo | Commit `.claude/skills/` to repo |
85
-
86
- **Recommended**: Set up the MCP server (Quick start) + install the skill if you use Claude Code.
87
-
88
- ## MCP tools
89
-
90
- | Tool | Description |
91
- |------|-------------|
92
- | `generate_image` | Generate an image from a text prompt |
93
- | `edit_image` | Edit an existing image with text instructions |
94
- | `edit_last` | Edit the last generated/edited image (no input path needed) |
95
- | `undo_edit` | Undo the last edit, reverting to the previous image in the session |
96
- | `redo_edit` | Redo a previously undone edit |
97
- | `edit_history` | Show all sessions and their edit history with metadata |
98
- | `switch_session` | Switch to a different editing session |
99
- | `clear_history` | Clear project history (optionally delete image files) |
100
- | `set_output_dir` | Change the default output directory (optionally move existing files) |
101
- | `list_providers` | List available providers and capabilities |
102
-
103
- Images are saved to `<project-root>/.imgx/<session-id>/` when a project root is detected, or `~/Pictures/imgx/<session-id>/` otherwise. Each session gets its own directory. File paths are returned in the response. Inline image preview is included in MCP responses (base64).
104
-
105
- ### Iterative editing
106
-
107
- The `edit_last` tool uses the output of the previous `generate_image` or `edit_image` call as input. This enables a conversational workflow:
108
-
109
- ```
110
- "Generate a coffee shop interior" generate_image
111
- "Make the lighting warmer" → edit_last
112
- "Add a person reading a book" → edit_last
113
- ```
114
-
115
- No need to specify file paths between steps.
116
-
117
- ### Session management
118
-
119
- Each `generate_image` call starts a new session. Subsequent `edit_last` calls are added to the same session, forming an edit chain. Each session has its own output directory.
120
-
121
- **Undo / Redo** — Step backward and forward through the edit chain:
122
-
123
- ```
124
- generate edit_last → edit_last → edit_last
125
- ↑ current
126
- undo_edit
127
- ↑ current
128
- redo_edit
129
- ↑ current
130
- ```
131
-
132
- After undo, calling `edit_last` branches from the current position (abandoned entries and their files are deleted from disk).
133
-
134
- **File naming** — `edit_last` generates sequential filenames based on the origin file:
135
-
136
- ```
137
- generate_image → cover.png
138
- edit_last → cover-1.png
139
- edit_last cover-2.png
140
-
141
- generate_image (no output) imgx-a1b2c3d4.png
142
- edit_last → imgx-a1b2c3d4-1.png
143
- ```
144
-
145
- **Session switching** — Use `edit_history` to see all sessions, then `switch_session` to resume a previous session. The `edit_last` tool will use the current position in the switched session.
146
-
147
- **Output directory** — `edit_last` inherits the output directory from the session. If `generate_image` was called with `output_dir`, all subsequent `edit_last` calls in that session output to the same directory.
148
-
149
- ## API key setup
150
-
151
- Set up at least one provider:
152
-
153
- **Gemini** — get a key from [Google AI Studio](https://aistudio.google.com/apikey) (free tier available):
154
-
155
- ```bash
156
- imgx config set api-key YOUR_GEMINI_API_KEY --provider gemini
157
- ```
158
-
159
- **OpenAI** — get a key from [OpenAI Platform](https://platform.openai.com/api-keys):
160
-
161
- ```bash
162
- imgx config set api-key YOUR_OPENAI_API_KEY --provider openai
163
- ```
164
-
165
- Keys are stored in `~/.config/imgx/config.json` (Linux/macOS) or `%APPDATA%\imgx\config.json` (Windows). Alternatively, pass keys via the `env` section in your MCP config, or set environment variables:
166
-
167
- ```bash
168
- export GEMINI_API_KEY="your-api-key"
169
- export OPENAI_API_KEY="your-api-key"
170
- ```
171
-
172
- Only include the API keys for providers you want to use. At least one is required.
173
-
174
- ## MCP configuration by tool
175
-
176
- ### Claude Code
177
-
178
- `.mcp.json` in your project root:
179
-
180
- ```json
181
- {
182
- "mcpServers": {
183
- "imgx": {
184
- "command": "npx",
185
- "args": ["--package=imgx-mcp", "-y", "imgx-mcp"],
186
- "env": { "GEMINI_API_KEY": "your-key", "OPENAI_API_KEY": "your-key" }
187
- }
188
- }
189
- }
190
- ```
191
-
192
- ### Gemini CLI
193
-
194
- `~/.gemini/settings.json`:
195
-
196
- ```json
197
- {
198
- "mcpServers": {
199
- "imgx": {
200
- "command": "npx",
201
- "args": ["--package=imgx-mcp", "-y", "imgx-mcp"],
202
- "env": { "GEMINI_API_KEY": "your-key", "OPENAI_API_KEY": "your-key" }
203
- }
204
- }
205
- }
206
- ```
207
-
208
- ### Claude Desktop
209
-
210
- `claude_desktop_config.json`:
211
-
212
- macOS / Linux:
213
-
214
- ```json
215
- {
216
- "mcpServers": {
217
- "imgx": {
218
- "command": "npx",
219
- "args": ["--package=imgx-mcp", "-y", "imgx-mcp"],
220
- "env": { "GEMINI_API_KEY": "your-key", "OPENAI_API_KEY": "your-key" }
221
- }
222
- }
223
- }
224
- ```
225
-
226
- Windows:
227
-
228
- ```json
229
- {
230
- "mcpServers": {
231
- "imgx": {
232
- "command": "cmd",
233
- "args": ["/c", "npx", "--package=imgx-mcp", "-y", "imgx-mcp"],
234
- "env": { "GEMINI_API_KEY": "your-key", "OPENAI_API_KEY": "your-key" }
235
- }
236
- }
237
- }
238
- ```
239
-
240
- Config file location: `%APPDATA%\Claude\claude_desktop_config.json` (Windows) or `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS). After editing, restart Claude Desktop.
241
-
242
- > **Note:** Claude Desktop runs the MCP server from its own app directory. To control image output location, add `"IMGX_OUTPUT_DIR": "C:\\Users\\you\\Pictures"` to the `env` section, or run `imgx config set output-dir <path>` beforehand.
243
-
244
- ### Codex CLI
245
-
246
- `.codex/config.toml`:
247
-
248
- ```toml
249
- [mcp_servers.imgx]
250
- command = "npx"
251
- args = ["--package=imgx-mcp", "-y", "imgx-mcp"]
252
- env = { GEMINI_API_KEY = "your-key", OPENAI_API_KEY = "your-key" }
253
- ```
254
-
255
- ### Other tools
256
-
257
- The same `npx` pattern works with Cursor, Windsurf, Continue.dev, Cline, Zed, and other MCP-compatible tools. On Windows, use `cmd /c npx` instead of `npx` directly.
258
-
259
- ## Providers
260
-
261
- | Provider | Models | Capabilities |
262
- |----------|--------|-------------|
263
- | Gemini | `gemini-3-pro-image-preview`, `gemini-2.5-flash-image` | Generate, edit, aspect ratio, resolution, reference images, person control |
264
- | OpenAI | `gpt-image-1` | Generate, edit, aspect ratio, multi-output, output format (PNG/JPEG/WebP) |
265
-
266
- ## Architecture
267
-
268
- imgx separates **model-independent** and **model-dependent** concerns:
269
-
270
- ```
271
- MCP server (tool definitions, stdio transport) CLI (argument parsing, output formatting)
272
- ↓ ↓
273
- Core (Capability enum, ImageProvider interface, provider registry, file I/O, history)
274
-
275
- Provider (model-specific API calls, capability declarations)
276
- ```
277
-
278
- MCP server and CLI are two entry points into the same core. Both call the same provider functions.
279
-
280
- Each provider declares its supported capabilities. Adding a new provider means implementing the `ImageProvider` interface and registering it no changes to the MCP or CLI layer.
281
-
282
- ### Capability system
283
-
284
- | Capability | Description |
285
- |------------|-------------|
286
- | `TEXT_TO_IMAGE` | Generate images from text prompts |
287
- | `IMAGE_EDITING` | Edit images with text instructions |
288
- | `ASPECT_RATIO` | Control output aspect ratio |
289
- | `RESOLUTION_CONTROL` | Control output resolution |
290
- | `MULTIPLE_OUTPUTS` | Generate multiple images per request |
291
- | `REFERENCE_IMAGES` | Use reference images for guidance |
292
- | `PERSON_CONTROL` | Control person generation in output |
293
- | `OUTPUT_FORMAT` | Choose output format (PNG, JPEG, WebP) |
294
-
295
- ## CLI
296
-
297
- imgx-mcp also works as a standalone command-line tool.
298
-
299
- ### Install
300
-
301
- ```bash
302
- npm install -g imgx-mcp
303
- ```
304
-
305
- Requires Node.js 18+.
306
-
307
- ### Usage
308
-
309
- ```bash
310
- # Generate
311
- imgx generate -p "A coffee cup on a wooden table, morning light" -o output.png
312
-
313
- # Edit
314
- imgx edit -i photo.png -p "Change the background to sunset" -o edited.png
315
-
316
- # Iterative editing
317
- imgx edit -i photo.png -p "Make the background darker"
318
- imgx edit --last -p "Add warm lighting"
319
- imgx edit --last -p "Crop to 16:9" -o final.png
320
-
321
- # Undo / redo
322
- imgx undo # Revert to previous image in session
323
- imgx redo # Re-apply an undone edit
324
-
325
- # History
326
- imgx history # Show all sessions and entries
327
- imgx history switch <session-id> # Switch to a different session
328
- imgx history clear # Clear project history (interactive)
329
- imgx history clear --yes # Clear without confirmation
330
- imgx history clear --keep-files # Clear history but keep image files
331
- imgx history clear --all # Clear ALL history across all projects
332
-
333
- # Provider management
334
- imgx providers # List providers and capabilities
335
- imgx capabilities # Detailed capabilities of current provider
336
- ```
337
-
338
- ### CLI options
339
-
340
- | Flag | Short | Description |
341
- |------|-------|-------------|
342
- | `--prompt` | `-p` | Image description or edit instruction (required) |
343
- | `--output` | `-o` | Output file path (auto-generated if omitted) |
344
- | `--input` | `-i` | Input image to edit (`edit` command only) |
345
- | `--last` | `-l` | Use last output as input (`edit` command only) |
346
- | `--aspect-ratio` | `-a` | `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `2:3`, `3:2` |
347
- | `--resolution` | `-r` | `1K`, `2K`, `4K` |
348
- | `--count` | `-n` | Number of images to generate |
349
- | `--format` | `-f` | Output format: `png`, `jpeg`, `webp` (OpenAI only) |
350
- | `--model` | `-m` | Model name |
351
- | `--provider` | | Provider name (default: `gemini`) |
352
- | `--output-dir` | `-d` | Output directory |
353
-
354
- ### Configuration
355
-
356
- ```bash
357
- imgx config set api-key <key> --provider gemini # Save Gemini API key
358
- imgx config set api-key <key> --provider openai # Save OpenAI API key
359
- imgx config set model <name> # Set default model
360
- imgx config set output-dir <dir> # Set default output directory
361
- imgx config set aspect-ratio 16:9 # Set default aspect ratio
362
- imgx config set resolution 2K # Set default resolution
363
- imgx config list # Show all settings
364
- imgx config get api-key # Show a specific setting (API key is masked)
365
- imgx config path # Show config file location
366
- ```
367
-
368
- ### Project config (`.imgxrc`)
369
-
370
- Generate a template with `imgx init`:
371
-
372
- ```bash
373
- imgx init
374
- # creates .imgxrc in current directory
375
- ```
376
-
377
- Or create manually:
378
-
379
- ```json
380
- {
381
- "defaults": {
382
- "model": "gemini-2.5-flash-image",
383
- "outputDir": "./assets/images",
384
- "aspectRatio": "16:9"
385
- }
386
- }
387
- ```
388
-
389
- Project config is shared via Git. Do not put API keys in `.imgxrc`.
390
-
391
- When used via MCP (Claude Code, etc.), imgx-mcp automatically detects the project root from the client's workspace via MCP roots. When `.imgxrc` is present, that directory is used as the project root (CLI fallback). You can also set `IMGX_PROJECT_ROOT` environment variable explicitly. History is saved to `<project-root>/.imgx/output-history.json` (project-scoped, not shared with other projects). Default image output goes to `<project-root>/.imgx/<session-id>/`. Relative paths in `output` and `output_dir` are resolved against the project root instead of the MCP server's working directory.
392
-
393
- ### Settings resolution
394
-
395
- 1. CLI flags (`--model`, `--output-dir`, etc.)
396
- 2. Environment variables (`IMGX_MODEL`, `IMGX_OUTPUT_DIR`, etc.)
397
- 3. Project config (`.imgxrc` — searched from current directory upward)
398
- 4. User config (`~/.config/imgx/config.json` or `%APPDATA%\imgx\config.json`)
399
- 5. Provider defaults
400
-
401
- ### Output format
402
-
403
- All CLI commands output JSON:
404
-
405
- ```json
406
- {"success": true, "filePaths": ["./output.png"]}
407
- ```
408
-
409
- ## Claude Code plugin
410
-
411
- The plugin bundles MCP server + skill in one step. If you prefer not to configure `.mcp.json` and skill files manually:
412
-
413
- ```
414
- /plugin marketplace add somacoffeekyoto/imgx-mcp
415
- /plugin install imgx-mcp@somacoffeekyoto-imgx-mcp
416
- ```
417
-
418
- Update: `/plugin` installed imgx-mcp update. If the update shows no changes, uninstall and reinstall.
419
-
420
- Uninstall: `/plugin uninstall imgx-mcp@somacoffeekyoto-imgx-mcp` then `/plugin marketplace remove somacoffeekyoto-imgx-mcp`.
421
-
422
- ## Development
423
-
424
- ```bash
425
- git clone https://github.com/somacoffeekyoto/imgx-mcp.git
426
- cd imgx-mcp
427
- npm install
428
- npm run bundle # TypeScript compile + esbuild bundle
429
- ```
430
-
431
- The build produces two bundles:
432
-
433
- - `dist/mcp.bundle.js` MCP server entry point
434
- - `dist/cli.bundle.js` — CLI entry point
435
-
436
- ## Uninstall
437
-
438
- ### MCP server
439
-
440
- Remove the `imgx` entry from your tool's MCP configuration file.
441
-
442
- ### Skill
443
-
444
- Delete the `image-generation/` directory from `.claude/skills/` or `~/.claude/skills/`.
445
-
446
- ### CLI
447
-
448
- ```bash
449
- npm uninstall -g imgx-mcp
450
- ```
451
-
452
- `npm uninstall` removes the package but does not delete configuration or generated files. Remove them manually if needed:
453
-
454
- **Global configuration:**
455
-
456
- ```bash
457
- # Linux / macOS
458
- rm -rf ~/.config/imgx/
459
-
460
- # Windows (PowerShell)
461
- Remove-Item -Recurse -Force "$env:APPDATA\imgx"
462
- ```
463
-
464
- **Project history and images:** Each project may have a `.imgx/` directory containing edit history and generated images. Remove it from each project as needed.
465
-
466
- ```bash
467
- rm -rf <project-root>/.imgx/
468
- ```
469
-
470
- ## License
471
-
472
- MIT — [SOMA COFFEE KYOTO](https://github.com/somacoffeekyoto)
473
-
474
- ## Links
475
-
476
- - [Official page](https://somacoffee.net/imgx-mcp/)
477
- - [GitHub](https://github.com/somacoffeekyoto/imgx-mcp)
478
- - [npm](https://www.npmjs.com/package/imgx-mcp)
479
- - [MCP Registry](https://registry.modelcontextprotocol.io)
480
- - [SOMA COFFEE KYOTO](https://somacoffee.net)
481
- - [X (@somacoffeekyoto)](https://x.com/somacoffeekyoto)
1
+ # imgx-mcp
2
+
3
+ AI image generation and editing MCP server. Works with Claude Code, Gemini CLI, Cursor, Windsurf, and any MCP-compatible tool.
4
+
5
+ Generate images from text, edit existing images with text instructions, iterate on results — all from your AI coding environment.
6
+
7
+ ## Quick start
8
+
9
+ Add to your tool's MCP config (`.mcp.json`, `settings.json`, etc.):
10
+
11
+ ```json
12
+ {
13
+ "mcpServers": {
14
+ "imgx": {
15
+ "command": "npx",
16
+ "args": ["--package=imgx-mcp", "-y", "imgx-mcp"],
17
+ "env": { "GEMINI_API_KEY": "your-key" }
18
+ }
19
+ }
20
+ }
21
+ ```
22
+
23
+ That's it. Your AI agent can now generate and edit images.
24
+
25
+ > **Windows**: Replace `"command": "npx"` with `"command": "cmd"` and prepend `"/c"` to the args array.
26
+
27
+ ## Skill (Claude Code)
28
+
29
+ For Claude Code users, imgx-mcp includes an `image-generation` skill — a guided prompt that teaches Claude how to use the MCP tools effectively. With the skill installed, type `/image-generation` to start a guided workflow.
30
+
31
+ ### Install the skill
32
+
33
+ Copy the skill directory from the npm package or GitHub repository to your project:
34
+
35
+ ```bash
36
+ # From npm (after npx has cached the package)
37
+ cp -r $(npm root -g)/imgx-mcp/skills .claude/skills
38
+
39
+ # Or from the GitHub repository
40
+ curl -sL https://raw.githubusercontent.com/somacoffeekyoto/imgx-mcp/main/skills/image-generation/SKILL.md \
41
+ -o .claude/skills/image-generation/SKILL.md --create-dirs
42
+ curl -sL https://raw.githubusercontent.com/somacoffeekyoto/imgx-mcp/main/skills/image-generation/references/providers.md \
43
+ -o .claude/skills/image-generation/references/providers.md --create-dirs
44
+ ```
45
+
46
+ Or place skill files manually:
47
+
48
+ ```
49
+ your-project/
50
+ .mcp.json ← MCP server config (Quick start above)
51
+ .claude/
52
+ skills/
53
+ image-generation/
54
+ SKILL.md ← skill prompt
55
+ references/
56
+ providers.md ← provider reference
57
+ ```
58
+
59
+ The skill files are included in the [npm package](https://www.npmjs.com/package/imgx-mcp) under `skills/` and in the [GitHub repository](https://github.com/somacoffeekyoto/imgx-mcp/tree/main/skills/image-generation).
60
+
61
+ > **Personal skill** (all projects): Place in `~/.claude/skills/image-generation/` instead of `.claude/skills/`.
62
+
63
+ ### Claude Desktop
64
+
65
+ Claude Desktop supports skills via ZIP upload:
66
+
67
+ 1. Download [`image-generation-skill.zip`](dist/image-generation-skill.zip) from the repository (or find it in the [npm package](https://www.npmjs.com/package/imgx-mcp) under `dist/`)
68
+ 2. In Claude Desktop: **Settings > Profile > Customize > Skills > Add Skill**
69
+ 3. Upload the ZIP
70
+
71
+ > Update the skill by re-downloading and re-uploading the ZIP after new releases.
72
+
73
+ ### What the skill does
74
+
75
+ The skill guides Claude Code through image workflows: blog covers, iterative editing, provider comparison, icon generation. It knows the MCP tool parameters and best practices, so you get better results with less effort.
76
+
77
+ ### MCP server vs Skill
78
+
79
+ | | MCP server | Skill |
80
+ |---|---|---|
81
+ | What it does | Exposes image tools to AI agents | Guided prompt for using the tools |
82
+ | Works with | Any MCP-compatible tool | Claude Code, Claude Desktop |
83
+ | Install | Add to `.mcp.json` | Copy skill files to project |
84
+ | Team sharing | Commit `.mcp.json` to repo | Commit `.claude/skills/` to repo |
85
+
86
+ **Recommended**: Set up the MCP server (Quick start) + install the skill if you use Claude Code.
87
+
88
+ ## MCP tools
89
+
90
+ | Tool | Description |
91
+ |------|-------------|
92
+ | `generate_image` | Generate an image from a text prompt |
93
+ | `edit_image` | Edit an existing image with text instructions |
94
+ | `edit_last` | Edit the last generated/edited image (no input path needed) |
95
+ | `undo_edit` | Undo the last edit, reverting to the previous image in the session |
96
+ | `redo_edit` | Redo a previously undone edit |
97
+ | `edit_history` | Show all sessions and their edit history with metadata |
98
+ | `switch_session` | Switch to a different editing session |
99
+ | `clear_history` | Clear project history (optionally delete image files) |
100
+ | `set_output_dir` | Change the default output directory (optionally move existing files) |
101
+ | `list_providers` | List available providers and capabilities |
102
+
103
+ The `.imgx/` directory holds both edit history and default image output. Its location depends on project root detection:
104
+
105
+ | Project root | `.imgx/` location | History |
106
+ |---|---|---|
107
+ | Detected | `<project-root>/.imgx/` | `<project-root>/.imgx/output-history.json` |
108
+ | Not detected | `~/Pictures/imgx/` (images only) | `~/.config/imgx/output-history.json` (global) |
109
+
110
+ All clients that resolve to the same project root share the same history. Each session gets its own subdirectory. File paths are returned in the response. Inline image preview is included in MCP responses (base64).
111
+
112
+ ### Iterative editing
113
+
114
+ The `edit_last` tool uses the output of the previous `generate_image` or `edit_image` call as input. This enables a conversational workflow:
115
+
116
+ ```
117
+ "Generate a coffee shop interior" → generate_image
118
+ "Make the lighting warmer" → edit_last
119
+ "Add a person reading a book" → edit_last
120
+ ```
121
+
122
+ No need to specify file paths between steps.
123
+
124
+ ### Session management
125
+
126
+ Each `generate_image` call starts a new session. Subsequent `edit_last` calls are added to the same session, forming an edit chain. Each session has its own output directory.
127
+
128
+ **Undo / Redo** — Step backward and forward through the edit chain:
129
+
130
+ ```
131
+ generate → edit_last → edit_last → edit_last
132
+ current
133
+ ← undo_edit
134
+ current
135
+ redo_edit →
136
+ ↑ current
137
+ ```
138
+
139
+ After undo, calling `edit_last` branches from the current position (abandoned entries and their files are deleted from disk).
140
+
141
+ **File naming** `edit_last` generates sequential filenames based on the origin file:
142
+
143
+ ```
144
+ generate_image → cover.png
145
+ edit_last cover-1.png
146
+ edit_last → cover-2.png
147
+
148
+ generate_image (no output) → imgx-a1b2c3d4.png
149
+ edit_last → imgx-a1b2c3d4-1.png
150
+ ```
151
+
152
+ **Session switching** — Use `edit_history` to see all sessions, then `switch_session` to resume a previous session. The `edit_last` tool will use the current position in the switched session.
153
+
154
+ **Output directory** — `edit_last` inherits the output directory from the session. If `generate_image` was called with `output_dir`, all subsequent `edit_last` calls in that session output to the same directory. The `output_dir` path is recorded as session metadata in `output-history.json`. This only affects where image files are saved — history always stays in `.imgx/` (or the global config directory).
155
+
156
+ ## API key setup
157
+
158
+ Set up at least one provider:
159
+
160
+ **Gemini** — get a key from [Google AI Studio](https://aistudio.google.com/apikey) (free tier available):
161
+
162
+ ```bash
163
+ imgx config set api-key YOUR_GEMINI_API_KEY --provider gemini
164
+ ```
165
+
166
+ **OpenAI** — get a key from [OpenAI Platform](https://platform.openai.com/api-keys):
167
+
168
+ ```bash
169
+ imgx config set api-key YOUR_OPENAI_API_KEY --provider openai
170
+ ```
171
+
172
+ Keys are stored in `~/.config/imgx/config.json` (Linux/macOS) or `%APPDATA%\imgx\config.json` (Windows). Alternatively, pass keys via the `env` section in your MCP config, or set environment variables:
173
+
174
+ ```bash
175
+ export GEMINI_API_KEY="your-api-key"
176
+ export OPENAI_API_KEY="your-api-key"
177
+ ```
178
+
179
+ Only include the API keys for providers you want to use. At least one is required.
180
+
181
+ ## MCP configuration by tool
182
+
183
+ ### Claude Code
184
+
185
+ `.mcp.json` in your project root:
186
+
187
+ ```json
188
+ {
189
+ "mcpServers": {
190
+ "imgx": {
191
+ "command": "npx",
192
+ "args": ["--package=imgx-mcp", "-y", "imgx-mcp"],
193
+ "env": { "GEMINI_API_KEY": "your-key", "OPENAI_API_KEY": "your-key" }
194
+ }
195
+ }
196
+ }
197
+ ```
198
+
199
+ ### Gemini CLI
200
+
201
+ `~/.gemini/settings.json`:
202
+
203
+ ```json
204
+ {
205
+ "mcpServers": {
206
+ "imgx": {
207
+ "command": "npx",
208
+ "args": ["--package=imgx-mcp", "-y", "imgx-mcp"],
209
+ "env": { "GEMINI_API_KEY": "your-key", "OPENAI_API_KEY": "your-key" }
210
+ }
211
+ }
212
+ }
213
+ ```
214
+
215
+ ### Claude Desktop
216
+
217
+ `claude_desktop_config.json`:
218
+
219
+ macOS / Linux:
220
+
221
+ ```json
222
+ {
223
+ "mcpServers": {
224
+ "imgx": {
225
+ "command": "npx",
226
+ "args": ["--package=imgx-mcp", "-y", "imgx-mcp"],
227
+ "env": {
228
+ "GEMINI_API_KEY": "your-key",
229
+ "OPENAI_API_KEY": "your-key",
230
+ "IMGX_PROJECT_ROOT": ""
231
+ }
232
+ }
233
+ }
234
+ }
235
+ ```
236
+
237
+ Windows:
238
+
239
+ ```json
240
+ {
241
+ "mcpServers": {
242
+ "imgx": {
243
+ "command": "cmd",
244
+ "args": ["/c", "npx", "--package=imgx-mcp", "-y", "imgx-mcp"],
245
+ "env": {
246
+ "GEMINI_API_KEY": "your-key",
247
+ "OPENAI_API_KEY": "your-key",
248
+ "IMGX_PROJECT_ROOT": ""
249
+ }
250
+ }
251
+ }
252
+ }
253
+ ```
254
+
255
+ `IMGX_PROJECT_ROOT` Set to your project path to save images inside the project (e.g. `"C:\\Users\\you\\my-project"`). Leave empty to use the global default (`~/Pictures/imgx`).
256
+
257
+ Config file location: `%APPDATA%\Claude\claude_desktop_config.json` (Windows) or `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS). After editing, restart Claude Desktop.
258
+
259
+ > **Note:** Claude Desktop does not support auto-detection (MCP roots / CWD-based `.imgxrc` search). Use `IMGX_PROJECT_ROOT` in the config above (per-client), or run `imgx config set project-root /path/to/project` (shared across all clients).
260
+
261
+ ### Codex CLI
262
+
263
+ `.codex/config.toml`:
264
+
265
+ ```toml
266
+ [mcp_servers.imgx]
267
+ command = "npx"
268
+ args = ["--package=imgx-mcp", "-y", "imgx-mcp"]
269
+ env = { GEMINI_API_KEY = "your-key", OPENAI_API_KEY = "your-key" }
270
+ ```
271
+
272
+ ### Other tools
273
+
274
+ The same `npx` pattern works with Cursor, Windsurf, Continue.dev, Cline, Zed, and other MCP-compatible tools. On Windows, use `cmd /c npx` instead of `npx` directly.
275
+
276
+ ## Providers
277
+
278
+ | Provider | Models | Capabilities |
279
+ |----------|--------|-------------|
280
+ | Gemini | `gemini-3-pro-image-preview`, `gemini-2.5-flash-image` | Generate, edit, aspect ratio, resolution, reference images, person control |
281
+ | OpenAI | `gpt-image-1` | Generate, edit, aspect ratio, multi-output, output format (PNG/JPEG/WebP) |
282
+
283
+ ## Architecture
284
+
285
+ imgx separates **model-independent** and **model-dependent** concerns:
286
+
287
+ ```
288
+ MCP server (tool definitions, stdio transport) CLI (argument parsing, output formatting)
289
+ ↓ ↓
290
+ Core (Capability enum, ImageProvider interface, provider registry, file I/O, history)
291
+
292
+ Provider (model-specific API calls, capability declarations)
293
+ ```
294
+
295
+ MCP server and CLI are two entry points into the same core. Both call the same provider functions.
296
+
297
+ Each provider declares its supported capabilities. Adding a new provider means implementing the `ImageProvider` interface and registering it — no changes to the MCP or CLI layer.
298
+
299
+ ### Capability system
300
+
301
+ | Capability | Description |
302
+ |------------|-------------|
303
+ | `TEXT_TO_IMAGE` | Generate images from text prompts |
304
+ | `IMAGE_EDITING` | Edit images with text instructions |
305
+ | `ASPECT_RATIO` | Control output aspect ratio |
306
+ | `RESOLUTION_CONTROL` | Control output resolution |
307
+ | `MULTIPLE_OUTPUTS` | Generate multiple images per request |
308
+ | `REFERENCE_IMAGES` | Use reference images for guidance |
309
+ | `PERSON_CONTROL` | Control person generation in output |
310
+ | `OUTPUT_FORMAT` | Choose output format (PNG, JPEG, WebP) |
311
+
312
+ ## CLI
313
+
314
+ imgx-mcp also works as a standalone command-line tool.
315
+
316
+ ### Install
317
+
318
+ ```bash
319
+ npm install -g imgx-mcp
320
+ ```
321
+
322
+ Requires Node.js 18+.
323
+
324
+ ### Usage
325
+
326
+ ```bash
327
+ # Generate
328
+ imgx generate -p "A coffee cup on a wooden table, morning light" -o output.png
329
+
330
+ # Edit
331
+ imgx edit -i photo.png -p "Change the background to sunset" -o edited.png
332
+
333
+ # Iterative editing
334
+ imgx edit -i photo.png -p "Make the background darker"
335
+ imgx edit --last -p "Add warm lighting"
336
+ imgx edit --last -p "Crop to 16:9" -o final.png
337
+
338
+ # Undo / redo
339
+ imgx undo # Revert to previous image in session
340
+ imgx redo # Re-apply an undone edit
341
+
342
+ # History
343
+ imgx history # Show all sessions and entries
344
+ imgx history switch <session-id> # Switch to a different session
345
+ imgx history clear # Clear project history (interactive)
346
+ imgx history clear --yes # Clear without confirmation
347
+ imgx history clear --keep-files # Clear history but keep image files
348
+ imgx history clear --all # Clear ALL history across all projects
349
+
350
+ # Provider management
351
+ imgx providers # List providers and capabilities
352
+ imgx capabilities # Detailed capabilities of current provider
353
+ ```
354
+
355
+ ### CLI options
356
+
357
+ | Flag | Short | Description |
358
+ |------|-------|-------------|
359
+ | `--prompt` | `-p` | Image description or edit instruction (required) |
360
+ | `--output` | `-o` | Output file path (auto-generated if omitted) |
361
+ | `--input` | `-i` | Input image to edit (`edit` command only) |
362
+ | `--last` | `-l` | Use last output as input (`edit` command only) |
363
+ | `--aspect-ratio` | `-a` | `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `2:3`, `3:2` |
364
+ | `--resolution` | `-r` | `1K`, `2K`, `4K` |
365
+ | `--count` | `-n` | Number of images to generate |
366
+ | `--format` | `-f` | Output format: `png`, `jpeg`, `webp` (OpenAI only) |
367
+ | `--model` | `-m` | Model name |
368
+ | `--provider` | | Provider name (default: `gemini`) |
369
+ | `--output-dir` | `-d` | Output directory |
370
+
371
+ ### Configuration
372
+
373
+ ```bash
374
+ imgx config set api-key <key> --provider gemini # Save Gemini API key
375
+ imgx config set api-key <key> --provider openai # Save OpenAI API key
376
+ imgx config set model <name> # Set default model
377
+ imgx config set output-dir <dir> # Set default output directory
378
+ imgx config set aspect-ratio 16:9 # Set default aspect ratio
379
+ imgx config set resolution 2K # Set default resolution
380
+ imgx config list # Show all settings
381
+ imgx config get api-key # Show a specific setting (API key is masked)
382
+ imgx config path # Show config file location
383
+ ```
384
+
385
+ ### Project config (`.imgxrc`)
386
+
387
+ Generate a template with `imgx init`:
388
+
389
+ ```bash
390
+ imgx init
391
+ # creates .imgxrc in current directory
392
+ ```
393
+
394
+ Or create manually:
395
+
396
+ ```json
397
+ {
398
+ "defaults": {
399
+ "model": "gemini-2.5-flash-image",
400
+ "outputDir": "./assets/images",
401
+ "aspectRatio": "16:9"
402
+ }
403
+ }
404
+ ```
405
+
406
+ Project config is shared via Git. Do not put API keys in `.imgxrc`.
407
+
408
+ #### Project root configuration (3 tiers)
409
+
410
+ | Method | Scope | How to set |
411
+ |--------|-------|------------|
412
+ | `IMGX_PROJECT_ROOT` env var in client config | Per-client (highest priority) | Add to `env` in `claude_desktop_config.json`, `.mcp.json`, etc. |
413
+ | Auto-detection (MCP roots / `.imgxrc` search) | Automatic | Works on CLI agents (Claude Code, Gemini CLI). Not available on Claude Desktop |
414
+ | `imgx config set project-root` | All clients on the machine | Stored in user config (`~/.config/imgx/config.json` or `%APPDATA%\imgx\config.json`) |
415
+
416
+ Detection priority: env var → MCP roots → `.imgxrc` upward search → user config `projectRoot`.
417
+
418
+ History is saved to `<project-root>/.imgx/output-history.json` (project-scoped, not shared with other projects). Default image output goes to `<project-root>/.imgx/<session-id>/`. Relative paths in `output` and `output_dir` are resolved against the project root instead of the MCP server's working directory.
419
+
420
+ ### Settings resolution
421
+
422
+ 1. CLI flags (`--model`, `--output-dir`, etc.)
423
+ 2. Environment variables (`IMGX_MODEL`, `IMGX_OUTPUT_DIR`, etc.)
424
+ 3. Project config (`.imgxrc` — searched from current directory upward)
425
+ 4. User config (`~/.config/imgx/config.json` or `%APPDATA%\imgx\config.json`)
426
+ 5. Provider defaults
427
+
428
+ ### Output format
429
+
430
+ All CLI commands output JSON:
431
+
432
+ ```json
433
+ {"success": true, "filePaths": ["./output.png"]}
434
+ ```
435
+
436
+ ## Claude Code plugin
437
+
438
+ The plugin bundles MCP server + skill in one step. If you prefer not to configure `.mcp.json` and skill files manually:
439
+
440
+ ```
441
+ /plugin marketplace add somacoffeekyoto/imgx-mcp
442
+ /plugin install imgx-mcp@somacoffeekyoto-imgx-mcp
443
+ ```
444
+
445
+ Update: `/plugin` → installed → imgx-mcp → update. If the update shows no changes, uninstall and reinstall.
446
+
447
+ Uninstall: `/plugin uninstall imgx-mcp@somacoffeekyoto-imgx-mcp` then `/plugin marketplace remove somacoffeekyoto-imgx-mcp`.
448
+
449
+ ## Development
450
+
451
+ ```bash
452
+ git clone https://github.com/somacoffeekyoto/imgx-mcp.git
453
+ cd imgx-mcp
454
+ npm install
455
+ npm run bundle # TypeScript compile + esbuild bundle
456
+ ```
457
+
458
+ The build produces two bundles:
459
+
460
+ - `dist/mcp.bundle.js` — MCP server entry point
461
+ - `dist/cli.bundle.js` CLI entry point
462
+
463
+ ## Uninstall
464
+
465
+ ### MCP server
466
+
467
+ Remove the `imgx` entry from your tool's MCP configuration file.
468
+
469
+ ### Skill
470
+
471
+ Delete the `image-generation/` directory from `.claude/skills/` or `~/.claude/skills/`.
472
+
473
+ ### CLI
474
+
475
+ ```bash
476
+ npm uninstall -g imgx-mcp
477
+ ```
478
+
479
+ `npm uninstall` removes the package but does not delete configuration or generated files. Remove them manually if needed:
480
+
481
+ **Global configuration:**
482
+
483
+ ```bash
484
+ # Linux / macOS
485
+ rm -rf ~/.config/imgx/
486
+
487
+ # Windows (PowerShell)
488
+ Remove-Item -Recurse -Force "$env:APPDATA\imgx"
489
+ ```
490
+
491
+ **Project history and images:** Each project may have a `.imgx/` directory containing edit history and generated images. Remove it from each project as needed.
492
+
493
+ ```bash
494
+ rm -rf <project-root>/.imgx/
495
+ ```
496
+
497
+ ## License
498
+
499
+ MIT — [SOMA COFFEE KYOTO](https://github.com/somacoffeekyoto)
500
+
501
+ ## Links
502
+
503
+ - [Official page](https://somacoffee.net/imgx-mcp/)
504
+ - [GitHub](https://github.com/somacoffeekyoto/imgx-mcp)
505
+ - [npm](https://www.npmjs.com/package/imgx-mcp)
506
+ - [MCP Registry](https://registry.modelcontextprotocol.io)
507
+ - [SOMA COFFEE KYOTO](https://somacoffee.net)
508
+ - [X (@somacoffeekyoto)](https://x.com/somacoffeekyoto)
@@ -22071,6 +22071,11 @@ function findProjectRoot(startDir) {
22071
22071
  break;
22072
22072
  dir = parent;
22073
22073
  }
22074
+ const config = loadConfig();
22075
+ if (config.projectRoot) {
22076
+ _cachedProjectRoot = config.projectRoot;
22077
+ return config.projectRoot;
22078
+ }
22074
22079
  _cachedProjectRoot = null;
22075
22080
  return null;
22076
22081
  }
@@ -39958,7 +39963,7 @@ function runConfig(args) {
39958
39963
  const key = filtered[0];
39959
39964
  const value = filtered[1];
39960
39965
  if (!key || !value) {
39961
- fail("Usage: imgx config set <key> <value> [--provider <name>]\n Keys: api-key, provider, model, output-dir, aspect-ratio, resolution");
39966
+ fail("Usage: imgx config set <key> <value> [--provider <name>]\n Keys: api-key, provider, model, output-dir, aspect-ratio, resolution, project-root");
39962
39967
  }
39963
39968
  if (key === "output-dir") {
39964
39969
  setOutputDir(value, hasYes, hasNoMove);
@@ -40023,8 +40028,12 @@ function setKey(key, value, provider) {
40023
40028
  config.defaults.resolution = value;
40024
40029
  break;
40025
40030
  }
40031
+ case "project-root": {
40032
+ config.projectRoot = value;
40033
+ break;
40034
+ }
40026
40035
  default:
40027
- fail(`Unknown key: ${key}. Valid keys: api-key, provider, model, output-dir, aspect-ratio, resolution`);
40036
+ fail(`Unknown key: ${key}. Valid keys: api-key, provider, model, output-dir, aspect-ratio, resolution, project-root`);
40028
40037
  }
40029
40038
  saveConfig(config);
40030
40039
  success({ key, status: "saved" });
@@ -40110,8 +40119,11 @@ function getKey(key, provider) {
40110
40119
  case "resolution":
40111
40120
  success({ key, value: config.defaults?.resolution ?? null });
40112
40121
  return;
40122
+ case "project-root":
40123
+ success({ key, value: config.projectRoot ?? null });
40124
+ return;
40113
40125
  default:
40114
- fail(`Unknown key: ${key}. Valid keys: api-key, provider, model, output-dir, aspect-ratio, resolution`);
40126
+ fail(`Unknown key: ${key}. Valid keys: api-key, provider, model, output-dir, aspect-ratio, resolution, project-root`);
40115
40127
  }
40116
40128
  }
40117
40129
  function showAll() {
@@ -40281,7 +40293,7 @@ function runRedo() {
40281
40293
  }
40282
40294
 
40283
40295
  // build/cli/index.js
40284
- var VERSION2 = "1.4.0";
40296
+ var VERSION2 = "1.5.1";
40285
40297
  var HELP = `imgx v${VERSION2} \u2014 AI image generation and editing for MCP-compatible AI agents
40286
40298
 
40287
40299
  Commands:
Binary file
@@ -6847,6 +6847,11 @@ function findProjectRoot(startDir) {
6847
6847
  break;
6848
6848
  dir = parent;
6849
6849
  }
6850
+ const config2 = loadConfig();
6851
+ if (config2.projectRoot) {
6852
+ _cachedProjectRoot = config2.projectRoot;
6853
+ return config2.projectRoot;
6854
+ }
6850
6855
  _cachedProjectRoot = null;
6851
6856
  return null;
6852
6857
  }
@@ -69977,7 +69982,7 @@ function buildImageContent(images, paths, extra) {
69977
69982
  }
69978
69983
  var server = new McpServer({
69979
69984
  name: "imgx",
69980
- version: "1.4.0"
69985
+ version: "1.5.1"
69981
69986
  });
69982
69987
  initGemini();
69983
69988
  initOpenAI();
@@ -70287,17 +70292,22 @@ function fileUriToPath(uri) {
70287
70292
  }
70288
70293
  async function main() {
70289
70294
  const transport = new StdioServerTransport();
70290
- await server.connect(transport);
70291
- try {
70292
- const result = await server.server.listRoots();
70293
- if (result.roots.length > 0) {
70294
- const rootUri = result.roots[0].uri;
70295
- if (rootUri.startsWith("file://")) {
70296
- setProjectRoot(fileUriToPath(rootUri));
70295
+ server.server.oninitialized = async () => {
70296
+ try {
70297
+ const caps = server.server.getClientCapabilities();
70298
+ if (!caps?.roots)
70299
+ return;
70300
+ const result = await server.server.listRoots();
70301
+ if (result.roots.length > 0) {
70302
+ const rootUri = result.roots[0].uri;
70303
+ if (rootUri.startsWith("file://")) {
70304
+ setProjectRoot(fileUriToPath(rootUri));
70305
+ }
70297
70306
  }
70307
+ } catch {
70298
70308
  }
70299
- } catch {
70300
- }
70309
+ };
70310
+ await server.connect(transport);
70301
70311
  }
70302
70312
  main().catch((err) => {
70303
70313
  console.error("MCP server error:", err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imgx-mcp",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
4
4
  "mcpName": "io.github.somacoffeekyoto/imgx",
5
5
  "description": "AI image generation and editing for Claude Code, Codex CLI, and MCP-compatible AI agents",
6
6
  "type": "module",
@@ -144,11 +144,12 @@ Switch to a different editing session to continue work on a previous image chain
144
144
 
145
145
  ### clear_history
146
146
 
147
- Clear all edit history. Optionally delete image files.
147
+ Clear edit history for the current project. Optionally delete image files in managed directories.
148
148
 
149
149
  | Parameter | Required | Description |
150
150
  |-----------|----------|-------------|
151
- | `delete_files` | No | Delete image files in session directories (default: false) |
151
+ | `delete_files` | No | Delete image files in managed directories only (default: false) |
152
+ | `session_id` | No | Session ID to clear. Omit to clear all sessions |
152
153
 
153
154
  ### set_output_dir
154
155
 
@@ -214,10 +215,14 @@ Generate the same prompt with different providers to let the user choose:
214
215
  - **Be specific in prompts**: "A wooden table with a ceramic pour-over dripper, steam rising, soft natural light from left" works better than "coffee scene"
215
216
  - **Use edit_last for iteration**: Don't ask the user to specify file paths. Just use `edit_last` after any generation or edit
216
217
  - **Check provider capabilities**: Use `list_providers` if unsure what a provider supports
217
- - **Default output**: Images save to `~/Pictures/imgx/` with auto-generated filenames. Use `output` or `output_dir` to customize
218
+ - **Where `.imgx/` is created**: The `.imgx/` directory holds both edit history (`output-history.json`) and default image output. When a project root is detected, it's created at `<project-root>/.imgx/`. Without a project root, images go to `~/Pictures/imgx/` and history to `~/.config/imgx/`. All clients sharing the same project root share the same history
219
+ - **Default output**: Images save to `<project-root>/.imgx/<session-id>/` (project auto-detected). Falls back to `~/Pictures/imgx/` when no project is detected. Use `output` or `output_dir` to customize
220
+ - **Custom output_dir and history**: When `output_dir` is specified on `generate_image`, the path is recorded as session metadata in `output-history.json`. `edit_last` reads this to inherit the output location. Only image files go to the custom path — history always stays in `.imgx/` (or global config directory)
218
221
  - **Inline preview**: MCP responses include base64 image data for inline display in supported clients
219
222
  - **Undo/redo**: Use `undo_edit` and `redo_edit` to step through edit history. Each session holds up to 10 entries
220
223
  - **Sessions**: Each `generate_image` starts a new session. Use `edit_history` to see all sessions and `switch_session` to resume a previous one
224
+ - **Sequential naming**: When `output` specifies a filename, `edit_last` appends sequential numbers: `cover.png` → `cover-1.png` → `cover-2.png`. Undo automatically deletes discarded files
225
+ - **Project scope**: History is stored per-project in `<project-root>/.imgx/output-history.json`. `clear_history` only affects the current project
221
226
 
222
227
  ## CLI fallback
223
228