Skip to main content
Glama
recraft-ai

Recraft AI MCP Server

Official

generate_image

Create custom images from text prompts using Recraft AI. Specify size, style, model, and quantity for raster or vector outputs. Local paths or URLs to generated images and previews are provided.

Instructions

Generate an image using Recraft from a text prompt. You can specify the image size, style, model, and number of images to generate. You don't need to change default parameters if you don't have any specific requirements. You can use styles to refine the image generation, and also to generate raster or vector images. Local paths or URLs to generated images and their previews will be returned in the response.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelNoModel version to use. Default is recraftv3. - recraftv3 is the latest model and should be used in most cases. - recraftv2 is the previous state model, it has a bit cheaper generation. Be accurate with compatibility of model with style if it is specified, otherwise generation will fail.
numberOfImagesNoNumber of images to generate. Should be from 1 to 6. Default is 1.
promptYesText prompt of the image you want to generate. Its length should be from 1 to 1024 characters.
sizeNoImage dimensions. Default is 1024x1024.
styleNoVisual style to apply. Default is realistic_image. Use this parameter only if you want to refine the image generation. Mutually exclusive with styleID, you can't specify both of them. realistic_image, digital_illustration, vector_illustration are available in both models, but icon is available only for recraftv2, and logo_raster is available only for recraftv3. If you will provide a style that is not available for the specified model, generation will fail. Styles use-cases: - realistic_image: for realistic images, photos, portraits, landscapes, etc. Raster is generated. - digital_illustration: for digital illustrations, concept art, fantasy art, etc. Raster is generated. - vector_illustration: for vector illustrations, logos, icons, etc. Vector is generated. - icon: for icons, small graphics (only in recraftv2). Vector is generated - logo_raster: for graphic design, raster logos, posters, emblems, and badges (only in recraftv3). Raster is generated.
styleIDNoID of the style to apply. Mutually exclusive with style, you can't specify both of them. This ID can be the style ID from recraft.ai or some previously created custom style.
substyleNoVisual substyle to apply. Can be specified only with style to refine more specifically. If this parameter is not specified, model will decide on the final style. Use this parameter only if you want to refine the image generation more. No need to specify if you don't have any specific requirements. Note that each combination of model and style has their own list of available substyles: - recraftv3 with style realistic_image: b_and_w, enterprise, evening_light, faded_nostalgia, forest_life, hard_flash, hdr, motion_blur, mystic_naturalism, natural_light, natural_tones, organic_calm, real_life_glow, retro_realism, retro_snapshot, studio_portrait, urban_drama, village_realism, warm_folk - recraftv2 with style realistic_image: b_and_w, enterprise, hard_flash, hdr, motion_blur, natural_light, studio_portrait - recraftv3 with style digital_illustration: 2d_art_poster, 2d_art_poster_2, antiquarian, bold_fantasy, child_book, cover, crosshatch, digital_engraving, engraving_color, expressionism, freehand_details, grain, grain_20, graphic_intensity, hand_drawn, hand_drawn_outline, handmade_3d, hard_comics, infantile_sketch, long_shadow, modern_folk, multicolor, neon_calm, noir, nostalgic_pastel, outline_details, pastel_gradient, pastel_sketch, pixel_art, plastic, pop_art, pop_renaissance, seamless, street_art, tablet_sketch, urban_glow, urban_sketching, young_adult_book, young_adult_book_2 - recraftv2 with style digital_illustration: 2d_art_poster, 2d_art_poster_2, 3d, 80s, engraving_color, glow, grain, hand_drawn, hand_drawn_outline, handmade_3d, infantile_sketch, kawaii, pixel_art, plastic, psychedelic, seamless, voxel, watercolor - recraftv3 with style vector_illustration: bold_stroke, chemistry, colored_stencil, cosmics, cutout, depressive, editorial, emotional_flat, engraving, line_art, line_circuit, linocut, marker_outline, mosaic, naivector, roundish_flat, seamless, segmented_colors, sharp_contrast, thin, vector_photo, vivid_shapes - recraftv2 with style vector_illustration: cartoon, doodle_line_art, engraving, flat_2, kawaii, line_art, line_circuit, linocut, seamless - recraftv2 with style icon: broken_line, colored_outline, colored_shapes, colored_shapes_gradient, doodle_fill, doodle_offset_fill, offset_fill, outline, outline_gradient, pictogram - recraftv3 with style logo_raster: emblem_graffiti, emblem_pop_art, emblem_punk, emblem_stamp, emblem_vintage If you will provide a substyle that is not available for the specified model and style, generation will fail.

Implementation Reference

  • The main execution logic for the generate_image tool: validates input args with Zod, calls the Recraft API to generate image, handles errors, and transforms response using helper.
    export const generateImageHandler = async (server: RecraftServer, args: Record<string, unknown>): Promise<CallToolResult> => {
      try {
        const { prompt, size, style, styleID, substyle, model, numberOfImages } = z.object({
          prompt: z.string(),
          size: z.nativeEnum(ImageSize).optional(),
          style: z.nativeEnum(ImageStyle).optional(),
          substyle: z.nativeEnum(ImageSubStyle).optional(),
          styleID: z.string().optional(),
          model: z.nativeEnum(TransformModel).optional(),
          numberOfImages: z.number().min(1).max(6).optional()
        }).parse(args)
    
        const result = await server.api.imageApi.generateImage({
          generateImageRequest: {
            prompt: prompt,
            size: size,
            style: styleID ? undefined : style,
            substyle: styleID ? undefined : substyle,
            styleId: styleID,
            model: model,
            responseFormat: 'url',
            n: numberOfImages,
            expire: server.isLocalResultsStorage,
          }
        })
    
        return await server.transformGenerateImageResponseToCallToolResult(result)
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error generating image: ${error}`
            }
          ],
          isError: true
        }
      }
    }
  • Tool metadata definition including name, description, and inputSchema (JSON Schema) for validation of tool parameters like prompt (required), size, style, etc.
    export const generateImageTool = {
      name: "generate_image",
      description: "Generate an image using Recraft from a text prompt.\n" +
          "You can specify the image size, style, model, and number of images to generate.\n" +
          "You don't need to change default parameters if you don't have any specific requirements.\n" +
          "You can use styles to refine the image generation, and also to generate raster or vector images.\n" +
          "Local paths or URLs to generated images and their previews will be returned in the response.",
      inputSchema: {
        type: "object",
        properties: {
          prompt: PARAMETERS.promptSimple,
          size: PARAMETERS.imageSize,
          style: PARAMETERS.imageStyle,
          substyle: PARAMETERS.imageSubStyle,
          styleID: PARAMETERS.imageStyleID,
          model: PARAMETERS.transformModel,
          numberOfImages: PARAMETERS.numberOfImages,
        },
        required: ["prompt"]
      }
    }
  • src/index.ts:68-82 (registration)
    Registers the generate_image tool (via generateImageTool) in the list of available tools for ListTools requests.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          generateImageTool,
          createStyleTool,
          vectorizeImageTool,
          imageToImageTool,
          removeBackgroundTool,
          replaceBackgroundTool,
          crispUpscaleTool,
          creativeUpscaleTool,
          getUserTool,
        ],
      }
    })
  • src/index.ts:102-103 (registration)
    In the CallTool request handler switch, dispatches to generateImageHandler when tool name is 'generate_image'.
    case generateImageTool.name:
      return await generateImageHandler(recraftServer, args ?? {})
  • Helper method to transform API GenerateImageResponse into MCP CallToolResult by downloading images, generating previews, and formatting the content block.
    transformGenerateImageResponseToCallToolResult = async (result: GenerateImageResponse): Promise<CallToolResult> => {
      const {downloadedImages: images, previews} = await downloadImagesAndMakePreviews(this.imageStorageDirectory, result.data)
    
      const pathOrUrlDesc = this.isLocalResultsStorage ? 'path' : 'URL'
    
      const ending = `${images.length === 1 ? '' : 's'}`
      const message = `Generated ${images.length} image${ending}.\n` +
       `Original image${ending} ${images.length === 1 ? 'is' : 'are'} saved to:\n${images.map(({pathOrUrl}) => `- ${pathOrUrl}`).join('\n')}` +
       `\nBelow you can see lower quality preview${ending} of generated image${ending}.` +
       `${previews.length < images.length ? `\nNote: last ${images.length - previews.length} images are not shown due to message limit, but you can still find them by given ${pathOrUrlDesc}s.` : ''}`
    
      const content = []
      content.push({
        type: 'text',
        text: message,
      })
      content.push(...previews)
    
      return {
        content: content,
        isError: false
      } as CallToolResult
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It does reveal important behavioral aspects: that generation can fail with incompatible model/style combinations, that local paths or URLs will be returned, and that raster vs vector output depends on style. However, it doesn't mention authentication requirements, rate limits, cost implications, or error handling beyond compatibility failures.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with 5 sentences that each serve a purpose: stating the core function, listing key parameters, advising on defaults, explaining style usage, and describing return values. It's front-loaded with the essential information, though the final sentence about return values could be more prominent.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex 7-parameter tool with no annotations and no output schema, the description provides adequate but incomplete coverage. It explains the tool's purpose and parameter usage well, but lacks information about authentication, rate limits, cost, error responses, and detailed output format beyond 'local paths or URLs and their previews'. Given the complexity, more behavioral context would be beneficial.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the baseline is 3. The description adds meaningful context by explaining the purpose of style parameters ('to refine the image generation'), clarifying that styles affect raster vs vector output, and emphasizing that default parameters are sufficient for basic use. It provides higher-level guidance beyond the detailed schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verb ('generate') and resource ('image using Recraft from a text prompt'), distinguishing it from siblings like 'image_to_image' or 'vectorize_image'. It establishes this as a text-to-image generation tool rather than image transformation or editing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context about when to use default parameters ('You don't need to change default parameters if you don't have any specific requirements') and when to use style parameters ('Use this parameter only if you want to refine the image generation'). However, it doesn't explicitly contrast when to use this versus sibling tools like 'image_to_image' or 'creative_upscale'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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/recraft-ai/mcp-recraft-server'

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