mcp-server-stability-ai
by: tadasant
MCP Server integrating MCP Clients with Stability AI-powered image manipulation functionalities: generate, edit, upscale, and more.
📌Overview
Purpose: The MCP Server integrates MCP Clients with Stability AI's advanced Stable Diffusion image manipulation capabilities, enabling users to generate, edit, and upscale images efficiently.
Overview: Built primarily for ease of use, the Stability AI MCP Server allows users to leverage Stability AI’s powerful image generation models through a streamlined interface, eliminating the need for technical expertise. It connects directly to Stability AI's hosted REST API, providing a practical solution for image manipulation tasks.
Key Features:
-
No Learning Curve: Designed with sensible defaults and a user-friendly experience, allowing anyone to easily generate and manipulate images without technical knowledge.
-
Chain Manipulations: Facilitates complex image manipulations in a single workflow, enabling users to generate, edit, and enhance images seamlessly within a single session.
-
Minimal Configuration: Users only need a Stability AI API key and can quickly set up their environment to start working with high-quality image models.
Stability AI MCP Server
Haven't heard about MCP yet? The easiest way to keep up-to-date is to read our weekly newsletter at PulseMCP: https://www.pulsemcp.com/.
This is an MCP (Model Context Protocol) Server integrating MCP Clients with Stability AI's Stable Diffusion image manipulation functionalities: generate, edit, upscale, and more.
Stability AI is a leading AI model provider, and this server connects directly to their hosted REST API. You will need to sign up for an API Key from stability.ai: https://platform.stability.ai/account/keys
They provide 25 credits for free. Afterward, pay-as-you-go pricing is reasonable: $0.01/credit, where 3 credits get you an image generation on their Core model – about $3 for 100 high quality images.
This project is NOT officially affiliated with Stability AI.
Demo video: https://youtu.be/7ceSgVC4ZLs
Table of Contents
- Highlights
- Capabilities
- Usage Tips
- Examples
- Setup
- Cheatsheet
- Claude Desktop
- Manual Setup
- SSE Mode
- Roadmap
- Contributing
Highlights
- No learning curve: Designed with sensible defaults and a smooth user experience for easy image generation and manipulation.
- Chain manipulations: Generate, modify, and manipulate images in a single conversation.
- Minimal configuration: Requires only a Stability AI API key and a directory path to store images.
- Leverage top-tier image models: Integrates Stability AI’s superior image models into Claude or other MCP clients.
Capabilities
This server is built and tested on macOS with Claude Desktop but should work with other MCP clients.
Tool Name | Description | Estimated Stability AI Cost |
---|---|---|
generate-image | Generate high quality images based on prompts and optional parameters. | $0.03 |
generate-image-sd35 | Generate images using Stable Diffusion 3.5 models with advanced options. | $0.04 - $0.07 |
remove-background | Remove image backgrounds. | $0.02 |
outpaint | Extend images in any direction while keeping consistency. | $0.04 |
search-and-replace | Replace elements in images by describing what to replace with what. | $0.04 |
upscale-fast | Enhance image resolution by 4x. | $0.01 |
upscale-creative | Enhance resolution up to 4K. | $0.25 |
control-sketch | Translate hand-drawn sketches into polished images. | $0.03 |
control-style | Generate images in the style of a reference image. | $0.04 |
control-structure | Maintain the structure of a reference image during generation. | $0.03 |
replace-background-and-relight | Replace image background and relight it. | $0.08 |
search-and-recolor | Search and recolor objects within images. | $0.05 |
Usage Tips
- All processed images are automatically saved in
IMAGE_STORAGE_DIRECTORY
, previewed, and available as resources. - Do not copy/paste or upload image files directly to Claude, as Claude does not store images. Images must be saved to
IMAGE_STORAGE_DIRECTORY
to be accessible as resources. - Use preloaded prompts included with the server for convenience.
Examples
Generate an image
- Generate an image of a cat
- Generate a photorealistic image of a cat in a cyberpunk city, neon lights reflecting off its fur, 16:9 aspect ratio
- Generate a detailed digital art piece of a cat wearing a space suit floating through a colorful nebula, style preset: digital-art, aspect ratio: 21:9
Generate an image with SD3.5
- Generate an image of a woman with cybernetic wolf ears using the SD3.5 model, with the "neon-punk" style preset
- Generate a futuristic city with SD3.5 Large Turbo model, aspect ratio 16:9
- Generate an astronaut on Mars with SD3.5 Large model, cfg scale 7.5, "analog-film" style, seed 42
Remove background
- Remove the background from the image just generated
- Remove background from product-photo.jpg for e-commerce
- Remove background from group-photo.png for compositing
Outpaint (Uncrop)
- Extend vacation-photo.jpg 500 pixels to the right to include more beach
- Extend family-portrait.png 300 pixels up and 200 pixels right to show more landscape
- Extend artwork.png in all directions for a wider fantasy forest scene
Search and Replace
- Replace the red car with a blue car in the last image
- Replace plain background in portrait.png with sunset over mountains
- Replace modern buildings in landscape.jpg with Victorian-era architecture
Upscale
- Upscale profile-pic.jpg for better resolution
- Upscale product-photo.png for print-ready quality
- Repeat upscale if needed with "Try again with better quality"
Control Sketch
- Transform sketch.png into colored illustration for children’s book
- Convert wireframe.jpg into detailed 3D render for architecture visualization
Control Style
- Generate image in the style of a reference image
Control Structure
- Generate image maintaining the structure of a reference image
Replace Background and Relight
- Replace background with sunset over mountains
Search and Recolor
- Change red car to blue in last image
Setup
Cheatsheet
Environment Variable | Description | Required | Default Value | Example |
---|---|---|---|---|
STABILITY_AI_API_KEY | Stability AI API key (get at platform.stability.ai) | Yes | N/A | sk-1234567890 |
IMAGE_STORAGE_DIRECTORY | Directory for saving generated images | No | /tmp/tadasant-mcp-server-stability-ai or Windows temp | /Users/admin/Downloads/stability-ai-images |
GCS_PROJECT_ID | Google Cloud Project ID for storing images (required if SSE) | No* | N/A | your-project-id |
GCS_CLIENT_EMAIL | Google Cloud service account email (required if SSE) | No* | N/A | your-service-account@project.iam.gserviceaccount.com |
GCS_PRIVATE_KEY | Google Cloud private key (required if SSE) | No* | N/A | -----BEGIN PRIVATE KEY-----\nYourKeyHere\n... |
GCS_BUCKET_NAME | Google Cloud Storage bucket name (required if SSE) | No* | N/A | your-bucket-name |
* Required only when using SSE mode.
Claude Desktop
Create a local folder to store images, e.g.:
/Users/<username>/Downloads/stability-ai-images
/Users/<username>/Library/Application Support/Claude/mcp-server-stability-ai/images
Make sure you have an API key from Stability AI.
If first time using MCP Servers, ensure you have Claude Desktop and follow official MCP setup instructions.
Manual Setup
Requires Node.js installed (from https://nodejs.org).
Modify claude_desktop_config.json
:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
Add:
{
"mcpServers": {
"stability-ai": {
"command": "npx",
"args": [
"-y",
"mcp-server-stability-ai"
],
"env": {
"STABILITY_AI_API_KEY": "sk-1234567890"
}
}
}
}
Restart Claude Desktop to activate the server.
Installing via Smithery
Install automatically:
npx @smithery/cli install mcp-server-stability-ai --client claude
SSE Mode
Start the server with SSE mode for third-party HTTP usage:
npx mcp-server-stability-ai -y --sse
Set these environment variables to store images in Google Cloud Storage:
GCS_PROJECT_ID
GCS_CLIENT_EMAIL
GCS_BUCKET_NAME
GCS_PRIVATE_KEY
Note: This multitenancy scheme uses IP addresses to segment storage and makes images publicly accessible, which is insecure and may expose image URLs to others.
Roadmap
Recently completed:
- Added support for Stable Diffusion 3.5 models
Upcoming features (contributions welcome):
inpaint
: more precise inpainting with masking- Base image manipulations (crop, rotate, resize)
- Inpainting one image into another (may require different API)
- Dedicated MCP client for image manipulation
Contributing
External contributions welcome! See CONTRIBUTING.md for details.
Please raise issues or feature requests to help improve the project.