Skip to main content

Z-Flux-MCP-

PyPI

🖼️ MEILL — Local MCP server that generates & edits images on your machine (Z-Image-Turbo, FLUX.1 Kontext via stable-diffusion.cpp). No cloud, no API keys — just ask your AI to make images.

A local MCP (Model Context Protocol) server that lets an AI chat model (e.g. Unsloth Studio's Qwen, Claude, etc.) generate and edit images on your own machine using free, open-source models — no cloud APIs, no subscriptions.

It runs stable-diffusion.cpp (sd-cli) as a subprocess for every job, so image-model RAM/VRAM is fully released between calls and never fights with your chat model.

Tools exposed

Tool What it does
load_model Prepare a model up front (verifies files, auto-downloads missing weights)
unload_model Free the image model's RAM/VRAM
generate_image Text → image (Z-Image-Turbo, anime/stylized)
edit_image Image + instruction → edited image (FLUX.1 Kontext)
list_images List generated images, newest first
delete_image Delete an image (safely scoped to the outputs folder)

Models auto-download on first use into your Hugging Face cache (~/.cache/huggingface), so a fresh machine only needs the server + sd-cli.

Supported models

Role Model Repo
Generation (gen) Z-Image-Turbo Q5_K_M unsloth/Z-Image-Turbo-GGUF
Generation text encoder Qwen3-4B-Instruct-2507 Q4_K_M unsloth/Qwen3-4B-Instruct-2507-GGUF
Editing (edit) FLUX.1 Kontext dev Q4_K_M unsloth/FLUX.1-Kontext-dev-GGUF
Editing text encoders clip_l + FLUX.1-schnell T5XXL FP8 comfyanonymous/flux_text_encoders, unsloth/FLUX.1-schnell-FP8
VAE (both) FLUX VAE unsloth/FLUX.1-Kontext-dev

Quick start

1. Get sd-cli (the image engine)

Download a prebuilt binary for your OS from the stable-diffusion.cpp releases:

  • Windows (NVIDIA GPU): sd-master-*-bin-win-cuda12-x64.zip
  • Windows (AMD/Intel/any GPU): sd-master-*-bin-win-vulkan-x64.zip
  • Linux: the .zip for your distro/GPU

Unzip it and put sd-cli (or sd-cli.exe) in image-mcp-home/bin/, or set the SD_CLI environment variable to its full path.

On a machine without a dedicated GPU (e.g. Intel iGPU), use the Vulkan build — it works on almost anything.

2. Install Python dependencies

pip install -r requirements.txt

3. Start the server

Windows: double-click run.bat Linux/macOS: ./run.sh (chmod +x first) Any: python server.py

You should see:

Serving MCP at http://127.0.0.1:8765/mcp

4. Connect it to your AI client

Add it as a streamable-HTTP MCP server pointing at:

http://127.0.0.1:8765/mcp

For example, in Unsloth Desktop / Claude Desktop / any MCP client config:

{
  "mcpServers": {
    "image-tools": {
      "url": "http://127.0.0.1:8765/mcp"
    }
  }
}

Then just ask the model: "generate an image of a cyberpunk cat" or "edit this image: make the sky a sunset."

Configuration (environment variables)

Everything is overridable without editing code:

Variable Default Purpose
IMAGE_MCP_HOME ./image-mcp-home Where sd-cli + outputs/ live
SD_CLI IMAGE_MCP_HOME/bin/sd-cli Path to the sd-cli executable
HF_HOME ~/.cache/huggingface Hugging Face cache (models auto-download here)
IMAGE_MCP_HOST 127.0.0.1 Bind address
IMAGE_MCP_PORT 8765 Server port

Example — run on all interfaces, port 9000, custom model folder:

IMAGE_MCP_HOST=0.0.0.0 IMAGE_MCP_PORT=9000 IMAGE_MCP_HOME=/data/images python server.py

How memory is managed

Each generate_image / edit_image call spawns sd-cli as a separate process that exits when done, so VRAM/RAM is physically freed after every job. load_model / unload_model manage explicit state and are mostly a readiness check (download missing weights, verify paths). Only one image job runs at a time (protected by a lock).

Requirements

  • Python 3.10+
  • A GPU is recommended but not required — the Vulkan build of sd-cli runs on CPU/iGPU too (just slower). Expect ~1-3 min per image on modest hardware.
  • ~15 GB disk for the models (auto-downloaded on first use)

Troubleshooting

  • "Missing file role(s)" — a model file didn't download. Check internet access, or download it manually into ~/.cache/huggingface.
  • huggingface_hub not installed — run the server with a Python that has the deps (pip install -r requirements.txt).
  • sd-cli fails / no output — check image-mcp-home/outputs/server_errors.log and the server console.
  • Very slow — expected on iGPU/CPU. Try smaller width/height, or fewer steps.

License

MIT — see LICENSE.

Installing from the MCP Registry

Once published, clients can install it directly:

uvx --from meill meill --stdio

or add to your MCP client config (stdio):

{
  "mcpServers": {
    "image-tools": {
      "command": "uvx",
      "args": ["--from", "meill", "meill", "--stdio"]
    }
  }
}

Publishing (maintainers)

  1. pip install build twine && python -m build && twine upload dist/* (PyPI package name must be unique; verify with twine upload --dry-run)
  2. Install mcp-publisher, then:
    mcp-publisher login github
    mcp-publisher publish
    
    mcp-publisher reads server.json. The registry verifies the PyPI README contains <!-- mcp-name: io.github.<user>/meill -->.

Metadata

Release files for meill 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for meill 0.1.0
File Size Uploaded Provenance Actions
meill-0.1.0.tar.gz 12.4 kB Without provenance Details for meill-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for meill 0.1.0
File Interpreter ABI Platform Actions
meill-0.1.0-py3-none-any.whl Python 3 none any Details for meill-0.1.0-py3-none-any.whl

Total release size: 24.0 kB

Release files / meill-0.1.0.tar.gz

Download URL meill-0.1.0.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
099d2a2adf20bd6eef72c72d546d1b7a44f66cfdcd48272a261df10d7c2a32f4
BLAKE2b-256 checksum
How to use checksums
241a7b0e3140ceb0aba806656181ab8c6eeb0a032d28a7b8590b8732af8e6ce5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release files / meill-0.1.0-py3-none-any.whl

Download URL meill-0.1.0-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85c0d95ef8b2b75fe9c08b5499b474b0f6524192900b7de7762e38228dec18d9
BLAKE2b-256 checksum
How to use checksums
fdc7324ceb5b21697de190d02cd628e2009e936a6db82be1ca706d4b5a3c7c3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Security for meill 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page