Blog

Mastodon MCP server: connect an account to Claude and agents

T. Krause ·

A Mastodon MCP server gives an AI client tools to read timelines, search, post and reply on a Mastodon account. Mastodon itself doesn't ship one. Its documentation describes a REST API and OAuth, and no MCP server, as of November 2026. What you connect is a server that calls that API with an access token from your Mastodon server. Community projects on PyPI and GitHub do this on your machine. Prompt TM does it as a hosted MCP URL.

Because every Mastodon server runs the same software, one set of tools works on mastodon.social, on a small community server and on your company's own instance. What changes from server to server is the address, the rules and some limits. This guide covers the token you need, the limits an agent runs into, the 26 Mastodon tools in Prompt TM and how to keep the agent's posts in check. The Mastodon details come from docs.joinmastodon.org and the Mastodon source code as of November 2026.

What an agent needs from your Mastodon server

The server's address. Accounts live on one server, such as mastodon.social or social.example.com, and every API call goes to that server. An account is written @name@server, and the API calls it acct. For an account on the same server, acct is just name, and for one elsewhere it is name@server.

An access token. Mastodon's token docs say tokens "will not expire automatically". A token stays valid until the user deletes it or the app revokes it. Treat it like a password.

The right scopes. Mastodon's scope list has these top-level scopes: profile, read, write, push, follow, admin:read and admin:write. profile, added in 4.3.0, covers only minimal information about the signed-in user. read and write cover reading and writing data, and push covers Web Push subscriptions. The two admin scopes are for the administration and moderation APIs, which nothing in this guide needs. follow is deprecated since Mastodon 3.5.0, and the docs say to request the finer scopes instead. Each top-level scope includes finer ones, such as read:statuses, write:statuses, read:notifications, write:follows and read:search.

Ask for the finer scopes where you can. An agent that summarises mentions needs read:notifications and read:statuses, and nothing that writes.

Create an access token on your server

The quickest way to get a token for your own account is the web interface. Log in to your Mastodon server, open Preferences, then Development, and choose New application. Give it a name, tick the scopes the agent needs and save. The application's page then shows Your access token, and you can regenerate it there later. Mastodon names this page Development in its settings navigation and labels the token Your access token, as its source code shows.

For an app that other people sign in to, register it through the API instead. Mastodon's app guide sends client_name, redirect_uris, scopes and website to POST /api/v1/apps on the server and gets back a client_id and client_secret. Users then sign in through /oauth/authorize on that server. Per the OAuth methods page, the requested scopes must be a subset of the ones registered, and PKCE with S256 works from Mastodon 4.3.0 on.

An app registration belongs to one server. An app registered on mastodon.social knows nothing about other servers, so a product whose users live on many servers has to register an app on each server, or ask each user for a token.

The limits an agent runs into

Rate limits. Mastodon's rate limits page lists 300 calls in 5 minutes per account and per IP address. Deleting statuses has its own limit of 30 in 30 minutes, and so do media uploads. Mastodon's current source code, in config/initializers/rack_attack.rb, counts in more detail. It allows 300 calls in 5 minutes per access token, 1,500 in 5 minutes per account, and 300 in 5 minutes per IP address for calls without a token. Calls that page with max_id, min_id or since_id have their own limit of 300 in 15 minutes per account. A call over a limit answers 429.

Per the docs, answers carry X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset, and where several limits apply, the headers report the one you are closest to. Have the agent read them and wait until the reset time when X-RateLimit-Remaining gets low, instead of counting on fixed numbers.

Per-server settings. The instance endpoint is public and returns the server's rules and limits, such as the maximum characters per status (500 in Mastodon's example) and the maximum media attachments. Have the agent read them before it writes long posts.

Search. Per the search docs, accounts and hashtags are always searchable. Full-text search of statuses needs a search backend on the server and a signed-in request, so on some servers a status search returns nothing. resolve, which fetches remote accounts and statuses the server hasn't seen yet, and offset need a user token with read:search. A search returns at most 40 results per category.

Automated accounts. Mastodon's account entity has a bot flag for accounts that "may perform automated actions". If an agent posts on its own, give it its own account and mark it as automated in the profile settings. Have it read the server's rules, which the instance endpoint returns, before it posts.

Connect Mastodon to Prompt TM

A local community server suits one person on one account. If you build the agent, and your users each bring their own Mastodon account on their own server, your code has to store each user's server and token and send them with every request. It also has to do the same for each other app the agent works in.

Prompt TM serves Mastodon tools at one MCP URL, together with any other toolkits you add. It calls the API of the user's Mastodon server with a token it stores encrypted. The agent calls a tool such as MASTODON_CREATE_STATUS, Prompt TM adds the token, and the token never reaches the agent. The server address must be a public host name such as mastodon.social. Prompt TM refuses IP addresses and internal names, checks that the name doesn't resolve to a private address before each request, and doesn't follow redirects.

The toolkit takes an access token or OAuth through an app you register. Prompt TM has no Mastodon app of its own, because each app belongs to one server.

1. Add an auth config. In the dashboard, open Auth configs, then New, and choose Mastodon with the access token method. Or with the API:

curl -X POST https://www.prompt-tm.com/api/v3/auth_configs \
  -H "x-api-key: $PROMPT_TM_KEY" -H "content-type: application/json" \
  -d '{ "toolkit": { "slug": "mastodon" }, "auth_config": { "auth_scheme": "BEARER_TOKEN" } }'

2. Connect an account. With the token from Development:

curl -X POST https://www.prompt-tm.com/api/v3/connected_accounts \
  -H "x-api-key: $PROMPT_TM_KEY" -H "content-type: application/json" \
  -d '{ "auth_config": { "id": "ac_..." }, "user_id": "me",
        "connection": { "data": { "instance": "mastodon.social", "token": "YOUR_MASTODON_TOKEN" } } }'

Before saving the token, Prompt TM calls /api/v1/accounts/verify_credentials on the server. If the server refuses, the request fails and the account is marked FAILED. A token that only writes fails this check, so give it profile, read:accounts or read as well. For your users, POST /api/v3/connected_accounts/link returns a connect link on prompt-tm.com where they enter their server and token. The link expires after one hour.

3. Create an MCP server. In MCP servers, choose New, then Custom, tick Mastodon, and under Only some tools pick the tools the agent should see. Copy the server URL.

4. Add it to Claude Code.

claude mcp add --transport http prompt-tm-mastodon \
  "https://www.prompt-tm.com/mcp/mcp_...?user_id=me" \
  --header "x-api-key: $PROMPT_TM_KEY"

The user_id in the URL picks whose Mastodon account the calls use. Claude Code MCP server setup covers scopes and fixes on the Claude Code side. Cursor, VS Code, Claude Desktop, claude.ai and the agent SDKs are in the MCP client docs, and the MCP config generator writes the config for your own server.

OAuth for users on one server

If your users all have accounts on the same server, for example your company's instance, register an app there with the redirect URI https://www.prompt-tm.com/api/v3/auth/callback and the scopes read write, which Prompt TM requests by default. Then create the auth config with the app's credentials and pin the server as instance_host:

curl -X POST https://www.prompt-tm.com/api/v3/auth_configs \
  -H "x-api-key: $PROMPT_TM_KEY" -H "content-type: application/json" \
  -d '{ "toolkit": { "slug": "mastodon" },
        "auth_config": { "type": "use_custom_auth", "auth_scheme": "OAUTH2",
          "credentials": { "client_id": "...", "client_secret": "...",
            "instance_host": "social.example.com" } } }'

Users of this auth config can sign in on that server only, and Prompt TM refuses any other server before sending anything to it. The authentication docs explain why. The app's secret must only ever go to the server it was registered on. Prompt TM adds PKCE when the server runs Mastodon 4.3.0 or later. For users spread over many servers, use the token method above.

The 26 Mastodon tools in Prompt TM

The toolkit has 17 tools that only read and 9 that change something.

AreaReadWrite
Account and serverVerify the account, get the instance
AccountsGet an account, look up an account, list an account's statuses, list followers, list the accounts an account follows, get relationshipsFollow an account, unfollow an account
TimelinesHome, public, hashtag and list timelines
StatusesGet a status, get a status's threadPost a status, delete a status, favourite, boost, bookmark
SearchSearch accounts, hashtags and statuses
NotificationsList notifications, get a notificationDismiss a notification, clear all notifications

Five details the agent needs to know:

  • IDs belong to the server. An account or status has a different ID on every server that has seen it. To act on @name@other.server, have the agent look the account up first, or search with resolve, and use the ID that comes back.
  • Retries don't double-post. Mastodon's statuses docs say an Idempotency-Key is stored for up to an hour. Post a status sends one when the agent passes idempotency_key, so a retried call within the hour doesn't post twice. Tell the agent to always pass one.
  • Posts can wait. With scheduled_at at least 5 minutes in the future, the status is scheduled instead of posted, and the answer is the scheduled status.
  • Visibility is explicit. A status can be public, unlisted, private (followers only) or direct. A boost can't be direct. Have the agent set visibility on every post, so a reply to a private conversation doesn't go out as public.
  • No media or polls. The toolkit has no upload tool, and Post a status doesn't take polls. It can attach media that is already on the server through media_ids.

Pages go backwards with max_id, set to the last item's id, and forwards with min_id. Timelines return up to 40 statuses per call and notifications up to 80. Every call with max_id, min_id or since_id counts against the paging limit of 300 in 15 minutes, so ask for the largest limit the tool takes instead of many small pages. The Mastodon toolkit page lists every input. For an endpoint the tools don't cover, such as reading your lists or your saved bookmarks, the proxy endpoint POST /api/v3/tools/execute/proxy sends your request to the account's server with the same token.

Keep the agent's posts in check

Scopes. The server enforces them. A token with only read scopes can't post, follow or delete, whatever the agent tries.

The tool list. A custom MCP server shows only the tools you ticked. To block the rest for every account connected through an auth config, set restrict_to_following_tools on it. Those accounts can then call only the listed tools, and the proxy refuses them with a 403. The router docs have the details.

Approvals. Prompt TM marks two tools as destructive: MASTODON_DELETE_STATUS and MASTODON_CLEAR_NOTIFICATIONS. Posting isn't one of them, and a public post is the call you most likely want a person to see first. Set the MCP server's approvals to Ask a person before any call that changes something to hold all nine tools that write, including posts, boosts and follows. Ask a person before destructive calls holds only the two. A held call returns approval_required: true and does nothing yet. The approval link goes to your webhook and to the dashboard, never to the agent, so the agent can't approve its own call.

The log. Every call appears under Logs with the tool, the user and the result.

The Mastodon toolkit has no trigger yet, so Prompt TM doesn't learn about new mentions on its own. To have an agent answer mentions, start it on a schedule and let it list notifications of type mention with since_id set to the last one it handled. Each check is one paged call, so a check every minute uses 15 of the 300 paged calls allowed per 15 minutes.

Prompt TM is free during early access, with 20,000 tool calls per project per month. To try it, create a free project and connect a token with read scopes only.

Frequently asked questions

Is there an official Mastodon MCP server?

Not as of November 2026. Mastodon's documentation covers the REST API and OAuth, and no MCP server. Community servers on PyPI and GitHub, and hosted platforms such as Prompt TM, call that API with an access token from your Mastodon server.

Which scopes does a Mastodon agent need?

As few as the job allows. Reading mentions needs read:notifications and read:statuses. Posting needs write:statuses. For Prompt TM, add profile or read:accounts, which the connection check needs. Plain read and write cover everything the toolkit does.

Do Mastodon access tokens expire?

No. Mastodon's docs say tokens don't expire on their own. A token stops working when the user deletes it or the app revokes it, so delete the application under Development when you stop using the agent.

Can an agent post to any Mastodon server?

It posts as the account it signed in with, on that account's server. From there, its public posts federate to other servers like any other post. To work as an account on another server, it needs a token from that server.

Cookies and analytics

Prompt TM's own cookies only keep you signed in and remember the project you last opened. Accepting turns on Google Analytics on the public pages, so we can count visits and see which pages get read. It never runs in the dashboard, and it does not load until you choose.

Read the privacy notice