X
STDIOX平台集成服务,用于读取时间线和发推
X平台集成服务,用于读取时间线和发推
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:
You can access the free tier at: https://developer.x.com/en/portal/products/free
git clone [your-repo-url] cd x-mcp-server
npm install
npm run build
You need to set up your X (Twitter) API credentials. Follow these detailed steps:
Go to the Twitter Developer Portal
Access the Free Tier:
Create a new project:
Create a new app within your project:
Configure app settings:
Set app permissions:
Generate API Keys and Tokens:
Important:
To connect the X MCP server with Claude desktop, you need to configure it in the Claude settings. Follow these steps:
Open File Explorer
Navigate to the Claude config directory:
%APPDATA%/Claude and press EnterCreate or edit claude_desktop_config.json:
claude_desktop_config.jsonAdd 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" } } } }
Note: Make sure to:
.json extensionGet 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 with optional image attachment.
Parameters:
text (required): The text content of the tweet (max 280 characters)image_path (optional): Absolute path to an image file (PNG, JPEG, GIF, WEBP, max 5MB)Example (text-only):
await use_mcp_tool({ server_name: "x", tool_name: "create_tweet", arguments: { text: "Hello from MCP! 🤖" } });
Example (with image):
await use_mcp_tool({ server_name: "x", tool_name: "create_tweet", arguments: { text: "Check out this image! 📸", image_path: "/path/to/image.png" } });
Reply to a tweet with optional image attachment.
Parameters:
tweet_id (required): The ID of the tweet to reply totext (required): The text content of the reply (max 280 characters)image_path (optional): Absolute path to an image file (PNG, JPEG, GIF, WEBP, max 5MB)Example (text-only):
await use_mcp_tool({ server_name: "x", tool_name: "reply_to_tweet", arguments: { tweet_id: "1234567890", text: "Great tweet! 👍" } });
Example (with image):
await use_mcp_tool({ server_name: "x", tool_name: "reply_to_tweet", arguments: { tweet_id: "1234567890", text: "Here's my response 📸", image_path: "/path/to/image.jpg" } });
Delete a tweet. Parameters:
tweet_id (required): The ID of the tweet to delete
Example:await use_mcp_tool({ server_name: "x", tool_name: "delete_tweet", arguments: { tweet_id: "1234567890" } });
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:
MIT
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)