Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

x-mcp-server

An MCP (Model Context Protocol) server that connects Claude Code (or any MCP client) to the X/Twitter API. Post tweets, pull analytics, manage your account — all through natural language.

What it does

14 tools for reading and writing to X/Twitter:

Read / Analytics

  • x_get_me — Your profile with follower, following, and tweet counts
  • x_get_my_tweets — Recent tweets with engagement metrics (likes, retweets, replies, impressions)
  • x_get_tweet — Look up any tweet by ID with full metrics
  • x_search_recent — Search tweets from the last 7 days
  • x_get_mentions — Recent mentions of your account
  • x_get_followers — Your follower list with profile info
  • x_get_following — Accounts you follow

Write

  • x_post_tweet — Post a tweet (supports replies and quote tweets)
  • x_delete_tweet — Delete a tweet
  • x_like_tweet / x_unlike_tweet — Like or unlike a tweet
  • x_retweet / x_unretweet — Retweet or undo a retweet
  • x_post_reply — Reply to a tweet

Prerequisites

You need an X/Twitter developer account with API access.

Step 1: Create an X Developer App

  1. Go to developer.x.com and sign in
  2. Create a new project and app (or use an existing one)
  3. You'll get a Consumer Key and Consumer Secret — save these

Step 2: Configure App Permissions

  1. In your app's settings, go to User authentication settings and click Set up
  2. App permissions: Select "Read and write"
  3. Type of App: Select "Web App, Automated App or Bot"
  4. Callback URL: Enter http://localhost:3000/callback (required by the form but not used)
  5. Website URL: Enter your website URL
  6. Save changes

After saving, the console will show new OAuth 2.0 Keys (Client ID and Client Secret). Ignore these — this server uses OAuth 1.0a only.

Step 3: Generate Access Tokens

  1. Go back to Keys and tokens for your app
  2. Under OAuth 1.0 Keys, you should see your Consumer Key (click "Show" to reveal it, or "Regenerate" if you didn't save the secret)
  3. Under Access Token, click Generate — make sure it says "Read and write" under the token (if it says "Read", go back to Step 2 and update permissions first, then regenerate the token)
  4. Save the Access Token and Access Token Secret immediately — the secret is only shown once

You should now have 4 values:

X Developer Console Environment Variable
Consumer Key X_API_KEY
Consumer Secret X_API_SECRET
Access Token X_ACCESS_TOKEN
Access Token Secret X_ACCESS_TOKEN_SECRET

Installation

Option A: npx (no install needed)

Use directly in your MCP client config — nothing to install:

{
  "mcpServers": {
    "x-twitter": {
      "command": "npx",
      "args": ["-y", "x-mcp-server"],
      "env": {
        "X_API_KEY": "your_consumer_key",
        "X_API_SECRET": "your_consumer_secret",
        "X_ACCESS_TOKEN": "your_access_token",
        "X_ACCESS_TOKEN_SECRET": "your_access_token_secret"
      }
    }
  }
}

Option B: Clone and build locally

git clone https://github.com/noahrasheta/x-mcp-server.git
cd x-mcp-server
npm install
npm run build

Then configure your MCP client:

{
  "mcpServers": {
    "x-twitter": {
      "command": "node",
      "args": ["/path/to/x-mcp-server/build/index.js"],
      "env": {
        "X_API_KEY": "your_consumer_key",
        "X_API_SECRET": "your_consumer_secret",
        "X_ACCESS_TOKEN": "your_access_token",
        "X_ACCESS_TOKEN_SECRET": "your_access_token_secret"
      }
    }
  }
}

Claude Code Setup

Add the MCP server config to one of these locations:

  • Global (all projects): ~/.claude.json under the mcpServers key
  • Project-specific: .mcp.json in your project root

After adding the config, restart Claude Code. You can verify it's connected by running /mcp to check server status, then ask Claude to "get my X profile" or "show my recent tweets."

Managing Multiple Accounts

To manage multiple X accounts, add separate MCP server entries pointing to the same server with different credentials:

{
  "mcpServers": {
    "x-brand-a": {
      "command": "npx",
      "args": ["-y", "x-mcp-server"],
      "env": {
        "X_API_KEY": "same_consumer_key",
        "X_API_SECRET": "same_consumer_secret",
        "X_ACCESS_TOKEN": "brand_a_access_token",
        "X_ACCESS_TOKEN_SECRET": "brand_a_access_token_secret"
      }
    },
    "x-brand-b": {
      "command": "npx",
      "args": ["-y", "x-mcp-server"],
      "env": {
        "X_API_KEY": "same_consumer_key",
        "X_API_SECRET": "same_consumer_secret",
        "X_ACCESS_TOKEN": "brand_b_access_token",
        "X_ACCESS_TOKEN_SECRET": "brand_b_access_token_secret"
      }
    }
  }
}

The Consumer Key/Secret (API Key) stay the same — they belong to your developer app. The Access Token/Secret are different per account and represent which X user authorized your app.

To get access tokens for additional accounts, either:

  • Log into X as that account and generate tokens from the developer portal, or
  • Use the OAuth 1.0a PIN-based authorization flow to have each account authorize your app

Testing

You can test interactively with the MCP Inspector:

npx @modelcontextprotocol/inspector node build/index.js

License

MIT

About

An MCP server to connect your X account to Claude Code or other AIs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages