image-2-Agent
Allows generating images through an OpenAI-compatible image generation API.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@image-2-AgentGenerate a blue and white technology poster."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Local Codex + MCP Image Agent Demo
这是一个本地运行的图片生成 Demo,完整调用链为:
React → FastAPI → Codex CLI → STDIO MCP generate_image → OpenAI-compatible 中转 API → 本地存储
项目只包含单用户本地原型需要的功能:提交提示词、异步查询状态、预览和下载图片。它不包含登录、计费、历史记录、图片编辑或多用户并发。
环境要求
Python 3.13+
Node.js 20+
已安装并登录的 Codex CLI
支持
POST /images/generations的 OpenAI-compatible 图片中转 API
Related MCP server: EFLOWCODE Image MCP
安装
在项目根目录执行:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -e ".[dev]"
Copy-Item .env.example .env编辑 .env,至少填写:
IMAGE_API_BASE=https://relay.example.com/v1
IMAGE_API_KEY=your-local-key
IMAGE_MODEL=gpt-image-2真实 .env 已被 Git 忽略。不要把 Key 写进 .codex/config.toml、前端代码或日志。
安装前端依赖:
Set-Location frontend
npm install
Set-Location ..分层验证
先绕过 Codex 和 MCP 验证中转 API:
python scripts/test_relay_api.py成功后,图片会保存到 data/generated/test-output.<格式>。
项目级 .codex/config.toml 已配置 image_generator STDIO MCP。项目被 Codex 信任并激活虚拟环境后,可检查连接:
codex mcp list
codex进入 Codex TUI 后使用 /mcp,确认存在 image_generator 和 generate_image。也可以要求:
使用 image generator MCP 工具生成一张蓝白色科技风海报。启动
终端一,启动后端:
激活后,提示符前会出现 (.venv)
python -m pip install -e ".[dev]"
启动后端
python -m uvicorn backend.app.main:app --host 127.0.0.1 --port 8000 --reload
python -m uvicorn backend.app.main:app --host 127.0.0.1 --port 8000 --reload终端二,启动前端: Set-Location d:\project\image-2-Agent\frontend
Set-Location frontend
npm run dev浏览器打开 http://127.0.0.1:5173。
API
POST /api/generations:创建任务,返回job_idGET /api/generations/{job_id}:查询任务状态GET /api/images/{image_id}:预览图片GET /api/images/{image_id}/download:下载图片GET /api/health:健康检查
任务状态保存在内存中,服务重启后会丢失。图片和元数据分别保存在 data/generated 与 data/results。
测试与构建
pytest
Set-Location frontend
npm run buildProvider 和后端测试全部使用 mock,不会请求真实中转 API,也不会产生图片费用。真实端到端测试必须由本机已登录的 Codex 和有效中转 Key 完成。
常见错误
codex_not_found:后端账号找不到 Codex CLI。codex_not_authenticated:先在同一操作系统账号下登录 Codex。mcp_unavailable:检查虚拟环境、项目信任和.codex/config.toml。provider_auth_failed:检查 API Base、Key 和模型别名。provider_rate_limited:请求过于频繁,稍后重试。provider_quota_exhausted:中转 API 免费额度已用完,请充值或更换模型。provider_unavailable(no_available_channel):免费模型通道暂不可用,可改用gpt-image-2或稍后重试。provider_auth_failed:检查 API Key 是否来自当前平台,修改.env后需重启后端。provider_timeout:提高IMAGE_API_TIMEOUT_SECONDS或检查中转服务。tool_not_called:Codex 没有实际调用generate_image,结果会被拒绝。mcp_tool_cancelled/user cancelled MCP tool call:Codexexec在read-only沙箱下会取消 MCP 工具调用。将.env中CODEX_SANDBOX设为danger-full-access。provider_invalid_response(404 Invalid URL):IMAGE_API_BASE应填写到/v1,不要包含/images/generations。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityDmaintenanceA local MCP server for generating and editing images using OpenAI-compatible APIs. It provides text-to-image generation and image editing capabilities with configurable endpoints and saves output directly to local files.27MIT
- AlicenseBqualityCmaintenanceMCP server for generating and editing images using EFLOWCODE's Responses API. Supports text-to-image, image editing, batch editing, and multi-reference synthesis for MCP clients like Codex and Claude.56MIT
- Flicense-qualityDmaintenanceAn MCP server for AI-powered image processing (generate, edit, vary, analyze) supporting OpenAI, Gemini, Ideogram, and custom relay endpoints.
- Flicense-qualityCmaintenanceMCP server for generating and editing images via PackyAPI's gpt-image-2 model, enabling Codex to create and modify images based on prompts.
Related MCP Connectors
MCP server for Flux AI image generation
MCP server for Wan AI video generation
MCP server for Grok Imagine AI video generation
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/wqy-2002/image-2-Agent'
If you have feedback or need assistance with the MCP directory API, please join our Discord server