Skip to main content
Glama
paragdesai1

Cursor Talk to Figma MCP

by paragdesai1

set_multiple_annotations

Apply multiple annotations simultaneously to Figma design elements using Cursor AI, enabling batch labeling and documentation of nodes.

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

  • MCP tool registration, input schema, and handler implementation for 'set_multiple_annotations'. The handler proxies to Figma plugin command, handles progress, and formats results.
    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 parameters for set_multiple_annotations, matching the Zod schema.
    interface SetMultipleAnnotationsParams {
      nodeId: string;
      annotations: Array<{
        nodeId: string;
        labelMarkdown: string;
        categoryId?: string;
        annotationId?: string;
        properties?: Array<{ type: string }>;
      }>;
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'parallelly' for concurrency but doesn't disclose critical behaviors like whether this overwrites existing annotations, requires specific permissions, or has side effects. For a mutation tool with zero annotation coverage, this is insufficient.

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 with no wasted words. It's front-loaded with the core action and target, making it easy to parse quickly.

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 details on behavioral traits (e.g., idempotency, error handling), return values, or how it interacts with sibling tools like 'get_annotations'. Given the complexity of bulk 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?

Schema description coverage is 100%, so the schema fully documents the two parameters (nodeId and annotations array). The description adds no additional meaning beyond implying bulk operations, which is already suggested by the schema's array structure. 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 annotations') and target ('in a node'), with 'parallelly' suggesting simultaneous processing. It distinguishes from the sibling 'set_annotation' by indicating multiple annotations, though it doesn't explicitly contrast them.

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 alternatives like 'set_annotation' or 'get_annotations' is provided. The description implies bulk operations but lacks explicit usage context or prerequisites.

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/paragdesai1/parag-Figma-MCP'

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