跳到内容
Twexapi
简体中文
Esc
导航打开⌘J预览
本页内容

Composio 迁移

将 X/Twitter Agent 工作流从 Composio 风格工具迁移到 Twexapi MCP。

AI Agent已调用打包的 X/Twitter 工具且希望迁移到 Twexapi MCP 时,使用本指南。

前置条件

  • Twexapi API 密钥
  • AI Agent使用的现有 X/Twitter 操作列表
  • 已连接 https://api.twexapi.io/mcp 的 MCP capable 运行时
  • 旧工作流的测试 prompt 与期望输出

MCP 客户端用 x-api-key: YOUR_API_KEY,REST 回退用 Authorization: Bearer YOUR_API_KEY

迁移映射

现有行为 Twexapi MCP 模式
搜索推文 explore(query="advanced search"),再 twexapi_request
读取资料 explore(category="users")explore(category="accounts")
获取粉丝 explore(category="followers")
读取回复或引用 explore(category="engagement")
发帖或回复 使用 read_only: false 目录项并需确认

Agent 指令

Replace packaged X/Twitter tools with Twexapi MCP.
First call explore to find the closest Twexapi endpoint.
Then call twexapi_request with the exact method and relative path returned by explore.
Preserve tweet_id, user_id, route_used, has_more, and next_cursor.
Ask for confirmation before read_only: false actions.

Handoff 契约

下游步骤消费前,每个迁移工具应返回稳定 handoff 对象。

{
  "route_used": "/twitter/advanced_search/page",
  "method": "POST",
  "source_tool": "legacy_twitter_search",
  "has_more": true,
  "next_cursor": "cursor_123",
  "rows": [
    {
      "tweet_id": "1803006263529541838",
      "author_username": "openai",
      "text": "Example tweet text",
      "created_at": "2026-07-02T10:00:00Z",
      "public_url": "https://x.com/i/web/status/1803006263529541838"
    }
  ]
}

迁移示例

旧任务:

Search Twitter for AI agent launch announcements and summarize the top posts.

Twexapi MCP 任务:

Use Twexapi MCP to search recent X posts about "AI agent launch".
Call explore first and choose the search endpoint.
Return JSON with route_used, tweets[{tweet_id,text,author_username,created_at,public_url}], has_more, next_cursor, and a short summary.

验证清单

  • 迁移前后对比行数。
  • 确认所有下游步骤使用 tweet_id 而非 URL 解析。
  • 确认游标保存在 AI Agent 对话外。
  • 为任何迁移的写操作添加人工审批。

工具调用改写

适配旧Agent 指令时的机械改写:

旧指令 新指令
“Call the Twitter search tool” “Call explore(query=\"advanced search\"), then twexapi_request.”
“Fetch this profile” “Call explore(category=\"users\") and preserve user_id.”
“Continue pagination” “Use the returned next_cursor; do not parse it.”
“Post this tweet” “Prepare a write plan and ask for approval before read_only: false.”

回归 prompt

迁移前后运行:

Find recent posts about "AI agents" from the last 24 hours.
Return exactly 10 rows with tweet_id, author_username, text, created_at, public_url, route_used, has_more, and next_cursor.
Do not call write endpoints.

生产 rollout

  1. 只读任务上新旧工作流并行运行。
  2. 对比行数、必填字段与代表性 URL。
  3. 定时作业切换到 Twexapi MCP/REST 路由。
  4. 审批 prompt 测试通过后再启用写操作。

这个页面有帮助吗?