Set up Twitter/X MCP in Claude Code
Post tweets, search timelines, manage followers, and analyze engagement on Twitter/X from your AI editor.
1
Locate the config file
Claude Code reads MCP server configuration from the following file:
~/.claude.jsonCreate this file if it does not already exist.
2
Add the configuration
You can configure Twitter/X MCP using the CLI command or by editing the config file directly.
Option A: CLI command
bash
claude mcp add twitter-mcp -e TWITTER_API_KEY=YOUR_TWITTER_API_KEY -e TWITTER_API_SECRET=YOUR_TWITTER_API_SECRET -e TWITTER_ACCESS_TOKEN=YOUR_TWITTER_ACCESS_TOKEN -e TWITTER_ACCESS_SECRET=YOUR_TWITTER_ACCESS_SECRET -- npx -y twitter-mcpOption B: Config file
json
{
"mcpServers": {
"twitter-mcp": {
"command": "npx",
"args": [
"-y",
"twitter-mcp"
],
"env": {
"TWITTER_API_KEY": "YOUR_TWITTER_API_KEY",
"TWITTER_API_SECRET": "YOUR_TWITTER_API_SECRET",
"TWITTER_ACCESS_TOKEN": "YOUR_TWITTER_ACCESS_TOKEN",
"TWITTER_ACCESS_SECRET": "YOUR_TWITTER_ACCESS_SECRET"
}
}
}
}3
Set up environment variables
Twitter/X MCP requires the following environment variables:
TWITTER_API_KEYRequiredTwitter API key
TWITTER_API_SECRETRequiredTwitter API secret
TWITTER_ACCESS_TOKENRequiredTwitter access token
TWITTER_ACCESS_SECRETRequiredTwitter access token secret
4
Verify it works
Restart Claude Code. Twitter/X MCP should appear in your MCP server list with 8 tools available.
This server adds approximately 4,120 tokens to your context window for tool definitions.