Files
gpt-edit/SETUP_GUIDE.md

223 lines
5.8 KiB
Markdown
Raw Permalink Normal View History

2025-08-26 01:31:42 +09:00
# GPT-Edit MCP Server Setup Guide
2025-08-25 00:39:39 +09:00
## 🚀 Quick Setup
2025-08-26 01:31:42 +09:00
### 1. Install GPT-Edit
2025-08-25 00:39:39 +09:00
```bash
# Clone or navigate to the project
2025-08-26 01:31:42 +09:00
cd D:\Project\gpt-edit
2025-08-25 00:39:39 +09:00
# Install dependencies
pip install -r requirements.txt
```
### 2. Configure API Key
Create a `.env` file in the project directory:
```env
# Required
OPENAI_API_KEY=sk-your-api-key-here
# Directory paths (optional)
INPUT_PATH=./input_images
GENERATED_IMAGES_PATH=./generated_images
```
### 3. Configure Claude Desktop
2025-08-26 01:31:42 +09:00
Add GPT-Edit to your Claude Desktop configuration file:
2025-08-25 00:39:39 +09:00
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
```json
{
"mcpServers": {
2025-08-26 01:31:42 +09:00
"gpt-edit": {
2025-08-25 00:39:39 +09:00
"command": "python",
2025-08-26 01:31:42 +09:00
"args": ["D:\\Project\\gpt-edit\\main.py"]"
2025-08-25 00:39:39 +09:00
}
}
}
```
### 4. Restart Claude Desktop
After saving the configuration, restart Claude Desktop completely.
## ⚙️ Configuration Options
### Environment Variables
Create a `.env` file in the project root:
```env
# Required
OPENAI_API_KEY=sk-your-api-key-here
# Directory Configuration (optional)
INPUT_PATH=./input_images # Source images directory
GENERATED_IMAGES_PATH=./generated_images # Output directory
# File naming and processing (optional with defaults)
OUTPUT_FILENAME_PREFIX=gptimage1
MAX_IMAGE_SIZE_MB=4
DEFAULT_TIMEOUT=30
ENABLE_AUTO_OPTIMIZE=true
SAVE_ORIGINALS=true
SAVE_PARAMETERS=true
LOG_LEVEL=INFO
```
### Environment Variable Reference
| Variable | Description | Default | Example |
|----------|-------------|---------|---------|
| `OPENAI_API_KEY` | **Required** - Your OpenAI API key | - | `sk-xxxxx` |
| `INPUT_PATH` | Directory for source images | `./input_images` | `./my_images` |
| `GENERATED_IMAGES_PATH` | Directory for output files | `./generated_images` | `./results` |
| `OUTPUT_FILENAME_PREFIX` | Prefix for output files | `gptimage1` | `my_edit` |
| `MAX_IMAGE_SIZE_MB` | Auto-optimize threshold | `4` | `1-10` |
| `DEFAULT_TIMEOUT` | API request timeout (seconds) | `30` | `60` |
| `ENABLE_AUTO_OPTIMIZE` | Auto WebP conversion | `true` | `true/false` |
| `SAVE_ORIGINALS` | Copy input images to output | `true` | `true/false` |
| `SAVE_PARAMETERS` | Save JSON parameters | `true` | `true/false` |
| `LOG_LEVEL` | Logging level | `INFO` | `DEBUG`, `WARNING` |
## 📁 File Structure
2025-08-26 01:31:42 +09:00
After running, GPT-Edit creates this structure:
2025-08-25 00:39:39 +09:00
```
2025-08-26 01:31:42 +09:00
gpt-edit/
2025-08-25 00:39:39 +09:00
├── input_images/ # Source images (INPUT_PATH)
│ ├── photo.jpg
│ ├── portrait.png
│ └── mask.png
├── generated_images/ # All output files (GENERATED_IMAGES_PATH)
│ ├── gptimage1_20250824_143022_000.png # Original (copied from input)
│ ├── gptimage1_20250824_143022_001.png # Edited output
│ └── gptimage1_20250824_143022_001.json # Edit parameters
├── temp/ # Temporary files (auto-cleaned)
2025-08-26 01:31:42 +09:00
└── gpt-edit.log # Debug log
2025-08-25 00:39:39 +09:00
```
## 🎯 Usage Examples in Claude
### Method 1: File-based editing (Recommended)
```
I placed photo.jpg in the input_images folder.
Can you edit it using edit_image_from_file to make it more vibrant?
```
### Method 2: Direct upload editing
```
I have an image I'd like to edit. Can you make it more colorful and vibrant?
[Upload image to Claude]
```
### Method 3: Mask-based editing
```
I have photo.jpg and mask.png in input_images/.
Can you use edit_with_mask_from_file to replace only the background?
```
## 🔍 Troubleshooting
### Common Issues and Solutions
#### "Server disconnected"
1. Check Python is installed: `python --version`
2. Verify dependencies: `pip list | grep mcp`
3. Check `.env` file exists with API key
2025-08-26 01:31:42 +09:00
4. Look at `gpt-edit.log` for errors
2025-08-25 00:39:39 +09:00
#### "API key not found"
1. Ensure `.env` file is in project root (same folder as `main.py`)
2. Check API key format: `OPENAI_API_KEY=sk-xxxxx`
3. No quotes needed around the key
#### "Method not found"
1. Update to latest code: `git pull`
2. Reinstall dependencies: `pip install -r requirements.txt`
3. Restart Claude Desktop completely
#### "Image too large"
- Enable auto-optimization: `ENABLE_AUTO_OPTIMIZE=true`
- Or increase limit: `MAX_IMAGE_SIZE_MB=8`
#### "Cannot find output images"
- Check `generated_images/` folder
- Files named: `gptimage1_{seed}_{date}_{time}_{number}.png`
- Look for most recent by timestamp
### Verify Installation
Test the setup:
```bash
python main.py
```
You should see:
```
Starting GPTEdit MCP Server
GPTEdit MCP Server is running...
Ready to process image editing requests
```
Press `Ctrl+C` to stop.
## 🛡️ Security Best Practices
1. **API Key Management**
- Store API key only in `.env` file
- Never commit `.env` to version control
- Add `.env` to `.gitignore`
2. **File Permissions**
- Ensure `generated_images/` is writable
- Keep sensitive files in project directory only
3. **Logging**
- Use `INFO` level for normal operation
- `DEBUG` only for troubleshooting
- Rotate logs periodically
## 📚 Additional Resources
- [OpenAI API Documentation](https://platform.openai.com/docs)
- [MCP Protocol Specification](https://modelcontextprotocol.io)
- [Project README](README.md)
- [Technical Specifications](TECHNICAL_SPECS.md)
## 💡 Tips
1. **Performance**
- Smaller images (512x512) process faster
- Batch editing is more efficient than individual edits
- WebP format reduces file sizes significantly
2. **Quality**
- Use clear, specific prompts
- Provide masks for precise edits
- Save parameters for reproducibility
3. **Organization**
- Files are grouped by session (same seed)
- JSON parameters allow replay of edits
- Timestamps help track edit history
## 🆘 Support
For issues:
1. Check `gptedit.log` for detailed errors
2. Verify OpenAI API key has credits
3. Ensure all paths are accessible
4. Create an issue on GitHub
---
2025-08-26 01:31:42 +09:00
Happy editing with GPT-Edit! 🎨