AI-Powered Photoshop Automation via Model Context Protocol (MCP)
Project description
PSForge
๐จ AI-Powered Photoshop Automation via Model Context Protocol
PSForge is a comprehensive MCP (Model Context Protocol) server that bridges AI assistants like Claude with Adobe Photoshop. It provides 61 powerful tools for complete Photoshop automation through a clean, well-architected Python interface.
โก Quick Start: See QUICKSTART.md for setup and testing guide
โจ Key Features
- ๐ ๏ธ 61 Photoshop Tools - Complete automation from documents to filters
- ๐ง Context On-Demand - Query PS state when needed, zero overhead on normal operations
- โก Batch Execution - Run multiple operations in a single COM round trip
- ๐ Robust & Reliable - Auto-retry with exponential backoff, process monitoring
- ๐๏ธ Clean Architecture - Four-layer design with auto-discovery
- ๐ฏ Type-Safe - Full type annotations and parameter validation
- ๐ Comprehensive Logging - Debug logs for troubleshooting
- ๐ Easy to Extend - Drop a new tool file, it auto-registers
๐ Requirements
| Component | Version | Notes |
|---|---|---|
| Python | 3.10 - 3.14 | Required |
| OS | Windows | Uses COM interface |
| Photoshop | CC 2019+ | Must be running |
| MCP Client | Any | Claude Desktop, Cursor, etc. |
๐ Quick Installation
Using Poetry (Recommended)
# Clone or download the project
cd psforge
# Install dependencies
poetry install
# Verify installation
poetry run python check_tools.py
Using pip
cd psforge
pip install -e .
โ๏ธ Configuration
For Claude Desktop
Step 1: Edit %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"psforge": {
"command": "D:\\your-path\\PSForge\\start_psforge.bat"
}
}
}
โ ๏ธ Important: Replace the path with your actual project path!
Step 2: Restart Claude Desktop
Step 3: Test in Claude:
Get Photoshop session info using PSForge
For Cursor / Other MCP Clients
Configure according to your client's documentation:
- Command:
poetry run psforge(or justpsforgeif installed globally) - Protocol: stdio
- Working Directory: Your psforge installation path
See claude_desktop_config.example.json for reference.
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AI Client (Claude / Cursor) โ
โ Natural Language Commands โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Protocol (stdio)
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Layer 1: MCP Server (FastMCP) โ
โ โข Auto-discovery & Registration โ
โ โข server.py + registry.py โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Tool Calls
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Layer 2: Tools (61 tools) โ
โ โข 15 modules by functionality โ
โ โข Full parameter validation โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PS Operations
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Layer 3: PS Adapter โ
โ โข Connection Management โ
โ โข Context Tracking โ
โ โข Process Guard & Retry โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Windows COM / ExtendScript
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Layer 4: Adobe Photoshop โ
โ โข Direct API Calls โ
โ โข JavaScript Execution โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ ๏ธ Tool Categories (61 Total)
๐ Document Tools (5)
create_document- Create new document with full control (size, resolution, color mode)open_image- Open image file as documentsave_document- Save as PSD/JPG/PNG with quality settingsclose_document- Close with or without savingcrop_document- Crop to specified bounds
๐ Layer Tools (6)
create_layer- Create new empty layerdelete_layer- Delete active layer (with safety checks)duplicate_layer- Duplicate layer with optional renamemerge_visible_layers- Merge all visible layersflatten_image- Flatten to single background layerrasterize_layer- Convert text/shape/smart object to pixels
๐จ Layer Properties (6)
set_layer_opacity- Opacity 0-100%set_layer_blend_mode- 27 blend modes (Normal, Multiply, Screen, Overlay, etc.)set_layer_visibility- Show/hide layerset_layer_locked- Lock/unlock layerrename_layer- Rename active layerfill_layer- Fill with solid RGB color
๐ Layer Transform (5)
move_layer- Translate by X/Y pixelsscale_layer- Scale by percentage (proportional or independent W/H)rotate_layer- Rotate by degreesfit_layer_to_document- Fit or fill canvasresize_image- Resize entire document (5 resample methods)
๐ Layer Ordering (5)
move_layer_up/move_layer_down- Move one positionmove_layer_to_top/move_layer_to_bottom- Move to extremesmove_layer_to_position- Position relative to named layer (above/below)
โ๏ธ Text Tools (5)
create_text_layer- Create with content, position, font, size, colorupdate_text_content- Change text contentset_text_font- Set font family and/or sizeset_text_color- Set RGB colorset_text_alignment- Left/Center/Right alignment
๐ญ Filter Tools (4)
apply_gaussian_blur- Gaussian blur (radius 0.1-250)apply_motion_blur- Motion blur (angle + distance)apply_sharpen- Unsharp Mask (amount/radius/threshold)apply_noise- Add noise (Uniform/Gaussian, monochromatic option)
๐ Adjustment Tools (6)
adjust_brightness_contrast- Brightness (-150 to 150) / Contrast (-50 to 100)adjust_hue_saturation- Hue/Saturation/Lightness adjustmentsauto_levels- Automatic levels correctionauto_contrast- Automatic contrast correctiondesaturate- Convert to grayscaleinvert- Invert colors
โฌ Selection Tools (4)
select_all- Select entire documentselect_rectangle- Create rectangular selectiondeselect- Remove selectioninvert_selection- Invert current selection
๐ผ๏ธ Image Tools (2)
place_image- Place external image as new layerget_layers- Get comprehensive info on all layers
๐ญ Mask Tools (3)
create_layer_mask- Reveal-all or hide-all maskapply_layer_mask- Apply and remove maskdelete_layer_mask- Delete mask without applying
โฎ๏ธ History Tools (3)
undo- Undo multiple steps (1-50)redo- Redo multiple steps (1-50)get_history- Get list of all history states
โก Action & Script Tools (2)
play_action- Execute Photoshop action from action setexecute_script- Run arbitrary ExtendScript/JavaScript
โน๏ธ Session Tools (3)
get_session_info- PS version, running status, document countget_active_document_info- Detailed document informationget_selection_info- Current selection bounds and dimensions
๐ Batch Tools (2)
execute_batch- Run multiple ExtendScript snippets in a single COM round tripselect_layer_by_name- Activate a layer by name (recursive search including layer groups)
๐ก Usage Examples
Example 1: Create a Social Media Banner
You: Create a 1200x628 Instagram post with a blue background and centered white text saying "Hello PSForge"
Claude will:
1. create_document(width=1200, height=628, name="Instagram Post")
2. create_layer(name="Background")
3. fill_layer(red=52, green=152, blue=219) # Nice blue
4. create_text_layer(text="Hello PSForge", x=600, y=314, font_size=72, color_r=255, color_g=255, color_b=255)
5. set_text_alignment(alignment="CENTER")
Example 2: Batch Apply Effects
You: Apply a 5px Gaussian blur and increase brightness by 20 on the current layer
Claude will:
1. apply_gaussian_blur(radius=5)
2. adjust_brightness_contrast(brightness=20, contrast=0)
Example 3: Complex Layer Manipulation
You: Duplicate the current layer, move it down, reduce opacity to 50%, and apply motion blur
Claude will:
1. duplicate_layer()
2. move_layer_down()
3. set_layer_opacity(opacity=50)
4. apply_motion_blur(angle=0, radius=20)
๐งช Testing
Quick Connection Test
# Requires Photoshop to be running
poetry run python test_connection.py
Expected output:
โ
All tests passed! PSForge is working correctly
Verify All Tools
poetry run python check_tools.py
Expected output:
โ
Success! All 61 tools registered
Run Unit Tests
poetry run pytest tests/unit/
Run Integration Tests
# โ ๏ธ Warning: These tests will create/modify documents in Photoshop
poetry run pytest tests/integration/
๐ง Development
Project Structure
psforge/
โโโ psforge/
โ โโโ server.py # MCP server entry point
โ โโโ registry.py # Auto-discovery system
โ โโโ decorators.py # Error handling & logging
โ โโโ app.py # Version and metadata
โ โโโ ps_adapter/ # Photoshop interface layer
โ โ โโโ application.py # Connection singleton + retry
โ โ โโโ context.py # On-demand state querying
โ โ โโโ process_guard.py # Health check & auto-restart
โ โ โโโ utils.py # Helpers & validation
โ โโโ tools/ # 15 tool modules (61 tools)
โ โ โโโ session_tools.py
โ โ โโโ document_tools.py
โ โ โโโ layer_tools.py
โ โ โโโ batch_tools.py
โ โ โโโ ... (11 more)
โ โโโ resources/
โ โโโ (resource providers)
โโโ tests/
โ โโโ unit/ # Unit tests
โ โโโ integration/ # Integration tests
โโโ test_connection.py # Quick connection test
โโโ check_tools.py # Tool registration checker
โโโ pyproject.toml # Dependencies & config
โโโ README.md # This file
โโโ README_ZH.md # ไธญๆๆๆกฃ
โโโ QUICKSTART.md # Quick start guide
โโโ CHANGELOG.md # Version history
โโโ .gitignore # Git ignore rules
Adding Custom Tools
PSForge uses an auto-discovery system. Just drop a new Python file into tools/:
Example: psforge/tools/my_custom_tools.py
from psforge.decorators import debug_tool, log_tool_call
from psforge.ps_adapter import PhotoshopApp
from psforge.registry import register_tool
def register(mcp):
"""This function is called automatically by the registry."""
registered_tools = []
@debug_tool
@log_tool_call
def my_awesome_tool(param: str) -> dict:
"""Do something awesome in Photoshop.
Args:
param: Parameter description.
Returns:
dict: Operation result.
"""
ps_app = PhotoshopApp()
doc = ps_app.get_active_document()
if not doc:
return {
"success": False,
"error": "No active document",
}
try:
# Your implementation here
result = ps_app.execute_javascript(f'alert("{param}");')
return {
"success": True,
"message": f"Executed with param: {param}",
}
except Exception as e:
return {
"success": False,
"error": str(e),
}
registered_tools.append(register_tool(mcp, my_awesome_tool, "my_awesome_tool"))
return registered_tools
That's it! The tool will be automatically discovered and registered on next server start.
Code Quality
# Format code (line-length 120)
poetry run ruff format .
# Lint code
poetry run ruff check .
# Fix auto-fixable issues
poetry run ruff check --fix .
๐ Troubleshooting
Problem: "Could not connect to Photoshop"
Solutions:
- Ensure Photoshop is running
- Check if scripting is enabled: Preferences โ General โ Enable Remote Connections
- Restart Photoshop
- Check
psforge_debug.logfor detailed errors
Problem: "Operation timed out"
Solutions:
- Default timeout is 30 seconds
- PSForge will auto-kill and restart PS on timeout
- Check if Photoshop has dialog boxes open (should be auto-disabled)
- Verify PS isn't frozen or unresponsive
Problem: Tools not showing in Claude
Solutions:
- Verify
claude_desktop_config.jsonpath is correct - Use absolute path for
start_psforge.bat(no~or relative paths) - Restart Claude Desktop completely
- Check Claude Desktop logs:
%APPDATA%\Claude\logs\
Problem: Import errors
Solutions:
# Reinstall dependencies
poetry install
# Or with pip
pip install -e .
๐ Debug Logging
PSForge automatically logs to psforge_debug.log in the working directory.
View logs:
# Windows
type psforge_debug.log
# Or open in editor
notepad psforge_debug.log
Log levels:
INFO- General operation flowDEBUG- Detailed execution stepsWARNING- Non-critical issuesERROR- Failures and exceptions
๐ License
MIT License - See LICENSE file for details
๐ค Contributing
Contributions are welcome! Please ensure:
- โ All functions have complete docstrings (Google style)
- โ Full type annotations on all parameters and returns
- โ
Tests pass:
poetry run pytest - โ
Code formatted:
poetry run ruff format . - โ
Linting passes:
poetry run ruff check . - โ
Tools return
{"success": bool, ...}format (noget_context_info()in tool returns)
Built with:
- photoshop-python-api - Photoshop Python API
- Model Context Protocol - MCP specification
- mcp - MCP Python SDK
๐ Documentation
- Quick Start Guide - Get up and running in 5 minutes
- Changelog - Version history and changes
- ไธญๆๆๆกฃ - Chinese documentation
๐ฆ Version History
v0.2.0 (2026-06-01)
Performance: Removed automatic get_context_info() from all tool returns โ each tool call now saves one COM round trip. Fixed 3ร3 double retry nesting down to single-layer retry.
New tools: execute_batch (batch JS execution in one COM call), select_layer_by_name (recursive layer lookup). Total: 61 tools / 15 modules.
Cleanup: Removed dead code โ ActionManager placeholder, unused execute_with_timeout, OperationCounter, and redundant schema building in register_tool.
See CHANGELOG.md for full details.
v0.1.0 (2024-05-26)
Initial release. 59 tools, 4-layer architecture, auto-discovery registration, context-aware returns.
โญ Star History
If you find PSForge useful, please consider giving it a star! โญ
Made with โค๏ธ for the Photoshop automation community
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file psforge-0.2.0.tar.gz.
File metadata
- Download URL: psforge-0.2.0.tar.gz
- Upload date:
- Size: 32.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e1da02fbda6c677b0d21587f361a3b9f909ad4fc90f98f613df6c9a35cb0e33
|
|
| MD5 |
a0ac87548432b1041f32a0fa611fc4f2
|
|
| BLAKE2b-256 |
cc72210e3626a82337d499388c5d79bab51b33f031334c5b4a8d32a579c75feb
|
File details
Details for the file psforge-0.2.0-py3-none-any.whl.
File metadata
- Download URL: psforge-0.2.0-py3-none-any.whl
- Upload date:
- Size: 48.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b29fea647a6964d2caf25e831cd573757bdca342b7bf3c02c8ad6169e634d0d0
|
|
| MD5 |
84ef81d27baef1e151e72f520904d86e
|
|
| BLAKE2b-256 |
ad7e5adf499652d2134b637f215eca203eaa867e098fba67e2207f1e3ae37343
|