MCP (streamable HTTP) via MCPServerStreamableHttp · Instagram

Draft Instagram posts with the OpenAI Agents SDK

The OpenAI Agents SDK makes it easy to give an agent both MCP tools and plain Python functions. For Instagram, the MCP tools from SocialHandoff cover it: attach_media stores the image, and draft_post and preview_posts create and check the post. Keep your own functions for reading episode data. The agent writes the caption, uploads the photo with alt text, and creates a draft that waits in the approval inbox. It cannot publish on its own, and it cannot create an Instagram post that has no media.

Prompt

Instructions: You announce new podcast episodes on Instagram. From the episode metadata, upload the cover art with alt text, then create one Instagram draft: guest name, the most surprising point from the summary, and "link in bio". Max 5 hashtags.

How to do it

  1. Connect Instagram and mint a key In https://app.socialhandoff.com, open Connections, connect an Instagram professional account (Business or Creator). Then create an agent key named OpenAI Agents SDK scoped to Instagram with draft and schedule permission.
  2. Load the tools Connect with MCPServerStreamableHttp inside an async with block, pointing at https://app.socialhandoff.com/mcp and sending the key as a bearer header. The agent gets attach_media, draft_post, schedule_post, and preview_posts.
  3. Attach media The agent calls attach_media through the MCP adapter with a public url (or base64 data up to 8 MB) and alt text for the JPEG image, Reel, or carousel (up to 10 items). From plain code, POST https://app.socialhandoff.com/v1/media/import does the same. Pass the ids to draft_post in mediaIds.
  4. Run the agent Run the agent with Runner.run and the episode metadata as input. Inspect the result for the draft id, then open the inbox.

Example draft

Episode 42: Dana Ortiz on why most small shops should raise their prices.

Her most surprising point: customers rarely leave over a 10% increase, but they do leave over slow replies.

Listen now, link in bio.

#podcast #smallbusiness #pricing #entrepreneur #retail

[Image: episode cover art JPEG, alt text: "Podcast cover with a portrait of Dana Ortiz"]

Gotchas

  • Images must be JPEG (up to 8 MB). A PNG screenshot is not accepted, so convert it before upload.
  • The SDK caches nothing about approvals. If a run retries, send the same idempotencyKey so you get the same draft back.
  • Captions allow 2,200 characters, 30 hashtags, and 20 mentions. A thread is joined into one caption, so a 5-part draft becomes one long caption.
Instagram
  • Account type: Professional accounts only (Business or Creator). Personal accounts cannot publish through the API.
  • Media: Every post needs an image or video. Text-only posts are not possible on Instagram.
  • Image files: JPEG only, up to 8 MB. Convert PNG or WebP before posting.
  • Reels: Video posts publish as Reels, from MP4 or MOV files.
Schedule Instagram posts and Reels your agents draft

Frequently asked questions

Does it work with a personal Instagram account?
No. Instagram only allows publishing through its API for professional accounts, Business or Creator. Switching is free in the Instagram app settings.
Do I need the hosted MCP tool?
No. MCPServerStreamableHttp connects from your own process, so the key stays in your environment.
Can I post Reels?
Yes. Attach an MP4 or MOV video and it publishes as a Reel with your caption.

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