count_tweet_charactersLABSCO SUMMARY
It solves the one thing string length gets wrong.
A URL does not cost what it looks like it costs, and an emoji can count as two — which is why drafts written by a model routinely come back over the limit despite looking short. Running the platform's own counting library locally removes the guesswork entirely, with no credential to manage because nothing leaves the machine. Pair the count with the optimiser: knowing a draft is over the limit is only half of what you need.
What it is
A text tool for X and Twitter posts. It counts characters using the platform's own counting method rather than string length, validates a draft against the limits, suggests how to shorten one that is too long, and extracts the URLs, mentions and hashtags it contains.
What you get
count_tweet_characterstakestextand returns the count, the remaining characters and whether the post is validvalidate_tweetchecks a draft against the constraints and reports the specific issuesoptimize_tweetsuggests how to shorten a post, with an optionalmaxLengthdefaulting to 280extract_entitiesreturns the URLs, mentions and hashtags separately- Counting runs on twitter-text, the official character-counting library, so emoji and URLs weigh what the platform says they weigh
Requirements
Node.js. Clone the repository, npm install and npm run build, then point the client at the built server. The npm package mcp-x-post-optimizer has been unpublished, so building from the clone is the only way in. There is nothing to authenticate — no account, no key, no network call, because the counting happens locally.
Setup effort
Build from source — git clone https://github.com/serima/twitter-mcp-server.git
USE CASES
Making sure a drafted post actually fits
Count it the way the platform will, including URLs and emoji, before posting.
Shortening a post that went over
Get concrete suggestions against the limit rather than rewriting it blind.
Checking a draft for problems beyond length
Validate it and read the specific issues that would make it invalid.
Auditing the links and tags in a post
Pull the URLs, mentions and hashtags out as separate lists.
4 tools
Listed in project docs. Your client may show a different list.
validate_tweetoptimize_tweetextract_entitiesBEFORE YOU INSTALL
What to know first
Tools you get
4 tools named in the project's documentation.
Requires
Node.js and npm
Where it runs
The documented client runs the server on your machine.
INSTALLATION
Connect your client
You clone and build this one yourself.
Server setup
git clone https://github.com/serima/twitter-mcp-server.git
cd twitter-mcp-server
npm install
npm run buildMCP Clients
Claude Desktop
{
"mcpServers": {
"twitter-mcp-server": {
"command": "node",
"args": [
"<YOUR_PATH_TO_TWITTER_MCP_SERVER>/dist/server.js"
]
}
}
}