set_sd_model
Define the active Stable Diffusion model for text-to-image generation and image upscaling within the Image Generation MCP Server by specifying the model name.
Instructions
Set the active Stable Diffusion model
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model_name | Yes | Name of the model to set as active |
Implementation Reference
- src/index.ts:303-314 (handler)The handler function for the 'set_sd_model' tool. It validates the input arguments using isSetModelArgs, then sends a POST request to the Stable Diffusion WebUI API endpoint '/sdapi/v1/options' to set the active model checkpoint using the provided model_name, and returns a confirmation message.case 'set_sd_model': { const args = request.params.arguments; if (!isSetModelArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid parameters'); } await this.axiosInstance.post('/sdapi/v1/options', { sd_model_checkpoint: args.model_name }); return { content: [{ type: 'text', text: `Model set to: ${args.model_name}` }] }; }
- src/index.ts:181-191 (registration)The registration of the 'set_sd_model' tool in the list of tools provided by the ListToolsRequestHandler. Includes the tool name, description, and input schema definition.{ name: 'set_sd_model', description: 'Set the active Stable Diffusion model', inputSchema: { type: 'object', properties: { model_name: { type: 'string', description: 'Name of the model to set as active' } }, required: ['model_name'] } },
- src/index.ts:73-75 (schema)TypeScript interface defining the expected input arguments for the set_sd_model tool.interface SetModelArgs { model_name: string; }
- src/index.ts:432-436 (helper)Helper function to validate and type-guard the input arguments for the set_sd_model tool, ensuring model_name is a string.function isSetModelArgs(value: unknown): value is SetModelArgs { if (typeof value !== 'object' || value === null) return false; const v = value as Record<string, unknown>; return typeof v.model_name === 'string'; }