X推特
STDIOX平台交互服务器,支持发帖、搜索与账户管理
X平台交互服务器,支持发帖、搜索与账户管理
This MCP server allows Clients to interact with X (formerly Twitter), enabling comprehensive platform operations including posting tweets, searching content, managing accounts, and organizing lists.
git clone https://github.com/Dishant27/twitter-mcp.gitnpm installTWITTER_API_KEY=your_api_key \ TWITTER_API_SECRET=your_api_secret \ TWITTER_ACCESS_TOKEN=your_access_token \ TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret \ npm start
.env file:# Create a .env file with your X API keys echo "TWITTER_API_KEY=your_api_key TWITTER_API_SECRET=your_api_secret TWITTER_ACCESS_TOKEN=your_access_token TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret" > .env # Start the server npm start
To use this server with Claude, you'll need to set up the MCP configuration. Here's an example of how the configuration structure should look:
{ "name": "x", "display_name": "X", "description": "X MCP allows Claude to interact with X (formerly Twitter)", "path": "path/to/twitter-mcp/dist/index.js", "startup": { "env": { "TWITTER_API_KEY": "your_api_key", "TWITTER_API_SECRET": "your_api_secret", "TWITTER_ACCESS_TOKEN": "your_access_token", "TWITTER_ACCESS_TOKEN_SECRET": "your_access_token_secret" } }, "transport": "stdio" }
Save this configuration in your Claude MCP config directory, typically located at:
%APPDATA%\AnthropicClaude\mcp-servers~/Library/Application Support/AnthropicClaude/mcp-servers~/.config/AnthropicClaude/mcp-servers| Tool Name | Description | 
|---|---|
post_tweet | Post new content to X | 
search_tweets | Search for content on X | 
get_profile | Get profile information for a user or the authenticated account | 
update_profile | Update the authenticated user's profile | 
follow_user | Follow a user | 
unfollow_user | Unfollow a user | 
list_followers | List followers of a user or the authenticated account | 
list_following | List accounts that a user or the authenticated account is following | 
create_list | Create a new list | 
get_list_info | Get information about a list | 
get_user_lists | Get all lists owned by the authenticated user | 
| Variable | Description | 
|---|---|
TWITTER_API_KEY | Your API key | 
TWITTER_API_SECRET | Your API secret | 
TWITTER_ACCESS_TOKEN | Your access token | 
TWITTER_ACCESS_TOKEN_SECRET | Your access token secret | 
twitter-mcp/
├── .github/
│   └── workflows/
│       ├── publish.yml
│       └── release.yml
├── code/
│   ├── account_management.py  # Sample Python code for account management
│   ├── post_tweet.py          # Sample Python code for posting content
│   └── retrieve_tweets.py     # Sample Python code for retrieving content
├── src/
│   ├── index.ts        # Main entry point
│   ├── twitter-api.ts  # X API client
│   ├── formatter.ts    # Response formatter
│   └── types.ts        # Type definitions
├── .env.example
├── .gitignore
├── Dockerfile
├── LICENSE
├── package.json
├── README.md
└── tsconfig.json
MIT