INSTALLATION.md•9.57 kB
# DALL-E MCP Server Installation Guide
Complete step-by-step installation guide for setting up the DALL-E MCP server with various AI clients.
## Prerequisites
Before installing, ensure you have:
- **Node.js** (version 18 or higher) - [Download from nodejs.org](https://nodejs.org/)
- **OpenAI API Key** - [Get from OpenAI Platform](https://platform.openai.com/api-keys)
- **MCP-compatible client** (Claude Desktop, ChatGPT, or custom implementation)
## Step 1: Download and Setup
### Option A: Clone from Repository
```bash
git clone <repository-url>
cd dall-e-mcp-server
```
### Option B: Download and Extract
1. Download the project files
2. Extract to your desired directory
3. Open terminal in the project directory
## Step 2: Install Dependencies
```bash
# Install all required packages
npm install
# Verify installation
npm list
```
Expected output should show packages like:
- `@modelcontextprotocol/sdk`
- `openai`
- `fs-extra`
## Step 3: Configure Environment
### Create Environment File
```bash
# Copy the example environment file
cp .env.example .env
```
### Edit Environment Variables
Open `.env` file and configure:
```env
# Required: Your OpenAI API Key
OPENAI_API_KEY=sk-your-actual-openai-api-key-here
# Optional: Customize defaults
DEFAULT_IMAGE_SIZE=1024x1024
DEFAULT_QUALITY=standard
OUTPUT_DIRECTORY=./generated_images
```
**⚠️ Important:** Replace `sk-your-actual-openai-api-key-here` with your real OpenAI API key.
### Verify API Key
Test your API key works:
```bash
# Quick test (optional)
node -e "
const OpenAI = require('openai').default;
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
console.log('API key configured correctly!');
"
```
## Step 4: Build the Server
```bash
# Compile TypeScript to JavaScript
npm run build
# Verify build succeeded
ls dist/
```
You should see `index.js` and related files in the `dist/` directory.
## Step 5: Test Installation
```bash
# Quick test - server should start and show "running on stdio"
timeout 3s npm start || echo "✅ Server test completed"
# On Windows (PowerShell):
# Start-Job { npm start } | Wait-Job -Timeout 3 | Remove-Job
```
Expected output: `DALL-E MCP Server running on stdio`
---
## Client Integration
Choose your AI client and follow the appropriate setup:
### 🔷 Claude Desktop Integration
#### macOS/Linux Setup
1. **Find config location:**
```bash
# Config file location
~/.config/claude/claude_desktop_config.json
```
2. **Create/edit config file:**
```bash
# Create directory if it doesn't exist
mkdir -p ~/.config/claude
# Edit config file
nano ~/.config/claude/claude_desktop_config.json
```
3. **Add server configuration:**
```json
{
"mcpServers": {
"dall-e-image-generator": {
"command": "node",
"args": ["/FULL/PATH/TO/dall-e-mcp-server/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-actual-api-key-here"
}
}
}
}
```
4. **Update the path:**
```bash
# Get full path to your project
pwd
# Copy this path and replace /FULL/PATH/TO/dall-e-mcp-server above
```
#### Windows Setup
1. **Find config location:**
```
%APPDATA%\Claude\claude_desktop_config.json
```
2. **Create/edit config file:**
- Open File Explorer
- Type `%APPDATA%\Claude` in address bar
- Create `claude_desktop_config.json` if it doesn't exist
3. **Add server configuration:**
```json
{
"mcpServers": {
"dall-e-image-generator": {
"command": "node",
"args": ["C:\\FULL\\PATH\\TO\\dall-e-mcp-server\\dist\\index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-actual-api-key-here"
}
}
}
}
```
4. **Get Windows path:**
```cmd
# In your project directory
cd
# Copy this path and use double backslashes in config
```
#### Restart Claude Desktop
- Completely quit Claude Desktop
- Restart the application
- The MCP server should now be available
### 🔷 ChatGPT Integration
ChatGPT integration depends on your setup:
#### OpenAI API with MCP Support
```json
{
"mcpServers": {
"dall-e-generator": {
"command": "node",
"args": ["/path/to/dall-e-mcp-server/dist/index.js"],
"env": {
"OPENAI_API_KEY": "your-api-key"
}
}
}
}
```
#### Custom Implementation
Use the OpenAI Agents SDK or Responses API to connect to the MCP server.
### 🔷 Other MCP Clients
For custom MCP clients, connect via stdio transport:
```typescript
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
const transport = new StdioClientTransport({
command: "node",
args: ["/path/to/dall-e-mcp-server/dist/index.js"],
env: {
OPENAI_API_KEY: "your-api-key"
}
});
const client = new Client({ name: "dall-e-client", version: "1.0.0" }, {});
await client.connect(transport);
```
---
## Step 6: Verify Installation
### Test with Claude Desktop
1. Open Claude Desktop
2. Start a new conversation
3. Try generating an image:
```
Can you generate an image of a sunset over mountains?
```
4. Claude should use the `generate_image` tool and save the image locally
### Check Generated Images
```bash
# Check if images are being saved
ls generated_images/
# View a generated image (macOS)
open generated_images/dalle_*.png
# View a generated image (Linux)
xdg-open generated_images/dalle_*.png
# View a generated image (Windows)
start generated_images\dalle_*.png
```
---
## Troubleshooting
### Common Issues
#### ❌ "OPENAI_API_KEY is missing"
**Solution:**
1. Verify `.env` file exists and contains your API key
2. Check that the API key starts with `sk-`
3. Ensure no extra spaces around the key
#### ❌ "Command not found: node"
**Solution:**
1. Install Node.js from [nodejs.org](https://nodejs.org/)
2. Restart terminal after installation
3. Verify with: `node --version`
#### ❌ "Cannot find module"
**Solution:**
```bash
# Reinstall dependencies
rm -rf node_modules package-lock.json
npm install
npm run build
```
#### ❌ "Permission denied"
**Solution:**
```bash
# Make script executable (macOS/Linux)
chmod +x dist/index.js
# Or run with explicit node command
node dist/index.js
```
#### ❌ Claude Desktop doesn't see the server
**Solution:**
1. Check config file path is correct
2. Verify JSON syntax is valid
3. Use absolute paths, not relative paths
4. Restart Claude Desktop completely
5. Check Claude Desktop logs/console for errors
#### ❌ "Failed to download image"
**Solution:**
1. Check internet connection
2. Verify OpenAI API credits/billing
3. Try a simpler prompt first
### Debug Mode
Enable detailed logging:
```bash
# Set debug environment
export DEBUG=dall-e-mcp:*
# Run server with debug info
npm run dev
```
### Check Server Status
```bash
# Test server manually
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | node dist/index.js
```
Expected response should include the `generate_image` tool.
### Validate Configuration
Create a test script:
```bash
# Create test file
cat > test_config.js << 'EOF'
const config = require('./claude_desktop_config.json');
console.log('Config loaded successfully:', config);
EOF
# Run test
node test_config.js
```
---
## Advanced Configuration
### Custom Output Directory
```env
OUTPUT_DIRECTORY=/custom/path/to/images
```
### Multiple API Keys (Enterprise)
```json
{
"mcpServers": {
"dall-e-prod": {
"command": "node",
"args": ["/path/to/dall-e-mcp-server/dist/index.js"],
"env": {
"OPENAI_API_KEY": "prod-key-here"
}
},
"dall-e-dev": {
"command": "node",
"args": ["/path/to/dall-e-mcp-server/dist/index.js"],
"env": {
"OPENAI_API_KEY": "dev-key-here",
"OUTPUT_DIRECTORY": "./dev_images"
}
}
}
}
```
### System Service (Optional)
For production deployments, create a system service:
#### Linux (systemd)
```bash
# Create service file
sudo nano /etc/systemd/system/dall-e-mcp.service
```
```ini
[Unit]
Description=DALL-E MCP Server
After=network.target
[Service]
Type=simple
User=your-username
WorkingDirectory=/path/to/dall-e-mcp-server
Environment=OPENAI_API_KEY=your-key
ExecStart=/usr/bin/node dist/index.js
Restart=always
[Install]
WantedBy=multi-user.target
```
```bash
# Enable and start service
sudo systemctl enable dall-e-mcp
sudo systemctl start dall-e-mcp
```
---
## Security Notes
1. **Never commit `.env` files** - they contain your API key
2. **Restrict file permissions:**
```bash
chmod 600 .env
```
3. **Use environment variables** in production instead of `.env` files
4. **Monitor API usage** to prevent unexpected charges
5. **Rotate API keys** regularly
---
## Next Steps
After successful installation:
1. **Read the [README.md](./README.md)** for usage examples
2. **Experiment with different prompts** and parameters
3. **Check the `generated_images/` directory** for your creations
4. **Monitor OpenAI API usage** in your dashboard
5. **Customize the server** for your specific needs
---
## Support
If you encounter issues:
1. **Check this troubleshooting section** first
2. **Verify your OpenAI API key** and billing status
3. **Test with a minimal prompt** to isolate issues
4. **Check MCP client logs** for detailed error messages
5. **Ensure all prerequisites** are properly installed
---
**🎉 Congratulations!** Your DALL-E MCP server should now be ready to generate amazing images through your AI client!