Skip to main content
Glama
arinspunk

Claude Talk to Figma MCP

by arinspunk

create_polygon

Create polygons in Figma designs by specifying position, dimensions, sides, colors, and stroke properties for geometric shapes.

Instructions

Create a new polygon in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xYesX position
yYesY position
widthYesWidth of the polygon
heightYesHeight of the polygon
sidesNoNumber of sides (default: 6)
nameNoOptional name for the polygon
parentIdNoOptional parent node ID to append the polygon to
fillColorNoFill color in RGBA format
strokeColorNoStroke color in RGBA format
strokeWeightNoStroke weight

Implementation Reference

  • Handler function for the 'create_polygon' MCP tool. It constructs parameters with defaults and sends a websocket command to Figma using sendCommandToFigma, then returns success/error text response.
    async ({ x, y, width, height, sides, name, parentId, fillColor, strokeColor, strokeWeight }) => {
      try {
        const result = await sendCommandToFigma("create_polygon", {
          x,
          y,
          width,
          height,
          sides: sides || 6,
          name: name || "Polygon",
          parentId,
          fillColor,
          strokeColor,
          strokeWeight,
        });
        
        const typedResult = result as { id: string, name: string };
        return {
          content: [
            {
              type: "text",
              text: `Created polygon with ID: ${typedResult.id} and ${sides || 6} sides`
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error creating polygon: ${error instanceof Error ? error.message : String(error)}`
            }
          ]
        };
      }
    }
  • Zod input schema for the 'create_polygon' tool parameters including position, dimensions, number of sides, name, parent, and optional color/stroke properties.
    {
      x: z.number().describe("X position"),
      y: z.number().describe("Y position"),
      width: z.number().describe("Width of the polygon"),
      height: z.number().describe("Height of the polygon"),
      sides: z.number().min(3).optional().describe("Number of sides (default: 6)"),
      name: z.string().optional().describe("Optional name for the polygon"),
      parentId: z.string().optional().describe("Optional parent node ID to append the polygon to"),
      fillColor: z
        .object({
          r: z.number().min(0).max(1).describe("Red component (0-1)"),
          g: z.number().min(0).max(1).describe("Green component (0-1)"),
          b: z.number().min(0).max(1).describe("Blue component (0-1)"),
          a: z.number().min(0).max(1).optional().describe("Alpha component (0-1)"),
        })
        .optional()
        .describe("Fill color in RGBA format"),
      strokeColor: z
        .object({
          r: z.number().min(0).max(1).describe("Red component (0-1)"),
          g: z.number().min(0).max(1).describe("Green component (0-1)"),
          b: z.number().min(0).max(1).describe("Blue component (0-1)"),
          a: z.number().min(0).max(1).optional().describe("Alpha component (0-1)"),
        })
        .optional()
        .describe("Stroke color in RGBA format"),
      strokeWeight: z.number().positive().optional().describe("Stroke weight"),
    },
  • Direct registration of the 'create_polygon' tool on the MCP server instance inside registerCreationTools function.
      "create_polygon",
      "Create a new polygon in Figma",
      {
        x: z.number().describe("X position"),
        y: z.number().describe("Y position"),
        width: z.number().describe("Width of the polygon"),
        height: z.number().describe("Height of the polygon"),
        sides: z.number().min(3).optional().describe("Number of sides (default: 6)"),
        name: z.string().optional().describe("Optional name for the polygon"),
        parentId: z.string().optional().describe("Optional parent node ID to append the polygon to"),
        fillColor: z
          .object({
            r: z.number().min(0).max(1).describe("Red component (0-1)"),
            g: z.number().min(0).max(1).describe("Green component (0-1)"),
            b: z.number().min(0).max(1).describe("Blue component (0-1)"),
            a: z.number().min(0).max(1).optional().describe("Alpha component (0-1)"),
          })
          .optional()
          .describe("Fill color in RGBA format"),
        strokeColor: z
          .object({
            r: z.number().min(0).max(1).describe("Red component (0-1)"),
            g: z.number().min(0).max(1).describe("Green component (0-1)"),
            b: z.number().min(0).max(1).describe("Blue component (0-1)"),
            a: z.number().min(0).max(1).optional().describe("Alpha component (0-1)"),
          })
          .optional()
          .describe("Stroke color in RGBA format"),
        strokeWeight: z.number().positive().optional().describe("Stroke weight"),
      },
      async ({ x, y, width, height, sides, name, parentId, fillColor, strokeColor, strokeWeight }) => {
        try {
          const result = await sendCommandToFigma("create_polygon", {
            x,
            y,
            width,
            height,
            sides: sides || 6,
            name: name || "Polygon",
            parentId,
            fillColor,
            strokeColor,
            strokeWeight,
          });
          
          const typedResult = result as { id: string, name: string };
          return {
            content: [
              {
                type: "text",
                text: `Created polygon with ID: ${typedResult.id} and ${sides || 6} sides`
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error creating polygon: ${error instanceof Error ? error.message : String(error)}`
              }
            ]
          };
        }
      }
    );
  • registerTools calls registerCreationTools(server), which registers the create_polygon tool among others.
    registerCreationTools(server);
  • Main server initialization calls registerTools(server), starting the chain that registers create_polygon.
    registerTools(server);

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/arinspunk/claude-talk-to-figma-mcp'

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