x-mcp-playwright

x-mcp-playwright

A Twitter/X MCP server powered by patchright (stealth Playwright fork) and a persistent Chrome user profile. It enables posting, engaging, searching, and managing tweets, threads, media, and user interactions via natural language.

Category
Visit Server

README

x-mcp-playwright

A Twitter/X MCP server powered by patchright (stealth Playwright fork) and a persistent Chrome user profile.

9 grouped tools — 33 actions preserved, zero functionality lost.


1. Install

git clone <this-repo> x-mcp-playwright
cd x-mcp-playwright

python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activate

pip install -e .
patchright install chromium

One-time login

x-mcp-login
# or: python login.py

Opens a real browser window. Log in to X normally, then close the window. Session saved in ~/.x-mcp-playwright/profile/.


2. Register in your MCP client

Claude Code

claude mcp add --scope user x-twitter x-mcp-server

Claude Desktop

{
  "mcpServers": {
    "x-twitter": {
      "command": "x-mcp-server",
      "env": { "X_MCP_HEADLESS": "1" }
    }
  }
}

If x-mcp-server isn't on PATH, use:

{
  "mcpServers": {
    "x-twitter": {
      "command": "/absolute/path/to/.venv/bin/python",
      "args": ["-m", "x_mcp_server"]
    }
  }
}

Docker (headless VPS)

docker build -t x-mcp-playwright .
docker run -i --rm \
  -v ~/.x-mcp-playwright/profile:/root/.x-mcp-playwright/profile \
  x-mcp-playwright

3. Tool catalog (9 tools, 33 actions)

x_post — Publish tweets (6 actions)

action Required args Description
post text Post a single tweet
thread tweets (newline-separated) Post a connected thread
post_media text, media_paths (comma-separated) Up to 4 images or 1 video
reply tweet_url, reply_text Reply to a tweet
quote tweet_url, comment Quote-tweet with comment
delete tweet_url Delete your tweet

x_engage — Interact with tweets (4 actions)

action Required args on param
like tweet_url on=True to like, False to unlike
retweet tweet_url on=True to RT, False to undo
bookmark tweet_url on=True to save, False to remove
pin tweet_url on=True to pin, False to unpin

x_user — User operations (6 actions)

action Required args Optional
profile handle
timeline handle tab="tweets"|"likes"|"media", limit
connections handle kind="followers"|"following", limit
follow handle on=True to follow, False to unfollow
block handle
mute handle

x_search — Search tweets (simple + advanced)

arg Default Description
query Keywords to search
filter "top" "latest", "people", "media"
from_user Filter by author
to_user Filter by reply-to
since / until Date range (YYYY-MM-DD)
min_likes 0 Minimum likes
min_retweets 0 Minimum retweets
lang Language code
limit 10 Max results

x_feed — Browse feeds (4 actions)

action Description
home Your home timeline. Optional: tab="for_you"|"following"
bookmarks Your saved bookmarks
notifications Mentions, likes, follows
trending What's happening

x_tweet — Tweet details (4 actions)

action Required args Description
details tweet_url Full tweet with metrics
replies tweet_url Replies under a tweet
analytics tweet_url Impressions/engagements (own tweets)
engagers tweet_url Who liked/retweeted (kind="likes"|"retweets")

x_list — Lists

Scenario Args
Your lists No args
User's lists handle
List tweets list_id

x_dm — Direct messages (3 actions)

action Required args Description
send handle, message Send a DM
conversations List recent DM threads
messages handle Read messages with a user

x_session — Session management (2 actions)

action Description
check Returns {logged_in, current_url, user_handle}
screenshot Capture any X page. Optional: url, full_page

4. Environment variables

Variable Default Description
X_MCP_HEADLESS 1 0 to see the browser window
X_MCP_TIMEOUT_MS 20000 Default Playwright timeout (ms)
X_MCP_SCREENSHOT_DIR ~/.x-mcp-playwright/screenshots Debug screenshots
X_MCP_USE_SYSTEM_CHROME 0 1 to use system Chrome

5. Safety

  • Rate limiter: Write actions (post, delete, DM, reply) capped at 1/min. Engage actions (like, RT, follow) capped at 2/min. Read actions unlimited.
  • Session keepalive: Background task pings X every 30 min. Logs warning if session expires.
  • Pinned to your real account. Anything the LLM does, you did.

6. MCP resources

  • x://session/status — Login state
  • x://version — Server version
  • x://tools/list — All tools
  • x://tools/categories — Grouped taxonomy

7. MCP prompts

  • analyze_tweet(tweet_url) — Fetch & analyze a tweet (sentiment, engagement, response tone)
  • draft_reply(tweet_url, intent) — Draft 3 reply variants under 280 chars

7. Development

make install     # deps + chromium
make login       # interactive X login
make test        # unit tests (no browser)
make smoke       # live search test
make server      # run MCP server
make lint        # compile-check
make clean       # remove pycache, screenshots

8. Safety

  • Pinned to your real account. Anything the LLM does, you did.
  • Cap: <= 1-2 publish/reply actions per minute.
  • Gate destructive tools (delete, block, send_dm) behind human approval on VPS.

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured