join_channel
Connect to a designated channel to enable communication between Cursor AI and Figma, facilitating automated design task management through 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
- Primary handler for the MCP 'join_channel' tool. Validates input channel, calls joinChannel helper, handles errors, and provides user feedback.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", }, }; } 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) }`, }, ], }; } } );
- Zod schema defining the input parameter 'channel' as a string for the join_channel tool.channel: z.string().describe("The name of the channel to join").default(""), },
- src/talk_to_figma_mcp/server.ts:2961-3006 (registration)MCP server registration of the 'join_channel' tool using server.tool() method.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", }, }; } 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) }`, }, ], }; } } );
- Helper function joinChannel that sends the 'join' command via WebSocket to the socket server and updates currentChannel state.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; } }
- src/socket.ts:80-127 (helper)WebSocket server-side handler for 'join' messages that manages channel membership, notifies participants, and confirms connection.if (data.type === "join") { const channelName = data.channel; if (!channelName || typeof channelName !== "string") { ws.send(JSON.stringify({ type: "error", message: "Channel name is required" })); return; } // Create channel if it doesn't exist if (!channels.has(channelName)) { channels.set(channelName, new Set()); } // Add client to channel const channelClients = channels.get(channelName)!; channelClients.add(ws); // Notify client they joined successfully ws.send(JSON.stringify({ type: "system", message: `Joined channel: ${channelName}`, channel: channelName })); console.log("Sending message to client:", data.id); ws.send(JSON.stringify({ type: "system", message: { id: data.id, result: "Connected to channel: " + channelName, }, channel: channelName })); // Notify other clients in channel channelClients.forEach((client) => { if (client !== ws && client.readyState === WebSocket.OPEN) { client.send(JSON.stringify({ type: "system", message: "A new user has joined the channel", channel: channelName })); } }); return;