x mcp server
Server for X (Twitter) integration that provides tools for reading your timeline and engaging with tweets. Designed for use with Claude desktop.
Server for X (Twitter) integration that provides tools for reading your timeline and engaging with tweets. Designed for use with Claude desktop.
A Model Context Protocol (MCP) server for X (Twitter) integration that provides tools for reading your timeline and engaging with tweets. Designed for use with Claude desktop.
X (Twitter) provides a free tier for basic API access:
Note: For higher volume needs, paid tiers are available: - Basic tier ($100/month): 50,000 tweets/month, additional endpoints - Pro tier ($5000/month): Higher limits and enterprise features
You can access the free tier at: https://developer.x.com/en/portal/products/free
Clone the repository:
git clone [your-repo-url]
cd x-mcp-server
Install dependencies:
npm install
Build the server:
npm run build
You need to set up your X (Twitter) API credentials. Follow these detailed steps:
If you Do not have a developer account, you'll be prompted to create one
Access the Free Tier:
Complete the registration process
Create a new project:
Click "Next"
Create a new app within your project:
Click "Complete Setup"
Configure app settings:
Under "User authentication settings":
Set app permissions:
Click "Save"
Generate API Keys and Tokens:
Important: - Keep your keys and tokens secure and never share them publicly - You'll need all four values: - API Key (also called Consumer Key) - API Key Secret (also called Consumer Secret) - Access Token - Access Token Secret - Remember the free tier limits: - 500 posts per month at user level - 500 posts per month at app level - 100 reads per month
To connect the X MCP server with Claude desktop, you need to configure it in the Claude settings. Follow these steps:
%APPDATA%/Claude
and press EnterIf the Claude folder does not exist, create it
Create or edit claude_desktop_config.json
:
claude_desktop_config.json
If it exists, open it in a text editor (like Notepad)
Add the following configuration, replacing the placeholder values with your actual API credentials from the previous section:
{
"mcpServers": {
"x": {
"command": "node",
"args": ["%USERPROFILE%/Projects/MCP Basket/x-server/build/index.js"],
"env": {
"TWITTER_API_KEY": "paste-your-api-key-here",
"TWITTER_API_SECRET": "paste-your-api-key-secret-here",
"TWITTER_ACCESS_TOKEN": "paste-your-access-token-here",
"TWITTER_ACCESS_SECRET": "paste-your-access-token-secret-here"
}
}
}
}
Save the file and restart Claude desktop
Note: Make sure to:
- Replace all four credential values with your actual API keys and tokens
- Keep the quotes ("") around each value
- Maintain the exact spacing and formatting shown above
- Save the file with the .json
extension
Get the most recent tweets from your home timeline.
Parameters:
- limit
(optional): Number of tweets to retrieve (default: 20, max: 100)
Example:
await use_mcp_tool({
server_name: "x",
tool_name: "get_home_timeline",
arguments: { limit: 5 }
});
Create a new tweet.
Parameters:
- text
(required): The text content of the tweet (max 280 characters)
Example:
await use_mcp_tool({
server_name: "x",
tool_name: "create_tweet",
arguments: { text: "Hello from MCP! ?" }
});
Reply to a tweet.
Parameters:
- tweet_id
(required): The ID of the tweet to reply to
- text
(required): The text content of the reply (max 280 characters)
Example:
await use_mcp_tool({
server_name: "x",
tool_name: "reply_to_tweet",
arguments: {
tweet_id: "1234567890",
text: "Great tweet! ?"
}
});
npm run build
: Build the TypeScript codenpm run dev
: Run TypeScript in watch modenpm start
: Start the MCP serverThe server includes built-in rate limit handling for X's free tier: - Monthly limits: - 500 posts per month at user level - 500 posts per month at app level - 100 reads per month - Features: - Tracks monthly usage - Provides exponential backoff for rate limit errors - Clear error messages when limits are reached - Automatic retry after rate limit window expires
MIT
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)[
{
"description": "Get the most recent tweets from your home timeline",
"inputSchema": {
"properties": {
"limit": {
"default": 20,
"description": "Number of tweets to retrieve (max 100)",
"maximum": 100,
"minimum": 1,
"type": "number"
}
},
"type": "object"
},
"name": "get_home_timeline"
},
{
"description": "Create a new tweet",
"inputSchema": {
"properties": {
"text": {
"description": "The text content of the tweet",
"maxLength": 280,
"type": "string"
}
},
"required": [
"text"
],
"type": "object"
},
"name": "create_tweet"
},
{
"description": "Reply to a tweet",
"inputSchema": {
"properties": {
"text": {
"description": "The text content of the reply",
"maxLength": 280,
"type": "string"
},
"tweet_id": {
"description": "The ID of the tweet to reply to",
"type": "string"
}
},
"required": [
"tweet_id",
"text"
],
"type": "object"
},
"name": "reply_to_tweet"
}
]