MCP (streamable HTTP) or REST API · Mastodon

A n8n Mastodon bot that asks first

Self-hosters often run n8n and a Mastodon account for the same project, so linking them is natural. A workflow in n8n can turn events such as a new release, a finished status incident, or a weekly digest into a Mastodon draft through SocialHandoff's REST API. Idempotency keys protect against duplicate toots when a workflow retries. The draft sits in the approval inbox; you publish it, not the agent.

Prompt

Every Friday at 16:00, collect the issues closed this week from our Gitea repo, and draft a Mastodon weekly-roundup post: number of issues closed, the 2 most notable by title, and a thank-you line. Send it to the REST API with networks ["mastodon"] and an idempotencyKey of weekly-YYYY-WW.

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. Pick a trigger Start the workflow with the event that should produce a post: an RSS item, a new row, a form submission, or a Schedule Trigger.
  3. Add an HTTP Request node Set it to POST https://app.socialhandoff.com/v1/posts with a Header Auth credential for the key. Send JSON with body, networks set to ["mastodon"], and mode "submit".
  4. Handle the response The response carries the post id and status. Branch on it to log the draft, or wait for the approval.requested and post.published outbound webhooks.

Example draft

Weekly roundup: 23 issues closed this week.

Notable: sync no longer stalls on files over 2 GB, and the settings page finally remembers your sort order.

Thanks to the 7 people who filed reports and the 3 who sent patches. You make this project better every week.

#OpenSource #WeeklyRoundup

Gotchas

  • Publishing uses idempotency keys, so a retried request after a timeout does not produce a duplicate toot.
  • 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.
  • Store the key in an n8n Header Auth credential, not typed into the node, so it does not leak when you export or share the workflow.
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

Should n8n use the REST API or MCP?
Use REST. The HTTP Request node maps cleanly to POST /v1/posts, and the OpenAPI spec at /openapi.json documents every field.
Will a retried n8n run post the same toot twice?
Not if you send an idempotencyKey. A second request with the same key returns the existing post instead of creating a new one.
Can I post to several fediverse accounts at once?
Yes. Connect each Mastodon account, and a single draft can target several. Each target is published and retried on its own.

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