generate-ai-image
Convert text prompts into AI-generated images using customizable models, aspect ratios, output formats, and quality settings. Ideal for visual content creation.
Instructions
Generate AI images from text prompts.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | Model-specific parameters | |
| model | Yes | Model to use for generation |
Implementation Reference
- src/index.ts:970-986 (handler)The handler function that executes the tool logic by proxying a POST request to the external Dumpling AI API endpoint for generating AI images from text prompts using specified model and parameters.async ({ model, input }) => { const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch(`${NWS_API_BASE}/api/v1/generate-ai-image`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ model, input }), }); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );
- src/index.ts:956-969 (schema)Zod schema defining the input parameters for the 'generate-ai-image' tool: 'model' string and 'input' object containing prompt, seed, num_outputs, aspect_ratio, output_format, output_quality, num_inference_steps, and guidance scale.model: z.string().describe("Model to use for generation"), input: z .object({ prompt: z.string().describe("Text prompt"), seed: z.number().optional().describe("Random seed"), num_outputs: z.number().optional().describe("Number of images"), aspect_ratio: z.string().optional().describe("Aspect ratio"), output_format: z.string().optional().describe("Output format"), output_quality: z.number().optional().describe("Output quality"), num_inference_steps: z.number().optional().describe("Inference steps"), guidance: z.number().optional().describe("Guidance scale"), }) .describe("Model-specific parameters"), },
- src/index.ts:952-953 (registration)Registration of the 'generate-ai-image' tool on the MCP server using server.tool(), specifying name, description, input schema, and handler function.server.tool( "generate-ai-image",