@ldavis9000aws/swarmui-generator
Version:
A Model Context Protocol server for SwarmUI image generation with TypeScript
131 lines (91 loc) • 3.94 kB
Markdown
# SwarmUI MCP Server
A [Model Context Protocol (MCP)](https://github.com/modelcontextprotocol/mcp) server for SwarmUI image generation with TypeScript.
This server provides an MCP interface for AI assistants to interact with the SwarmUI image generation API, allowing them to generate images, list available models and schedulers, and check system status.
## 🔥 Latest Update (v1.0.12)
- **Major Fix**: Corrected MCP server implementation to comply with official TypeScript SDK patterns
- **Amazon Bedrock Compatibility**: Fixed validation errors when using with Amazon Bedrock Claude models
- **Proper Protocol Implementation**: Now follows the correct `server.tool()` parameter pattern
- **Enhanced Robustness**: Improved error handling in accordance with MCP specifications
## Features
- **Image Generation**: Generate images from text prompts using stable diffusion models
- **Model Listing**: List available stable diffusion models with metadata
- **Scheduler Listing**: List available sampling methods/schedulers
- **System Status**: Check the current state of the SwarmUI engine
## Requirements
- Node.js 16+
- TypeScript 4.9+
- A running SwarmUI instance with API access
## Installation
### Using npx (Recommended)
You can run the server directly using npx without installing it:
```bash
NPX_CONFIG_SWARMUI_API_URL=http://your-swarmui-server:port npx @ldavis9000aws/swarmui-generator
```
Or create a .env file with SWARMUI_API_URL and run:
```bash
npx @ldavis9000aws/swarmui-generator
```
### Global Installation
You can also install the package globally:
```bash
npm install -g @ldavis9000aws/swarmui-generator
```
And then run it:
```bash
SWARMUI_API_URL=http://your-swarmui-server:port swarmui-generator
```
## Usage
### Running the Server
```bash
npm run start
```
The server will connect to the SwarmUI API and listen for MCP commands via stdio.
### Development Mode
```bash
npm run dev
```
This runs the server using ts-node for development purposes.
## Using with LibreChat
To use this MCP server with LibreChat, add the configuration to your `librechat.yaml` file:
```yaml
mcpServers:
swarmui:
title: SwarmUI Image Generator
description: Generate images using the SwarmUI API with stable diffusion models
command: npx
args:
- "@ldavis9000aws/swarmui-generator"
env:
SWARMUI_API_URL: http://your-swarmui-server:port
timeout: 120000 # Optional: timeout in milliseconds (2 minutes)
```
After adding this configuration:
1. Restart your LibreChat server
2. The SwarmUI Image Generator will appear in the model selection dropdown
3. Select Claude + SwarmUI to use this integration
You can use it with prompts like:
- "Please generate an image of a cat in a space suit"
- "Show me different models you can use for image generation"
## API Reference
### Tools
#### `generate_images`
Generates one or more images from a text prompt.
Parameters:
- `prompt` (string, required): The main text prompt describing what to generate
- `negative_prompt` (string, optional): Text describing what to avoid in the generation
- `width` (integer, optional): Image width in pixels (256-1024)
- `height` (integer, optional): Image height in pixels (256-1024)
- `guidance_scale` (number, optional): How closely to follow the prompt (1-20)
- `num_inference_steps` (integer, optional): Number of denoising steps (1-150)
- `num_images` (integer, optional): Number of images to generate (1-4)
- `seed` (integer, optional): Random seed for reproducible results
- `model_name` (string, optional): Model to use for generation
- `scheduler` (string, optional): Scheduler algorithm to use
#### `list_models`
Lists all available stable diffusion models for image generation.
#### `list_schedulers`
Lists all available scheduler algorithms for image generation.
#### `get_system_status`
Gets the current status of the SwarmUI system including GPU usage and job queue.
## License
MIT