Skip to main content
Glama
arinspunk

Claude Talk to Figma MCP

by arinspunk

get_selection

Retrieve details about currently selected elements in Figma to enable AI-assisted design analysis and modifications.

Instructions

Get information about the current selection in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'get_selection' tool. It sends the 'get_selection' command to the Figma plugin using sendCommandToFigma and returns the result as JSON-formatted text content. Includes try-catch for error handling.
    async () => {
      try {
        const result = await sendCommandToFigma("get_selection");
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result)
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error getting selection: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }
  • The registration of the 'get_selection' tool using server.tool(), specifying name, description, empty input schema ({}), and the handler function. This is called within registerDocumentTools.
    server.tool(
      "get_selection",
      "Get information about the current selection in Figma",
      {},
      async () => {
        try {
          const result = await sendCommandToFigma("get_selection");
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(result)
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error getting selection: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Call to registerDocumentTools from the main registerTools function, which performs the tool registrations including get_selection.
    registerDocumentTools(server);
  • Invocation of registerTools(server) in the main server setup, which chains to the registration of get_selection.
    registerTools(server);
  • The 'get_selection' command is included in the FigmaCommand type union, used for type safety in command handling.
    | "get_selection"

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/arinspunk/claude-talk-to-figma-mcp'

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