Twitter MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone <your-repo-url>
cd twitter-mcp-server
npm install
npm run build
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add twitter-mcp-server -- node "<FULL_PATH_TO_TWITTER_MCP_SERVER>/dist/index.js"

Replace <FULL_PATH_TO_TWITTER_MCP_SERVER>/dist/index.js with the actual folder you prepared in step 1.

README.md

Accurately count Twitter/X post characters and optimize posts.

Twitter MCP Server

An MCP (Model Context Protocol) server for Claude to accurately count Twitter/X post characters and optimize posts.

Features

  • Accurate Character Counting: Calculate character count based on Twitter/X's official counting method
  • Post Validation: Check character limits and other constraints
  • Post Optimization: Suggestions for optimizing posts that are too long
  • Entity Extraction: Extract and analyze URLs, mentions, and hashtags

Installation

# Clone the repository
git clone <your-repo-url>
cd twitter-mcp-server

# Install dependencies
npm install

# Build
npm run build

Configuration for Claude Desktop

Add the following to your Claude Desktop configuration file (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "twitter-mcp-server": {
      "command": "node",
      "args": ["/path/to/twitter-mcp-server/dist/server.js"]
    }
  }
}

Usage

The following tools will be available in Claude:

1. count_tweet_characters

Please count the characters in this Twitter/X post accurately:
"Hello! It's a beautiful day today ☀️ #goodweather https://example.com"

2. validate_tweet

Please validate if this post is valid:
"(long post text)"

3. optimize_tweet

Please optimize this post:
"(post text to optimize)"

4. extract_entities

Please extract entities from this post:
"@user Hello! #hello please check out https://example.com"

Development

# Start in development mode
npm run dev

# Build
npm run build

# Start in production
npm start

API Details

count_tweet_characters

  • Input: text (string) - Text to count
  • Output: Detailed information including character count, remaining characters, validity

validate_tweet

  • Input: text (string) - Text to validate
  • Output: Validity, issues, entity information

optimize_tweet

  • Input:
    • text (string) - Text to optimize
    • maxLength (number, optional) - Maximum character count (default: 280)
  • Output: Optimized text and suggestions

extract_entities

  • Input: text (string) - Text to extract entities from
  • Output: Lists of URLs, mentions, and hashtags

Tech Stack

  • TypeScript: Type safety and better development experience
  • @modelcontextprotocol/sdk: MCP server implementation
  • twitter-text: Official Twitter character counting library

License

MIT License

Contributing

  1. Fork this repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Create a Pull Request

Support

If you have any issues or questions, please report them in GitHub Issues.

Tools (4)

count_tweet_charactersCalculate character count based on Twitter/X's official counting method.
validate_tweetCheck character limits and other constraints for a post.
optimize_tweetGet suggestions for optimizing posts that are too long.
extract_entitiesExtract and analyze URLs, mentions, and hashtags from a post.

Configuration

claude_desktop_config.json
{"mcpServers": {"twitter-mcp-server": {"command": "node", "args": ["/path/to/twitter-mcp-server/dist/server.js"]}}}

Try it

Count the characters in this draft tweet to see if it fits within the limit: 'Hello! It's a beautiful day today ☀️ #goodweather https://example.com'
Validate if this post is within the Twitter character limit: '(long post text)'
Optimize this post so it fits within the 280 character limit: '(post text to optimize)'
Extract all the hashtags, mentions, and URLs from this tweet: '@user Hello! #hello please check out https://example.com'

Frequently Asked Questions

What are the key features of Twitter MCP Server?

Accurate character counting using official Twitter/X methods. Post validation against platform constraints. Automated post optimization suggestions. Entity extraction for URLs, mentions, and hashtags.

What can I use Twitter MCP Server for?

Ensuring social media drafts meet platform character limits before posting. Analyzing engagement elements like hashtags and mentions in existing content. Automating the shortening of long-form content for Twitter/X compatibility. Validating user-generated content for social media management tools.

How do I install Twitter MCP Server?

Install Twitter MCP Server by running: git clone <your-repo-url> && cd twitter-mcp-server && npm install && npm run build

What MCP clients work with Twitter MCP Server?

Twitter MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Twitter MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare