FLUX_1-schnell-infer
Generate images from text prompts using customizable parameters like seed, dimensions, and inference steps with the HuggingFace Spaces integration on mcp-hfspace.
Instructions
Call the FLUX.1-schnell endpoint /infer
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| height | No | numeric value between 256 and 2048 | |
| num_inference_steps | No | numeric value between 1 and 50 | |
| prompt | Yes | Prompt | |
| randomize_seed | No | Randomize seed | |
| seed | No | numeric value between 0 and 2147483647 | |
| width | No | numeric value between 256 and 2048 |
Implementation Reference
- src/endpoint_wrapper.ts:61-64 (helper)Tool name formatting function that converts space and endpoint names into MCP tool names, replacing dots with underscores and other special charactersfunction formatMcpToolName(space: string, endpoint: string | number) { return `${space}-${endpoint}`.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64); }
- src/config.ts:32-38 (registration)Default configuration that includes black-forest-labs/FLUX.1-schnell space, which would be formatted as FLUX_1-schnell-infer tool when paired with /infer endpointspacePaths: (() => { const filtered = argv._.filter((arg) => arg.toString().trim().length > 0); return filtered.length > 0 ? filtered : ["black-forest-labs/FLUX.1-schnell"]; })(), };
- src/endpoint_wrapper.ts:96-108 (handler)Endpoint selection logic that prioritizes /infer endpoint for FLUX space, which creates the FLUX_1-schnell-infer toolconst preferredApis = [ "/predict", "/infer", "/generate", "/complete", "/model_chat", "/lambda", "/generate_image", "/process_prompt", "/on_submit", "/add_text", ];
- src/endpoint_wrapper.ts:193-224 (handler)Main handler function that executes tool calls for registered endpoints including FLUX_1-schnell-inferasync call( request: CallToolRequest, server: Server, ): Promise<CallToolResult> { const progressToken = request.params._meta?.progressToken as | string | number | undefined; const parameters = request.params.arguments as Record<string, unknown>; // Get the endpoint parameters to check against const endpointParams = this.endpoint.parameters; // Process each parameter, applying handle_file for file inputs for (const [key, value] of Object.entries(parameters)) { const param = endpointParams.find( (p) => p.parameter_name === key || p.label === key, ); if (param && isFileParameter(param) && typeof value === "string") { const file = await this.validatePath(value); parameters[key] = handle_file(file); } } const normalizedToken = typeof progressToken === "number" ? progressToken.toString() : progressToken; return this.handleToolCall(parameters, normalizedToken, server); }
- src/index.ts:110-113 (registration)Dynamic tool registration that includes FLUX_1-schnell-infer tool in the MCP server's available tools list...Array.from(endpoints.values()).map((endpoint) => endpoint.toolDefinition(), ), ],