Twitter MCP Server

Twitter MCP Server

Enables interaction with Twitter through a Model Context Protocol, allowing large language models to post tweets, search for tweets, and reply to tweets.

crazyrabbitLTC

Social Media
Visit Server

Tools

createList

Create a new Twitter list

postTweet

Post a tweet to Twitter

addUserToList

Add a user to a Twitter list

postTweetWithMedia

Post a tweet with media attachment to Twitter

likeTweet

Like a tweet by its ID

unlikeTweet

Unlike a previously liked tweet

getLikedTweets

Get a list of tweets liked by a user

searchTweets

Search for tweets using a query string

replyToTweet

Reply to a tweet

getUserTimeline

Get recent tweets from a user timeline

getTweetById

Get a tweet by its ID

getUserInfo

Get information about a Twitter user

getTweetsByIds

Get multiple tweets by their IDs

retweet

Retweet a tweet by its ID

undoRetweet

Undo a retweet by its ID

getRetweets

Get a list of retweets of a tweet

followUser

Follow a user by their username

unfollowUser

Unfollow a user by their username

getFollowers

Get followers of a user

getFollowing

Get a list of users that a user is following

removeUserFromList

Remove a user from a Twitter list

getListMembers

Get members of a Twitter list

getUserLists

Get lists owned by a user

getHashtagAnalytics

Get analytics for a specific hashtag

deleteTweet

Delete a tweet by its ID

README

Twitter MCP Server

A Model Context Protocol server implementation for Twitter API integration.

Setup

  1. Clone the repository
  2. Install dependencies: npm install
  3. Copy .env.example to .env and fill in your Twitter API credentials
  4. Build the project: npm run build
  5. Start the server: npm start

Environment Variables

Required Twitter API credentials in .env:

X_API_KEY=your_api_key
X_API_SECRET=your_api_secret
X_ACCESS_TOKEN=your_access_token
X_ACCESS_TOKEN_SECRET=your_access_token_secret

Available Tools

Tweet Operations

  • postTweet: Post a new tweet

    {
      "text": "Your tweet text here"
    }
    
  • postTweetWithMedia: Post a tweet with media attachment

    {
      "text": "Your tweet text",
      "mediaPath": "path/to/media/file",
      "mediaType": "image/jpeg|image/png|image/gif|video/mp4",
      "altText": "Optional alt text for accessibility"
    }
    
  • getTweetById: Get a specific tweet by ID

    {
      "tweetId": "tweet_id",
      "tweetFields": ["created_at", "public_metrics"]
    }
    
  • replyToTweet: Reply to an existing tweet

    {
      "tweetId": "tweet_id",
      "text": "Your reply text"
    }
    
  • deleteTweet: Delete a tweet

    {
      "tweetId": "tweet_id"
    }
    

Search & Analytics

  • searchTweets: Search for tweets

    {
      "query": "search query",
      "maxResults": 10,
      "tweetFields": ["created_at", "public_metrics"]
    }
    
  • getHashtagAnalytics: Get analytics for a hashtag

    {
      "hashtag": "hashtag",
      "startTime": "ISO-8601 date",
      "endTime": "ISO-8601 date"
    }
    

User Operations

  • getUserInfo: Get user information

    {
      "username": "twitter_username",
      "fields": ["description", "public_metrics"]
    }
    
  • getUserTimeline: Get user's tweets

    {
      "username": "twitter_username",
      "maxResults": 10,
      "tweetFields": ["created_at", "public_metrics"]
    }
    
  • getFollowers: Get user's followers

    {
      "username": "twitter_username",
      "maxResults": 100,
      "userFields": ["description", "public_metrics"]
    }
    
  • getFollowing: Get accounts a user follows

    {
      "username": "twitter_username",
      "maxResults": 100,
      "userFields": ["description", "public_metrics"]
    }
    

Engagement

  • likeTweet: Like a tweet

    {
      "tweetId": "tweet_id"
    }
    
  • unlikeTweet: Unlike a tweet

    {
      "tweetId": "tweet_id"
    }
    
  • retweet: Retweet a tweet

    {
      "tweetId": "tweet_id"
    }
    
  • undoRetweet: Undo a retweet

    {
      "tweetId": "tweet_id"
    }
    
  • getRetweets: Get users who retweeted a tweet

    {
      "tweetId": "tweet_id",
      "maxResults": 100,
      "userFields": ["description", "public_metrics"]
    }
    
  • getLikedTweets: Get tweets liked by a user

    {
      "userId": "user_id",
      "maxResults": 100,
      "tweetFields": ["created_at", "public_metrics"]
    }
    

List Management

  • createList: Create a new list

    {
      "name": "List name",
      "description": "List description",
      "isPrivate": false
    }
    
  • addUserToList: Add a user to a list

    {
      "listId": "list_id",
      "username": "twitter_username"
    }
    
  • removeUserFromList: Remove a user from a list

    {
      "listId": "list_id",
      "username": "twitter_username"
    }
    
  • getListMembers: Get members of a list

    {
      "listId": "list_id",
      "maxResults": 100,
      "userFields": ["description", "public_metrics"]
    }
    

Error Handling

All tools return standardized error responses:

  • Missing parameters: Missing required parameter: parameter_name
  • API errors: Error message from Twitter API
  • Not found errors: Appropriate "not found" message for the resource

Response Format

All successful responses follow this format:

{
  "content": [
    {
      "type": "text",
      "text": "Operation result message"
    }
  ]
}

Development

  • Build: npm run build
  • Start: npm start
  • Watch mode: npm run dev
Here's a comprehensive status report of all Twitter tools:

## Working Tools (✓)

1. postTweet

Status: Working perfectly Response: Returns tweet ID Latest test: Success


2. getTweetById

Status: Working perfectly Response: Returns complete tweet data Latest test: Success


3. likeTweet & unlikeTweet

Status: Working perfectly Response: Confirmation of action Latest test: Success


4. retweet & undoRetweet

Status: Working perfectly Response: Confirmation of action Latest test: Success


5. replyToTweet

Status: Working perfectly Response: Returns reply tweet ID Latest test: Success


6. getUserInfo

Status: Working perfectly Response: Complete user profile data Latest test: Success


7. followUser & unfollowUser

Status: Working perfectly Response: Confirmation of action Latest test: Success


8. createList

Status: Working perfectly Response: Confirmation of list creation Latest test: Success


9. getUserLists

Status: Working perfectly Response: Returns both owned and member lists Latest test: Success


## Tools with Issues (⚠️)

1. getUserTimeline

Status: Error 400 Error: Invalid Request parameters Fix needed: Parameter validation


2. searchTweets

Status: Error 400 Error: Invalid Request parameters Fix needed: Query parameter formatting


3. getLikedTweets

Status: Error 400 Error: Invalid Request parameters Fix needed: Parameter validation


## Missing Tools (❌)
- getHomeTimeline (not found in available tools)
- getFollowers (not available)
- getFollowing (not available)
- getHashtagAnalytics (not available)

## Priority Fixes Needed

1. Parameter Validation:
```typescript
// Implement for getUserTimeline, searchTweets, getLikedTweets
interface TwitterParamValidator {
  validateTimelineParams(params: any): boolean;
  validateSearchParams(params: any): boolean;
  validateLikedTweetsParams(params: any): boolean;
}
  1. Error Handling:
// Enhance error handling for 400 errors
interface TwitterErrorHandler {
  handle400Error(endpoint: string, params: any): void;
  logErrorDetails(error: any): void;
  suggestParameterFixes(params: any): string[];
}

Recommended Servers

@wopal/mcp-server-hotnews

@wopal/mcp-server-hotnews

A Model Context Protocol server that provides real-time hot trending topics from major Chinese social platforms and news sites.

Featured
actors-mcp-server

actors-mcp-server

Use 3,000+ pre-built cloud tools from Apify, known as Actors, to extract data from websites, e-commerce, social media, search engines, maps, and more

Official
TypeScript
mcp-maigret

mcp-maigret

MCP server for maigret, a powerful OSINT tool that collects user account information from various public sources. This server provides tools for searching usernames across social networks and analyzing URLs.

Local
JavaScript
Instagram MCP Server

Instagram MCP Server

A server that allows fetching Instagram posts using Chrome's existing login session via Model Context Protocol (MCP).

Local
TypeScript
X(Twitter) MCP Server

X(Twitter) MCP Server

An MCP server that allows Claude to create, manage and publish X/Twitter posts directly through the chat interface.

Local
Python
LinkedIn MCP Server

LinkedIn MCP Server

A Model Context Protocol server that enables seamless interaction with LinkedIn for job applications, profile retrieval, feed browsing, and resume analysis through natural language commands.

Local
Python
Twitter MCP Server

Twitter MCP Server

Provides AI agents with comprehensive Twitter functionality through the Model Context Protocol standard, enabling reading tweets, posting content, managing interactions, and accessing timeline data with robust error handling.

Local
JavaScript
Twitch MCP Server

Twitch MCP Server

Enables interaction with the Twitch API, allowing users to retrieve comprehensive information about channels, streams, games, and more, with additional support for searching and accessing chat elements like emotes and badges.

TypeScript
LinkedIn Browser MCP Server

LinkedIn Browser MCP Server

A FastMCP-based server that enables programmatic LinkedIn automation and data extraction through browser automation, offering secure authentication and tools for profile operations and post interactions while respecting LinkedIn's rate limits.

Python
Hive MCP Server

Hive MCP Server

Enables AI assistants to interact with the Hive blockchain through the Model Context Protocol, allowing for account info retrieval, content reading/creation, cryptocurrency transfers, and cryptographic operations.

TypeScript