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.
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 statex://version— Server versionx://tools/list— All toolsx://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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。