x-mcp-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@x-mcp-server show me the profile of @jack"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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.
Disclaimer: This is an independent, community project. It is not affiliated with, authorized by, endorsed by, or sponsored by X Corp. "X" and "Twitter" are trademarks of X Corp, used here only descriptively to identify the third-party service this software interoperates with.
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.
Related MCP server: X Browser MCP
Tools
Tool | Description |
| Display name, bio, location, website, join date, follower/following counts. |
| A user's most recent posts from their timeline. |
| A single post by URL or numeric status id. |
| Search across X; supports operators like |
| Diagnose whether the session is logged in. |
| Open a visible browser and sign in interactively; persists the session. |
| Best-effort automated DOM login from |
| Publish a post from the logged-in account. |
| Reply to an existing post. |
| Like a post. |
| Follow a user from their profile. |
Handles may be passed as @name, name, or a full https://x.com/name URL.
Write tools require an authenticated session (run login or set X_AUTH_TOKEN).
See docs/RESEARCH.md for the reverse-engineered login/post
HTTP flow behind a future browserless implementation.
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 — the
logintool opens a browser for manual auth and persists the session (run withX_HEADLESS=false). Cookie auth still works.post_tweet(text)— publish a post from the logged-in account.
Scaffolded but not yet validated against live X — selectors and the compose DOM drift. Verify with a real session before trusting output.
Write actions (X-native, inspired by connect_with_person / send_message)
reply_to_tweetquote_tweetlike_tweetrepostdelete_tweetfollow_userunfollowsend_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. Two options:
Option 1: Interactive login (recommended)
uv run mcp-server-x --loginThis opens a browser where you sign in manually (handles 2FA and challenges).
The session is saved to X_USER_DATA_DIR (default: ~/.x-mcp/profile) and reused
on all future runs — no cookie management needed.
Option 2: Manual session cookies
Set environment variables in .env (copy from .env.example):
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.
Verify authentication
uv run mcp-server-x --check-authClear the saved session
uv run mcp-server-x --logoutRun
With uvx, from PyPI (recommended)
Published as mcp-server-x — uvx runs
it without a local install:
# one-time interactive login (opens a browser, saves the session)
uvx mcp-server-x --login
# then run the server
uvx mcp-server-xPin a version for reproducibility, e.g. uvx mcp-server-x@0.2.2.
With uvx, straight from GitHub
To run an unreleased commit, point uvx at the repo instead:
uvx --from git+https://github.com/afikrim/x-mcp-server.git mcp-server-x --login
uvx --from git+https://github.com/afikrim/x-mcp-server.git mcp-server-xPin a tag or commit for reproducibility, e.g.
git+https://github.com/afikrim/x-mcp-server.git@v0.2.2.
The Chromium browser is auto-provisioned on first launch if it isn't already
present, so there's no separate patchright install step. (It downloads ~150MB
once into the Patchright browser cache.)
Install into an MCP client (automatic)
--install writes the config for you, merging into the client's existing servers
(it never clobbers other entries) and using each client's own CLI when available:
uvx mcp-server-x --install claude-desktop
uvx mcp-server-x --install claude-code
uvx mcp-server-x --install codex
uvx mcp-server-x --install opencodeClient | Config written |
|
|
|
|
|
|
|
|
Restart the client afterward. Run --login once (see above) so the session
exists before the client first calls a tool.
MCP client config (manual)
If you'd rather configure by hand:
{
"mcpServers": {
"mcp-server-x": {
"command": "uvx",
"args": ["mcp-server-x"]
}
}
}No env block is needed once you've run --login — the session is read from
~/.x-mcp/profile. (You can still pass X_AUTH_TOKEN / X_CSRF_TOKEN instead.)
Local development
uv sync
uv run patchright install chromium
# Option 1: Interactive login (saves session for future runs)
uv run mcp-server-x --login
# Option 2: Run the server (with X_AUTH_TOKEN/X_CSRF_TOKEN from .env)
uv run mcp-server-x
# Check auth status
uv run mcp-server-x --check-auth
# Clear the saved session
uv run mcp-server-x --logoutCLI flags:
--login— Open browser for interactive sign-in, save session.--logout— Clear the saved browser profile.--check-auth— Check if the session is authenticated and exit.--install {claude-desktop,claude-code,codex,opencode}— Register the server in a client's config and exit.--no-headless— Show the browser window (useful for debugging login).--log-level {DEBUG,INFO,WARNING,ERROR}— Set verbosity (default: INFO).
Docker
docker build -t x-mcp-server .
docker run --rm -i -e X_AUTH_TOKEN=... -e X_CSRF_TOKEN=... x-mcp-serverConfiguration
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.
Contributing
Contributions welcome — see CONTRIBUTING.md for setup,
conventions (notably: data-testid selectors only, browser-driven not API), and
the current feature status.
Disclaimer & responsible use
This tool is for personal and research use only, and comes with no warranty of any kind. Use it in accordance with X's Terms of Service.
Is this safe? Will I get banned?
This server controls a real, logged-in browser session — it does not exploit undocumented APIs or bypass authentication. That said, X's Terms of Service prohibit scraping and automated access without prior consent, and accounts using automated tools can be rate-limited, restricted, or banned. There is no guarantee of account safety. Use at your own risk, and prefer an account you can afford to lose.
Because the session is authenticated, you have agreed to X's terms — so the risk here is contractual (breach of the ToS) and operational (account action), not just abstract. See the LinkedIn precedent (hiQ v. LinkedIn) for how courts have treated authenticated scraping versus public-data scraping.
Keep volume sane
You are responsible for the volume of automation you run. Use it sparingly, keep pacing human-like, respect rate limits, and prompt your agents responsibly. Do not redistribute, resell, or build public datasets from the output.
For anything commercial or at scale
Use the official X API, or obtain written consent from X. The browser route is not defensible at scale — switch to a licensed path before you grow beyond personal use.
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.
Available Tools
11 toolscheck_authA
Report whether the browser session is logged in to X.
Returns a dict with 'authenticated' (bool) and 'has_session_cookies' (whether X_AUTH_TOKEN was supplied). Use this to diagnose empty results.
Inputs: no named parameters. Returns: object
follow_userA
Follow a user from their profile page.
Inputs: username (required). Returns: Outcome of a write action (post, reply, like, follow, login).
get_profileB
Fetch a user's public profile on X.
Inputs: username (required). Returns: A user profile on X.
get_tweetA
Fetch a single post by its URL or numeric status id.
Inputs: url_or_id (required). Returns: A single post on X.
get_user_tweetsB
Fetch a user's most recent posts from their profile timeline.
Inputs: username (required), limit. Returns: result
like_tweetA
Like a post by URL or status id (no-op if already liked).
Inputs: url_or_id (required). Returns: Outcome of a write action (post, reply, like, follow, login).
loginA
Open a visible browser and wait for you to sign in to X interactively.
Run the server with X_HEADLESS=false so the window is visible, call this
tool, complete the login (including any 2FA / email step) in the browser, and
the session is persisted to the on-disk profile for all later calls.
Inputs: timeout_seconds. Returns: Outcome of a write action (post, reply, like, follow, login).
login_with_credentialsA
Attempt an automated DOM login using X_USERNAME / X_PASSWORD (fragile).
This types the configured credentials into the login form. It does NOT handle
2FA, email confirmation, or the anti-bot challenges X frequently injects, so
it only works for simple accounts. Prefer login or session cookies.
Returns: ActionResult describing whether the session ended up authenticated.
Inputs: no named parameters. Returns: Outcome of a write action (post, reply, like, follow, login).
post_tweetB
Publish a new post (tweet) from the authenticated account.
Inputs: text (required). Returns: Outcome of a write action (post, reply, like, follow, login).
reply_to_tweetB
Reply to an existing post.
Inputs: text (required), url_or_id (required). Returns: Outcome of a write action (post, reply, like, follow, login).
search_tweetsB
Search X for posts matching a query.
Inputs: query (required), limit, latest. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Each tool targets a distinct action (check auth, follow, get profile, get tweet, get user tweets, like, login, login with credentials, post, reply, search). Even the two login tools are clearly differentiated by method (interactive vs automated). There is no ambiguity between tools.
All tool names follow a consistent verb_noun pattern in snake_case (e.g., check_auth, get_profile, like_tweet, search_tweets). The only deviation is login_with_credentials, which is still a verb phrase and fits the pattern. No mixing of styles.
With 11 tools, the server covers the essential operations for interacting with X (authentication, profile viewing, tweeting, searching, following, liking, replying). The count is well-scoped for this domain, neither too few nor too many.
The tool set covers core X workflows: authentication, profile and tweet retrieval, posting, replying, liking, following, and searching. However, notable gaps exist, such as no retweet, quote tweet, delete tweet, unfollow, or direct message support. These are common actions that agents may need, but the set is still functional for basic interactions.
Maintenance
Related MCP Connectors
Read public Twitter/X data: tweets, profiles, followers, search. No X developer account.
Read-only public X (Twitter) data: profiles, tweets, threads, followers, search. Pay per result.
Read public X posts and full X Articles as clean Markdown. Free, no X API key.
Read public X posts with no account or key: Articles as Markdown, video transcripts, posts.
Related MCP Servers
- AlicenseCqualityBmaintenanceEnables AI agents to search, read user profiles, timelines, media, follow threads, track trends, and manage accounts on X/Twitter via GraphQL, without browser automation or paid API keys.113111 PyPI13MIT
- FlicenseBqualityCmaintenanceEnables browser-based Twitter/X research and account workflows through a signed-in browser, supporting search, timeline/profile reads, saved searches, snapshot exports, and prepared account actions without requiring an X developer API key.25-
- AlicenseNot gradedqualityCmaintenanceEnables reading public X/Twitter posts by URL or numeric ID and returning original structured data, including articles, quoted posts, and media fields, without requiring an X API key.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to read public X (Twitter) data without the paid official API, including tweet and user search, profiles, timelines, media, replies, retweeters, followers, lists, and trends. All tools are read-only and rotate across multiple scraping accounts with proxy and rate-limit support.MIT