X(Twitter)MCP 服务器
该 MCP 服务器允许客户端与 X(以前称为 Twitter)进行交互,从而实现包括发布推文、搜索内容、管理帐户和组织列表在内的综合平台操作。
快速入门
创建 X 开发者帐户并从X 开发者门户获取 API 密钥
在环境变量中设置所有必需的 API 密钥
克隆此存储库:
git clone https://github.com/Dishant27/twitter-mcp.git安装依赖项:
npm install运行服务器:
使用环境变量:
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 \
npm start使用
.env文件:
# 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与 MCP 客户端(例如 Claude)一起使用。
Related MCP server: Twitter MCP Server
克劳德配置
要将此服务器与 Claude 一起使用,您需要设置 MCP 配置。以下是配置结构的示例:
{
"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"
}将此配置保存在您的 Claude MCP 配置目录中,通常位于:
Windows:
%APPDATA%\AnthropicClaude\mcp-serversmacOS:
~/Library/Application Support/AnthropicClaude/mcp-serversLinux:
~/.config/AnthropicClaude/mcp-servers
特征
后期操作
帖子内容(最多 280 个字符)
按查询搜索帖子,可自定义结果计数
账户管理
获取任何用户或经过身份验证的帐户的个人资料信息
更新个人资料详细信息(姓名、简历、位置、网站网址)
关注和取消关注用户
列出任何用户或经过身份验证的帐户的关注者
列出用户关注的帐户
列表管理
创建新列表(公共或私人)
获取有关特定列表的信息
检索经过身份验证的用户拥有的所有列表
可用的 MCP 工具
工具名称 | 描述 |
| 将新内容发布到 X |
| 在 X 上搜索内容 |
| 获取用户或经过身份验证的帐户的个人资料信息 |
| 更新已验证用户的个人资料 |
| 关注用户 |
| 取消关注用户 |
| 列出用户或已验证帐户的关注者 |
| 列出用户或经过身份验证的帐户正在关注的帐户 |
| 创建新列表 |
| 获取有关列表的信息 |
| 获取已验证用户拥有的所有列表 |
要求
Node.js 18.x 或更高版本
X 带有 API 密钥的开发者帐户
API v1 和 v2 访问
环境变量
多变的 | 描述 |
| 您的 API 密钥 |
| 您的 API 秘密 |
| 您的访问令牌 |
| 您的访问令牌秘密 |
存储库结构
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执照
麻省理工学院
This server cannot be installed
Resources
Looking for Admin?
Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.
Appeared in Searches
- Search for posts related to X
- A search for strategies to promote a directory website and generate ideas for solopreneur SAAS businesses
- Managing Social Media Content Creation Using Monday
- A guide to researching LinkedIn profiles and personalizing outreach based on customer persona and company signals
- How to access and manage bookmarks on X / Twitter