
Kie AI MCP: Let Your AI Assistant Generate Images and Save Them to Disk
- Published on
- • 4 mins read•--- views

The last gap in giving an AI assistant real hands is letting it create images, not just describe them. There are plenty of generation APIs, but every one comes with the same dance: submit a task, poll for status, wait, then download the file before it expires. Tedious to wire up by hand, and a poor fit for a chat turn. So I built kie-ai-mcp: a Model Context Protocol server, written in Go, that bridges to the Kie AI image generation API and handles that whole loop for you.
It creates tasks, polls them to completion, and saves the resulting image straight to disk — so your agent can go from a prompt to a file in one call.
What It Does
The server collapses the create → poll → download lifecycle into tools an agent can drive from natural language:
- Creates image generation tasks via Kie AI
- Polls task status until completion — or returns a task id for async flows
- Downloads the resulting image and writes it to disk
- Supports parallel batch generation with an explicit style and prompt per item
That last point is the one I lean on most. Asking for ten variations of a concept used to mean ten round-trips; here it's one batch call with max_workers and per-item outputs and errors.
The Toolbox
Five focused MCP tools cover both the fire-and-forget and the wait-for-it workflows:
| Tool | What it does |
|---|---|
describe_imager_interface | Returns the tool contracts and environment info — call it first to see what's configured. |
create_visual_task | Creates a generation task and returns a task_id. |
get_visual_task | Fetches task status by task_id. |
generate_visual | Creates a task and waits for the resulting image. |
generate_visual_batch | Runs multiple generations in parallel (items[], default_style, max_workers, per-item outputs/errors). |
Use generate_visual when you just want the picture. Drop down to create_visual_task + get_visual_task when you'd rather kick off a long job and check back later.
Setup
Build
The server is a single Go binary:
make build
Configure your API key
Pass the key via the MCP host's env block — the key lives outside the repo and never appears in tool messages or logs.
{
"kie-ai-mcp": {
"command": "/path/to/kie-ai-mcp",
"env": {
"KIE_AI_API_KEY": "your-key-here"
}
}
}
That's the only required variable. Everything else has a sensible default:
| Variable | Required | Default | Description |
|---|---|---|---|
KIE_AI_API_KEY | yes | — | Your Kie AI API key |
KIE_AI_BASE_URL | no | https://api.kie.ai/api/v1 | API base URL |
KIE_AI_MODEL | no | nano-banana-pro | Image generation model |
KIE_AI_OUTPUT_DIR | no | output | Directory where generated images are saved |
KIE_AI_TIMEOUT_SECONDS | no | 90 | Per-request HTTP timeout |
KIE_AI_POLL_INTERVAL_SECONDS | no | 3 | Seconds between task status polls |
KIE_AI_POLL_TIMEOUT_SECONDS | no | 300 | Max seconds to wait for a task to complete |
KIE_AI_HTTP_RETRIES | no | 3 | Retry attempts on transient HTTP errors |
KIE_AI_HTTP_RETRY_BACKOFF_SECONDS | no | 1.5 | Initial backoff delay for retries (doubles each attempt) |
If you're on fish, universal vars persist across sessions and reach any child process — no .env needed:
set -Ux KIE_AI_API_KEY your-api-key-here
set -Ux KIE_AI_MODEL nano-banana-pro
set -Ux KIE_AI_OUTPUT_DIR output
The server also reads a .env from the working directory or the binary's directory — just don't commit it. Images land in KIE_AI_OUTPUT_DIR unless you pass an output_path per call.
Why a Server Instead of a Raw API Call
The value here isn't the generation — Kie AI does that. It's everything around it: polling with sane timeouts, retrying transient HTTP failures with exponential backoff, downloading the result before the URL expires, and running a batch concurrently without melting the rate limit. Baking that into a server means the model never has to reason about task lifecycles. It says "make me four hero images in this style" and gets four files back.
It's the same pattern behind my other MCP servers — wrap a capable backend, expose exactly the operations an agent needs, and keep secrets in the host's env where they never leak into a transcript.
The project is open on GitHub: github.com/artschekoff/kie-ai-mcp — built with Go. Issues and pull requests welcome.
Open for contract collaboration
I am available for contract-based collaboration. If you have an interesting project idea, schedule a call via Calendly.
Schedule a 30-min call