Skip to main content
Glama

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
NameRequiredDescriptionDefault
textYesThe full text content

Implementation Reference

  • 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) }], }; }
  • 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, }; });

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/samusilv/growth-hacker-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server