MCP (streamable HTTP) via MCPServerStreamableHttp · Mastodon

A OpenAI Agents SDK Mastodon bot that asks first

With the OpenAI Agents SDK, a triage agent can hand off to a specialist, for example a Mastodon writer that knows fediverse conventions. That writer calls SocialHandoff's draft_post over MCP, and the trace records the handoff and the tool call. Nothing federates until a person approves the toot in the inbox. The draft sits in the approval inbox; you publish it, not the agent.

Prompt

Triage agent hands off to the Mastodon writer when the request mentions the fediverse. Mastodon writer instructions: plain language, content warning for anything over 3 paragraphs, CamelCase hashtags at the end, under 500 characters, call draft_post for mastodon. Request: announce our new public status page.

How to do it

  1. Mint a Mastodon agent key In https://app.socialhandoff.com, open Connections, connect your Mastodon account, then create an agent key scoped to Mastodon with draft permission only. Copy the key when it is shown; only its hash is stored.
  2. Connect the MCP server Create an MCPServerStreamableHttp with url https://app.socialhandoff.com/mcp and an Authorization: Bearer header, and open it with async with.
  3. Attach it to an Agent Pass it in mcp_servers when you build the Agent. Write instructions that name Mastodon, its length limit, and the draft_post tool.
  4. Run and trace Call Runner.run, then read the trace to see each tool call. The post id in the output points at a pending draft in the approval inbox.

Example draft

We now have a public status page: status.example.org

It shows live uptime for the API, the web app, and sync, plus a history of past incidents with write-ups. You can subscribe by email or RSS.

If something looks down and the page says otherwise, please tell us.

#StatusPage #DevOps

Gotchas

  • Read your instance rules on automated posting. Many ask that bot-driven accounts tick the automated account box in profile settings.
  • Use CamelCase hashtags such as #OpenSource so screen readers say them correctly, and a content warning for long logs or spoilers.
  • 500 characters is only the default. Many instances allow more or less, so set the per-network length guardrail to your server's real limit.
  • Do not design a handoff where one agent approves another's draft. Agent keys cannot call approve_post; that step belongs to a person or an owner key.
Mastodon
  • Character limit: 500 characters on a default Mastodon server. Each instance can raise it, so check yours.
  • Links: Every URL counts as 23 characters, however long it is.
  • Media per post: Up to 4 attachments on a default server.
  • File sizes: Images up to 16 MB and video up to about 99 MB on a default install. Instances can set their own limits.
Mastodon scheduler with approval for any instance

Frequently asked questions

Does this work with non-OpenAI models in the SDK?
The MCP server does not care which model calls it. Any model the Agents SDK can drive can call draft_post.
Can a OpenAI Agents SDK agent post to more than one Mastodon account?
Yes. Connect each account, scope the key to Mastodon, and pass accountIds to target one or several. Each target is approved and published separately.
Is posting to Mastodon from an agent good etiquette?
It can be, if the account is labeled as automated where your instance asks for it, posts carry alt text, and a person reviews each post. The approval inbox covers the last part.

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