sd-api-mcp
sd-api-mcp
Un servidor MCP (Model Context Protocol) que expone una API REST de Stable Diffusion a agentes de IA. Admite pipelines SD1.5, SDXL e Illustrious XL para generación de texto a imagen, inpainting, gestión de modelos y fusión de modelos.
Se sitúa sobre el proyecto SD API Backend.
Construido con el MCP Python SDK y gestionado con uv.
Requisitos
Python >= 3.11
Gestor de paquetes uv
Una instancia en ejecución de Stable Diffusion API (por defecto:
http://localhost:8000)
Related MCP server: Segmind MCP Server
Instalación
git clone <repo-url>
cd sd-api-mcp
uv syncUso
stdio (predeterminado)
Para clientes MCP que gestionan el proceso del servidor (p. ej., Claude Code, Claude Desktop):
uv run sd-api-mcpSSE
uv run sd-api-mcp --transport sse --host 0.0.0.0 --port 8080HTTP Streamable (recomendado para despliegues en red)
uv run sd-api-mcp --transport streamable-http --host 0.0.0.0 --port 8080El endpoint MCP estará disponible en http://<host>:<port>/mcp.
Configuración de Claude Desktop
Añade a tu 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"
}
}
}
}Configuración de Claude Code
claude mcp add stable-diffusion -- uv run --project /path/to/sd-api-mcp sd-api-mcpConfiguración de OpenCode
Añade a tu 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"
}
}
}
}Para transportes SSE o HTTP Streamable, inicia el servidor por separado y usa una URL remota en su lugar:
{
"mcp": {
"stable-diffusion": {
"type": "sse",
"url": "http://localhost:8080/sse"
}
}
}Variables de Entorno
Variable | Default | Descripción |
|
| URL base de la API de Stable Diffusion |
|
| Segundos entre consultas de estado de trabajos |
|
| Máximo de segundos para esperar la finalización del trabajo |
|
| Protocolo de transporte ( |
|
| Dirección de enlace para transportes SSE/HTTP |
|
| Puerto para transportes SSE/HTTP |
Herramientas Disponibles
Generación de Imágenes
Herramienta | Descripción |
| Genera una imagen y espera el resultado |
| Inpaint una región enmascarada y espera el resultado |
| Envía un trabajo de generación, devuelve el ID del trabajo inmediatamente |
| Envía un trabajo de inpainting, devuelve el ID del trabajo inmediatamente |
| Envía hasta 10 solicitudes de generación a la vez |
| Genera con 2-6 modelos usando el mismo prompt para comparar |
Todas las herramientas de generación aceptan un parámetro pipeline: "sd15", "sdxl" o "illustrious".
Gestión de Modelos
Herramienta | Descripción |
| Lista checkpoints, LoRAs o VAEs disponibles |
| Lee metadatos del encabezado safetensors de un modelo |
Gestión de Trabajos
Herramienta | Descripción |
| Lista todos los trabajos con estado y progreso |
| Obtiene el estado y resultado de un trabajo específico |
| Cancela un trabajo pendiente o en ejecución |
Sistema
Herramienta | Descripción |
| Comprueba si la API de SD es accesible |
| Obtiene estadísticas de GPU, caché y cola |
| Lista los schedulers de ruido disponibles |
| Obtiene los parámetros de configuración actuales |
Fusión de Modelos
Herramienta | Descripción |
| Fusiona dos checkpoints (lineal, slerp, aditivo, resta) |
| Fusiona un modelo base con múltiples objetivos |
| Ejecuta una receta de fusión de varios pasos |
Ejemplos
Generar una imagen (perspectiva del agente)
Un agente de IA llamaría a la herramienta generate_image con:
{
"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"
}La herramienta envía el trabajo a la API de SD, consulta hasta que se completa y devuelve el resultado completo, incluida la imagen generada.
Listar modelos disponibles
{
"model_type": "sdxl",
"resource_type": "checkpoints"
}Fusionar dos modelos
{
"model_type": "sd15",
"base_model": "v1-5-pruned.safetensors",
"target_model": "dreamshaper_8.safetensors",
"output_name": "merged_model.safetensors",
"method": "slerp",
"alpha": 0.5
}Estructura del Proyecto
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 APILicencia
Este proyecto está licenciado bajo la GNU General Public License v3.0. Consulta LICENSE para más detalles.
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