generate_svg
Convert text prompts into scalable SVG images with customizable styles and sizes using the Recraft model via the replicate-flux-mcp server.
Instructions
Generate an SVG from a text prompt using Recraft model
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | Prompt for generated SVG | |
| size | No | Size of the generated SVG | 1024x1024 |
| style | No | Style of the generated image. | any |
Implementation Reference
- src/tools/generateSVG.ts:9-50 (handler)The main handler function that calls the Replicate API to generate SVG using the provided input parameters, processes the output URL to SVG, and returns the result in MCP format.export const registerGenerateSvgTool = async ( input: SvgGenerationParams ): Promise<CallToolResult> => { try { const output = (await replicate.run(CONFIG.svgModelId, { input, })) as FileOutput; const svgUrl = output.url() as unknown as string; if (!svgUrl) { throw new Error("Failed to generate SVG URL"); } try { const svg = await urlToSvg(svgUrl); return { content: [ { type: "text", text: `This is a generated SVG url: ${svgUrl}`, }, { type: "text", text: svg, }, ], }; } catch (error) { return { content: [ { type: "text", text: `This is a generated SVG url: ${svgUrl}`, }, ], }; } } catch (error) { return handleError(error); } };
- src/tools/index.ts:40-44 (registration)Registers the 'generate_svg' tool with the server, associating the tool name, description, input schema, and handler function."generate_svg", "Generate an SVG from a text prompt using Recraft model", svgGenerationSchema, registerGenerateSvgTool );
- src/types/index.ts:87-113 (schema)Zod schema defining the input parameters for the generate_svg tool: prompt, size (with enum of dimensions), and style (with enum options).export const svgGenerationSchema = { prompt: z.string().min(1).describe("Prompt for generated SVG"), size: z .enum([ "1024x1024", "1365x1024", "1024x1365", "1536x1024", "1024x1536", "1820x1024", "1024x1820", "1024x2048", "2048x1024", "1434x1024", "1024x1434", "1024x1280", "1280x1024", "1024x1707", "1707x1024", ]) .default("1024x1024") .describe("Size of the generated SVG"), style: z .enum(["any", "engraving", "line_art", "line_circuit", "linocut"]) .default("any") .describe("Style of the generated image."), };