Skip to main content
Glama

create_style

Generate custom visual styles by extracting patterns from reference images for use in image generation tools. Input includes style type and 1-5 image URLs or file paths, output provides the style ID.

Instructions

Create a style in Recraft from the set of style reference images. A style is extracted from the provided images and can be used in image generation tools. ID of the created style will be returned in the response.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imageURIsYesArray of images to use as a style references. Each item can be a URL (starting with http:// or https://) or a file path (starting with file://). The length should be from 1 to 5.
styleYesBasic visual style in which the style will be created.

Implementation Reference

  • The createStyleHandler function that executes the 'create_style' tool: parses and validates arguments, downloads images from URIs, converts to blobs, calls the API to create style, and returns appropriate text content.
    export const createStyleHandler = async (server: RecraftServer, args: Record<string, unknown>): Promise<CallToolResult> => { try { const { style, imageURIs } = z.object({ style: z.nativeEnum(ImageStyle), imageURIs: z.array(z.string()).nonempty(), }).parse(args) const blobPromises = imageURIs.map(async (imageURI) => await downloadImage(imageURI).then(imageDataToBlob)) const blobs = await Promise.all(blobPromises) const result = await server.api.styleApi.createStyle({ style: style, images: blobs, }) return { content: [ { type: 'text', text: `A new style with style_id ${result.id} created.\nYou can use this style in the image generation tools.` } ], isError: false } } catch (error) { return { content: [ { type: 'text', text: `Error creating style: ${error}` } ], isError: true } } }
  • The createStyleTool object defines the tool's name, description, and inputSchema for validation, which specifies 'style' enum and 'imageURIs' array.
    export const createStyleTool = { name: "create_style", description: "Create a style in Recraft from the set of style reference images.\n" + "A style is extracted from the provided images and can be used in image generation tools.\n" + "ID of the created style will be returned in the response.", inputSchema: { type: "object", properties: { style: { type: "string", enum: [ImageStyle.RealisticImage, ImageStyle.DigitalIllustration, ImageStyle.VectorIllustration, ImageStyle.Icon], description: "Basic visual style in which the style will be created." }, imageURIs: { type: "array", items: { type: "string", }, description: "Array of images to use as a style references. Each item can be a URL (starting with http:// or https://) or a file path (starting with file://). The length should be from 1 to 5." }, }, required: ["style", "imageURIs"] }
  • src/index.ts:68-82 (registration)
    Registration of the 'create_style' tool in the MCP server's list of available tools via createStyleTool inclusion in the ListToolsRequest handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ generateImageTool, createStyleTool, vectorizeImageTool, imageToImageTool, removeBackgroundTool, replaceBackgroundTool, crispUpscaleTool, creativeUpscaleTool, getUserTool, ], } })
  • src/index.ts:104-105 (registration)
    Handler dispatch registration: maps 'create_style' tool calls to the createStyleHandler function in the CallToolRequest switch statement.
    case createStyleTool.name: return await createStyleHandler(recraftServer, args ?? {})

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