Skip to main content
Glama
arinspunk

Claude Talk to Figma MCP

by arinspunk

rename_page

Rename an existing page in a Figma document by providing the page ID and the new name.

Instructions

Rename an existing page in the Figma document

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageIdYesID of the page to rename
nameYesNew name for the page

Implementation Reference

  • The 'rename_page' tool handler: registers the tool with MCP server, accepts pageId and name params, calls sendCommandToFigma('rename_page', ...), and returns a success/error response.
    // Rename Page Tool
    server.tool(
      "rename_page",
      "Rename an existing page in the Figma document",
      {
        pageId: z.string().describe("ID of the page to rename"),
        name: z.string().describe("New name for the page"),
      },
      async ({ pageId, name }) => {
        try {
          const result = await sendCommandToFigma("rename_page", { pageId, name });
          const typedResult = result as { id: string; name: string; oldName: string };
          return {
            content: [
              {
                type: "text",
                text: `Renamed page from "${typedResult.oldName}" to "${typedResult.name}"`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error renaming page: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • The FigmaCommand union type which includes 'rename_page' (line 95) as a valid command string for type safety.
    export type FigmaCommand =
      | "get_document_info"
      | "get_selection"
      | "get_node_info"
      | "create_rectangle"
      | "create_frame"
      | "create_text"
      | "create_ellipse"
      | "create_polygon"
      | "create_star"
      | "create_vector"
      | "create_line"
      | "set_fill_color"
      | "set_stroke_color"
      | "move_node"
      | "resize_node"
      | "delete_node"
      | "get_styles"
      | "get_local_components"
      | "get_team_components"
      | "create_component_instance"
      | "export_node_as_image"
      | "join"
      | "ping"
      | "set_corner_radius"
      | "clone_node"
      | "set_text_content"
      | "scan_text_nodes"
      | "set_multiple_text_contents"
      | "set_auto_layout"
      | "set_font_name"
      | "set_font_size"
      | "set_font_weight"
      | "set_letter_spacing"
      | "set_line_height"
      | "set_paragraph_spacing"
      | "set_text_case"
      | "set_text_decoration"
      | "get_styled_text_segments"
      | "load_font_async"
      | "get_remote_components"
      | "set_effects"
      | "set_effect_style_id"
      | "set_text_style_id"
      | "group_nodes"
      | "ungroup_nodes"
      | "flatten_node"
      | "insert_child"
      | "create_component_from_node"
      | "create_component_set"
      | "set_instance_variant"
      | "create_page"
      | "delete_page"
      | "rename_page"
      | "get_pages"
      | "set_current_page"
      | "rename_node"
      | "set_selection_colors"
      | "set_image_fill"
      | "get_image_from_node"
      | "replace_image_fill"
      // | "get_image_bytes" // COMMENTED OUT: Issues pending investigation
      | "apply_image_transform"
      | "set_image_filters"
      | "rotate_node"
      | "set_node_properties"
      | "reorder_node"
      | "duplicate_page"
      | "convert_to_frame"
      | "set_gradient"
      | "boolean_operation"
      | "set_svg"
      | "get_svg"
      | "set_image"
      | "set_grid"
      | "get_grid"
      | "set_guide"
      | "get_guide"
      | "set_annotation"
      | "get_annotation"
      | "get_variables"
      | "set_variable"
      | "apply_variable_to_node"
      | "switch_variable_mode"
      | "get_figjam_elements"
      | "create_sticky"
      | "set_sticky_text"
      | "create_shape_with_text"
      | "create_connector"
  • The tool is registered via server.tool('rename_page', ...) inside registerDocumentTools() function (line 11). The zod schema at lines 464-467 defines the input validation for pageId and name.
    // Rename Page Tool
    server.tool(
      "rename_page",
      "Rename an existing page in the Figma document",
      {
        pageId: z.string().describe("ID of the page to rename"),
        name: z.string().describe("New name for the page"),
      },
      async ({ pageId, name }) => {
        try {
          const result = await sendCommandToFigma("rename_page", { pageId, name });
          const typedResult = result as { id: string; name: string; oldName: string };
          return {
            content: [
              {
                type: "text",
                text: `Renamed page from "${typedResult.oldName}" to "${typedResult.name}"`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error renaming page: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • sendCommandToFigma() helper function that sends the command string over WebSocket to the Figma server. It constructs a request with the command type and params, and returns a promise.
    export function sendCommandToFigma(
      command: FigmaCommand,
      params: unknown = {},
      timeoutMs: number = 300000
    ): Promise<unknown> {
      return new Promise((resolve, reject) => {
        // If not connected, try to connect first
        if (!ws || ws.readyState !== WebSocket.OPEN) {
          connectToFigma();
          reject(new Error("Not connected to Figma. Attempting to connect..."));
          return;
        }
    
        // Check if we need a channel for this command
        const requiresChannel = command !== "join";
        if (requiresChannel && !currentChannel) {
          reject(new Error("Must join a channel before sending commands"));
          return;
        }
    
        const id = uuidv4();
        const request = {
          id,
          type: command === "join" ? "join" : "message",
          ...(command === "join"
            ? { channel: (params as any).channel, sessionId: SESSION_ID }
            : { channel: currentChannel }),
          message: {
            id,
            command,
            params: {
              ...(params as any),
              commandId: id, // Include the command ID in params
            },
          },
        };
    
        // Set timeout for request
        const timeout = setTimeout(() => {
          if (pendingRequests.has(id)) {
            pendingRequests.delete(id);
            logger.error(`Request ${id} to Figma timed out after ${timeoutMs / 1000} seconds`);
            reject(new Error('Request to Figma timed out'));
          }
        }, timeoutMs);
    
        // Store the promise callbacks to resolve/reject later
        pendingRequests.set(id, {
          resolve,
          reject,
          timeout,
          lastActivity: Date.now()
        });
    
        // Send the request
        logger.info(`Sending command to Figma: ${command}`);
        logger.debug(`Request details: ${JSON.stringify(request)}`);
        ws.send(JSON.stringify(request));
      });
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.8.2

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations, the description carries full responsibility for behavioral transparency. It reveals that the tool mutates the document by renaming a page, but does not disclose side effects, such as impact on nested elements or potential name conflicts. No read-only or destructive hints are provided.

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 a single, front-loaded sentence that efficiently conveys the core action. It is concise with no redundant words, though it could include brief context without becoming verbose.

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 simple two-parameter tool with no output schema, the description is minimally adequate. However, it lacks completeness on preconditions (e.g., page must exist) and postconditions (e.g., name change affects references), which would help an agent avoid errors.

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

Parameters3/5

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

The input schema has 100% coverage with clear descriptions for both parameters ('ID of the page to rename' and 'New name for the page'). The tool description adds no additional meaning beyond the schema, meeting the baseline for full schema coverage.

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

Purpose4/5

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

The description clearly states it renames an existing page in the Figma document. The tool name and description together specify the resource (page) and action (rename). However, it does not explicitly differentiate from the sibling tool 'rename_node', which could rename any node, leaving potential ambiguity.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'rename_node' or 'create_page'. There is no mention of prerequisites, such as the page needing to exist, or exclusions.

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

Deploy Server

Other Tools