x-mcp-playwright
x-mcp-playwright
一个由 patchright(Stealth Playwright 分支)和持久化 Chrome 用户配置文件驱动的 Twitter/X MCP 服务器。
9 个分组的工具 — 33 项操作完整保留,零功能丢失。
1. 安装
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一次性登录
x-mcp-login
# or: python login.py会打开一个真实的浏览器窗口。正常登录 X 后关闭窗口。会话保存在 ~/.x-mcp-playwright/profile/。
Related MCP server: X MCP Server
2. 在你的 MCP 客户端中注册
Claude Code
claude mcp add --scope user x-twitter x-mcp-serverClaude Desktop
{
"mcpServers": {
"x-twitter": {
"command": "x-mcp-server",
"env": { "X_MCP_HEADLESS": "1" }
}
}
}如果 x-mcp-server 不在 PATH 中,请使用:
{
"mcpServers": {
"x-twitter": {
"command": "/absolute/path/to/.venv/bin/python",
"args": ["-m", "x_mcp_server"]
}
}
}Docker(无头 VPS)
docker build -t x-mcp-playwright .
docker run -i --rm \
-v ~/.x-mcp-playwright/profile:/root/.x-mcp-playwright/profile \
x-mcp-playwright3. 工具目录(9 个工具,33 项操作)
x_post — 发布推文(6 项操作)
操作 | 必需参数 | 描述 |
|
| 发布单条推文 |
|
| 发布关联的推文串 |
|
| 最多 4 张图片或 1 个视频 |
|
| 回复一条推文 |
|
| 带评论的引用转推 |
|
| 删除你的推文 |
x_engage — 与推文互动(4 项操作)
操作 | 必需参数 |
|
|
|
|
|
|
|
|
|
|
|
|
|
x_user — 用户操作(6 项操作)
操作 | 必需参数 | 可选参数 |
|
| — |
|
|
|
|
|
|
|
|
|
|
| — |
|
| — |
x_search — 搜索推文(简单 + 高级)
参数 | 默认值 | 描述 |
| — | 要搜索的关键词 |
|
|
|
| — | 按作者筛选 |
| — | 按回复对象筛选 |
| — | 日期范围(YYYY-MM-DD) |
| 0 | 最低点赞数 |
| 0 | 最低转推数 |
| — | 语言代码 |
| 10 | 最大结果数 |
x_feed — 浏览信息流(4 项操作)
操作 | 描述 |
| 你的主页时间线。可选: |
| 你保存的书签 |
| 提及、点赞、关注 |
| 热门趋势 |
x_tweet — 推文详情(4 项操作)
操作 | 必需参数 | 描述 |
|
| 包含指标的完整推文 |
|
| 一条推文下的回复 |
|
| 展示次数/互动量(仅限自己的推文) |
|
| 谁点赞/转推了( |
x_list — 列表
场景 | 参数 |
你的列表 | 无参数 |
用户的列表 |
|
列表推文 |
|
x_dm — 私信(3 项操作)
操作 | 必需参数 | 描述 |
|
| 发送私信 |
| — | 列出最近的私信会话 |
|
| 读取与某个用户的私信 |
x_session — 会话管理(2 项操作)
操作 | 描述 |
| 返回 |
| 截取任意 X 页面。可选: |
4. 环境变量
变量 | 默认值 | 描述 |
|
| 设为 |
|
| 默认 Playwright 超时时间(毫秒) |
|
| 调试截图 |
|
| 设为 |
5. 安全
速率限制器:写入操作(post、delete、DM、reply)上限为每分钟 1 次。互动操作(like、RT、follow)上限为每分钟 2 次。读取操作不限。
会话保活:后台任务每 30 分钟 ping 一次 X。如果会话过期,会记录警告。
绑定到你的真实账号。 LLM 做的任何事,都是你做的。
6. MCP 资源
x://session/status— 登录状态x://version— 服务器版本x://tools/list— 所有工具x://tools/categories— 分组分类
7. MCP 提示词
analyze_tweet(tweet_url)— 获取并分析一条推文(情感、互动、回复语气)draft_reply(tweet_url, intent)— 起草 3 个不超过 280 字符的回复变体
7. 开发
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, screenshots8. 安全
绑定到你的真实账号。 LLM 做的任何事,都是你做的。
上限:每分钟不超过 1-2 次发布/回复操作。
破坏性工具(
delete、block、send_dm)在 VPS 上需人工审批后才能执行。
许可证
MIT
This server cannot be deployed
Related MCP Connectors
Hosted X (Twitter) MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Twitter/X read-only MCP server — 12 tools: search, users, tweets, followers, timelines, trends.
Official twitterapi.io hosted MCP: Twitter/X tweets, users, followers, trends. OAuth or API key.
Official MCP server for twitterapis.com. Twitter/X search, users, DMs, Grok, monitoring and writes.
Related MCP Servers
FlicenseNot gradedqualityFmaintenanceA local MCP server that exposes the X API (formerly Twitter API) as tools, enabling operations like posting, searching, user management, and more via natural language commands.867-- AlicenseBqualityDmaintenanceMCP server for interacting with the X platform (Twitter) via MCP clients like Claude, Cursor AI, and Windsurf AI.203 npm6MIT
- AlicenseNot gradedqualityDmaintenanceProvides programmatic X (Twitter) engagement via MCP, offering 24 tools for search, timelines, notifications, bookmarks, profiles, and tweet actions through a headless browser.MIT
- AlicenseAqualityAmaintenanceMCP server for the Twitter/X API, enabling search, user profiles, tweets, followers, and more via natural language.94464 npm5MIT