MCP (streamable HTTP) via MCPServerStreamableHttp · X

Draft X posts from an OpenAI Agents SDK app

The OpenAI Agents SDK makes it simple to build an agent with handoffs: a triage agent passes work to a specialist. A social specialist that can draft for X is a natural addition, as long as it cannot publish unreviewed. Connect it to SocialHandoff with MCPServerStreamableHttp and it gets draft_post, schedule_post, and preview_posts. The rest of your app never touches X credentials, and every tweet waits in the inbox.

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

  1. Mint a key Create an X-scoped key with the draft permission for this app.
  2. 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.
  3. 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.
  4. Run and trace Run the agent with Runner.run. The SDK trace shows the draft_post call and its arguments.
  5. 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.
X
  • 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).
Schedule tweets and X threads with a human approval step

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.

Let your agents post. Keep the final say.

Connect your first agent in minutes. Every draft waits in your inbox until you approve it.

14 days free. No card required.

The hosted version is opening soon

Leave your email and we will send one message when hosted accounts open, with your 14-day trial ready. Want it today? Self-host it free from the repo.

Start free trial