sd-api-mcp
sd-api-mcp
Stable Diffusion REST API を AI エージェントに公開する MCP (Model Context Protocol) サーバーです。SD1.5、SDXL、Illustrious XL パイプラインをサポートし、テキストから画像への生成、インペインティング、モデル管理、モデルマージに対応しています。
これは SD API Backend プロジェクトの上に構築されています。
MCP Python SDK を使用して構築され、uv で管理されています。
要件
Python >= 3.11
uv パッケージマネージャー
稼働中の Stable Diffusion API インスタンス (デフォルト:
http://localhost:8000)
Related MCP server: Segmind MCP Server
インストール
git clone <repo-url>
cd sd-api-mcp
uv sync使用方法
stdio (デフォルト)
サーバープロセスを管理する MCP クライアント (例: Claude Code、Claude Desktop) で使用する場合:
uv run sd-api-mcpSSE
uv run sd-api-mcp --transport sse --host 0.0.0.0 --port 8080Streamable HTTP (ネットワーク展開に推奨)
uv run sd-api-mcp --transport streamable-http --host 0.0.0.0 --port 8080MCP エンドポイントは http://<host>:<port>/mcp で利用可能になります。
Claude Desktop の設定
claude_desktop_config.json に追加します:
{
"mcpServers": {
"stable-diffusion": {
"command": "uv",
"args": ["run", "--project", "/path/to/sd-api-mcp", "sd-api-mcp"],
"env": {
"SD_API_URL": "http://localhost:8000"
}
}
}
}Claude Code の設定
claude mcp add stable-diffusion -- uv run --project /path/to/sd-api-mcp sd-api-mcpOpenCode の設定
opencode.json に追加します:
{
"mcp": {
"stable-diffusion": {
"type": "stdio",
"command": "uv",
"args": ["run", "--project", "/path/to/sd-api-mcp", "sd-api-mcp"],
"env": {
"SD_API_URL": "http://localhost:8000"
}
}
}
}SSE または Streamable HTTP トランスポートの場合は、サーバーを別途起動し、代わりにリモート URL を使用します:
{
"mcp": {
"stable-diffusion": {
"type": "sse",
"url": "http://localhost:8080/sse"
}
}
}環境変数
変数 | デフォルト | 説明 |
|
| Stable Diffusion API のベース URL |
|
| ジョブステータスのポーリング間隔 (秒) |
|
| ジョブ完了までの最大待機時間 (秒) |
|
| トランスポートプロトコル ( |
|
| SSE/HTTP トランスポートのバインドアドレス |
|
| SSE/HTTP トランスポートのポート |
利用可能なツール
画像生成
ツール | 説明 |
| 画像を生成し、結果を待ちます |
| マスクされた領域をインペイントし、結果を待ちます |
| 生成ジョブを送信し、ジョブ ID をすぐに返します |
| インペインティングジョブを送信し、ジョブ ID をすぐに返します |
| 最大 10 件の生成リクエストを一度に送信します |
| 比較用に同じプロンプトで 2〜6 個のモデルを使用して生成します |
すべての生成ツールは pipeline パラメータ ("sd15"、"sdxl"、"illustrious") を受け付けます。
モデル管理
ツール | 説明 |
| 利用可能なチェックポイント、LoRA、VAE を一覧表示します |
| モデルの safetensors ヘッダーからメタデータを読み取ります |
ジョブ管理
ツール | 説明 |
| ステータスと進捗を含むすべてのジョブを一覧表示します |
| 特定のジョブのステータスと結果を取得します |
| 保留中または実行中のジョブをキャンセルします |
システム
ツール | 説明 |
| SD API に到達可能かどうかを確認します |
| GPU、キャッシュ、キューの統計情報を取得します |
| 利用可能なノイズスケジューラーを一覧表示します |
| 現在の構成パラメータを取得します |
モデルマージ
ツール | 説明 |
| 2 つのチェックポイントをマージします (linear、slerp、additive、subtract) |
| ベースモデルを複数のターゲットとマージします |
| 複数ステップのマージレシピを実行します |
例
画像を生成する (エージェントの視点)
AI エージェントは generate_image ツールを次のように呼び出します:
{
"pipeline": "sdxl",
"positive_prompt": "a cat sitting on a windowsill, golden hour lighting, photorealistic",
"negative_prompt": "blurry, low quality",
"model_checkpoint": "dreamshaperXL_v2.safetensors",
"width": 1024,
"height": 1024,
"steps": 30,
"cfg_scale": 7.0,
"seed": -1,
"scheduler": "DPM++ 2M"
}このツールは SD API にジョブを送信し、完了するまでポーリングし、生成された画像を含む完全な結果を返します。
利用可能なモデルを一覧表示する
{
"model_type": "sdxl",
"resource_type": "checkpoints"
}2 つのモデルをマージする
{
"model_type": "sd15",
"base_model": "v1-5-pruned.safetensors",
"target_model": "dreamshaper_8.safetensors",
"output_name": "merged_model.safetensors",
"method": "slerp",
"alpha": 0.5
}プロジェクト構造
src/sd_api_mcp/
__init__.py # CLI entry point with transport selection
server.py # MCPServer instance and tool definitions
client.py # Async HTTP client for the SD APIライセンス
このプロジェクトは GNU General Public License v3.0 の下でライセンスされています。詳細は LICENSE を参照してください。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceGive AI agents full control over your local ComfyUI by exposing 77 tools for workflow management, image generation, model handling, and real-time canvas control.3AGPL 3.0
- AlicenseNot gradedqualityCmaintenanceEnables AI image and video generation using Segmind's API with 30+ models including FLUX, Stable Diffusion XL, and more, accessible through any MCP-compatible AI assistant.50MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to generate images using ComfyUI by exposing tools for image generation, batch processing, and status checking through the Model Context Protocol.MIT
- FlicenseNot gradedqualityDmaintenanceEnables LLM clients to generate, edit, and evaluate images through the Replicate API.
Related MCP Connectors
Generate images, GIFs, and PDFs from HTML, URLs, or templates — from your AI agent.
Create and manage cinematic AI video renders through the Future Video Studio Agent API.
LLM chat, text summarization and AI image generation
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/mcaimi/sd-api-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server