Prompt
Instructions for the social_writer agent: when handed a product update, write one X post under 240 characters that names the feature and the user problem it solves. Call draft_post with networks ['x']. Never call draft_post more than once per handoff. How to do it
- Mint a key Create an X-scoped key with the draft permission for this app.
- Connect the server Create MCPServerStreamableHttp with url https://app.socialhandoff.com/mcp and an Authorization header, and open it with async with before running the agent.
- Attach it to one agent Pass the server in mcp_servers on the social_writer agent only, and add it as a handoff target from your triage agent.
- Run and trace Run the agent with Runner.run. The SDK trace shows the draft_post call and its arguments.
- Approve The draft waits in the inbox as pending until you approve it.
Example draft
Shared inboxes can now assign a thread to a teammate without forwarding it. One click, the owner shows up for everyone, and replies stay in the same conversation.
Gotchas
- The SDK can list MCP tools on every run. Enable tool-list caching on the server object to avoid an extra request each time.
- Handoffs can loop back to the social agent. The instruction to call draft_post once, plus duplicate protection, keeps you from getting two identical drafts.
- X limits: weighted 280 per tweet, links count 23, up to 4 media. Guardrails reject a draft that breaks them and return the reason to the agent.
- Character limit: 280 weighted characters for standard accounts. Most CJK characters and many emoji count as 2. Premium accounts can post longer, but SocialHandoff checks against 280.
- Links: Every URL is wrapped by t.co and counts as 23 characters, whatever its real length.
- Media per post: Up to 4 images, or 1 GIF, or 1 video.
- File sizes: Images up to 5 MB, GIFs up to 15 MB, video up to 512 MB (uploaded in chunks).
Frequently asked questions
Does the agent need the OpenAI hosted MCP tool?
No. MCPServerStreamableHttp connects from your process to the server directly. Hosted MCP tools also work if the server is reachable from the internet.
Can I restrict the agent to X only?
Yes. Scope the key to X in Connections. Calls for other networks are refused.