Skip to main content
Glama
yhc984

Talk to Figma MCP

by yhc984

delete_node

Remove a specific element from Figma designs by providing its node ID to clean up or modify layouts.

Instructions

Delete a node from Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the node to delete

Implementation Reference

  • Core Figma plugin handler function that implements node deletion by fetching the node by ID and calling node.remove()
    async function deleteNode(params) {
      const { nodeId } = params || {};
    
      if (!nodeId) {
        throw new Error("Missing nodeId parameter");
      }
    
      const node = await figma.getNodeByIdAsync(nodeId);
      if (!node) {
        throw new Error(`Node not found with ID: ${nodeId}`);
      }
    
      // Save node info before deleting
      const nodeInfo = {
        id: node.id,
        name: node.name,
        type: node.type,
      };
    
      node.remove();
    
      return nodeInfo;
    }
  • MCP server.tool registration for 'delete_node' tool, including schema, description, and proxy handler that calls the Figma plugin
    server.tool(
      "delete_node",
      "Delete a node from Figma",
      {
        nodeId: z.string().describe("The ID of the node to delete")
      },
      async ({ nodeId }) => {
        try {
          await sendCommandToFigma('delete_node', { nodeId });
          return {
            content: [
              {
                type: "text",
                text: `Deleted node with ID: ${nodeId}`
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error deleting node: ${error instanceof Error ? error.message : String(error)}`
              }
            ]
          };
        }
      }
    );
  • Dispatch handler in Figma plugin's handleCommand switch statement that routes 'delete_node' command to deleteNode function
    case "delete_node":
      return await deleteNode(params);
  • Zod input schema for delete_node MCP tool requiring nodeId string
    {
      nodeId: z.string().describe("The ID of the node to delete")
    },
  • Call to sendCommandToFigma helper function that forwards the delete_node command to the Figma WebSocket server
    await sendCommandToFigma('delete_node', { nodeId });

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/yhc984/cursor-talk-to-figma-mcp-main'

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