X/Twitter MCP Server

X/Twitter MCP Server

x-mcp•bybarresider

An MCP server that offers unofficial X/Twitter access through browser automation with Playwright, letting AI agents create content, interact with posts, and scrape timelines, profiles, and search results.

License: Not specified•Runtime: Awaiting documentation review•Category: communication social

WHAT IT DOES

  • •Posts single tweets and multi-tweet threads, with support for attaching media.
  • •Likes, retweets, bookmarks, quotes, and replies to posts and comments.
  • •Scrapes profiles, timelines, comments, and trending topics, and searches tweets with advanced filters.
  • •Supports both stdio and HTTP/SSE transports and exposes 20+ tools with JSON-formatted structured responses.

BEST FOR

  • •AI agents that need to post tweets or threads on X/Twitter.
  • •Scraping profile data and recent posts for a specific X/Twitter user.
  • •Searching X/Twitter with advanced filters for content analysis.

ABOUT X-MCP

X/Twitter MCP Server is cataloged as an MCP server attributed to barresider. An MCP server that offers unofficial X/Twitter access through browser automation with Playwright, letting AI agents create content, interact with posts, and scrape timelines, profiles, and search results. It is categorized under communication social. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for X/Twitter MCP Server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

上游原版 README

在 GitHub 查看同一版本原文

README.md · 77817e489836 · 采集于 2026-11-13 10:22:26 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

X/Twitter MCP Server

A Model Context Protocol (MCP) server that provides unofficial X/Twitter API access through browser automation using Playwright. This server enables AI agents and applications to interact with X/Twitter programmatically for content creation, scraping, and social media automation.

🚀 Features

Content Creation & Interaction

  • Tweet & Thread Posting: Post single tweets or multi-tweet threads with media support
  • Post Interactions: Like, unlike, retweet, unretweet, bookmark, quote tweet, and reply to posts
  • Comment Management: Like, unlike, reply to, and edit comments
  • Media Support: Upload and attach images, videos, and GIFs to tweets

Content Scraping & Analysis

  • Timeline Scraping: Extract posts from "For You" and "Following" timelines
  • Profile Scraping: Get comprehensive user profile data and recent posts
  • Search Functionality: Advanced search with filters for viral content, specific users, and date ranges
  • Comment Scraping: Extract comments and replies from specific posts
  • Trending Topics: Retrieve current trending topics and hashtags

MCP Integration

  • Dual Transport Support: Works with both stdio and HTTP/SSE transports
  • Tool-based Interface: 20+ tools available for AI agents to interact with X/Twitter
  • Structured Responses: JSON-formatted responses with comprehensive metadata
  • Error Handling: Robust error handling with descriptive error messages

📋 Prerequisites

  • Node.js 18+
  • Valid X/Twitter account credentials
  • Docker (optional, for containerized deployment)

Quick Start

  1. Add this configuration to your Claude Desktop config file:

Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "x-mcp": {
      "command": "npx",
      "args": ["-y", "@barresider/x-mcp"],
      "env": {
        "TWITTER_USERNAME": "your_twitter_username",
        "TWITTER_PASSWORD": "your_twitter_password"
      }
    }
  }
}

With proxy (optional):

{
  "mcpServers": {
    "x-mcp": {
      "command": "npx",
      "args": ["-y", "@barresider/x-mcp"],
      "env": {
        "TWITTER_USERNAME": "your_twitter_username",
        "TWITTER_PASSWORD": "your_twitter_password",
        "PROXY_URL": "http://proxy-server:port"
      }
    }
  }
}
  1. Restart Claude Desktop

That's it! Claude can now interact with X/Twitter through 25+ powerful tools including:

  • tweet: Post a new tweet with optional media
  • thread: Post a multi-tweet thread
  • search_twitter: Search for tweets with advanced filters
  • scrape_profile: Get comprehensive user profile data
  • scrape_timeline: Extract posts from timelines
  • like_post, retweet_post, bookmark_post: Interact with posts
  • And many more for comprehensive X/Twitter automation

Example Usage

Try asking Claude:

  • "Can you post a tweet saying 'Hello from Claude!'"
  • "Can you search for tweets about Claude AI?"
  • "Can you scrape Elon Musk's profile and show me his latest 5 tweets?"
  • "Can you post a thread about the benefits of AI?"

🛠️ Installation

Local Development Installation

  1. Clone the repository:
git clone <repository-url>
cd x-mcp
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

Docker Installation

  1. Build the Docker image:
docker build -t x-mcp .
  1. Or use Docker Compose:
docker-compose --profile mcp up --build

⚙️ Configuration

Environment Variables

Create a .env file in the project root:

# Required: X/Twitter credentials
TWITTER_USERNAME=your_username
TWITTER_PASSWORD=your_password

# Optional: Proxy configuration
PROXY_URL=http://proxy-server:port          # Full proxy URL (supports http/https)
# or with authentication
PROXY_URL=http://username:password@proxy-server:port
# or separately
PROXY_URL=http://proxy-server:port
PROXY_USERNAME=proxy_username               # Optional: separate username
PROXY_PASSWORD=proxy_password               # Optional: separate password

# Optional: MCP server configuration
MCP_TRANSPORT=stdio           # Options: stdio, sse, http
MCP_PORT=3000                # Port for HTTP/SSE transport

# Optional: Directory for authentication state (default: playwright/.auth)
AUTH_DIR=playwright/.auth

Authentication Setup

  1. (Optional) Create authentication directory or set AUTH_DIR environment variable:
export AUTH_DIR=/path/to/auth/dir
mkdir -p "${AUTH_DIR:-playwright/.auth}"
  1. Login to X/Twitter (stores session for reuse):
npm run cli login
# or
node dist/cli.js login

🔧 Available MCP Tools

The server provides 25+ tools for comprehensive X/Twitter interaction:

Authentication & Setup

  • login - Authenticate with X/Twitter

Content Creation

  • tweet - Post a single tweet with optional media
  • thread - Post a multi-tweet thread
  • reply_to_post - Reply to a specific post
  • quote_tweet - Quote tweet with additional text

Post Interactions

  • like_post / unlike_post - Like/unlike posts
  • retweet_post / unretweet_post - Retweet/unretweet posts
  • bookmark_post / unbookmark_post - Bookmark management

Comment Interactions

  • like_comment_by_id / unlike_comment_by_id - Like/unlike comments
  • reply_to_comment_by_id - Reply to comments
  • replace_comment_by_id - Edit comments (if supported)

Content Scraping

  • scrape_posts - Scrape posts from current page
  • scrape_profile - Get user profile and recent posts
  • scrape_comments - Extract comments from posts
  • scrape_timeline - Scrape For You/Following timelines
  • scrape_trending - Get trending topics
  • search_twitter - General search functionality
  • search_viral - Search for viral content with minimum engagement

📊 Data Structures

TwitterPost

interface TwitterPost {
  postId: string;
  author: TwitterUser;
  content: string;
  timestamp: Date;
  media: TwitterMedia[];
  metrics: PostMetrics;
  engagementRate: number;
  isRetweet?: boolean;
  retweetedFrom?: TwitterUser;
  quotedPost?: TwitterPost;
  url: string;
}

TwitterProfile

interface TwitterProfile extends TwitterUser {
  bannerUrl?: string;
  bio?: string;
  location?: string;
  website?: string;
  joinedDate?: Date;
  followingCount: number;
  followersCount: number;
  postsCount: number;
  isFollowing?: boolean;
  isFollowedBy?: boolean;
  latestPosts?: TwitterPost[];
}

PostMetrics

interface PostMetrics {
  likesCount: number;
  retweetsCount: number;
  quotesCount: number;
  repliesCount: number;
  impressionsCount: number;
  bookmarksCount: number;
}

🔒 Security & Best Practices

Rate Limiting

  • Implement delays between requests to avoid rate limiting
  • Use reasonable limits for scraping operations
  • Monitor for rate limit responses

Authentication

  • Store credentials securely in environment variables
  • Session data is stored in the directory specified by the AUTH_DIR environment variable (default playwright/.auth/)
  • Regular re-authentication may be required

Error Handling

  • All operations include comprehensive error handling
  • Descriptive error messages for troubleshooting
  • Graceful degradation for missing elements

Proxy Configuration

  • Supports HTTP/HTTPS proxies for all browser connections
  • Configure via PROXY_URL environment variable
  • Supports authentication with username/password
  • Useful for:
    • Rotating IP addresses to avoid rate limits
    • Accessing X/Twitter from restricted networks
    • Adding an extra layer of anonymity
  • Example formats:
    • Basic: http://proxy-server:port
    • With auth: http://username:password@proxy-server:port
    • Separate auth: Use PROXY_USERNAME and PROXY_PASSWORD

🐳 Docker Deployment

Using Docker Compose

# Start the MCP server
docker-compose --profile mcp up

# With environment variables
TWITTER_USERNAME=your_username TWITTER_PASSWORD=your_password docker-compose --profile mcp up

Custom Docker Run

docker run -d \
  --name x-mcp \
  -e TWITTER_USERNAME=your_username \
  -e TWITTER_PASSWORD=your_password \
  -e PROXY_URL=http://proxy-server:port \
  -e MCP_TRANSPORT=sse \
  -e MCP_PORT=3000 \
  -p 3000:3000 \
  x-mcp

🛠️ Development

Project Structure

src/
├── mcp.ts                    # Main MCP server implementation
├── cli.ts                    # Command line interface
├── types.ts                  # TypeScript type definitions
├── utils.ts                  # Utility functions
├── behaviors/                # User interaction behaviors
│   ├── login.ts             # Authentication logic
│   ├── interact-with-post.ts # Post interaction functions
│   ├── interact-with-comment.ts # Comment interaction functions
│   └── upload-media.ts      # Media upload functionality
└── scrapers/                # Data scraping modules
    ├── index.ts             # Scraper exports
    ├── post-scraper.ts      # Post scraping logic
    ├── profile-scraper.ts   # Profile scraping logic
    ├── comment-scraper.ts   # Comment scraping logic
    ├── search-scraper.ts    # Search functionality
    ├── timeline-scraper.ts  # Timeline scraping
    └── utils.ts             # Scraping utilities

Building and Testing

# Build TypeScript
npm run build

# Run MCP server
npm run mcp

# Run CLI commands
npm run cli <command>

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

Guidelines

  • Follow TypeScript best practices
  • Add comprehensive error handling
  • Update type definitions for new features
  • Test with real X/Twitter interactions
  • Document new functionality

⚠️ Disclaimers

  • This is an unofficial tool using browser automation
  • X/Twitter's terms of service apply
  • Use responsibly and respect rate limits
  • UI changes may require updates to selectors
  • Not affiliated with X/Twitter

📄 License

[License information here]

🐛 Troubleshooting

Common Issues

Authentication Failures

  • Verify credentials in .env file
  • Try logging in again with npm run cli login
  • Check for 2FA requirements

Element Not Found Errors

  • X/Twitter may have updated their UI
  • Clear browser cache and re-authenticate
  • Check for element selector updates

Rate Limiting

  • Reduce request frequency
  • Add delays between operations
  • Use smaller batch sizes

Container Issues

  • Ensure proper environment variables
  • Check port availability
  • Verify Docker network configuration

For more help, please open an issue on the project repository.

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for X/Twitter MCP Server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/x-mcp)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related communication social MCP Servers

Alternative and complementary servers in the same category

View all in communication social →

An AI receptionist platform with an MCP server for accessing business calls, contacts and appointments from AI assistants.

52
Communication

Pidgeon provides an MCP server and an email inbox API that gives AI agents their own addresses for sending, awaiting, and replying to email.

Repository stats unavailable
Communication