dsh-zimage-mcp
Generates images through the Hugging Face-hosted Z-Image-Turbo Space, with configurable prompt, width, height, steps, and seed, plus tools to check Space status and save generated image URLs locally.
Click on "Deploy 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., "@dsh-zimage-mcpGenerate a photorealistic image of a fox in a snowy forest"
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.
dsh-zimage-mcp
Zero-dependency MCP (stdio) server that wraps the Hugging Face Space mrfakename/Z-Image-Turbo (Alibaba Tongyi Z-Image turbo text-to-image, running on ZeroGPU A10G) and exposes it as agent-friendly tools. Built for the DeepSeek Harness (DSH) MCP bridge, but works with any MCP client (Claude Desktop, Cursor, …).
prompt ──▶ mcp__zimage__generate_image ──▶ Z-Image-Turbo Space (Gradio REST)
│
├─ downloads the PNG locally (default Documents/DSH/zimage-output)
└─ returns JSON: savedPath + url + seedUsed + elapsedMsWhy a wrapper (and not the Space's own MCP endpoint)?
The Space is Gradio ≥5, so it already exposes https://mrfakename-z-image-turbo.hf.space/gradio_api/mcp.
Pointing a client there works, but:
Space's built-in MCP | this server | |
Tool result | image inline as base64 content (hundreds of KB into the model context) | trimmed JSON: local file path, temporary URL, seed |
Where the image lives | Space | your disk (survives cleanup) |
ZeroGPU errors | raw | relayed with actionable hints (quota / sleeping space) |
Token handling | none |
|
Dependencies | — | zero (plain Node ≥18, newline-delimited JSON-RPC over stdio) |
Related MCP server: Z-Image Studio
Tools
generate_image
arg | type | default | notes |
| string | required | natural language; EN/JA/ZH all work (≤4000 chars) |
| int 512–2048 | 1024 | Space slider bounds |
| int 512–2048 | 1024 | |
| int 1–20 | 9 | turbo model: 6–12 is plenty |
| int | 0 | used when |
| bool |
|
|
| bool |
| download result locally |
| string | auto | absolute path override |
Returns {ok, savedPath, url, seedUsed, width, height, steps, elapsedMs, bytes, note}.
Typical wall time 10–40 s (ZeroGPU queue dependent). Point an image-reading
tool (or a multimodal model) at savedPath to inspect the result.
space_status
{stage, hardware, sdk, likes, note} — RUNNING / SLEEPING / PAUSED diagnosis.
save_image
{url, outPath?} → {savedPath, bytes} — persist a generation URL before the
Space cleans up /tmp/gradio.
DSH registration
In ~/.dsh/profiles/web/cordis.patch.yml (requires host restart, or HMR
hot-swap of the mcp-client entry):
- insert:
- id: mcp-zimage
name: '@deepseek-ai/dsh-mcp-client'
config:
serverName: zimage
transport: stdio
command: 'C:\Program Files\nodejs\node.exe'
args:
- 'C:\Users\motch\Documents\DSH\dsh-zimage-mcp\zimage-mcp.mjs'
env:
HF_TOKEN: !!js process.env.HF_TOKEN || ''
failOnStartupError: false
toolCallTimeoutMs: 600000Tools appear as mcp__zimage__generate_image, mcp__zimage__space_status,
mcp__zimage__save_image. toolCallTimeoutMs must exceed the Space's worst
queue wait; 10 min is a safe ceiling.
ZeroGPU quota
Generation is billed against ZeroGPU quota:
Anonymous (per IP): tiny — a few short generations per window; when exhausted the Space returns
You have exceeded your ZeroGPU quota (Ns requested vs. Ns left). The tool relays this verbatim; wait for the window to reset and retry.With a free HF token (
HF_TOKEN): substantially more GPU-seconds. Create one at https://huggingface.co/settings/tokens (read is enough), then either set theHF_TOKENWindows/host environment variable or putHF_TOKEN: hf_xxxin~/.dsh/.credentials.yaml— the server picks it up (env first, credentials file as fallback; the placeholderunusedis ignored). No restart of this server is needed between calls, but a new server process re-reads both.
Configuration (env)
var | default | meaning |
| (auto) | Bearer token for the Space API; empty → anonymous |
|
| per-generation SSE timeout |
|
| default save directory |
How it talks to the Space
Plain Gradio REST, no gradio_client dependency:
POST /gradio_api/call/generate_image {"data":[prompt,h,w,steps,seed,randomize]} → {"event_id": …}
GET /gradio_api/call/generate_image/<event_id> (text/event-stream)
event: progress|process_starts|heartbeat … until
event: complete data=[[{url,path,orig_name,mime_type}, seedUsed]]
event: error data=[{"error": "You have exceeded your ZeroGPU quota …"}]Slider bounds (verified 2026-09-01): width/height 512–2048, steps 1–20, defaults 1024/1024/9.
Test
node test/server-test.mjs --skip-live # protocol round-trips only
node test/server-test.mjs # + one real 512x512/4-step generationAll assertions passing 2026-09-01 (protocol 5/5; live suite validated end-to-end against the running Space).
License
MIT — see LICENSE.
This server cannot be deployed
Maintenance
Related MCP Connectors
Generate AI images and videos from any compatible MCP client.
Focused MCP server for OpenAI image/audio generation (v2.0.0). Wraps endpoints via HAPI CLI.
Create and manage AI image and video generations through Quriov's fixed public MCP tools.
Create images and videos from prompts, with options for image mixing, reference images, and start/…
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables the generation of images using Together AI's models through an MCP server, supporting customizable parameters such as model selection, image dimensions, and output directory.17MIT
- AlicenseAqualityAmaintenanceA local text-to-image generation server that enables AI agents to generate images, manage models, and browse history using the Z-Image-Turbo model. It supports hardware acceleration across NVIDIA, Apple Silicon, and AMD GPUs via multiple MCP transport protocols.3128Apache 2.0
- AlicenseAqualityAmaintenanceEnables image generation via MiniMax's API through MCP, supporting text-to-image, batch generation, aspect ratios, seed reproducibility, and image-to-image with character references.111 npmMIT
- AlicenseAqualityBmaintenanceGenerates and edits images using OpenAI GPT Image or Google Gemini models, saving every result to disk and returning local file paths so AI assistants can continue working with the images. It enables prompt-based image creation, editing, inpainting, multi-image composition, and model listing through MCP tools.116 npm1Apache 2.0