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.
14 tools for reading and writing to X/Twitter:
Read / Analytics
x_get_me— Your profile with follower, following, and tweet countsx_get_my_tweets— Recent tweets with engagement metrics (likes, retweets, replies, impressions)x_get_tweet— Look up any tweet by ID with full metricsx_search_recent— Search tweets from the last 7 daysx_get_mentions— Recent mentions of your accountx_get_followers— Your follower list with profile infox_get_following— Accounts you follow
Write
x_post_tweet— Post a tweet (supports replies and quote tweets)x_delete_tweet— Delete a tweetx_like_tweet/x_unlike_tweet— Like or unlike a tweetx_retweet/x_unretweet— Retweet or undo a retweetx_post_reply— Reply to a tweet
You need an X/Twitter developer account with API access.
- Go to developer.x.com and sign in
- Create a new project and app (or use an existing one)
- You'll get a Consumer Key and Consumer Secret — save these
- In your app's settings, go to User authentication settings and click Set up
- App permissions: Select "Read and write"
- Type of App: Select "Web App, Automated App or Bot"
- Callback URL: Enter
http://localhost:3000/callback(required by the form but not used) - Website URL: Enter your website URL
- 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.
- Go back to Keys and tokens for your app
- 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)
- 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)
- 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 |
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"
}
}
}
}git clone https://github.com/noahrasheta/x-mcp-server.git
cd x-mcp-server
npm install
npm run buildThen 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"
}
}
}
}Add the MCP server config to one of these locations:
- Global (all projects):
~/.claude.jsonunder themcpServerskey - Project-specific:
.mcp.jsonin 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."
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
You can test interactively with the MCP Inspector:
npx @modelcontextprotocol/inspector node build/index.jsMIT