MCP server that brings Stability AI to Claude Code — image generation, editing, upscaling, ControlNet, and 3D mesh generation. 15 tools powered by Stable Diffusion 3.5, Stable Image Ultra/Core, and Stable Fast 3D.
- Go to Stability AI Platform
- Create an account or sign in
- Generate an API key
- Copy the key (you'll need it in Step 3)
- Node.js 18+ - Download here
- Claude Code CLI - Installation guide
git clone https://github.com/wynandw87/claude-code-stabilityai-mcp.git
cd claude-code-stabilityai-mcp
macOS / Linux / Windows:
npm install
Note: Dependencies are installed and the server is built automatically in one step.
Choose your install scope:
| Scope | Flag | Who can use it |
|---|---|---|
| User (recommended) | -s user |
You, in any project |
| Project | -s project |
Anyone who clones this repo |
| Local | -s local |
Only in current directory |
Replace YOUR_API_KEY with your actual Stability AI API key, and use the full path to dist/index.js.
Tip: To get the full path, run this from the cloned directory:
- macOS/Linux:
echo "$(pwd)/dist/index.js"- Windows:
echo %cd%\dist\index.js
macOS / Linux:
claude mcp add -s user StabilityAI -e STABILITY_API_KEY=YOUR_API_KEY -- node /full/path/to/dist/index.js
Windows (CMD):
claude mcp add -s user StabilityAI -e "STABILITY_API_KEY=YOUR_API_KEY" -- node "C:\full\path\to\dist\index.js"
Windows (PowerShell):
claude mcp add -s user StabilityAI -e "STABILITY_API_KEY=YOUR_API_KEY" '--' node "C:\full\path\to\dist\index.js"
The setup scripts handle dependency installation, building, and registration automatically.
macOS / Linux:
chmod +x setup.sh
./setup.sh YOUR_API_KEY
Windows (PowerShell):
.\setup.ps1 -ApiKey YOUR_API_KEY
Close and reopen Claude Code for the changes to take effect.
claude mcp list
You should see StabilityAI listed with a Connected status.
- Generate Image (
generate_image) - Text-to-image and image-to-image using Ultra, Core, or SD 3.5 models
- Erase Object (
erase_object) - Remove objects from images with optional mask - Inpaint (
inpaint) - Fill masked areas with AI-generated content - Outpaint (
outpaint) - Extend image boundaries in any direction - Search & Replace (
search_and_replace) - Find and replace objects by text description - Search & Recolor (
search_and_recolor) - Find and recolor objects by text description - Remove Background (
remove_background) - Remove image background with transparency - Replace Background (
replace_background) - Replace background with AI content and relighting
- Upscale Image (
upscale_image) - Enhance resolution with fast, conservative, or creative modes
- Sketch to Image (
control_sketch) - Generate images from sketches/drawings - Structure-Guided (
control_structure) - Generate images following reference structure - Style-Guided (
control_style) - Generate images matching a reference style - Style Transfer (
style_transfer) - Transfer style from one image to another
- Generate 3D (
generate_3d) - Create 3D meshes (glTF/glb) from single images
- Check Balance (
check_balance) - View remaining Stability AI credits
Once installed, use trigger phrases to invoke Stability AI:
| Trigger | Tool | Example |
|---|---|---|
stability generate, stability image |
Generate Image | "stability generate a sunset over mountains" |
stability erase |
Erase Object | "stability erase the person from this photo" |
stability inpaint |
Inpaint | "stability inpaint a cat in the masked area" |
stability outpaint, stability extend |
Outpaint | "stability extend this image 500px to the right" |
stability replace |
Search & Replace | "stability replace the car with a bicycle" |
stability recolor |
Search & Recolor | "stability recolor the dress to red" |
stability remove bg |
Remove Background | "stability remove background from this photo" |
stability replace bg |
Replace Background | "stability replace background with a beach" |
stability upscale |
Upscale Image | "stability upscale this image using creative mode" |
stability sketch |
Sketch to Image | "stability sketch: turn this into a realistic house" |
stability structure |
Structure-Guided | "stability structure: same layout but as a painting" |
stability style guide |
Style-Guided | "stability style: generate in the style of this reference" |
stability style transfer |
Style Transfer | "stability transfer the style of painting.png onto photo.jpg" |
stability 3d, stability mesh |
Generate 3D | "stability 3d: create a mesh from this object photo" |
stability balance, stability credits |
Check Balance | "stability check my credits balance" |
Or ask naturally:
- "Use Stability AI to generate an anime-style character"
- "Remove the background from this product photo using Stability"
- "Upscale this low-res image with Stability AI"
- "Turn this sketch into a photorealistic house using Stability"
- "Generate a 3D model from this object image"
- "Replace the sky in this photo with a dramatic sunset"
- "Extend this image to make it wider for a banner"
Generate images using Stable Diffusion models. Supports text-to-image and image-to-image.
Parameters:
prompt(string, required) - Text description of the image to generatemodel(string, optional) -"ultra"(highest quality, 8 credits),"core"(fast, 3 credits),"sd3.5-large","sd3.5-large-turbo","sd3.5-medium"negative_prompt(string, optional) - What to exclude from the imageimage_path(string, optional) - Source image for image-to-image generationstrength(number, optional) - Transform amount for img-to-img (0-1)aspect_ratio(string, optional) -"1:1","16:9","21:9","2:3","3:2","4:5","5:4","9:16","9:21"style_preset(string, optional) -"photographic","anime","digital-art","cinematic","3d-model","pixel-art", etc.output_format(string, optional) -"png"(default),"jpeg","webp"seed(integer, optional) - Random seed for reproducibility (0-4294967294)save_path(string, optional) - File path to save the image
Erase objects from an image.
Parameters:
image_path(string, required) - Absolute path to the source imagemask_path(string, optional) - Mask image (white areas erased). Auto-detection if omitted.output_format(string, optional) -"png","jpeg","webp"save_path(string, optional) - File path to save the result
Fill masked areas with AI-generated content.
Parameters:
image_path(string, required) - Absolute path to the source imageprompt(string, required) - What to generate in the masked areamask_path(string, optional) - Mask image (white areas inpainted)negative_prompt(string, optional) - What to avoidseed(integer, optional) - Random seedoutput_format(string, optional) -"png","jpeg","webp"save_path(string, optional) - File path to save the result
Extend an image's boundaries in any direction.
Parameters:
image_path(string, required) - Absolute path to the source imageprompt(string, optional) - Description of what to generate in extended arealeft/right/top/bottom(integer, optional) - Pixels to extend (0-2000 each)creativity(number, optional) - Creativity level (0-1)output_format(string, optional) -"png","jpeg","webp"save_path(string, optional) - File path to save the result
Find an object by text description and replace it. No mask needed.
Parameters:
image_path(string, required) - Absolute path to the source imageprompt(string, required) - What to replace the object withsearch_prompt(string, required) - Description of the object to findnegative_prompt(string, optional) - What to avoidseed(integer, optional) - Random seedoutput_format(string, optional) -"png","jpeg","webp"save_path(string, optional) - File path to save the result
Find an object by text description and recolor it. No mask needed.
Parameters:
image_path(string, required) - Absolute path to the source imageprompt(string, required) - New color/appearance for the objectselect_prompt(string, required) - Description of the object to findnegative_prompt(string, optional) - What to avoidseed(integer, optional) - Random seedoutput_format(string, optional) -"png","jpeg","webp"save_path(string, optional) - File path to save the result
Remove the background, leaving the foreground subject with transparency.
Parameters:
image_path(string, required) - Absolute path to the source imageoutput_format(string, optional) -"png","webp"(PNG recommended for transparency)save_path(string, optional) - File path to save the result
Replace the background with AI-generated content and optionally adjust lighting.
Parameters:
image_path(string, required) - Absolute path to the source imagebackground_prompt(string, required) - Description of the new backgroundforeground_prompt(string, optional) - Description of the foreground subjectnegative_prompt(string, optional) - What to avoidlight_source_direction(string, optional) -"above","below","left","right"light_source_strength(number, optional) - Light intensity (0-1)output_format(string, optional) -"png","jpeg","webp"save_path(string, optional) - File path to save the result
Upscale an image to higher resolution.
Parameters:
image_path(string, required) - Absolute path to the imagemode(string, optional) -"fast"(quick 2x, 2 credits),"conservative"(detail-preserving, 25 credits),"creative"(AI-enhanced, 25 credits, async)prompt(string, optional) - Guide the upscaler (conservative/creative only)negative_prompt(string, optional) - What to avoidcreativity(number, optional) - How creative the upscaler should be (0-0.35)seed(integer, optional) - Random seedoutput_format(string, optional) -"png","jpeg","webp"save_path(string, optional) - File path to save the result
Generate an image from a sketch/drawing using ControlNet.
Parameters:
image_path(string, required) - Absolute path to the sketch imageprompt(string, required) - What to generate from the sketchnegative_prompt(string, optional) - What to avoidcontrol_strength(number, optional) - How closely to follow the sketch (0-1)seed(integer, optional) - Random seedoutput_format(string, optional) -"png","jpeg","webp"save_path(string, optional) - File path to save the result
Generate an image guided by the structure/edges of a reference image.
Parameters:
image_path(string, required) - Absolute path to the reference imageprompt(string, required) - What to generatenegative_prompt(string, optional) - What to avoidcontrol_strength(number, optional) - How closely to follow the structure (0-1)seed(integer, optional) - Random seedoutput_format(string, optional) -"png","jpeg","webp"save_path(string, optional) - File path to save the result
Generate an image using a reference image to guide visual style.
Parameters:
image_path(string, required) - Absolute path to the style reference imageprompt(string, required) - What to generate in the reference stylenegative_prompt(string, optional) - What to avoidfidelity(number, optional) - How closely to match the reference style (0-1)seed(integer, optional) - Random seedoutput_format(string, optional) -"png","jpeg","webp"save_path(string, optional) - File path to save the result
Transfer the visual style of one image onto another.
Parameters:
init_image_path(string, required) - Absolute path to the content imagestyle_image_path(string, required) - Absolute path to the style reference imageprompt(string, optional) - Guide the style transfernegative_prompt(string, optional) - What to avoidseed(integer, optional) - Random seedoutput_format(string, optional) -"png","jpeg","webp"save_path(string, optional) - File path to save the result
Generate a 3D mesh (glTF/glb) from a single image.
Parameters:
image_path(string, required) - Absolute path to the source imagemodel(string, optional) -"stable-fast-3d"(fast, 10 credits) or"spar3d"(advanced, 4 credits)texture_resolution(integer, optional) - 512, 1024, or 2048foreground_ratio(number, optional) - Foreground object ratio, 0.1-1.0 (stable-fast-3d only)remesh(string, optional) -"none","triangle","quad"(stable-fast-3d only)guidance_scale(number, optional) - 1-10 (spar3d only)save_path(string, optional) - File path to save the .glb file
Check your Stability AI credits balance. No parameters required.
| Model | Endpoint | Credits | Best For |
|---|---|---|---|
ultra |
Stable Image Ultra | 8 | Highest quality, photorealistic |
core |
Stable Image Core | 3 | Fast iteration, affordable |
sd3.5-large |
SD 3.5 Large | 6.5 | High quality, good prompt adherence |
sd3.5-large-turbo |
SD 3.5 Large Turbo | 4 | Fast, good quality |
sd3.5-medium |
SD 3.5 Medium | 3.5 | Balanced speed and quality |
| Model | Credits | Best For |
|---|---|---|
stable-fast-3d |
10 | Fast general-purpose 3D |
spar3d |
4 | Advanced with backside editing |
3d-model · analog-film · anime · cinematic · comic-book · digital-art · enhance · fantasy-art · isometric · line-art · low-poly · modeling-compound · neon-punk · origami · photographic · pixel-art · tile-texture
| Variable | Required | Default | Description |
|---|---|---|---|
STABILITY_API_KEY |
Yes | — | Stability AI API key |
STABILITY_TIMEOUT |
No | 60000 |
API timeout in ms |
STABILITY_OUTPUT_DIR |
No | ./generated-images |
Directory for auto-saved images |
STABILITY_3D_OUTPUT_DIR |
No | ./generated-3d |
Directory for auto-saved 3D models |
This MCP server uses the Stability AI REST API (v2beta) directly with fetch and FormData. No SDK required. It connects to Claude Code via stdio transport.
All image endpoints use multipart/form-data requests and return binary image data. The creative upscale endpoint is asynchronous — the server handles polling automatically.
Tools provided:
| Tool | API Endpoint | Credits |
|---|---|---|
generate_image |
/v2beta/stable-image/generate/{ultra,core,sd3} |
3-8 |
erase_object |
/v2beta/stable-image/edit/erase |
4 |
inpaint |
/v2beta/stable-image/edit/inpaint |
4 |
outpaint |
/v2beta/stable-image/edit/outpaint |
4 |
search_and_replace |
/v2beta/stable-image/edit/search-and-replace |
4 |
search_and_recolor |
/v2beta/stable-image/edit/search-and-recolor |
5 |
remove_background |
/v2beta/stable-image/edit/remove-background |
4 |
replace_background |
/v2beta/stable-image/edit/replace-background-and-relight |
8 |
upscale_image |
/v2beta/stable-image/upscale/{fast,conservative,creative} |
2-25 |
control_sketch |
/v2beta/stable-image/control/sketch |
5 |
control_structure |
/v2beta/stable-image/control/structure |
5 |
control_style |
/v2beta/stable-image/control/style |
5 |
style_transfer |
/v2beta/stable-image/control/style-transfer |
8 |
generate_3d |
/v2beta/3d/stable-fast-3d or /v2beta/3d/stable-point-aware-3d |
4-10 |
check_balance |
/v1/user/balance |
0 |
If you entered the wrong API key, remove and reinstall:
claude mcp remove StabilityAI
Then reinstall using the command from Step 3.3 above (use the same scope you originally installed with).
Check if the server is installed:
claude mcp list
If not listed, follow Step 3 to install it.
-
Verify your API key is valid at Stability AI Platform
-
Check Node.js version (needs 18+):
node --version -
Ensure the server was built — if
dist/index.jsis missing, runnpm installagain
- Check that
dist/index.jsexists — if not, runnpm install - Verify the path is absolute in your
claude mcp addcommand - Restart Claude Code after any configuration changes
If you get a 402 error, add credits at platform.stability.ai. Check your balance with the check_balance tool.
- Image generation and upscaling use extended timeouts (3x base)
- Creative upscale uses async polling (up to 5 minutes)
- Increase
STABILITY_TIMEOUTenvironment variable for slow connections
claude mcp list
Pull requests welcome! Please keep it simple and beginner-friendly.
MIT
Made for the Claude Code community