x-mcp-server
Enables reading public X (Twitter) content like profiles, tweets, and search results via a stealth browser, without official API costs.
README
x-mcp-server
An MCP server that scrapes public content from
X (formerly Twitter) using a stealth Patchright
browser, exposed over FastMCP. Designed to run
with uvx, so any MCP client can launch it with zero local setup.
Inspired by stickerdaniel/linkedin-mcp-server.
Why a browser instead of the API
X's official API is expensive and heavily gated. This server drives a real,
undetected Chrome session via Patchright and reads the rendered page, so it works
with a normal logged-in account. Selectors target X's stable data-testid
attributes and will need occasional maintenance as the UI changes.
Tools
| Tool | Description |
|---|---|
get_profile(username) |
Display name, bio, location, website, join date, follower/following counts. |
get_user_tweets(username, limit=20) |
A user's most recent posts from their timeline. |
get_tweet(url_or_id) |
A single post by URL or numeric status id. |
search_tweets(query, limit=20, latest=True) |
Search across X; supports operators like from:, min_faves:, #tag. |
check_auth() |
Diagnose whether the session is logged in. |
Handles may be passed as @name, name, or a full https://x.com/name URL.
Roadmap
The current scope is intentionally minimal: sign in and start posting. Everything below is a TODO, modelled on the capabilities of stickerdaniel/linkedin-mcp-server (the project that inspired this one) and adapted to X.
Near-term (the current focus)
- [ ] Interactive sign-in flow — a
--login/--logoutCLI flag that opens a browser for manual auth, persisting the session instead of pasting cookies. - [ ]
post_tweet(text)— publish a post from the logged-in account.
Write actions (X-native, inspired by connect_with_person / send_message)
- [ ]
reply_to_tweet,quote_tweet - [ ]
like_tweet,repost - [ ]
delete_tweet - [ ]
follow/unfollow - [ ]
send_dm,get_inbox,get_conversation,search_conversations(mirrors LinkedIn's messaging tools)
Read actions
- [ ]
get_my_profile— the authenticated user's own profile (get_my_profile). - [ ]
get_home_timeline— the logged-in home feed (get_feed). - [ ]
search_users— people search (search_people). - [ ]
get_who_to_follow— recommended accounts (get_sidebar_profiles).
Session & tooling
- [ ]
close_sessiontool to terminate the browser and clean up. - [ ] Streamable HTTP transport in addition to stdio.
- [ ] Claude Desktop one-click
.mcpbbundle. - [ ] Secure credential storage via the system keyring.
Authentication
Most X content requires a logged-in session. Provide your session cookies via
environment variables (copy .env.example to .env):
X_AUTH_TOKEN=... # the `auth_token` cookie from x.com
X_CSRF_TOKEN=... # the `ct0` cookie (optional but recommended)
To grab them: log in to x.com, open DevTools → Application → Cookies →
https://x.com, and copy auth_token and ct0.
Alternatively, run once with X_HEADLESS=false and log in interactively; the
session is persisted in X_USER_DATA_DIR for subsequent headless runs.
Run
With uvx (recommended)
uvx --from . x-mcp-server # from a checkout
# once published to PyPI:
uvx x-mcp-server
First run needs the browser binaries:
uvx --from . --with patchright patchright install chromium
MCP client config
{
"mcpServers": {
"x": {
"command": "uvx",
"args": ["x-mcp-server"],
"env": {
"X_AUTH_TOKEN": "your_auth_token",
"X_CSRF_TOKEN": "your_ct0"
}
}
}
}
Local development
uv sync
uv run patchright install chromium
uv run x-mcp-server
Docker
docker build -t x-mcp-server .
docker run --rm -i -e X_AUTH_TOKEN=... -e X_CSRF_TOKEN=... x-mcp-server
Configuration
All settings are environment variables (prefix X_). See .env.example
for the full list: X_HEADLESS, X_USER_DATA_DIR, X_BROWSER_CHANNEL,
X_NAV_TIMEOUT_MS, X_LOG_LEVEL.
Disclaimer
For research and personal use. Scraping may conflict with X's Terms of Service; you are responsible for how you use this tool. Respect rate limits and applicable law.
Credits
This project is directly inspired by
stickerdaniel/linkedin-mcp-server
by Daniel Sticker — a stealth-browser MCP
server for LinkedIn. The architecture (Patchright + FastMCP, cookie/session auth,
uvx distribution) and the Roadmap above follow its design. Go give
it a star.
License
MIT — see LICENSE.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。