Skip to main content
Glama

set_multiple_annotations

Apply multiple annotations simultaneously to Figma design elements to document components, provide feedback, or categorize sections within a node.

Instructions

Set multiple annotations parallelly in a node

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodeIdYesThe ID of the node containing the elements to annotate
annotationsYesArray of annotations to apply

Implementation Reference

  • Registration and handler implementation of the MCP tool 'set_multiple_annotations'. The handler validates input using Zod schema, processes annotations in batches via the Figma plugin using sendCommandToFigma, and provides progress feedback.
    server.tool(
      "set_multiple_annotations",
      "Set multiple annotations parallelly in a node",
      {
        nodeId: z
          .string()
          .describe("The ID of the node containing the elements to annotate"),
        annotations: z
          .array(
            z.object({
              nodeId: z.string().describe("The ID of the node to annotate"),
              labelMarkdown: z.string().describe("The annotation text in markdown format"),
              categoryId: z.string().optional().describe("The ID of the annotation category"),
              annotationId: z.string().optional().describe("The ID of the annotation to update (if updating existing annotation)"),
              properties: z.array(z.object({
                type: z.string()
              })).optional().describe("Additional properties for the annotation")
            })
          )
          .describe("Array of annotations to apply"),
      },
      async ({ nodeId, annotations }, extra) => {
        try {
          if (!annotations || annotations.length === 0) {
            return {
              content: [
                {
                  type: "text",
                  text: "No annotations provided",
                },
              ],
            };
          }
    
          // Initial response to indicate we're starting the process
          const initialStatus = {
            type: "text" as const,
            text: `Starting annotation process for ${annotations.length} nodes. This will be processed in batches of 5...`,
          };
    
          // Track overall progress
          let totalProcessed = 0;
          const totalToProcess = annotations.length;
    
          // Use the plugin's set_multiple_annotations function with chunking
          const result = await sendCommandToFigma("set_multiple_annotations", {
            nodeId,
            annotations,
          });
    
          // Cast the result to a specific type to work with it safely
          interface AnnotationResult {
            success: boolean;
            nodeId: string;
            annotationsApplied?: number;
            annotationsFailed?: number;
            totalAnnotations?: number;
            completedInChunks?: number;
            results?: Array<{
              success: boolean;
              nodeId: string;
              error?: string;
              annotationId?: string;
            }>;
          }
    
          const typedResult = result as AnnotationResult;
    
          // Format the results for display
          const success = typedResult.annotationsApplied && typedResult.annotationsApplied > 0;
          const progressText = `
          Annotation process completed:
          - ${typedResult.annotationsApplied || 0} of ${totalToProcess} successfully applied
          - ${typedResult.annotationsFailed || 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 annotations: ${error instanceof Error ? error.message : String(error)
                  }`,
              },
            ],
          };
        }
      }
    );
  • TypeScript interface defining the parameters for set_multiple_annotations command sent to Figma plugin.
    interface SetMultipleAnnotationsParams {
      nodeId: string;
      annotations: Array<{
        nodeId: string;
        labelMarkdown: string;
        categoryId?: string;
        annotationId?: string;
        properties?: Array<{ type: string }>;
      }>;
    }
  • Zod schema for input validation of the MCP tool 'set_multiple_annotations'.
      nodeId: z
        .string()
        .describe("The ID of the node containing the elements to annotate"),
      annotations: z
        .array(
          z.object({
            nodeId: z.string().describe("The ID of the node to annotate"),
            labelMarkdown: z.string().describe("The annotation text in markdown format"),
            categoryId: z.string().optional().describe("The ID of the annotation category"),
            annotationId: z.string().optional().describe("The ID of the annotation to update (if updating existing annotation)"),
            properties: z.array(z.object({
              type: z.string()
            })).optional().describe("Additional properties for the annotation")
          })
        )
        .describe("Array of annotations to apply"),
    },
    async ({ nodeId, annotations }, extra) => {
      try {
        if (!annotations || annotations.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: "No annotations provided",
              },
            ],
          };
        }
    
        // Initial response to indicate we're starting the process
        const initialStatus = {
          type: "text" as const,
          text: `Starting annotation process for ${annotations.length} nodes. This will be processed in batches of 5...`,
        };
    
        // Track overall progress
        let totalProcessed = 0;
        const totalToProcess = annotations.length;
    
        // Use the plugin's set_multiple_annotations function with chunking
        const result = await sendCommandToFigma("set_multiple_annotations", {
          nodeId,
          annotations,
        });
    
        // Cast the result to a specific type to work with it safely
        interface AnnotationResult {
          success: boolean;
          nodeId: string;
          annotationsApplied?: number;
          annotationsFailed?: number;
          totalAnnotations?: number;
          completedInChunks?: number;
          results?: Array<{
            success: boolean;
            nodeId: string;
            error?: string;
            annotationId?: string;
          }>;
        }
    
        const typedResult = result as AnnotationResult;
    
        // Format the results for display
        const success = typedResult.annotationsApplied && typedResult.annotationsApplied > 0;
        const progressText = `
        Annotation process completed:
        - ${typedResult.annotationsApplied || 0} of ${totalToProcess} successfully applied
        - ${typedResult.annotationsFailed || 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 annotations: ${error instanceof Error ? error.message : String(error)
                }`,
            },
          ],
        };
      }
    }
  • The core handler function that executes the tool logic by forwarding the annotations to the Figma plugin via WebSocket (sendCommandToFigma), handles batch processing feedback, and formats the response with success metrics.
    async ({ nodeId, annotations }, extra) => {
      try {
        if (!annotations || annotations.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: "No annotations provided",
              },
            ],
          };
        }
    
        // Initial response to indicate we're starting the process
        const initialStatus = {
          type: "text" as const,
          text: `Starting annotation process for ${annotations.length} nodes. This will be processed in batches of 5...`,
        };
    
        // Track overall progress
        let totalProcessed = 0;
        const totalToProcess = annotations.length;
    
        // Use the plugin's set_multiple_annotations function with chunking
        const result = await sendCommandToFigma("set_multiple_annotations", {
          nodeId,
          annotations,
        });
    
        // Cast the result to a specific type to work with it safely
        interface AnnotationResult {
          success: boolean;
          nodeId: string;
          annotationsApplied?: number;
          annotationsFailed?: number;
          totalAnnotations?: number;
          completedInChunks?: number;
          results?: Array<{
            success: boolean;
            nodeId: string;
            error?: string;
            annotationId?: string;
          }>;
        }
    
        const typedResult = result as AnnotationResult;
    
        // Format the results for display
        const success = typedResult.annotationsApplied && typedResult.annotationsApplied > 0;
        const progressText = `
        Annotation process completed:
        - ${typedResult.annotationsApplied || 0} of ${totalToProcess} successfully applied
        - ${typedResult.annotationsFailed || 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 annotations: ${error instanceof Error ? error.message : String(error)
                }`,
            },
          ],
        };
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the action without behavioral details. It doesn't disclose if this is a mutation, requires permissions, has side effects, rate limits, or error handling. 'Parallelly' hints at concurrency but is undefined, leaving critical behavioral traits unclear.

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, efficient sentence that's front-loaded with the core action. However, 'parallelly' is ambiguous and could be clarified, slightly reducing effectiveness. Overall, it's concise with minimal waste.

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 incomplete. It lacks behavioral context, usage guidelines, and details on what 'parallelly' entails. Given the complexity of batch operations and missing structured data, more explanation is needed for adequate agent use.

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 fully documents parameters. The description adds no meaning beyond the schema, not explaining 'parallelly' in parameter context or providing examples. Baseline 3 is appropriate as the schema handles parameter semantics adequately.

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

Purpose3/5

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

The description 'Set multiple annotations parallelly in a node' states the action (set) and resource (annotations) with a scope (multiple, parallelly, in a node), but it's vague about what 'parallelly' means operationally and doesn't differentiate from sibling 'set_annotation'. It's not tautological but lacks specificity about the parallel execution aspect.

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 on when to use this tool versus 'set_annotation' or other annotation-related tools like 'get_annotations'. The description implies batch operations but doesn't specify scenarios, prerequisites, or exclusions, leaving the agent without clear usage context.

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