hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Integrations
Optionally stores generated images in Google Cloud Storage when running in SSE mode, allowing the server to be deployed for third-party usage over HTTP.
还没听说过 MCP?想要随时了解最新动态,最简单的方法就是阅读我们每周在 PulseMCP 发布的新闻简报。
这是一个 MCP(模型上下文协议)服务器,集成了 MCP 客户端和Stability AI最新、最强大的 Stable Diffusion 图像处理功能:生成、编辑、升级等。
Stability AI 是领先的 AI 模型提供商,此服务器直接连接到其托管的 REST API 。您需要在 stability.ai 注册一个 API 密钥才能开始使用。
他们免费提供 25 个积分。之后,按使用量付费的价格非常合理:每个积分 0.01 美元,其中 3 个积分可以在他们的核心模型上生成图像。所以 100 张高质量图像 = 仅需 3 美元。
该项目与 Stability AI 没有正式关联。
演示视频和预告片在这里:
目录
亮点
轻松上手:此服务器采用合理的默认设置,为生成和操作图像文件等常见操作提供简洁流畅的用户体验。您无需具备专业技术或图像模型知识即可高效使用。
链式操作:您可以生成一个图像,然后替换其中的项目,然后删除背景……所有这些都在一次 Claude 对话中完成。
最低配置:您只需要一个 Stability AI API 密钥即可开始使用。设置环境变量以及用于存储输出图像的本地目录路径,即可开始使用。
利用一流的图像模型:Stability AI 是通过 API 公开图像模型的领先提供商。使用此服务器可以将模型集成到 Claude 或其他 MCP 客户端中,远胜于在 ChatGPT 中使用 DALL-E 模型的体验。
功能
该服务器在 macOS 上通过 Claude Desktop 构建并测试。它应该也能与其他 MCP 客户端兼容。
工具名称 | 描述 | 估计稳定性 API 成本 |
---|---|---|
generate-image | 根据提供的提示和其他可选参数生成任何事物的高质量图像。 | 0.03 美元 |
generate-image-sd35 | 使用具有高级配置选项的 Stable Diffusion 3.5 模型生成图像。 | 0.04-0.07美元 |
remove-background | 从图像中移除背景。 | 0.02 美元 |
outpaint | 在保持视觉一致性的同时向任意方向延伸图像。 | 0.04 美元 |
search-and-replace | 通过描述要替换的内容和用什么来替换图像中的对象或元素。 | 0.04 美元 |
upscale-fast | 将图像分辨率提高 4 倍。 | 0.01 美元 |
upscale-creative | 将图像分辨率提高至 4K。 | 0.25 美元 |
control-sketch | 将手绘草图转换为生产级图像。 | 0.03 美元 |
control-style | 以参考图像的风格生成图像。 | 0.04 美元 |
control-structure | 在保持参考图像结构的同时生成图像。 | 0.03 美元 |
replace-background-and-relight | 替换图像的背景并重新点亮它。 | 0.08 美元 |
search-and-recolor | 搜索图像中的对象并重新着色。 | 0.05 美元 |
使用技巧
- 所有处理过的图像都会自动保存到
IMAGE_STORAGE_DIRECTORY
,打开预览,并作为资源提供 - 请勿尝试复制/粘贴或上传图片文件到 Claude。Claude 不会在任何地方存储图片,因此我们无法处理 MCP 服务器中的图片。您必须将图片“上传”(保存)到
IMAGE_STORAGE_DIRECTORY
目录,它们才会在聊天中显示为可用资源。 - 您可以使用预加载的提示,而不必编写自己的措辞:
示例
生成图像
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
使用 SD3.5 生成图像
Generate an image of a woman with cybernetic wolf ears using the SD3.5 model, with the "neon-punk" style preset
Generate an image of a futuristic city using the SD3.5 Large Turbo model, with aspect ratio 16:9
Generate an image of an astronaut on mars using the SD3.5 Large model, with cfg scale 7.5, "analog-film" style preset, and seed 42
删除背景
Remove the background from the image I just generated
Remove the background from product-photo.jpg to prepare it for my e-commerce site
Remove the background from group-photo.png so I can composite it with another image
Outpaint(取消裁剪)
Extend vacation-photo.jpg 500 pixels to the right to include more of the beach
Extend family-portrait.png 300 pixels up to show more of the mountains, and 200 pixels right to include more landscape
Extend artwork.png in all directions to create a wider fantasy forest scene that matches the original environment
搜索和替换
In my last image, replace the red car with a blue car
In portrait.png, replace the plain background with a sunset over mountains
In landscape.jpg, replace the modern buildings with victorian-era architecture while maintaining the same atmosphere
高档
Upscale profile-pic.jpg for better resolution
Upscale product-photo.png to make it print-ready
然后,如果输出仍然不够好,您可以再次升级它:
Try again with better quality
控制草图
Transform sketch.png into a colored illustration for a children's book
Convert wireframe.jpg into a detailed 3D render for a modern architectural visualization
控制风格
Generate an image in the style of the reference image
控制结构
Generate an image while maintaining the structure of the reference image
更换背景并重新照明
Replace the background of the image I just generated with a sunset over mountains
搜索和重新着色
In my last image, make the red car be blue instead
设置
备忘单
环境变量 | 描述 | 必需的 | 默认值 | 例子 |
---|---|---|---|---|
STABILITY_AI_API_KEY | 您的 Stability AI API 密钥。请访问platform.stability.ai获取。 | 是 | 不适用 | sk-1234567890 |
IMAGE_STORAGE_DIRECTORY | 生成的图像的保存目录 | 北 | /tmp/tadasant-mcp-server-stability-ai 或C:\\Windows\\Temp\\mcp-server-stability-ai | /Users/admin/Downloads/stability-ai-images |
GCS_PROJECT_ID | 用于存储图像的 Google Cloud 项目 ID | N(如果使用 SSE,则为 Y) | 不适用 | your-project-id |
GCS_CLIENT_EMAIL | 用于存储图像的 Google Cloud 服务帐户客户端电子邮件 | N(如果使用 SSE,则为 Y) | 不适用 | your-service-account@project.iam.gserviceaccount.com |
GCS_PRIVATE_KEY | 用于存储图像的 Google Cloud 服务帐户私钥 | N(如果使用 SSE,则为 Y) | 不适用 | -----BEGIN PRIVATE KEY-----\nYourKeyHere\n-----END PRIVATE KEY-----\n |
GCS_BUCKET_NAME | 用于存储图像的 Google Cloud Storage 存储桶名称 | N(如果使用 SSE,则为 Y) | 不适用 | your-bucket-name |
克劳德桌面
如果您更喜欢视频教程,这里有一个简短的教程。
在你的机器上创建一个文件夹目录,用于存储生成/修改后的图像。以下是一些选项:
/Users/<username>/Downloads/stability-ai-images
/Users/<username>/Library/Application Support/Claude/mcp-server-stability-ai/images
并确保您拥有来自 Stability AI 的 API 密钥。
然后按照您喜欢的方式配置服务器。如果您是第一次使用 MCP 服务器,请确保您已安装Claude Desktop 应用程序,并按照官方的 MCP 设置说明进行操作。
手动设置
你需要在你的机器上运行 Node,这样你才能在终端中运行npx
命令。如果你没有 Node,可以从nodejs.org安装。
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
修改claude_desktop_config.json
文件以添加以下内容:
重新启动 Claude Desktop,您就可以开始了:
通过 Smithery 安装
要通过Smithery自动安装 Claude Desktop:
SSE模式
该服务器可以选择通过使用以下命令启动以在 SSE 模式下运行:
如果您打算通过 HTTP 部署此服务器以供第三方使用,此模式很有用。
您将需要设置GCS_PROJECT_ID
、 GCS_CLIENT_EMAIL
、 GCS_BUCKET_NAME
和GCS_PRIVATE_KEY
环境变量,因为服务器将把图像文件存储在 Google Cloud Storage 而不是其本地文件系统中。
请注意,多租户方案非常简单且不安全:它使用请求者的 IP 地址来分割用于存储图片的 GCS 前缀,并将所有图片公开访问,以便将其返回给 MCP 客户端。因此,理论上,如果有人知道您的 IP 地址以及您生成的文件的名称,他们就可以通过猜测 URL 来访问您的图片。
路线图
最近完成:
- ✅ 增加了对最新 Stable Diffusion 3.5 模型的支持
这些即将推出;但欢迎 PR!请参阅CONTRIBUTING.md 。
inpaint
-search-and-x
功能的更精确版本,需要管理掩码来定义要替换的区域。- 基本图像处理(裁剪、旋转、调整大小等):可能作为其自己的 MCP 服务器
- 能够将一幅图像修复到另一幅图像中。稳定性 API 似乎无法实现;可能需要另一个 MCP 服务器使用不同的 API 来实现此功能。
- 为图像处理定制的 MCP 客户端
贡献
欢迎外部贡献!更多详情请参阅CONTRIBUTING.md 。
也请随时提出问题或功能请求;喜欢看到人们如何使用它以及如何使其变得更好。
You must be authenticated.
Tools
MCP 服务器与 Stability AI 的 API 集成,提供高质量的图像生成、编辑和处理功能,包括背景去除、去除图像、搜索和替换以及升级。