loading…
Search for a command to run...
loading…
Enables Claude.ai to interact with Twitter/X by using browser automation to perform actions like posting, replying, and searching through a logged-in Chrome ses
Enables Claude.ai to interact with Twitter/X by using browser automation to perform actions like posting, replying, and searching through a logged-in Chrome session. It provides a cost-effective alternative to the official API by bridging the Model Context Protocol with a real browser instance.
Connect Claude.ai to Twitter/X — without paying $100/month for the official API.
Uses bb-browser (open-source browser automation) to control a logged-in Chrome session, wrapped as an MCP server that Claude.ai can talk to.
Claude.ai ──MCP──▶ your-server:8080 ──bb-browser──▶ Chrome (logged in) ──▶ Twitter/X
Cost: ~$5/year (just a domain for Cloudflare Tunnel).
| Tool | Method | Status |
|---|---|---|
twitter_post |
Browser automation | ✅ |
twitter_reply |
Browser automation | ✅ |
twitter_like |
GraphQL API | ✅ |
twitter_retweet |
GraphQL API | ✅ |
twitter_quote |
Browser automation | ✅ |
twitter_follow |
Browser automation | ✅ |
twitter_unfollow |
Browser automation | ✅ |
twitter_undo |
GraphQL API | ✅ |
twitter_search |
Browser DOM parsing | ✅ |
twitter_timeline |
Browser DOM parsing | ✅ |
twitter_bookmarks |
Browser DOM parsing | ✅ |
twitter_tweets |
Browser DOM parsing | ✅ |
twitter_notifications |
bb-sites adapter | ✅ |
twitter_user |
bb-sites adapter | ✅ |
twitter_view_tweet |
Browser DOM parsing | ✅ |
twitter_mentions |
Browser DOM parsing | ✅ |
twitter_my_replies |
Browser DOM parsing | ✅ |
twitter_dm_read |
Browser automation | ⚠️ partial |
twitter_screenshot |
bb-browser | ✅ |
browser_open |
bb-browser | ✅ |
browser_snapshot |
bb-browser | ✅ |
DM reading works but Twitter's E2E encryption may limit what's visible via browser automation.
twitter_view_tweet now includes replies — Pass include_replies: true (default) to fetch up to 20 replies from the tweet's thread. Uses cellInnerDiv container traversal with auto-scrolling.twitter_mentions — Fetches tweets that mention/reply to you from the Mentions tab.twitter_my_replies — Fetches your own replies to other tweets. Requires screen_name parameter..tokens.json and survive server restarts. No more re-authenticating after every reboot.bb-browser open creates a new tab without switching to it, causing all subsequent operations to run on the wrong page. Affects view_tweet, openAndParseTweets (used by timeline, search, bookmarks, tweets, mentions, my_replies).view_tweet now polls for the main tweet article to appear (up to 15s) instead of using a fixed sleep, improving reliability on slow connections.The server has three layers:
Browser automation was chosen over GraphQL API for most read operations because Twitter's API requires a x-client-transaction-id header generated from webpack internals — the module IDs change on every Twitter deploy, causing random 404s. DOM parsing is slower but never breaks.
# Create a dedicated Chrome profile
mkdir -p ~/chrome-mcp-profile
# Launch Chrome with remote debugging
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--remote-debugging-port=9222 \
--user-data-dir=$HOME/chrome-mcp-profile
Log in to Twitter/X in this Chrome window.
git clone https://github.com/replica882/twitter-bridge-mcp.git
cd twitter-bridge-mcp
npm install
cp .env.example .env
# Edit .env with your values
node server.mjs
# Twitter MCP Bridge v0.6.1: http://0.0.0.0:8080/mcp
cloudflared tunnel --url http://localhost:8080
Or set up a named tunnel for a permanent URL.
In Claude.ai → Settings → Connected Tools → Add Custom Connector:
https://your-tunnel-domain.com/mcpClaude will auto-discover OAuth endpoints and connect.
All config is via environment variables (or .env file):
| Variable | Default | Description |
|---|---|---|
PORT |
8080 |
Server port |
CDP_PORT |
9222 |
Chrome DevTools Protocol port |
BASE_URL |
http://localhost:8080 |
Public URL (for OAuth discovery) |
BB_BROWSER_PATH |
~/local/bin/bb-browser |
Path to bb-browser binary |
DM_PIN |
(empty) | Twitter DM encryption PIN (if set up) |
OAUTH_CLIENT_ID |
twitter-mcp-client |
OAuth client ID |
OAUTH_CLIENT_SECRET |
(auto-generated) | OAuth client secret |
Twitter/X API Basic tier costs $100/month. This project does the same thing for $5/year by automating a real browser session.
Twitter's internal GraphQL API requires a x-client-transaction-id header. This ID is generated by a function buried in Twitter's webpack bundles — the module number changes every time Twitter deploys. We use GraphQL only for simple mutations (like, retweet, delete) that don't need this header. Everything else uses DOM parsing.
Every browser operation opens a new tab. Without cleanup, Chrome accumulates 40+ tabs and crashes. The server auto-closes excess tabs, keeping a maximum of 10.
Twitter requires a PIN every time you open the DM page (E2E encryption). If DM_PIN is set, the server auto-enters it using React-compatible input simulation (native property setter + keyboard events).
--user-data-dir and log in manually.contenteditable div. Normal DOM manipulation doesn't trigger React state updates. The server uses ClipboardEvent paste for quote tweets and bb-browser's type command for regular posts.WorkingDirectory to the project directory. Without this, dotenv can't find .env, BASE_URL falls back to http://localhost:8080, and OAuth discovery returns localhost URLs — Claude.ai will fail to connect. For macOS launchd, add <key>WorkingDirectory</key><string>/path/to/twitter-bridge-mcp</string> to your plist. For systemd, add WorkingDirectory=/path/to/twitter-bridge-mcp to your unit file.MIT
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"twitter-bridge-mcp": {
"command": "npx",
"args": []
}
}
}