How to Control Twitter with AI Using MCP (Claude, Cursor, GPT)
What if you could tell your AI assistant "Unfollow everyone who hasn't tweeted in 6 months" and it just... did it? That's what Model Context Protocol (MCP) enables. And with XActions, you can set it up in under 5 minutes.
What is MCP?
Model Context Protocol is an open standard (created by Anthropic) that lets AI assistants connect to external tools. Think of it as "USB for AI" — a universal plug that lets any AI client (Claude, Cursor, Windsurf) talk to any tool server (XActions, GitHub, databases, etc.).
Before MCP, if you wanted Claude to interact with Twitter, you'd need to:
- Write custom API integration code
- Handle authentication yourself
- Parse responses into a format Claude understands
- Deal with errors, rate limits, pagination...
With MCP, all of that is handled by the MCP server (XActions). You just install it, add one config line, and start talking to your AI in natural language.
What Can You Do?
XActions MCP server exposes 140+ tools to your AI assistant. Here are some examples:
Setup: 3 Steps, 5 Minutes
Step 1: Prerequisites
Make sure you have Node.js 18+ installed. Check with:
node --version
Step 2: Set Your Auth Cookie
XActions needs your X/Twitter session cookie to act on your behalf. Get it from your browser:
- Go to x.com and make sure you're logged in
- Open DevTools (F12) → Application tab → Cookies → x.com
- Find the cookie named
auth_tokenand copy its value
Set it as an environment variable:
# macOS/Linux
export X_AUTH_TOKEN="your_auth_token_here"
# Windows PowerShell
$env:X_AUTH_TOKEN="your_auth_token_here"
Step 3: Add to Your AI Client
Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"xactions": {
"command": "npx",
"args": ["-y", "xactions", "mcp"],
"env": {
"X_AUTH_TOKEN": "your_auth_token_here"
}
}
}
}
Config file location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Cursor
Add to .cursor/mcp.json in your project:
{
"mcpServers": {
"xactions": {
"command": "npx",
"args": ["-y", "xactions", "mcp"],
"env": {
"X_AUTH_TOKEN": "your_auth_token_here"
}
}
}
}
Windsurf
Add to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"xactions": {
"command": "npx",
"args": ["-y", "xactions", "mcp"],
"env": {
"X_AUTH_TOKEN": "your_auth_token_here"
}
}
}
}
npx xactions mcp-config --client claude --write
Tool Categories
The 140+ tools are organized into categories:
- Scraping — profiles, tweets, followers, following, search, hashtags, media
- Actions — follow, unfollow, like, unlike, repost, post, reply, DM
- Analytics — engagement rates, best time to post, sentiment analysis
- Content — AI tweet writer, thread composer, voice analyzer
- Account — detect unfollowers, audit followers, check shadowban
- Export — JSON, CSV, bookmarks, media download
How It Works Under the Hood
When you say "scrape @elonmusk's profile" to Claude:
- Claude recognizes the intent and calls the
x_scrape_profileMCP tool - XActions MCP server receives the tool call and opens a Puppeteer browser
- Puppeteer navigates to x.com/elonmusk and scrapes the page using
data-testidselectors - XActions returns structured JSON data back through MCP
- Claude formats the data and presents it to you in natural language
All of this happens locally on your machine. No data leaves your computer except the normal browser requests to x.com.
Tips for Best Results
- Be specific — "Unfollow the 50 accounts I followed most recently that don't follow me back" is better than "clean up my account"
- Start small — test with read-only operations (scraping) before write operations (posting, unfollowing)
- Check the output — always review what the AI did before moving on, especially for destructive actions
- Use Claude's artifacts — ask Claude to format scraped data as tables or charts
Ready to give your AI full Twitter access?
XActions MCP server — 140+ tools, free, runs locally.