Skip to main content
Glama

set_multiple_text_contents

Update multiple text elements simultaneously within a Figma design node to modify content in bulk.

Instructions

Set multiple text contents parallelly in a node

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the node containing the text nodes to replace
textYesArray of text node IDs and their replacement texts

Implementation Reference

  • The handler function for the 'set_multiple_text_contents' MCP tool. It validates input, sends the command to the Figma plugin via sendCommandToFigma, processes the result including progress and errors, and returns a formatted response with status updates.
    async ({ nodeId, text }, extra) => {
      try {
        if (!text || text.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: "No text provided",
              },
            ],
          };
        }
    
        // Initial response to indicate we're starting the process
        const initialStatus = {
          type: "text" as const,
          text: `Starting text replacement for ${text.length} nodes. This will be processed in batches of 5...`,
        };
    
        // Track overall progress
        let totalProcessed = 0;
        const totalToProcess = text.length;
    
        // Use the plugin's set_multiple_text_contents function with chunking
        const result = await sendCommandToFigma("set_multiple_text_contents", {
          nodeId,
          text,
        });
    
        // Cast the result to a specific type to work with it safely
        interface TextReplaceResult {
          success: boolean;
          nodeId: string;
          replacementsApplied?: number;
          replacementsFailed?: number;
          totalReplacements?: number;
          completedInChunks?: number;
          results?: Array<{
            success: boolean;
            nodeId: string;
            error?: string;
            originalText?: string;
            translatedText?: string;
          }>;
        }
    
        const typedResult = result as TextReplaceResult;
    
        // Format the results for display
        const success = typedResult.replacementsApplied && typedResult.replacementsApplied > 0;
        const progressText = `
        Text replacement completed:
        - ${typedResult.replacementsApplied || 0} of ${totalToProcess} successfully updated
        - ${typedResult.replacementsFailed || 0} failed
        - Processed in ${typedResult.completedInChunks || 1} batches
        `;
    
        // Detailed results
        const detailedResults = typedResult.results || [];
        const failedResults = detailedResults.filter(item => !item.success);
    
        // Create the detailed part of the response
        let detailedResponse = "";
        if (failedResults.length > 0) {
          detailedResponse = `\n\nNodes that failed:\n${failedResults.map(item =>
            `- ${item.nodeId}: ${item.error || "Unknown error"}`
          ).join('\n')}`;
        }
    
        return {
          content: [
            initialStatus,
            {
              type: "text" as const,
              text: progressText + detailedResponse,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error setting multiple text contents: ${error instanceof Error ? error.message : String(error)
                }`,
            },
          ],
        };
      }
    }
  • The MCP server.tool registration for 'set_multiple_text_contents', including the tool name, description, input schema using Zod, and reference to the handler function.
    server.tool(
      "set_multiple_text_contents",
      "Set multiple text contents parallelly in a node",
      {
        nodeId: z
          .string()
          .describe("The ID of the node containing the text nodes to replace"),
        text: z
          .array(
            z.object({
              nodeId: z.string().describe("The ID of the text node"),
              text: z.string().describe("The replacement text"),
            })
          )
          .describe("Array of text node IDs and their replacement texts"),
      },
      async ({ nodeId, text }, extra) => {
        try {
          if (!text || text.length === 0) {
            return {
              content: [
                {
                  type: "text",
                  text: "No text provided",
                },
              ],
            };
          }
    
          // Initial response to indicate we're starting the process
          const initialStatus = {
            type: "text" as const,
            text: `Starting text replacement for ${text.length} nodes. This will be processed in batches of 5...`,
          };
    
          // Track overall progress
          let totalProcessed = 0;
          const totalToProcess = text.length;
    
          // Use the plugin's set_multiple_text_contents function with chunking
          const result = await sendCommandToFigma("set_multiple_text_contents", {
            nodeId,
            text,
          });
    
          // Cast the result to a specific type to work with it safely
          interface TextReplaceResult {
            success: boolean;
            nodeId: string;
            replacementsApplied?: number;
            replacementsFailed?: number;
            totalReplacements?: number;
            completedInChunks?: number;
            results?: Array<{
              success: boolean;
              nodeId: string;
              error?: string;
              originalText?: string;
              translatedText?: string;
            }>;
          }
    
          const typedResult = result as TextReplaceResult;
    
          // Format the results for display
          const success = typedResult.replacementsApplied && typedResult.replacementsApplied > 0;
          const progressText = `
          Text replacement completed:
          - ${typedResult.replacementsApplied || 0} of ${totalToProcess} successfully updated
          - ${typedResult.replacementsFailed || 0} failed
          - Processed in ${typedResult.completedInChunks || 1} batches
          `;
    
          // Detailed results
          const detailedResults = typedResult.results || [];
          const failedResults = detailedResults.filter(item => !item.success);
    
          // Create the detailed part of the response
          let detailedResponse = "";
          if (failedResults.length > 0) {
            detailedResponse = `\n\nNodes that failed:\n${failedResults.map(item =>
              `- ${item.nodeId}: ${item.error || "Unknown error"}`
            ).join('\n')}`;
          }
    
          return {
            content: [
              initialStatus,
              {
                type: "text" as const,
                text: progressText + detailedResponse,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error setting multiple text contents: ${error instanceof Error ? error.message : String(error)
                  }`,
              },
            ],
          };
        }
      }
    );
  • Zod schema defining the input parameters for the 'set_multiple_text_contents' tool: nodeId (string) and text (array of {nodeId: string, text: string}).
    {
      nodeId: z
        .string()
        .describe("The ID of the node containing the text nodes to replace"),
      text: z
        .array(
          z.object({
            nodeId: z.string().describe("The ID of the text node"),
            text: z.string().describe("The replacement text"),
          })
        )
        .describe("Array of text node IDs and their replacement texts"),
    },
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'parallelly' which suggests concurrent processing, but doesn't explain what this means operationally (e.g., atomicity, error handling, performance implications). For a mutation tool that modifies multiple text nodes, this is insufficient behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point with zero wasted words. It's appropriately sized for a tool with good schema documentation and no complex behavioral nuances to explain.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is inadequate. It doesn't explain what happens on success/failure, whether changes are reversible, what permissions are required, or what the return value contains. The 'parallelly' hint is insufficient given the tool's complexity.

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?

Schema description coverage is 100%, so the schema already fully documents both parameters. The description doesn't add any meaningful semantic context beyond what's in the schema (e.g., what constitutes valid node IDs, text length limits, or the relationship between the parent node and text nodes). Baseline 3 is appropriate when schema does the heavy lifting.

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 the action ('Set multiple text contents parallelly') and target ('in a node'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from its sibling 'set_text_content' (singular vs. multiple), which is a missed opportunity for differentiation.

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?

The description provides no guidance on when to use this tool versus alternatives like 'set_text_content' (for single text nodes) or other text manipulation tools. There's no mention of prerequisites, constraints, or appropriate contexts for this parallel operation.

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

Install Server

Other 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/pipethedev/Talk-to-Figma-MCP'

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