Skip to main content
Glama

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
NameRequiredDescriptionDefault
promptYesPrompt for generated SVG
sizeNoSize of the generated SVG1024x1024
styleNoStyle of the generated image.any

Implementation Reference

  • 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); } };
  • 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 );
  • 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."), };

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/awkoy/replicate-flux-mcp'

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