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)Handler for the 'format_thread' tool. Splits input text into Twitter threads by grouping sentences into chunks under 260 characters, numbers each as (1/n), and returns JSON array of formatted tweets.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 (schema)Input schema definition for the 'format_thread' tool, specifying the required 'text' parameter.{ 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:59-63 (registration)Registration of tools list handler, which includes 'format_thread' in the TOOLS array returned to clients.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: TOOLS, }; });