twitter-automation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTwitter/X Automation via Rube MCP
通过Rube MCP实现Twitter/X自动化
Automate Twitter/X operations through Composio's Twitter toolkit via Rube MCP.
通过Rube MCP,借助Composio的Twitter工具包实现Twitter/X操作自动化。
Prerequisites
前提条件
- Rube MCP must be connected (RUBE_SEARCH_TOOLS available)
- Active Twitter connection via with toolkit
RUBE_MANAGE_CONNECTIONStwitter - Always call first to get current tool schemas
RUBE_SEARCH_TOOLS
- 已连接Rube MCP(可使用RUBE_SEARCH_TOOLS)
- 通过建立了有效的Twitter连接,且工具包为
RUBE_MANAGE_CONNECTIONStwitter - 请始终先调用以获取最新的工具架构
RUBE_SEARCH_TOOLS
Setup
设置步骤
Get Rube MCP: Add as an MCP server in your client configuration. No API keys needed — just add the endpoint and it works.
https://rube.app/mcp- Verify Rube MCP is available by confirming responds
RUBE_SEARCH_TOOLS - Call with toolkit
RUBE_MANAGE_CONNECTIONStwitter - If connection is not ACTIVE, follow the returned auth link to complete Twitter OAuth
- Confirm connection status shows ACTIVE before running any workflows
获取Rube MCP:在客户端配置中添加作为MCP服务器。无需API密钥,只需添加该端点即可使用。
https://rube.app/mcp- 通过确认能正常响应,验证Rube MCP是否可用
RUBE_SEARCH_TOOLS - 调用,指定工具包为
RUBE_MANAGE_CONNECTIONStwitter - 如果连接状态未显示为ACTIVE,请按照返回的授权链接完成Twitter OAuth认证
- 在运行任何工作流之前,确认连接状态为ACTIVE
Core Workflows
核心工作流
1. Create and Manage Posts
1. 创建与管理帖子
When to use: User wants to create, delete, or look up tweets/posts
Tool sequence:
- - Get authenticated user info [Prerequisite]
TWITTER_USER_LOOKUP_ME - /
TWITTER_UPLOAD_MEDIA- Upload media [Optional]TWITTER_UPLOAD_LARGE_MEDIA - - Create a new post [Required]
TWITTER_CREATION_OF_A_POST - - Look up a specific post [Optional]
TWITTER_POST_LOOKUP_BY_POST_ID - - Delete a post [Optional]
TWITTER_POST_DELETE_BY_POST_ID
Key parameters:
- : Post text content (max 280 weighted characters)
text - : Array of media ID strings for attachments
media__media_ids - : Tweet ID to reply to
reply__in_reply_to_tweet_id - : Tweet ID to quote
quote_tweet_id - : Post ID for lookup/delete
id
Pitfalls:
- Post text is limited to 280 weighted characters; some characters count as more than one
- Posting is NOT idempotent; retrying on timeout will create duplicate posts
- Media IDs must be numeric strings, not integers
- UPLOAD_LARGE_MEDIA is for videos/GIFs; UPLOAD_MEDIA for images
- Always call USER_LOOKUP_ME first to get the authenticated user's ID
适用场景:用户需要创建、删除或查询推文/帖子
工具执行顺序:
- - 获取已认证用户信息【前提步骤】
TWITTER_USER_LOOKUP_ME - /
TWITTER_UPLOAD_MEDIA- 上传媒体【可选】TWITTER_UPLOAD_LARGE_MEDIA - - 创建新帖子【必填】
TWITTER_CREATION_OF_A_POST - - 查询特定帖子【可选】
TWITTER_POST_LOOKUP_BY_POST_ID - - 删除帖子【可选】
TWITTER_POST_DELETE_BY_POST_ID
关键参数:
- : 帖子文本内容(最多280个加权字符)
text - : 媒体ID字符串数组(用于附件)
media__media_ids - : 要回复的推文ID
reply__in_reply_to_tweet_id - : 要引用的推文ID
quote_tweet_id - : 用于查询/删除的帖子ID
id
注意事项:
- 帖子文本限制为280个加权字符;部分字符会占用多个字符额度
- 帖子创建不具备幂等性;超时重试会创建重复帖子
- 媒体ID必须是数字字符串,而非整数
- UPLOAD_LARGE_MEDIA适用于视频/GIF;UPLOAD_MEDIA适用于图片
- 请始终先调用USER_LOOKUP_ME获取已认证用户的ID
2. Search Posts
2. 搜索帖子
When to use: User wants to find tweets matching specific criteria
Tool sequence:
- - Search recent tweets (last 7 days) [Required]
TWITTER_RECENT_SEARCH - - Search full archive (Academic access) [Optional]
TWITTER_FULL_ARCHIVE_SEARCH - - Get tweet count matching query [Optional]
TWITTER_RECENT_SEARCH_COUNTS
Key parameters:
- : Search query using Twitter search operators
query - : Results per page (10-100)
max_results - : Pagination token
next_token - /
start_time: ISO 8601 time rangeend_time - : Comma-separated fields to include
tweet__fields - : Related objects to expand
expansions
Pitfalls:
- RECENT_SEARCH covers only the last 7 days; use FULL_ARCHIVE_SEARCH for older tweets
- FULL_ARCHIVE_SEARCH requires Academic Research or Enterprise access
- Query operators: ,
from:username,to:username,is:retweet,has:media-is:retweet - Empty results return with no
meta.result_count: 0fielddata - Rate limits vary by endpoint and access level; check response headers
适用场景:用户需要查找符合特定条件的推文
工具执行顺序:
- - 搜索近期推文(过去7天)【必填】
TWITTER_RECENT_SEARCH - - 搜索完整归档内容(需学术访问权限)【可选】
TWITTER_FULL_ARCHIVE_SEARCH - - 获取匹配查询条件的推文数量【可选】
TWITTER_RECENT_SEARCH_COUNTS
关键参数:
- : 使用Twitter搜索运算符的查询语句
query - : 每页结果数量(10-100)
max_results - : 分页令牌
next_token - /
start_time: ISO 8601格式的时间范围end_time - : 要包含的字段(逗号分隔)
tweet__fields - : 要展开的关联对象
expansions
注意事项:
- RECENT_SEARCH仅覆盖过去7天的内容;如需查找更早的推文,请使用FULL_ARCHIVE_SEARCH
- FULL_ARCHIVE_SEARCH需要学术研究或企业访问权限
- 查询运算符示例:、
from:username、to:username、is:retweet、has:media-is:retweet - 无结果时会返回,且不包含
meta.result_count: 0字段data - 速率限制因端点和访问级别而异;请检查响应头信息
3. Look Up Users
3. 查询用户信息
When to use: User wants to find or inspect Twitter user profiles
Tool sequence:
- - Get authenticated user [Optional]
TWITTER_USER_LOOKUP_ME - - Look up by username [Optional]
TWITTER_USER_LOOKUP_BY_USERNAME - - Look up by user ID [Optional]
TWITTER_USER_LOOKUP_BY_ID - - Batch look up multiple users [Optional]
TWITTER_USER_LOOKUP_BY_IDS
Key parameters:
- : Twitter handle without @ prefix
username - : Numeric user ID string
id - : Comma-separated user IDs for batch lookup
ids - : Fields to return (description, public_metrics, etc.)
user__fields
Pitfalls:
- Usernames are case-insensitive but must not include the @ prefix
- User IDs are numeric strings, not integers
- Suspended or deleted accounts return errors, not empty results
- LOOKUP_BY_IDS accepts max 100 IDs per request
适用场景:用户需要查找或查看Twitter用户资料
工具执行顺序:
- - 获取已认证用户信息【可选】
TWITTER_USER_LOOKUP_ME - - 通过用户名查询用户【可选】
TWITTER_USER_LOOKUP_BY_USERNAME - - 通过用户ID查询用户【可选】
TWITTER_USER_LOOKUP_BY_ID - - 批量查询多个用户【可选】
TWITTER_USER_LOOKUP_BY_IDS
关键参数:
- : 不带@前缀的Twitter用户名
username - : 数字用户ID字符串
id - : 批量查询的用户ID(逗号分隔)
ids - : 要返回的字段(简介、公开数据指标等)
user__fields
注意事项:
- 用户名不区分大小写,但不能包含@前缀
- 用户ID是数字字符串,而非整数
- 已暂停或已删除的账户会返回错误,而非空结果
- LOOKUP_BY_IDS每次请求最多支持100个ID
4. Manage Bookmarks
4. 管理书签
When to use: User wants to save, view, or remove bookmarked tweets
Tool sequence:
- - Get authenticated user ID [Prerequisite]
TWITTER_USER_LOOKUP_ME - - List bookmarked posts [Required]
TWITTER_BOOKMARKS_BY_USER - - Bookmark a post [Optional]
TWITTER_ADD_POST_TO_BOOKMARKS - - Remove bookmark [Optional]
TWITTER_REMOVE_A_BOOKMARKED_POST
Key parameters:
- : User ID (from USER_LOOKUP_ME) for listing bookmarks
id - : Tweet ID to bookmark or unbookmark
tweet_id - : Results per page
max_results - : Token for next page
pagination_token
Pitfalls:
- Bookmarks require the authenticated user's ID, not username
- Bookmarks are private; only the authenticated user can see their own
- Pagination uses , not
pagination_tokennext_token
适用场景:用户需要保存、查看或移除已收藏的推文
工具执行顺序:
- - 获取已认证用户ID【前提步骤】
TWITTER_USER_LOOKUP_ME - - 列出已收藏的帖子【必填】
TWITTER_BOOKMARKS_BY_USER - - 收藏帖子【可选】
TWITTER_ADD_POST_TO_BOOKMARKS - - 移除收藏【可选】
TWITTER_REMOVE_A_BOOKMARKED_POST
关键参数:
- : 用于列出书签的用户ID(来自USER_LOOKUP_ME)
id - : 要收藏或取消收藏的推文ID
tweet_id - : 每页结果数量
max_results - : 下一页的分页令牌
pagination_token
注意事项:
- 书签操作需要已认证用户的ID,而非用户名
- 书签是私有的;只有已认证用户能查看自己的书签
- 分页使用,而非
pagination_tokennext_token
5. Manage Lists
5. 管理列表
When to use: User wants to view or manage Twitter lists
Tool sequence:
- - Get authenticated user ID [Prerequisite]
TWITTER_USER_LOOKUP_ME - - List owned lists [Optional]
TWITTER_GET_A_USER_S_OWNED_LISTS - - List memberships [Optional]
TWITTER_GET_A_USER_S_LIST_MEMBERSHIPS - - Get pinned lists [Optional]
TWITTER_GET_A_USER_S_PINNED_LISTS - - Get followed lists [Optional]
TWITTER_GET_USER_S_FOLLOWED_LISTS - - Get list details [Optional]
TWITTER_LIST_LOOKUP_BY_LIST_ID
Key parameters:
- : User ID for listing owned/member/followed lists
id - : List ID for specific list lookup
list_id - : Results per page (1-100)
max_results
Pitfalls:
- List IDs and User IDs are numeric strings
- Lists endpoints require the user's numeric ID, not username
适用场景:用户需要查看或管理Twitter列表
工具执行顺序:
- - 获取已认证用户ID【前提步骤】
TWITTER_USER_LOOKUP_ME - - 列出用户拥有的列表【可选】
TWITTER_GET_A_USER_S_OWNED_LISTS - - 列出用户加入的列表【可选】
TWITTER_GET_A_USER_S_LIST_MEMBERSHIPS - - 获取用户置顶的列表【可选】
TWITTER_GET_A_USER_S_PINNED_LISTS - - 获取用户关注的列表【可选】
TWITTER_GET_USER_S_FOLLOWED_LISTS - - 获取列表详情【可选】
TWITTER_LIST_LOOKUP_BY_LIST_ID
关键参数:
- : 用于列出拥有/加入/关注列表的用户ID
id - : 用于查询特定列表的列表ID
list_id - : 每页结果数量(1-100)
max_results
注意事项:
- 列表ID和用户ID均为数字字符串
- 列表相关端点需要用户的数字ID,而非用户名
6. Interact with Posts
6. 与帖子互动
When to use: User wants to like, unlike, or view liked posts
Tool sequence:
- - Get authenticated user ID [Prerequisite]
TWITTER_USER_LOOKUP_ME - - Get liked posts [Optional]
TWITTER_RETURNS_POST_OBJECTS_LIKED_BY_THE_PROVIDED_USER_ID - - Unlike a post [Optional]
TWITTER_UNLIKE_POST
Key parameters:
- : User ID for listing liked posts
id - : Tweet ID to unlike
tweet_id
Pitfalls:
- Like/unlike endpoints require user ID from USER_LOOKUP_ME
- Liked posts pagination may be slow for users with many likes
适用场景:用户需要点赞、取消点赞或查看已点赞的帖子
工具执行顺序:
- - 获取已认证用户ID【前提步骤】
TWITTER_USER_LOOKUP_ME - - 获取用户已点赞的帖子【可选】
TWITTER_RETURNS_POST_OBJECTS_LIKED_BY_THE_PROVIDED_USER_ID - - 取消点赞帖子【可选】
TWITTER_UNLIKE_POST
关键参数:
- : 用于列出已点赞帖子的用户ID
id - : 要取消点赞的推文ID
tweet_id
注意事项:
- 点赞/取消点赞端点需要来自USER_LOOKUP_ME的用户ID
- 对于点赞帖子较多的用户,分页加载可能较慢
Common Patterns
通用模式
Search Query Syntax
搜索查询语法
Operators:
- - Posts by user
from:username - - Replies to user
to:username - - Mentions user
@username - - Contains hashtag
#hashtag - - Exact match
"exact phrase" - - Contains media
has:media - - Contains links
has:links - /
is:retweet- Include/exclude retweets-is:retweet - /
is:reply- Include/exclude replies-is:reply - - Language filter
lang:en
Combinators:
- Space for AND
- for either condition
OR - prefix for NOT
- - Parentheses for grouping
运算符:
- - 来自指定用户的帖子
from:username - - 回复指定用户的帖子
to:username - - 提及指定用户的帖子
@username - - 包含指定话题标签的帖子
#hashtag - - 完全匹配短语
"exact phrase" - - 包含媒体的帖子
has:media - - 包含链接的帖子
has:links - /
is:retweet- 包含/排除转发-is:retweet - /
is:reply- 包含/排除回复-is:reply - - 语言过滤(英文)
lang:en
组合符:
- 空格表示逻辑与(AND)
- 表示逻辑或(任一条件满足)
OR - 前缀表示逻辑非(NOT)
- - 括号用于分组
Media Upload Flow
媒体上传流程
1. Upload media with TWITTER_UPLOAD_MEDIA (images) or TWITTER_UPLOAD_LARGE_MEDIA (video/GIF)
2. Get media_id from response
3. Pass media_id as string in media__media_ids array to TWITTER_CREATION_OF_A_POST1. 使用TWITTER_UPLOAD_MEDIA(图片)或TWITTER_UPLOAD_LARGE_MEDIA(视频/GIF)上传媒体
2. 从响应中获取media_id
3. 将media_id作为字符串传入TWITTER_CREATION_OF_A_POST的media__media_ids数组中Known Pitfalls
已知注意事项
Character Limits:
- Standard posts: 280 weighted characters
- Some Unicode characters count as more than 1
- URLs are shortened and count as fixed length (23 characters)
Rate Limits:
- Vary significantly by access tier (Free, Basic, Pro, Enterprise)
- Free tier: very limited (e.g., 1,500 posts/month)
- Check header in responses
x-rate-limit-remaining
Idempotency:
- Post creation is NOT idempotent; duplicate posts will be created on retry
- Implement deduplication logic for automated posting
字符限制:
- 标准帖子:280个加权字符
- 部分Unicode字符会占用多个字符额度
- URL会被缩短,且固定占用23个字符额度
速率限制:
- 不同访问层级(免费版、基础版、专业版、企业版)的限制差异显著
- 免费版限制非常严格(例如:每月最多发布1500条帖子)
- 请检查响应头中的字段
x-rate-limit-remaining
幂等性:
- 帖子创建不具备幂等性;重试会创建重复帖子
- 对于自动化发帖,请实现去重逻辑
Quick Reference
快速参考
| Task | Tool Slug | Key Params |
|---|---|---|
| Create post | TWITTER_CREATION_OF_A_POST | text |
| Delete post | TWITTER_POST_DELETE_BY_POST_ID | id |
| Look up post | TWITTER_POST_LOOKUP_BY_POST_ID | id |
| Recent search | TWITTER_RECENT_SEARCH | query |
| Archive search | TWITTER_FULL_ARCHIVE_SEARCH | query |
| Search counts | TWITTER_RECENT_SEARCH_COUNTS | query |
| My profile | TWITTER_USER_LOOKUP_ME | (none) |
| User by name | TWITTER_USER_LOOKUP_BY_USERNAME | username |
| User by ID | TWITTER_USER_LOOKUP_BY_ID | id |
| Users by IDs | TWITTER_USER_LOOKUP_BY_IDS | ids |
| Upload media | TWITTER_UPLOAD_MEDIA | media |
| Upload video | TWITTER_UPLOAD_LARGE_MEDIA | media |
| List bookmarks | TWITTER_BOOKMARKS_BY_USER | id |
| Add bookmark | TWITTER_ADD_POST_TO_BOOKMARKS | tweet_id |
| Remove bookmark | TWITTER_REMOVE_A_BOOKMARKED_POST | tweet_id |
| Unlike post | TWITTER_UNLIKE_POST | tweet_id |
| Liked posts | TWITTER_RETURNS_POST_OBJECTS_LIKED_BY_THE_PROVIDED_USER_ID | id |
| Owned lists | TWITTER_GET_A_USER_S_OWNED_LISTS | id |
| List memberships | TWITTER_GET_A_USER_S_LIST_MEMBERSHIPS | id |
| Pinned lists | TWITTER_GET_A_USER_S_PINNED_LISTS | id |
| Followed lists | TWITTER_GET_USER_S_FOLLOWED_LISTS | id |
| List details | TWITTER_LIST_LOOKUP_BY_LIST_ID | list_id |
| 任务 | 工具标识 | 关键参数 |
|---|---|---|
| 创建帖子 | TWITTER_CREATION_OF_A_POST | text |
| 删除帖子 | TWITTER_POST_DELETE_BY_POST_ID | id |
| 查询帖子 | TWITTER_POST_LOOKUP_BY_POST_ID | id |
| 近期搜索 | TWITTER_RECENT_SEARCH | query |
| 归档搜索 | TWITTER_FULL_ARCHIVE_SEARCH | query |
| 搜索计数 | TWITTER_RECENT_SEARCH_COUNTS | query |
| 我的资料 | TWITTER_USER_LOOKUP_ME | 无 |
| 通过用户名查询用户 | TWITTER_USER_LOOKUP_BY_USERNAME | username |
| 通过ID查询用户 | TWITTER_USER_LOOKUP_BY_ID | id |
| 批量查询用户 | TWITTER_USER_LOOKUP_BY_IDS | ids |
| 上传图片 | TWITTER_UPLOAD_MEDIA | media |
| 上传视频 | TWITTER_UPLOAD_LARGE_MEDIA | media |
| 列出书签 | TWITTER_BOOKMARKS_BY_USER | id |
| 添加书签 | TWITTER_ADD_POST_TO_BOOKMARKS | tweet_id |
| 移除书签 | TWITTER_REMOVE_A_BOOKMARKED_POST | tweet_id |
| 取消点赞 | TWITTER_UNLIKE_POST | tweet_id |
| 已点赞帖子 | TWITTER_RETURNS_POST_OBJECTS_LIKED_BY_THE_PROVIDED_USER_ID | id |
| 拥有的列表 | TWITTER_GET_A_USER_S_OWNED_LISTS | id |
| 加入的列表 | TWITTER_GET_A_USER_S_LIST_MEMBERSHIPS | id |
| 置顶的列表 | TWITTER_GET_A_USER_S_PINNED_LISTS | id |
| 关注的列表 | TWITTER_GET_USER_S_FOLLOWED_LISTS | id |
| 列表详情 | TWITTER_LIST_LOOKUP_BY_LIST_ID | list_id |