Twitter MCP Server
Twitter/X Data · User Profiles · Tweet Search · Follower Events · KOL Tracking
中文 | 日本語 | 한국어
______________________________________________________________________
快速安装
首先,转到 https://6551.io/mcp 获取您的API代币。
克劳德代码
claude mcp add twitter \
-e TWITTER_TOKEN= \
-- uv --directory /path/to/twitter-mcp run twitter-mcp替换 /path/to/twitter-mcp 使用您当地的项目路径,以及 `` 用你的代币。开爪
export TWITTER_TOKEN=""
cp -r openclaw-skill/opentwitter ~/.openclaw/skills/______________________________________________________________________
让AI为您审查和安装
不确定此MCP是否安全?将下面的提示粘贴到您的AI助手上——它将首先检查源代码,然后在安全的情况下进行安装:
**复制此提示并将其发送给您的AI助手(替换 `
和 ` 实际值):**
Please review and install the twitter-mcp MCP server for me. The project is at
.
Steps:
1. Review these files for security:
- src/twitter_mcp/api_client.py — Confirm it only connects to ai.6551.io, no data sent elsewhere
- src/twitter_mcp/config.py — Confirm token is only read from local config.json or env vars, no hardcoded secrets or leaks
- src/twitter_mcp/tools.py — Confirm all tools only perform API queries, no file writes, command execution, or dangerous operations
- pyproject.toml — Confirm dependencies are only mcp, httpx, no suspicious packages
2. Tell me your conclusion: safe / risky / problematic, with specific reasons
3. If safe, run the install (get Token from https://6551.io/mcp):
claude mcp add twitter -e TWITTER_TOKEN= -- uv --directory
run twitter-mcp______________________________________________________________________
它能做什么?
连接后,只需询问您的AI助手:
| 你说 | 确实如此 |
|---|---|
| “显示@elonmusk的推特个人资料” | 获取用户个人资料信息 |
| “@VitalikButerin最近发了什么推文” | 获取用户最近的推文 |
| “搜索与比特币相关的推文” | 关键字搜索 |
| “查找带有#crypto标签的推文” | 标签搜索 |
| “关于ETH的热门推文有1000+个赞” | 使用参与度过滤器搜索 |
| “使用关注者跟踪功能监视@elonmusk” | 使用选项将用户添加到观察列表 |
| “谁引用了这条推文” | 获取推文的引用推文 |
| “谁转发了这条推文” | 获取转发推文的用户 |
| “最近谁关注了@elonmusk” | 获取新的关注者事件 |
| “谁取消了@elonmusk的关注” | 获取取消关注者事件 |
| “@elonmusk删除了哪些推文” | 获取已删除的推文 |
| “哪些KOL关注@elonmusk” | 获取KOL关注者 |
______________________________________________________________________
可用工具
| 工具 | 说明 |
|---|---|
get_twitter_user | 按用户名获取用户资料 |
get_twitter_user_by_id | 通过数字ID获取用户配置文件 |
get_twitter_user_tweets | 获取用户最近的推文 |
search_twitter | 使用基本过滤器搜索推文 |
search_twitter_advanced | 具有多个过滤器的高级搜索 |
get_twitter_follower_events | 获取关注者/取消关注者事件 |
get_twitter_deleted_tweets | 获取用户已删除的推文 |
get_twitter_kol_followers | 获得KOL(关键意见领袖)追随者 |
get_twitter_article_by_id | 按ID获取推特文章 |
get_twitter_tweet_by_id | 按ID获取带有嵌套回复/引用推文的推文 |
get_twitter_quote_tweets_by_id | 获取引用特定推文的推文 |
get_twitter_retweet_users_by_id | 获取转发特定推文的用户 |
get_twitter_watch | 获取所有Twitter监控用户 |
add_twitter_watch | 将Twitter用户添加到监控列表(带事件类型选项) |
delete_twitter_watch | 从监控列表中删除推特用户 |
______________________________________________________________________
配置
获取API令牌
首选 https://6551.io/mcp 获取您的API代币。
设置环境变量:
# macOS / Linux
export TWITTER_TOKEN=""
# Windows PowerShell
$env:TWITTER_TOKEN = ""| 变量 | 必填 | 描述 |
|---|---|---|
TWITTER_TOKEN | 是 | 6551 API承载令牌(从https://6551.io/mcp) |
TWITTER_API_BASE | 否 | 覆盖REST API URL |
TWITTER_MAX_ROWS | 否 | 每次查询的最大结果数(默认值:100) |
还支持 config.json 在项目根目录中(环境变量优先):
{
"api_base_url": "https://ai.6551.io",
"api_token": "",
"max_rows": 100
}______________________________________________________________________
WebSocket实时订阅
端点: wss://ai.6551.io/open/twitter_wss?token=YOUR_TOKEN
从您监控的推特帐户订阅实时事件。
订阅推特活动
{
"jsonrpc": "2.0",
"id": 1,
"method": "twitter.subscribe"
}回应:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"success": true
}
}退订
{
"jsonrpc": "2.0",
"id": 2,
"method": "twitter.unsubscribe"
}服务器推送-推特事件
当被监控的帐户有活动时,服务器会推送:
{
"jsonrpc": "2.0",
"method": "twitter.event",
"params": {
"id": 123456,
"twAccount": "elonmusk",
"twUserName": "Elon Musk",
"profileUrl": "https://twitter.com/elonmusk",
"eventType": "NEW_TWEET",
"content": "...",
"ca": "0x1234...",
"remark": "Custom note",
"createdAt": "2026-03-06T10:00:00Z"
}
}备注:The content 字段结构因事件类型而异(见下文)。
**Event Types and Content Structure**:
#### Tweet Events
- `NEW_TWEET` - New tweet posted
- `NEW_TWEET_REPLY` - New reply tweet
- `NEW_TWEET_QUOTE` - New quote tweet
- `NEW_RETWEET` - Retweeted
- `CA` - Tweet with CA address
Content structure for tweet events:{ "id": "1234567890", "text": "Tweet content...", "createdAt": "2026-03-06T10:00:00Z", "language": "en", "retweetCount": 100, "favoriteCount": 500, "replyCount": 20, "quoteCount": 10, "viewCount": 10000, "userScreenName": "elonmusk", "userName": "Elon Musk", "userIdStr": "44196397", "userFollowers": 170000000, "userVerified": true, "conversationId": "1234567890", "isReply": false, "isQuote": false, "hashtags": ["crypto", "bitcoin"], "media": [ { "type": "photo", "url": "https://...", "thumbUrl": "https://..." } ], "urls": [ { "url": "https://...", "expandedUrl": "https://...", "displayUrl": "example.com" } ], "mentions": [ { "username": "VitalikButerin", "name": "Vitalik Buterin" } ] }
#### 关注者活动
- `NEW_FOLLOWER` -新追随者
- `NEW_UNFOLLOWER` -取消关注事件
关注者事件的内容结构(数组):
[ { "id": 123, "twId": 44196397, "twAccount": "elonmusk", "twUserName": "Elon Musk", "twUserLabel": "Verified", "description": "User bio...", "profileUrl": "https://...", "bannerUrl": "https://...", "followerCount": 170000000, "friendCount": 500, "createdAt": "2026-03-06T10:00:00Z" } ]
#### 个人资料更新事件
- `UPDATE_NAME` -用户名已更改(内容:新名称字符串)
- `UPDATE_DESCRIPTION` -生物更新(内容:新描述字符串)
- `UPDATE_AVATAR` -个人资料图片已更改(内容:新头像URL字符串)
- `UPDATE_BANNER` -横幅图像已更改(内容:新的横幅URL字符串)
#### 其他事件
- `TWEET_TOPPING` -推特已固定
- `DELETE` -推特已删除
- `SYSTEM` -系统事件
- `TRANSLATE` -推特翻译
- `CA_CREATE` -CA令牌已创建
______________________________________________________________________
## 数据结构
### 推特用户
{ "userId": "44196397", "screenName": "elonmusk", "name": "Elon Musk", "description": "...", "followersCount": 170000000, "friendsCount": 500, "statusesCount": 30000, "verified": true }
### 推文
{ "id": "1234567890", "text": "Tweet content...", "createdAt": "2024-02-20T12:00:00Z", "retweetCount": 1000, "favoriteCount": 5000, "replyCount": 200, "userScreenName": "elonmusk", "hashtags": ["crypto", "bitcoin"], "urls": [{"url": "https://..."}] }
______________________________________________________________________
Other Clients — Manual Install (click to expand)
> 在以下所有配置中,更换 `/path/to/twitter-mcp` 使用您的实际本地项目路径,以及 `` 使用您的令牌 [https://6551.io/mcp](https://6551.io/mcp).
### 克劳德桌面版
编辑配置(macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`,Windows: `%APPDATA%\Claude\claude_desktop_config.json`):
{ "mcpServers": { "twitter": { "command": "uv", "args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"], "env": { "TWITTER_TOKEN": "" } } } }
### 光标
`~/.cursor/mcp.json` 或设置>MCP服务器:
{ "mcpServers": { "twitter": { "command": "uv", "args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"], "env": { "TWITTER_TOKEN": "" } } } }
### 帆板运动
`~/.codeium/windsurf/mcp_config.json`:
{ "mcpServers": { "twitter": { "command": "uv", "args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"], "env": { "TWITTER_TOKEN": "" } } } }
### 克莱恩
VS代码侧栏>临床>MCP服务器>配置、编辑 `cline_mcp_settings.json`:
{ "mcpServers": { "twitter": { "command": "uv", "args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"], "env": { "TWITTER_TOKEN": "" }, "disabled": false, "autoApprove": [] } } }
### Continue.dev
`~/.continue/config.yaml`:
mcpServers: - name: twitter command: uv args: - --directory - /path/to/twitter-mcp - run - twitter-mcp env: TWITTER_TOKEN:
### 樱桃工作室
设置>MCP服务器>添加>键入stdio:命令 `uv`,Args `--directory /path/to/twitter-mcp run twitter-mcp`,Env `TWITTER_TOKEN`.
### 泽德编辑器
`~/.config/zed/settings.json`:
{ "context_servers": { "twitter": { "command": { "path": "uv", "args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"], "env": { "TWITTER_TOKEN": "" } } } } }
### 任何stdio MCP客户端
TWITTER_TOKEN= \ uv --directory /path/to/twitter-mcp run twitter-mcp
______________________________________________________________________
## 兼容性
|客户端|安装方法|状态|
|--------|---------------|--------|
| **克劳德代码** | `claude mcp add` |一个衬垫|
| **开爪** |复制技能目录|单行|
|Claude桌面| JSON配置|支持|
|游标|JSON配置|支持|
|Windsurf | JSON配置|支持|
|Cline|JSON配置|支持|
|Continue.dev | YAML/JSON |支持|
|Cherry Studio |图形用户界面|支持|
|Zed | JSON配置|支持|
______________________________________________________________________
## 发展
cd /path/to/twitter-mcp uv sync uv run twitter-mcp
MCP Inspector
npx @modelcontextprotocol/inspector uv --directory /path/to/twitter-mcp run twitter-mcp
### 项目结构
├── README.md ├── docs/ │ ├── README_JA.md # 日本語 │ └── README_KO.md # 한국어 ├── openclaw-skill/opentwitter/ # OpenClaw Skill ├── pyproject.toml ├── config.json └── src/twitter_mcp/ ├── server.py # Entry point ├── app.py # FastMCP instance ├── config.py # Config loader ├── api_client.py # HTTP client └── tools.py # 8 tools
## 许可证
麻省理工学院