join_channel
Link to a specific channel for direct communication with Figma, enabling AI-assisted design collaboration via natural language commands.
Instructions
Join a specific channel to communicate with Figma
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {},
"type": "object"
}
Implementation Reference
- src/talk_to_figma_mcp/tools/document-tools.ts:300-346 (registration)Registers the "join_channel" MCP tool, including schema and inline handler function.server.tool( "join_channel", "Join a specific channel to communicate with Figma", { channel: z.string().describe("The name of the channel to join").default(""), }, 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)}`, }, ], }; } } );
- Input schema using Zod: optional channel string with default empty.{ channel: z.string().describe("The name of the channel to join").default(""), },
- The MCP tool handler: validates channel, calls joinChannel helper, returns success or error text response.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)}`, }, ], }; } } );
- Core helper function implementing channel join via WebSocket sendCommandToFigma('join'), updates currentChannel state.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; logger.info(`Joined channel: ${channelName}`); } catch (error) { logger.error(`Failed to join channel: ${error instanceof Error ? error.message : String(error)}`); throw error; } }