Skip to main content
Glama
andreycretsu

Cursor Talk to Figma MCP

by andreycretsu

set_multiple_annotations

Apply multiple annotations simultaneously to design elements in Figma nodes to document and organize design specifications efficiently.

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 of the 'set_multiple_annotations' tool using server.tool(), including schema and handler function.
    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)
                  }`,
              },
            ],
          };
        }
      }
    );
  • The async handler function that executes the tool logic: validates input, sends batched command to Figma WebSocket server, processes results showing success/failure counts and details.
    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.
    interface SetMultipleAnnotationsParams {
      nodeId: string;
      annotations: Array<{
        nodeId: string;
        labelMarkdown: string;
        categoryId?: string;
        annotationId?: string;
        properties?: Array<{ type: string }>;
      }>;
    }
  • Zod schema for input validation in the MCP tool definition.
      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"),
    },
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 whether this is a mutation (implied by 'Set'), what permissions are needed, if it's idempotent, how errors are handled, or what 'parallelly' means operationally. This leaves significant behavioral gaps for a write operation.

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 gets straight to the point without unnecessary words. However, it could be slightly more structured by front-loading key distinctions (e.g., 'batch operation for multiple annotations') to improve immediate comprehension.

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 insufficient. It doesn't cover behavioral aspects (permissions, side effects), doesn't explain the return value or error handling, and doesn't differentiate from sibling tools. Given the complexity of batch annotation operations, more context is needed.

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 description adds no parameter-specific information beyond what's already in the schema (which has 100% coverage). It doesn't explain the relationship between the top-level 'nodeId' and nested 'nodeId' in annotations, or clarify what 'parallelly' means for the 'annotations' array processing. Baseline 3 is appropriate since the 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 annotations parallelly') and the target ('in a node'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from its sibling 'set_annotation' (singular vs. multiple), which prevents a perfect score.

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_annotation' (for single annotations) or 'get_annotations' (for retrieval). There's no mention of prerequisites, constraints, or typical use cases, leaving the agent without contextual usage direction.

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

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