Skip to main content
Glama

flatten_node

Flatten Figma nodes to enable boolean operations or convert them to paths for design manipulation.

Instructions

Flatten a node in Figma (e.g., for boolean operations or converting to path)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesID of the node to flatten

Implementation Reference

  • Registration of the MCP tool 'flatten_node'. Includes the tool name, description, Zod input schema (nodeId: string), and the handler function which sends the 'flatten_node' command to Figma via sendCommandToFigma and returns a text response with the result or error.
    server.tool(
      "flatten_node",
      "Flatten a node in Figma (e.g., for boolean operations or converting to path)",
      {
        nodeId: z.string().describe("ID of the node to flatten"),
      },
      async ({ nodeId }) => {
        try {
          const result = await sendCommandToFigma("flatten_node", { nodeId });
          
          const typedResult = result as { 
            id: string, 
            name: string, 
            type: string 
          };
          
          return {
            content: [
              {
                type: "text",
                text: `Node "${typedResult.name}" flattened successfully. The new node has ID: ${typedResult.id} and is of type ${typedResult.type}.`
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error flattening node: ${error instanceof Error ? error.message : String(error)}`
              }
            ]
          };
        }
      }
    );
  • The handler function for the flatten_node tool. It calls sendCommandToFigma with the nodeId, type-asserts the result, and returns a standardized MCP text response indicating success with new node details or an error message.
    async ({ nodeId }) => {
      try {
        const result = await sendCommandToFigma("flatten_node", { nodeId });
        
        const typedResult = result as { 
          id: string, 
          name: string, 
          type: string 
        };
        
        return {
          content: [
            {
              type: "text",
              text: `Node "${typedResult.name}" flattened successfully. The new node has ID: ${typedResult.id} and is of type ${typedResult.type}.`
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error flattening node: ${error instanceof Error ? error.message : String(error)}`
            }
          ]
        };
      }
  • Zod input schema for the flatten_node tool: requires a single 'nodeId' parameter as string, with description.
    {
      nodeId: z.string().describe("ID of the node to flatten"),
    },
  • 'flatten_node' is included in the FigmaCommand union type, indicating it's a recognized command for sending to Figma.
    | "flatten_node"

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/agenisea/cc-fig-mcp'

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