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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。