ImageRouter
Allows image generation through OpenAI Codex as a provider, with OAuth or manual token authentication.
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., "@ImageRouterGenerate a watercolor painting of a mountain lake at dawn"
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.
ImageRouter
Local MCP image-generation router for xAI/Grok, Antigravity, and OpenAI Codex with ordered fallback, a local Playground, and an OpenAI-compatible image endpoint.
ImageRouter is a local image-generation control plane for developer tools and AI agents. It exposes two MCP tools that route requests through configured xAI, Antigravity, and OpenAI Codex accounts.
ImageRouter v1 is intentionally narrow:
One image per request.
MCP over stdio and Streamable HTTP.
POST /v1/images/generationsfor REST clients.Ordered provider and account fallback.
No gallery, image cache, prompt history, chat, audio, video, search, or CLI integrations.
Prompts pass through unchanged. The prompt pipeline is a no-op extension point for a later template/enhancer phase.
Connector status
Provider | Status | Authentication | Notes |
xAI / Grok | Stable | API key or OAuth | Uses the published xAI Images API. |
Antigravity | Experimental | OAuth or manual token | Uses a private Code Assist endpoint that may change. |
OpenAI Codex | Experimental | OAuth or manual token | Uses a private ChatGPT Codex Responses endpoint and requires an eligible account. |
Experimental connector failures are isolated to their route attempt; they do not crash the MCP server.
Related MCP server: Grok Image MCP
Requirements
Node.js 20 or newer.
A supported provider account.
A local MCP client for MCP usage.
Quick start
Download and install
Requirements: Node.js 20+ and git.
Windows PowerShell, macOS, and Linux:
git clone https://github.com/Duylamneuuu/imagerouter.git
cd imagerouter
npm installOptional local environment file:
# macOS/Linux
cp .env.example .env.local
# Windows PowerShell
Copy-Item .env.example .env.localThe environment file is optional for the normal dashboard flow. Do not commit .env.local; it is ignored by Git. Antigravity OAuth reconnect/refresh additionally requires the two IMAGEROUTER_ANTIGRAVITY_* variables described below.
Run the dashboard
npm run devOpen http://127.0.0.1:20127, then:
Add one or more accounts on Providers.
Test each account.
Arrange the provider chain on Routing.
Reveal the HTTP token on Settings if an HTTP client needs it.
Production mode:
npm run build
npm run startBoth commands bind only to 127.0.0.1. The saved dashboard port is applied on restart; IMAGEROUTER_PORT overrides it.
Run the full local quality check:
npm run checkMCP
stdio
Run the protocol launcher directly:
npm run mcp:stdioExample client configuration:
{
"mcpServers": {
"imagerouter": {
"command": "npm",
"args": ["run", "mcp:stdio"],
"cwd": "C:/absolute/path/to/ImageRouter"
}
}
}The stdio launcher writes MCP protocol frames to stdout and diagnostics to stderr.
Streamable HTTP
Endpoint:
http://127.0.0.1:20127/mcpSend the token shown in Settings:
Authorization: Bearer <ImageRouter token>Example client configuration:
{
"mcpServers": {
"imagerouter": {
"url": "http://127.0.0.1:20127/mcp",
"headers": {
"Authorization": "Bearer ${IMAGEROUTER_TOKEN}"
}
}
}
}Tools
generate_image accepts:
{
"prompt": "A precise image prompt",
"provider": "auto",
"model": "xai/grok-imagine-image-quality",
"reference_images": [],
"aspect_ratio": "16:9",
"output_path": "C:/optional/output.png",
"overwrite": false
}providerdefaults toauto.modelmay be a plain model override orprovider/model, which pins that provider.Without
output_path, image bytes are returned only in the MCP response.With
output_path, exactly one file is written atomically. Existing files are protected unlessoverwriteistrue.
The response contains an MCP image block, a short text summary, and structured route metadata. get_image_router_status returns routes, capabilities, and redacted account health; it never returns credentials.
REST compatibility
curl http://127.0.0.1:20127/v1/images/generations \
-H "Authorization: Bearer $IMAGEROUTER_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "auto",
"prompt": "A cobalt technical illustration on white paper",
"response_format": "b64_json"
}'model accepts auto or provider/model. JSON responses follow the OpenAI image shape and add a router object with the actual provider/model and attempts. Set response_format to binary, or send Accept: image/*, to receive raw image bytes.
Routing semantics
The first enabled route is the default.
autoexhausts enabled accounts for a provider in account-priority order before moving to the next route.An explicit provider still tries its other accounts but never falls back to another provider.
Cross-provider fallback occurs only for timeout, network, quota/rate-limit, token-refresh, capacity, and upstream 5xx failures.
Invalid prompts/parameters, safety rejection, output-path errors, and capability mismatch do not cross-fallback.
In
auto, an incompatible route is recorded as skipped and the next compatible route is tried.
Local data and privacy
Default data locations:
Windows:
%APPDATA%/ImageRoutermacOS/Linux:
~/.imagerouter
Set IMAGEROUTER_DATA_DIR to use another location. ImageRouter never reads or modifies a legacy profile.
SQLite stores:
encrypted provider credentials;
route and account order;
runtime settings;
activity timestamp, provider/model, duration, status, fallback count, error code, and optional output path.
SQLite does not store prompts, image blobs, image base64, or generated previews. The Playground creates a temporary browser object URL and revokes it when replaced or unmounted.
The HTTP server binds to loopback, validates the Host and browser Origin, and requires a local bearer token on /mcp and /v1/images/generations.
Environment
See .env.example.
Variable | Default | Purpose |
| Platform data directory | SQLite and credential-vault location. |
| Saved setting or | Local dashboard, MCP HTTP, and REST port. |
|
| Next.js request body ceiling. |
| Auto-detected local browser | Optional existing Chromium/Chrome executable for E2E. |
| Empty | OAuth client ID for reconnecting Antigravity accounts. |
| Empty | OAuth client secret for reconnecting Antigravity accounts; never commit it. |
Development and tests
npm run lint
npm test
npm run build
npm run test:e2eE2E uses an already-installed Chromium/Chrome executable when one is available; the test command does not install a browser.
Real-provider smoke tests are opt-in and may incur provider charges:
npm run test:smokeThey remain skipped unless the matching IMAGEROUTER_SMOKE_* credentials are present.
Architecture
server/providers/ xAI, Antigravity, Codex adapters
server/image/ validation, capabilities, routing, artifacts
server/mcp/ shared MCP factory, HTTP and stdio transports
server/rest/ OpenAI-compatible image endpoint
server/db/ minimal SQLite schema and encrypted credentials
src/app/ six-screen local workbench
tests/ unit, integration, E2E and opt-in smoke testsAttribution
ImageRouter is an independent rewrite. Portions of the Antigravity and Codex adapter behavior were derived from the MIT-licensed decolua/9router project. See NOTICE.md for provenance.
License
MIT. See LICENSE.
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
- AlicenseAqualityBmaintenanceUse XAI's latest api functionalities with Grok MCP. It supports image understanding and generation, live search, latest models and more.Last updated2247MIT
- AlicenseAqualityCmaintenanceMCP server for generating and editing images using xAI's Grok image model, supporting text prompts, batch generation, local files, and optional proxy configurations.Last updated2629MIT
- AlicenseBqualityAmaintenanceProduction-grade MCP server for image and video understanding and generation across Gemini, OpenAI, and Grok.Last updated54MIT
- Flicense-qualityDmaintenanceAn MCP server for AI-powered image processing (generate, edit, vary, analyze) supporting OpenAI, Gemini, Ideogram, and custom relay endpoints.Last updated
Related MCP Connectors
MCP server for Grok Imagine AI video generation
MCP server for Flux AI image generation
MCP server for Hailuo (MiniMax) 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/Duylamneuuu/imagerouter'
If you have feedback or need assistance with the MCP directory API, please join our Discord server