format_thread
Split long text into numbered Twitter threads with proper character limits for social media content creation.
Instructions
Split long text into a numbered X (Twitter) thread (1/x).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The full text content |
Implementation Reference
- src/index.ts:85-107 (handler)The handler function that implements the 'format_thread' tool logic: splits input text into numbered Twitter thread tweets based on sentence length, respecting 260 char limit.if (name === "format_thread") { const text = String(args?.text || ""); const MAX_LENGTH = 260; const sentences = text.match(/[^.!?]+[.!?]+|[^.!?]+$/g) || [text]; const tweets: string[] = []; let currentTweet = ""; for (const sentence of sentences) { const trimmed = sentence.trim(); if (!trimmed) continue; if ((currentTweet + " " + trimmed).length > MAX_LENGTH) { if (currentTweet) tweets.push(currentTweet); currentTweet = trimmed; } else { currentTweet = currentTweet ? currentTweet + " " + trimmed : trimmed; } } if (currentTweet) tweets.push(currentTweet); const numberedTweets = tweets.map((t, i) => `${t} (${i + 1}/${tweets.length})`); return { content: [{ type: "text", text: JSON.stringify(numberedTweets, null, 2) }], }; }
- src/index.ts:34-44 (registration)Registration of the 'format_thread' tool in the TOOLS array, including name, description, and input schema for listing tools.{ name: "format_thread", description: "Split long text into a numbered X (Twitter) thread (1/x).", inputSchema: { type: "object", properties: { text: { type: "string", description: "The full text content" }, }, required: ["text"], }, },
- src/index.ts:37-43 (schema)Input schema definition for the 'format_thread' tool.inputSchema: { type: "object", properties: { text: { type: "string", description: "The full text content" }, }, required: ["text"], },