๐Ÿค– MCP Server Tutorial

๐Ÿ”Œ Connect AI Agents to X/Twitter Works with Claude Desktop, GPT, and more

๐Ÿ”Œ What is MCP?

Model Context Protocol (MCP) is a standard that allows AI assistants to use external tools. XActions provides an MCP server that lets Claude, GPT, and other AI agents automate X/Twitter tasks.

๐Ÿ’ก Why Use MCP?

Instead of manually running scripts, you can ask Claude to "scrape followers from @elonmusk" or "unfollow everyone who doesn't follow me back" - and it just works.

๐Ÿ–ฅ๏ธ Setup with Claude Desktop

Step 1: Install XActions globally

Terminal
npm install -g xactions

Step 2: Find your Claude Desktop config

The config file location depends on your OS:

Config file locations
# macOS
~/Library/Application Support/Claude/claude_desktop_config.json

# Windows
%APPDATA%\Claude\claude_desktop_config.json

# Linux
~/.config/Claude/claude_desktop_config.json

Step 3: Add XActions MCP server to config

Edit the config file and add the XActions server:

claude_desktop_config.json
{
  "mcpServers": {
    "xactions": {
      "command": "npx",
      "args": ["xactions-mcp"],
      "env": {
        "X_AUTH_TOKEN": "your_auth_token_here"
      }
    }
  }
}

Step 4: Get your X auth token

To get your auth token from X:

  1. Go to x.com and log in
  2. Open Developer Tools (F12)
  3. Go to Application โ†’ Cookies โ†’ x.com
  4. Find the auth_token cookie and copy its value

Step 5: Restart Claude Desktop

Quit and reopen Claude Desktop. You should now see XActions tools available!

๐Ÿ› ๏ธ Available MCP Tools

The XActions MCP server provides these tools to AI agents:

scrape_followers

Get a list of followers for any public account

username, limit

scrape_following

Get who an account follows (includes followsBack status)

username, limit

scrape_tweets

Get tweets from a profile with engagement stats

username, limit

search_tweets

Search X for tweets matching a query

query, limit

scrape_profile

Get full profile info (bio, followers count, etc.)

username

get_non_followers

Find who you follow that doesn't follow back

username

unfollow_users

Unfollow a list of usernames

usernames[]

follow_users

Follow a list of usernames

usernames[]

๐Ÿ’ฌ Example Prompts

Once connected, try these prompts with Claude:

Example prompts for Claude
# Scraping
"Get me a list of @elonmusk's last 50 followers"
"Who does @naval follow? Show me the first 100"
"Search for tweets about 'AI agents' from the last week"

# Analysis
"Find all the people I follow who don't follow me back"
"Get @pmarca's most liked tweets from his profile"
"Compare the followers of @a16z and @sequoia"

# Actions
"Unfollow everyone who doesn't follow me back"
"Follow the top 20 people who liked @balajis's last post"

# Combined
"Find tech founders who follow both @paulg and @naval, 
then follow them if they have over 1000 followers"

๐Ÿ”’ Safety Notes

The MCP server respects rate limits and adds human-like delays. Actions like unfollowing require explicit confirmation. Your auth token is stored locally and never sent to external servers.

โŒจ๏ธ Alternative: Direct CLI

If you prefer using the CLI directly instead of through AI:

CLI commands
# Install globally
npm install -g xactions

# Login (saves session)
xactions login

# Scrape followers
xactions followers elonmusk --limit 100 --output followers.json

# Get non-followers
xactions non-followers YOUR_USERNAME --output non-followers.json

# Unfollow non-followers
xactions unfollow non-followers.json

# Search tweets
xactions search "AI agents" --limit 50