Image Generation MCP Server
Enables image generation and editing via ChatGPT web without API keys, saving images locally with conversation-aware editing.
README
Image Generation MCP Server
An MCP server that automates image generation on ChatGPT web, edits images by instruction, and saves them locally — no API keys, no paid OpenAI API.
Features
- Generate images in ChatGPT web from a prompt
- Edit images by instruction (text-based, in the conversation)
- Conversation-aware: returns a
conversation_idso edits can resume the same thread - Flexible output: default Downloads folder, configurable folder, or per-call
save_pathandfilename - Aspect ratio hints (
cuadrada/horizontal/vertical) injected into the prompt - Persistent session: log in once; the server reuses the session headlessly
- Policy rejection detection: fails fast with a clear message instead of waiting for timeout
- Single browser tab reused across all requests
Requirements
- Node.js >= 18
- Google Chrome installed (used headless for automation)
- An OpenAI account with access to ChatGPT (login required once)
Installation
npm install
npm run build
Uses the system Chrome — no
npx playwright install chromiumneeded.
Usage in an MCP client
Add the server to your MCP client config (e.g. Command Code, Claude Desktop):
{
"mcpServers": {
"image-generation": {
"command": "node",
"args": ["/path/to/image-generation/dist/index.js"],
"cwd": "/path/to/image-generation"
}
}
}
For development (hot reload):
{
"mcpServers": {
"image-generation": {
"command": "npx",
"args": ["tsx", "/path/to/image-generation/src/index.ts"],
"cwd": "/path/to/image-generation"
}
}
}
First run (manual login)
- Start the server without a saved session (e.g.
npx tsx src/index.ts). Since no session is detected, it opens a visible window with the ChatGPT login page. - Log in to ChatGPT in that window (your normal account).
- The session is saved in the persistent profile
~/.image-generation/browser-profile. - From then on, the server runs headless (no window) and reuses the session.
To reset the session (expired or different account), delete the profile:
rm -rf ~/.image-generation/browser-profile
Tools
| Tool | Description |
|---|---|
generate_image(prompt, save_path?, filename?, aspect_ratio?) |
Generates an image and saves it. Returns the absolute path and the conversation_id. |
edit_image(edit_instruction, conversation_id?, save_path?, filename?, aspect_ratio?) |
Edits the image in the given conversation (or the most recent) and saves the result. |
get_conversation_id() |
Returns the current conversation ID (to resume it when editing). |
get_output_folder() |
Returns the current output folder. |
set_output_folder(folder) |
Changes the output folder (must exist). |
get_session_status() |
Indicates whether the ChatGPT session is active. |
Parameters
prompt/edit_instruction: required text.conversation_id: ID returned bygenerate_image; if omitted, edits the current conversation.save_path: optional destination directory (defaults to the configured folder or Downloads).filename: optional file name; invalid characters are sanitized,.pngis added if missing, and a numeric suffix avoids overwrites.aspect_ratio:cuadrada|horizontal|vertical(optional). Injected into the prompt (e.g.(formato 16:9)) since ChatGPT does not expose a UI control for it.
Configuration
The server persists its config in ~/.image-generation/config.json:
{
"outputFolder": "C:/Users/<user>/Downloads",
"browserProfilePath": "C:/Users/<user>/.image-generation/browser-profile",
"generationTimeoutMs": 180000
}
Behavior
- Headless: after the initial login, no window opens; a single persistent page is reused for all requests.
- Single tab: exactly one page is always kept active.
- Policy rejection: if ChatGPT rejects generation (content policy message), the server fails fast with the message instead of waiting for the timeout.
- Persistent session: the profile stores cookies; the session is reused across runs.
Development
npm run build # compile TypeScript
npm run typecheck # type-check without emitting
npm run dev # run with hot reload
Limitations
- Requires an active ChatGPT session (manual login the first time).
- Selectors target ChatGPT's current DOM; if the site changes,
src/selectors.tsmay need updates. - The visual editor (brush, region selection, canvas controls) is not automated — it's a proprietary canvas without accessible controls. Editing is done via chat instruction.
- Cloudflare may block headless on some networks; the real Chrome user agent mitigates this.
License
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.