Description
## Prerequisites
- Node.js >= 18 and npm
- OpenAI API key (with access to o1 models like `o1-preview` or `o1-mini`)
- fal.ai account and API key (for Flux image generation)
- ngrok account (free tier sufficient for local tunneling)
- ChatGPT Desktop app (latest version)
- Git (for cloning the repository)
## Setup for ChatGPT Desktop
### Option 1: Using Developer Mode (Recommended)
1. Open ChatGPT Desktop and go to **Settings → Apps & Connectors → Advanced settings → Enable Developer Mode**.
2. Start the MCP server locally (see Start Command above). Note the local URL: `http://localhost:3000`.
3. Expose the server publicly using ngrok:
```bash
ngrok http 3000
```
Copy the HTTPS URL (e.g., `https://abc123.ngrok.io`).
4. In ChatGPT Desktop, go to **Settings → Apps & Connectors → Create**.
5. Enter the MCP endpoint URL: `https://abc123.ngrok.io/mcp` (append `/mcp`).
6. Save the connector. It will appear in your apps list for use in chats.
### Option 2: Local Server Setup
For persistent local use without ngrok:
1. Run the server: `npm start`.
2. Use Cloudflare Tunnel:
Install `cloudflared`, then:
```bash
cloudflared tunnel --url http://localhost:3000
```
Use the provided HTTPS URL for the ChatGPT connector (as in Option 1).
3. Configure ChatGPT Desktop connector with the tunnel's `/mcp` endpoint.
## Configuration Examples
### Basic Setup
Create a `.env` file in the server directory:
```env
OPENAI_API_KEY=sk-your-openai-api-key
FAL_KEY=your-fal-ai-key
PORT=3000
```
Run `npm start`. Supports default `o1-preview` for reasoning and `flux-schnell` for images.
### Advanced Setup
Extend `.env` for custom models/parameters:
```env
OPENAI_API_KEY=sk-your-openai-api-key
FAL_KEY=your-fal-ai-key
OPENAI_MODEL=o1-mini
FLUX_MODEL=flux-pro
MAX_TOKENS=4096
TEMPERATURE=0.7
```
Restart server. Allows fine-tuned streaming chats and image variants.
### Production Setup
For reliable use:
1. Use PM2: `npm install -g pm2`, then `pm2 start npm --name "mcp-o1-flux" -- start`.
2. Deploy to VPS (e.g., Render, Fly.io) with HTTPS via Let's Encrypt.
3. `.env`:
```env
OPENAI_API_KEY=sk-prod-key
FAL_KEY=prod-fal-key
NODE_ENV=production
```
4. Use domain like `https://yourdomain.com/mcp` in ChatGPT connector.
## Using with ChatGPT
- **Available Tools**: `o1_reason` for advanced reasoning with streaming chat completions and parameter control (e.g., temperature, max tokens); `flux_image` for generating high-quality images from prompts.
- **Example Prompts**:
- Reasoning: "Use o1_reason to solve this puzzle: [describe problem]. Explain step-by-step."
- Images: "Generate a Flux image of a futuristic cityscape at sunset."
- Combined: "Reason with o1 about climate change impacts, then illustrate with a Flux image."
- **Limitations/Considerations**: API usage incurs OpenAI/fal.ai costs; o1 models have longer latency; rate limits apply (monitor via provider dashboards); requires stable internet for tunneling.
## Troubleshooting
- **Server not starting**: Check Node.js version (`node -v`) and `npm install`. Verify API keys.
- **ngrok/Cloudflare errors**: Ensure account auth (`ngrok authtoken <token>`). Use HTTPS only.
- **Connector fails in ChatGPT**: Confirm `/mcp` endpoint responds (curl `https://your-url/mcp`). Check browser console for CORS/auth issues.
- **Tool not appearing**: Restart ChatGPT Desktop after adding connector. Ensure server logs show no errors.
- **API errors**: Validate keys have quotas (o1 access via OpenAI playground); Flux prompts must be safe (no violations).
- **Port conflict**: Change `PORT` in `.env` and restart.
```