twitter-automation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Twitter/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
    RUBE_MANAGE_CONNECTIONS
    with toolkit
    twitter
  • Always call
    RUBE_SEARCH_TOOLS
    first to get current tool schemas
  • 已连接Rube MCP(可使用RUBE_SEARCH_TOOLS)
  • 通过
    RUBE_MANAGE_CONNECTIONS
    建立了有效的Twitter连接,且工具包为
    twitter
  • 请始终先调用
    RUBE_SEARCH_TOOLS
    以获取最新的工具架构

Setup

设置步骤

Get Rube MCP: Add
https://rube.app/mcp
as an MCP server in your client configuration. No API keys needed — just add the endpoint and it works.
  1. Verify Rube MCP is available by confirming
    RUBE_SEARCH_TOOLS
    responds
  2. Call
    RUBE_MANAGE_CONNECTIONS
    with toolkit
    twitter
  3. If connection is not ACTIVE, follow the returned auth link to complete Twitter OAuth
  4. Confirm connection status shows ACTIVE before running any workflows
获取Rube MCP:在客户端配置中添加
https://rube.app/mcp
作为MCP服务器。无需API密钥,只需添加该端点即可使用。
  1. 通过确认
    RUBE_SEARCH_TOOLS
    能正常响应,验证Rube MCP是否可用
  2. 调用
    RUBE_MANAGE_CONNECTIONS
    ,指定工具包为
    twitter
  3. 如果连接状态未显示为ACTIVE,请按照返回的授权链接完成Twitter OAuth认证
  4. 在运行任何工作流之前,确认连接状态为ACTIVE

Core Workflows

核心工作流

1. Create and Manage Posts

1. 创建与管理帖子

When to use: User wants to create, delete, or look up tweets/posts
Tool sequence:
  1. TWITTER_USER_LOOKUP_ME
    - Get authenticated user info [Prerequisite]
  2. TWITTER_UPLOAD_MEDIA
    /
    TWITTER_UPLOAD_LARGE_MEDIA
    - Upload media [Optional]
  3. TWITTER_CREATION_OF_A_POST
    - Create a new post [Required]
  4. TWITTER_POST_LOOKUP_BY_POST_ID
    - Look up a specific post [Optional]
  5. TWITTER_POST_DELETE_BY_POST_ID
    - Delete a post [Optional]
Key parameters:
  • text
    : Post text content (max 280 weighted characters)
  • media__media_ids
    : Array of media ID strings for attachments
  • reply__in_reply_to_tweet_id
    : Tweet ID to reply to
  • quote_tweet_id
    : Tweet ID to quote
  • id
    : Post ID for lookup/delete
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
适用场景:用户需要创建、删除或查询推文/帖子
工具执行顺序:
  1. TWITTER_USER_LOOKUP_ME
    - 获取已认证用户信息【前提步骤】
  2. TWITTER_UPLOAD_MEDIA
    /
    TWITTER_UPLOAD_LARGE_MEDIA
    - 上传媒体【可选】
  3. TWITTER_CREATION_OF_A_POST
    - 创建新帖子【必填】
  4. TWITTER_POST_LOOKUP_BY_POST_ID
    - 查询特定帖子【可选】
  5. TWITTER_POST_DELETE_BY_POST_ID
    - 删除帖子【可选】
关键参数:
  • text
    : 帖子文本内容(最多280个加权字符)
  • media__media_ids
    : 媒体ID字符串数组(用于附件)
  • reply__in_reply_to_tweet_id
    : 要回复的推文ID
  • quote_tweet_id
    : 要引用的推文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:
  1. TWITTER_RECENT_SEARCH
    - Search recent tweets (last 7 days) [Required]
  2. TWITTER_FULL_ARCHIVE_SEARCH
    - Search full archive (Academic access) [Optional]
  3. TWITTER_RECENT_SEARCH_COUNTS
    - Get tweet count matching query [Optional]
Key parameters:
  • query
    : Search query using Twitter search operators
  • max_results
    : Results per page (10-100)
  • next_token
    : Pagination token
  • start_time
    /
    end_time
    : ISO 8601 time range
  • tweet__fields
    : Comma-separated fields to include
  • expansions
    : Related objects to expand
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
    meta.result_count: 0
    with no
    data
    field
  • Rate limits vary by endpoint and access level; check response headers
适用场景:用户需要查找符合特定条件的推文
工具执行顺序:
  1. TWITTER_RECENT_SEARCH
    - 搜索近期推文(过去7天)【必填】
  2. TWITTER_FULL_ARCHIVE_SEARCH
    - 搜索完整归档内容(需学术访问权限)【可选】
  3. TWITTER_RECENT_SEARCH_COUNTS
    - 获取匹配查询条件的推文数量【可选】
关键参数:
  • query
    : 使用Twitter搜索运算符的查询语句
  • max_results
    : 每页结果数量(10-100)
  • next_token
    : 分页令牌
  • start_time
    /
    end_time
    : ISO 8601格式的时间范围
  • 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:
  1. TWITTER_USER_LOOKUP_ME
    - Get authenticated user [Optional]
  2. TWITTER_USER_LOOKUP_BY_USERNAME
    - Look up by username [Optional]
  3. TWITTER_USER_LOOKUP_BY_ID
    - Look up by user ID [Optional]
  4. TWITTER_USER_LOOKUP_BY_IDS
    - Batch look up multiple users [Optional]
Key parameters:
  • username
    : Twitter handle without @ prefix
  • id
    : Numeric user ID string
  • ids
    : Comma-separated user IDs for batch lookup
  • user__fields
    : Fields to return (description, public_metrics, etc.)
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用户资料
工具执行顺序:
  1. TWITTER_USER_LOOKUP_ME
    - 获取已认证用户信息【可选】
  2. TWITTER_USER_LOOKUP_BY_USERNAME
    - 通过用户名查询用户【可选】
  3. TWITTER_USER_LOOKUP_BY_ID
    - 通过用户ID查询用户【可选】
  4. TWITTER_USER_LOOKUP_BY_IDS
    - 批量查询多个用户【可选】
关键参数:
  • username
    : 不带@前缀的Twitter用户名
  • id
    : 数字用户ID字符串
  • ids
    : 批量查询的用户ID(逗号分隔)
  • 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:
  1. TWITTER_USER_LOOKUP_ME
    - Get authenticated user ID [Prerequisite]
  2. TWITTER_BOOKMARKS_BY_USER
    - List bookmarked posts [Required]
  3. TWITTER_ADD_POST_TO_BOOKMARKS
    - Bookmark a post [Optional]
  4. TWITTER_REMOVE_A_BOOKMARKED_POST
    - Remove bookmark [Optional]
Key parameters:
  • id
    : User ID (from USER_LOOKUP_ME) for listing bookmarks
  • tweet_id
    : Tweet ID to bookmark or unbookmark
  • max_results
    : Results per page
  • pagination_token
    : Token for next page
Pitfalls:
  • Bookmarks require the authenticated user's ID, not username
  • Bookmarks are private; only the authenticated user can see their own
  • Pagination uses
    pagination_token
    , not
    next_token
适用场景:用户需要保存、查看或移除已收藏的推文
工具执行顺序:
  1. TWITTER_USER_LOOKUP_ME
    - 获取已认证用户ID【前提步骤】
  2. TWITTER_BOOKMARKS_BY_USER
    - 列出已收藏的帖子【必填】
  3. TWITTER_ADD_POST_TO_BOOKMARKS
    - 收藏帖子【可选】
  4. TWITTER_REMOVE_A_BOOKMARKED_POST
    - 移除收藏【可选】
关键参数:
  • id
    : 用于列出书签的用户ID(来自USER_LOOKUP_ME)
  • tweet_id
    : 要收藏或取消收藏的推文ID
  • max_results
    : 每页结果数量
  • pagination_token
    : 下一页的分页令牌
注意事项:
  • 书签操作需要已认证用户的ID,而非用户名
  • 书签是私有的;只有已认证用户能查看自己的书签
  • 分页使用
    pagination_token
    ,而非
    next_token

5. Manage Lists

5. 管理列表

When to use: User wants to view or manage Twitter lists
Tool sequence:
  1. TWITTER_USER_LOOKUP_ME
    - Get authenticated user ID [Prerequisite]
  2. TWITTER_GET_A_USER_S_OWNED_LISTS
    - List owned lists [Optional]
  3. TWITTER_GET_A_USER_S_LIST_MEMBERSHIPS
    - List memberships [Optional]
  4. TWITTER_GET_A_USER_S_PINNED_LISTS
    - Get pinned lists [Optional]
  5. TWITTER_GET_USER_S_FOLLOWED_LISTS
    - Get followed lists [Optional]
  6. TWITTER_LIST_LOOKUP_BY_LIST_ID
    - Get list details [Optional]
Key parameters:
  • id
    : User ID for listing owned/member/followed lists
  • list_id
    : List ID for specific list lookup
  • max_results
    : Results per page (1-100)
Pitfalls:
  • List IDs and User IDs are numeric strings
  • Lists endpoints require the user's numeric ID, not username
适用场景:用户需要查看或管理Twitter列表
工具执行顺序:
  1. TWITTER_USER_LOOKUP_ME
    - 获取已认证用户ID【前提步骤】
  2. TWITTER_GET_A_USER_S_OWNED_LISTS
    - 列出用户拥有的列表【可选】
  3. TWITTER_GET_A_USER_S_LIST_MEMBERSHIPS
    - 列出用户加入的列表【可选】
  4. TWITTER_GET_A_USER_S_PINNED_LISTS
    - 获取用户置顶的列表【可选】
  5. TWITTER_GET_USER_S_FOLLOWED_LISTS
    - 获取用户关注的列表【可选】
  6. TWITTER_LIST_LOOKUP_BY_LIST_ID
    - 获取列表详情【可选】
关键参数:
  • id
    : 用于列出拥有/加入/关注列表的用户ID
  • list_id
    : 用于查询特定列表的列表ID
  • max_results
    : 每页结果数量(1-100)
注意事项:
  • 列表ID和用户ID均为数字字符串
  • 列表相关端点需要用户的数字ID,而非用户名

6. Interact with Posts

6. 与帖子互动

When to use: User wants to like, unlike, or view liked posts
Tool sequence:
  1. TWITTER_USER_LOOKUP_ME
    - Get authenticated user ID [Prerequisite]
  2. TWITTER_RETURNS_POST_OBJECTS_LIKED_BY_THE_PROVIDED_USER_ID
    - Get liked posts [Optional]
  3. TWITTER_UNLIKE_POST
    - Unlike a post [Optional]
Key parameters:
  • id
    : User ID for listing liked posts
  • tweet_id
    : Tweet ID to unlike
Pitfalls:
  • Like/unlike endpoints require user ID from USER_LOOKUP_ME
  • Liked posts pagination may be slow for users with many likes
适用场景:用户需要点赞、取消点赞或查看已点赞的帖子
工具执行顺序:
  1. TWITTER_USER_LOOKUP_ME
    - 获取已认证用户ID【前提步骤】
  2. TWITTER_RETURNS_POST_OBJECTS_LIKED_BY_THE_PROVIDED_USER_ID
    - 获取用户已点赞的帖子【可选】
  3. TWITTER_UNLIKE_POST
    - 取消点赞帖子【可选】
关键参数:
  • id
    : 用于列出已点赞帖子的用户ID
  • tweet_id
    : 要取消点赞的推文ID
注意事项:
  • 点赞/取消点赞端点需要来自USER_LOOKUP_ME的用户ID
  • 对于点赞帖子较多的用户,分页加载可能较慢

Common Patterns

通用模式

Search Query Syntax

搜索查询语法

Operators:
  • from:username
    - Posts by user
  • to:username
    - Replies to user
  • @username
    - Mentions user
  • #hashtag
    - Contains hashtag
  • "exact phrase"
    - Exact match
  • has:media
    - Contains media
  • has:links
    - Contains links
  • is:retweet
    /
    -is:retweet
    - Include/exclude retweets
  • is:reply
    /
    -is:reply
    - Include/exclude replies
  • lang:en
    - Language filter
Combinators:
  • Space for AND
  • OR
    for either condition
  • -
    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_POST
1. 使用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
    x-rate-limit-remaining
    header in responses
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

快速参考

TaskTool SlugKey Params
Create postTWITTER_CREATION_OF_A_POSTtext
Delete postTWITTER_POST_DELETE_BY_POST_IDid
Look up postTWITTER_POST_LOOKUP_BY_POST_IDid
Recent searchTWITTER_RECENT_SEARCHquery
Archive searchTWITTER_FULL_ARCHIVE_SEARCHquery
Search countsTWITTER_RECENT_SEARCH_COUNTSquery
My profileTWITTER_USER_LOOKUP_ME(none)
User by nameTWITTER_USER_LOOKUP_BY_USERNAMEusername
User by IDTWITTER_USER_LOOKUP_BY_IDid
Users by IDsTWITTER_USER_LOOKUP_BY_IDSids
Upload mediaTWITTER_UPLOAD_MEDIAmedia
Upload videoTWITTER_UPLOAD_LARGE_MEDIAmedia
List bookmarksTWITTER_BOOKMARKS_BY_USERid
Add bookmarkTWITTER_ADD_POST_TO_BOOKMARKStweet_id
Remove bookmarkTWITTER_REMOVE_A_BOOKMARKED_POSTtweet_id
Unlike postTWITTER_UNLIKE_POSTtweet_id
Liked postsTWITTER_RETURNS_POST_OBJECTS_LIKED_BY_THE_PROVIDED_USER_IDid
Owned listsTWITTER_GET_A_USER_S_OWNED_LISTSid
List membershipsTWITTER_GET_A_USER_S_LIST_MEMBERSHIPSid
Pinned listsTWITTER_GET_A_USER_S_PINNED_LISTSid
Followed listsTWITTER_GET_USER_S_FOLLOWED_LISTSid
List detailsTWITTER_LIST_LOOKUP_BY_LIST_IDlist_id
任务工具标识关键参数
创建帖子TWITTER_CREATION_OF_A_POSTtext
删除帖子TWITTER_POST_DELETE_BY_POST_IDid
查询帖子TWITTER_POST_LOOKUP_BY_POST_IDid
近期搜索TWITTER_RECENT_SEARCHquery
归档搜索TWITTER_FULL_ARCHIVE_SEARCHquery
搜索计数TWITTER_RECENT_SEARCH_COUNTSquery
我的资料TWITTER_USER_LOOKUP_ME
通过用户名查询用户TWITTER_USER_LOOKUP_BY_USERNAMEusername
通过ID查询用户TWITTER_USER_LOOKUP_BY_IDid
批量查询用户TWITTER_USER_LOOKUP_BY_IDSids
上传图片TWITTER_UPLOAD_MEDIAmedia
上传视频TWITTER_UPLOAD_LARGE_MEDIAmedia
列出书签TWITTER_BOOKMARKS_BY_USERid
添加书签TWITTER_ADD_POST_TO_BOOKMARKStweet_id
移除书签TWITTER_REMOVE_A_BOOKMARKED_POSTtweet_id
取消点赞TWITTER_UNLIKE_POSTtweet_id
已点赞帖子TWITTER_RETURNS_POST_OBJECTS_LIKED_BY_THE_PROVIDED_USER_IDid
拥有的列表TWITTER_GET_A_USER_S_OWNED_LISTSid
加入的列表TWITTER_GET_A_USER_S_LIST_MEMBERSHIPSid
置顶的列表TWITTER_GET_A_USER_S_PINNED_LISTSid
关注的列表TWITTER_GET_USER_S_FOLLOWED_LISTSid
列表详情TWITTER_LIST_LOOKUP_BY_LIST_IDlist_id