count_tweet_characters
Count Twitter/X post characters accurately, including URLs and emojis, to ensure content fits within platform constraints.
Instructions
Twitter/Xの投稿文字数を正確にカウントします。URLや絵文字も考慮します。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | カウントしたいTwitter/Xの投稿テキスト |
Implementation Reference
- src/server.ts:129-150 (handler)Implementation of the count_tweet_characters tool handler, which uses the twitter-text library to parse the text and calculate character counts.
private countTweetCharacters(text: string) { const parsed = twitterText.parseTweet(text); return { content: [ { type: 'text', text: JSON.stringify({ characterCount: parsed.weightedLength, maxLength: 280, remaining: 280 - parsed.weightedLength, valid: parsed.valid, details: { displayRangeStart: parsed.displayRangeStart, displayRangeEnd: parsed.displayRangeEnd, permillage: parsed.permillage, } }, null, 2), }, ], }; } - src/server.ts:42-55 (registration)Registration of the count_tweet_characters tool definition within the setupToolHandlers method.
{ name: 'count_tweet_characters', description: 'Twitter/Xの投稿文字数を正確にカウントします。URLや絵文字も考慮します。', inputSchema: { type: 'object', properties: { text: { type: 'string', description: 'カウントしたいTwitter/Xの投稿テキスト', }, }, required: ['text'], }, },