Skip to main content
Glama

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
NameRequiredDescriptionDefault
model_nameYesName of the model to set as active

Implementation Reference

  • 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'] } },
  • TypeScript interface defining the expected input arguments for the set_sd_model tool.
    interface SetModelArgs { model_name: string; }
  • 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'; }

Other Tools

Related Tools

Latest Blog Posts

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/Ichigo3766/image-gen-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server