Prerequisites
- A Twexapi API key
- A list of existing X/Twitter actions used by your agent
- An MCP-capable runtime connected to
https://api.twexapi.io/mcp - A test prompt and expected output from the old workflow
x-api-key: YOUR_API_KEY for MCP clients and Authorization: Bearer YOUR_API_KEY for REST fallbacks.
Migration map
| Existing behavior | Twexapi MCP pattern |
|---|---|
| Search tweets | explore(query="advanced search"), then twexapi_request |
| Read a profile | explore(category="users") or explore(category="accounts") |
| Get followers | explore(category="followers") |
| Read replies or quotes | explore(category="engagement") |
| Post or reply | Use a read_only: false catalog entry and require confirmation |
Agent instruction
Handoff contract
Make every migrated tool return a stable handoff object before downstream steps consume it.Example migration
Old task:Validation checklist
- Compare row counts before and after migration.
- Verify all downstream steps use
tweet_idinstead of URL parsing. - Confirm cursors are stored outside the agent conversation.
- Add human approval for any migrated write action.
Tool call rewrite
Use this mechanical rewrite when adapting old agent instructions.| Old instruction | New instruction |
|---|---|
| ”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.” |
Regression prompt
Run this before and after migration:Production rollout
- Run old and new workflows side by side on read-only tasks.
- Compare row counts, required fields, and representative URLs.
- Switch scheduled jobs to the Twexapi MCP/REST route.
- Re-enable write actions only after approval prompts are tested.