join_channel
Open a named channel to begin direct communication with Figma, enabling AI-assisted design actions through natural language commands.
Instructions
Join a specific channel to communicate with Figma
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel | Yes | The name of the channel to join |
Implementation Reference
- src/talk_to_figma_mcp/tools/document-tools.ts:304-351 (registration)Registration of the 'join_channel' tool on the MCP server, defining its schema (channel string) and handler callback.
// Join Channel Tool server.tool( "join_channel", "Join a specific channel to communicate with Figma", { channel: z.string().describe("The name of the channel to join"), }, async ({ channel }) => { try { if (!channel) { // If no channel provided, ask the user for input return { content: [ { type: "text", text: "Please provide a channel name to join:", }, ], followUp: { tool: "join_channel", description: "Join the specified channel", }, }; } // Use joinChannel instead of sendCommandToFigma to ensure currentChannel is updated await joinChannel(channel); return { content: [ { type: "text", text: `Successfully joined channel: ${channel}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error joining channel: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } ); - The joinChannel function that sends 'join' command via WebSocket to Figma, updates currentChannel, and verifies with a ping.
export async function joinChannel(channelName: string): Promise<void> { if (!ws || ws.readyState !== WebSocket.OPEN) { throw new Error("Not connected to Figma"); } try { await sendCommandToFigma("join", { channel: channelName }); currentChannel = channelName; try { await sendCommandToFigma("ping", {}, 12000); logger.info(`Joined channel: ${channelName}`); } catch (verificationError) { currentChannel = null; const errorMsg = verificationError instanceof Error ? verificationError.message : String(verificationError); logger.error(`Failed to verify channel ${channelName}: ${errorMsg}`); throw new Error(`Failed to verify connection to channel "${channelName}". The Figma plugin may not be connected to this channel.`); } } catch (error) { logger.error(`Failed to join channel: ${error instanceof Error ? error.message : String(error)}`); throw error; } - Input schema for the join_channel tool: requires a 'channel' string parameter.
{ channel: z.string().describe("The name of the channel to join"), - Import of the joinChannel helper function from the websocket utility.
import { sendCommandToFigma, joinChannel } from "../utils/websocket.js";