
mastodon-mcp
io.github.richarvey/mastodon-mcp
Give Claude and other AI assistants a Mastodon account: 95 tools for posting, timelines and search
Documentation
Give your AI assistant a Mastodon account. mastodon-mcp is a Model Context Protocol server that lets Claude, or any other MCP client, read timelines, post, search, manage notifications and curate your profile on any Mastodon instance.
- 95 tools covering the Mastodon client API, up to date with Mastodon 5.0
- Multiple accounts across different instances, side by side
- stdio and streamable HTTP transports
- No API keys to paste: accounts are added through Mastodon's own OAuth flow
- One runtime dependency: the official MCP SDK
You: What have I missed on Mastodon this morning? Skip the boosts.
Claude: (calls mastodon_get_timeline_home with exclude_reblogs)
Here's a summary of the 23 new posts on your home timeline…
You: Reply to the one about the Forgejo release and say thanks.
Claude: (calls mastodon_create_status with in_reply_to_id)
Posted: https://mastodon.social/@you/1155…
Contents
- Quick start
- Connecting to an MCP client
- Adding a Mastodon account
- Things to try
- Using several accounts
- Command-line options
- Tool reference
- Mastodon compatibility
- Security
- Development
- License
Quick start
You need Node.js 22.12 or newer.
The server is published on npm as @ric_/mastodon-mcp. The simplest way to run it is to let your MCP client start it with npx:
npx -y @ric_/mastodon-mcp
Or install it once, which gives you a mastodon-mcp command to use in place of npx -y @ric_/mastodon-mcp:
npm install -g @ric_/mastodon-mcp
Then point your MCP client at it (next section) and ask the assistant to add your Mastodon account.
From source
git clone https://code.squarecows.com/ric/mastodon-mcp.git
cd mastodon-mcp
npm install
npm run build
That produces dist/index.js, which is the server. In the examples below, use node /path/to/mastodon-mcp/dist/index.js in place of npx -y @ric_/mastodon-mcp.
Connecting to an MCP client
Claude Code
claude mcp add mastodon -- npx -y @ric_/mastodon-mcp
Claude Desktop and other stdio clients
Add the server to the client's MCP configuration (for Claude Desktop, claude_desktop_config.json):
{
"mcpServers": {
"mastodon": {
"command": "npx",
"args": ["-y", "@ric_/mastodon-mcp"]
}
}
}
Streamable HTTP
Start the server yourself and connect clients to its /mcp endpoint:
npx -y @ric_/mastodon-mcp --transport http --port 3000
# listening on http://localhost:3000/mcp
claude mcp add --transport http mastodon http://localhost:3000/mcp
The HTTP transport has no authentication of its own. Read Security before exposing it beyond your own machine.
Adding a Mastodon account
Accounts are added from inside the conversation. Ask your assistant something like "add my Mastodon account on mastodon.social" and it will walk through these steps:
mastodon_add_accountregisters the app on your instance and returns an authorization link.- You open the link, log in, approve access, and copy the code Mastodon shows you.
mastodon_complete_authexchanges that code for an access token and stores the account.
After that the account is remembered between sessions. mastodon_list_accounts shows what is configured, and mastodon_remove_account revokes the token and forgets the account.
Don't have an account yet? On Mastodon 5.0+ instances, mastodon_add_account with signup: true sends you to the instance's sign-up page instead of the log-in page. The account can be added straight away, and the server tells you if it is still waiting for e-mail confirmation or moderator approval.
The app requests the read, write, follow and push scopes.
Things to try
- "Summarise my home timeline since yesterday, without boosts or replies."
- "Who mentioned me this week? Group the notifications."
- "Post this photo with alt text describing it, visible to followers only."
- "Quote that post and add my thoughts, but only let followers quote mine."
- "Find people posting about #selfhosting and put the interesting ones in a list."
- "Create a collection called 'Rust folks' with these five accounts."
- "Mute any post that mentions the election for the next 7 days."
- "Update my bio and add my blog to my profile fields."
- "Schedule this announcement for 9am on Monday."
Using several accounts
Every tool that talks to Mastodon accepts an optional account parameter in username@instance form, for example ric@mastodon.social.
- With one account configured, it is used automatically.
- With several, a call without
accountreturns an error listing the available handles, so the assistant can ask you which one you mean rather than guess.
Accounts can live on any Mastodon-compatible instance; nothing is tied to a particular server.
Command-line options
| Option | Default | Description |
|---|---|---|
--transport <stdio|http> | stdio | How clients connect to the server. |
--port <number> | 3000 | Port for the HTTP transport. |
--passphrase <text> | built-in default | Passphrase used to encrypt stored credentials. See Security. |
Tool reference
All 95 tools, grouped by area. Each returns the Mastodon API's JSON response, so entity fields are the ones in the Mastodon API documentation.
Every tool also carries MCP tool annotations: a readable title, and hints saying whether it only reads, whether it deletes or overwrites something, whether repeating it is harmless, and whether it contacts a Mastodon instance. They are listed in src/lib/tool-annotations.ts.
Account management (4): connect and disconnect accounts
| Tool | What it does |
|---|---|
mastodon_add_account | Start the OAuth flow for an instance (signup: true to create a new account, Mastodon 5.0+) |
mastodon_complete_auth | Finish the OAuth flow with the authorization code |
mastodon_list_accounts | List configured accounts |
mastodon_remove_account | Revoke the token and remove an account |
Statuses (16): post, edit, interact, quote
| Tool | What it does |
|---|---|
mastodon_create_status | Post a status: text, media, polls, content warnings, scheduling, replies and quotes |
mastodon_get_status | Get a status by ID |
mastodon_edit_status | Edit a status |
mastodon_delete_status | Delete a status, optionally with its media |
mastodon_get_status_context | Get the thread around a status |
mastodon_boost_status / mastodon_unboost_status | Boost or undo a boost |
mastodon_favourite_status / mastodon_unfavourite_status | Favourite or undo a favourite |
mastodon_bookmark_status / mastodon_unbookmark_status | Bookmark or remove a bookmark |
mastodon_list_scheduled_statuses | List scheduled statuses |
mastodon_cancel_scheduled_status | Cancel a scheduled status |
mastodon_get_status_quotes | List statuses quoting one of yours (4.5+) |
mastodon_revoke_status_quote | Detach someone's quote from your status (4.5+) |
mastodon_set_status_quote_policy | Change who may quote a status (4.5+) |
Timelines (4): read feeds
| Tool | What it does |
|---|---|
mastodon_get_timeline_home | Home timeline, with server-side filters for boosts, replies, quotes and direct posts (5.0+) |
mastodon_get_timeline_public | Local or federated public timeline |
mastodon_get_timeline_hashtag | Posts for a hashtag |
mastodon_get_timeline_list | Posts from a list |
Accounts (13): look people up and manage relationships
| Tool | What it does |
|---|---|
mastodon_get_own_account | The authenticated account, including its state on 5.0+ |
mastodon_get_account | Get an account by ID |
mastodon_lookup_account | Find an account by handle |
mastodon_get_account_statuses | Posts by an account |
mastodon_get_followers / mastodon_get_following | Who follows an account, and who it follows |
mastodon_get_relationships | Your relationship to one or more accounts |
mastodon_follow_account / mastodon_unfollow_account | Follow or unfollow |
mastodon_mute_account / mastodon_unmute_account | Mute or unmute |
mastodon_block_account / mastodon_unblock_account | Block or unblock |
Profile (10): edit your profile and what it features
| Tool | What it does |
|---|---|
mastodon_get_profile | Your profile as raw text, ready for editing (4.6+) |
mastodon_update_profile | Update name, bio, fields, avatar, header and profile settings (4.6+) |
mastodon_delete_profile_avatar / mastodon_delete_profile_header | Remove the avatar or header (4.6+) |
mastodon_get_endorsements | Accounts featured on a profile |
mastodon_endorse_account / mastodon_unendorse_account | Feature an account on your profile, or stop (4.4+) |
mastodon_get_featured_tags | Hashtags featured on your profile |
mastodon_feature_tag / mastodon_unfeature_tag | Feature a hashtag on your profile, or stop (4.4+) |
Notifications (9): individual and grouped
| Tool | What it does |
|---|---|
mastodon_get_notifications | List notifications, filtered by type |
mastodon_get_notification | Get one notification |
mastodon_dismiss_notification | Dismiss one notification |
mastodon_clear_notifications | Clear all notifications |
mastodon_get_grouped_notifications | Notifications grouped as the web interface shows them (4.3+) |
mastodon_get_notification_group | Get one group (4.3+) |
mastodon_get_notification_group_accounts | Everyone behind a group (4.3+) |
mastodon_dismiss_notification_group | Dismiss a whole group (4.3+) |
mastodon_get_unread_notification_count | Number of unread notification groups (4.3+) |
Collections (9): public, curated lists of accounts (4.6+)
| Tool | What it does |
|---|---|
mastodon_get_account_collections | Collections created by an account |
mastodon_get_account_in_collections | Collections an account is featured in |
mastodon_get_collection | A collection with its accounts |
mastodon_create_collection / mastodon_update_collection / mastodon_delete_collection | Manage your collections |
mastodon_add_collection_item / mastodon_remove_collection_item | Add or remove an account |
mastodon_revoke_collection_item | Take yourself out of someone else's collection |
Lists (8): private lists for your own timelines
| Tool | What it does |
|---|---|
mastodon_get_lists / mastodon_get_list | List your lists, or get one |
mastodon_create_list / mastodon_update_list / mastodon_delete_list | Manage lists |
mastodon_get_list_accounts | Accounts in a list |
mastodon_add_list_accounts / mastodon_remove_list_accounts | Add or remove accounts |
Search, media, filters, conversations (13)
| Tool | What it does |
|---|---|
mastodon_search | Search accounts, statuses and hashtags |
mastodon_upload_media | Upload a local file, with alt text and focal point |
mastodon_update_media / mastodon_get_media / mastodon_delete_media | Manage an uploaded attachment |
mastodon_get_filters / mastodon_get_filter | List content filters, or get one |
mastodon_create_filter / mastodon_update_filter / mastodon_delete_filter | Manage filters that warn, hide or blur |
mastodon_get_conversations | Direct message conversations |
mastodon_mark_conversation_read / mastodon_delete_conversation | Mark a conversation read, or remove it |
Instance and annual reports (9)
| Tool | What it does |
|---|---|
mastodon_get_instance | Instance details, limits and API version |
mastodon_get_trending_tags / mastodon_get_trending_statuses | What is trending |
mastodon_get_custom_emojis | The instance's custom emoji |
mastodon_get_announcements | Announcements from the admins |
mastodon_get_directory | The profile directory |
mastodon_get_annual_report_state | Whether a year-in-review report exists or can be generated (4.6+) |
mastodon_generate_annual_report | Request generation of a report (4.6+) |
mastodon_get_annual_report | Get a generated report (4.6+) |
Mastodon compatibility
The server targets the Mastodon 5.0.0 API (API version 12) and stays usable on older 4.x instances:
- Parameters marked with a minimum version are ignored by older servers.
- Tools marked with a minimum version return the instance's own error there, usually a 404.
- Accounts added with an earlier version of this server keep working. The scopes they were granted already cover the newer endpoints.
Other software that implements the Mastodon API should work for the endpoints it supports.
Not covered: the admin API, the streaming API, and push subscriptions.
Security
Stored credentials. OAuth tokens and app credentials are kept in ~/.mastodon-mcp/accounts.json, readable only by your user and encrypted with AES-256-GCM using a key derived from the passphrase.
[!IMPORTANT] Without
--passphrase, the file is encrypted with a default passphrase that is in this repository's source code. That keeps tokens out of plain text but does not protect them from anyone who can read the file. Set your own passphrase if that matters to you, and use the same one every time: the store cannot be read with a different one.
A passphrase given on the command line is visible in the process list and in your client's configuration file.
HTTP transport. The HTTP server has no authentication and listens on all network interfaces. Anyone who can reach the port can act as every configured Mastodon account. Keep it on a trusted machine, or put it behind a firewall or an authenticating reverse proxy.
What the assistant can do. Once an account is connected, the assistant can post, follow, block and delete on your behalf. Every tool tells your client whether it only reads or changes something, and whether the change deletes or overwrites anything, so clients that support MCP tool annotations can let reads through and ask before destructive actions. Use your client's tool-approval settings if you want to confirm those actions.
Revoking access. mastodon_remove_account revokes the token. You can also revoke it yourself under Preferences → Account → Authorized apps on your instance.
Development
npm install
npm run dev # recompile on change
npm run build # one-off build into dist/
npm start # run the built server on stdio
src/
├── index.ts entry point
├── cli.ts command-line options and transports
├── server.ts builds the MCP server and registers the tools
├── auth/store.ts encrypted account storage
├── lib/
│ ├── mastodon-client.ts HTTP client for the Mastodon API
│ ├── account-resolver.ts picks the account for each tool call
│ └── tool-result.ts helpers for building tool results
└── tools/ one file per group of tools
Adding a tool means registering it with server.tool(...) in the matching file under src/tools/; a new group also needs registering in src/server.ts. It also needs a title and behaviour hints in src/lib/tool-annotations.ts, or the server refuses to start. The test suite fails until the new tool has a request test and an entry in this README.
Testing
| Command | What it checks |
|---|---|
npm run lint | ESLint over the source, tests and scripts |
npm run typecheck | TypeScript, including the tests |
npm test | Unit and tool tests: every tool's request to Mastodon, the OAuth flow, the encrypted store, error handling |
npm run test:coverage | The same, failing if coverage drops below the thresholds in vitest.config.ts |
npm run test:e2e | Builds the server, runs it as a real process and talks MCP to it over stdio and HTTP, against a mock Mastodon instance |
npm run test:package | Packs the npm tarball, checks its contents, installs it in an empty project and runs the installed command |
npm run test:security | Lockfile sources, npm audit, and registry signatures |
npm run test:all | Everything above |
No test talks to a real Mastodon instance or touches your real ~/.mastodon-mcp.
The same checks run in Forgejo Actions on every push and pull request, on Node 22 and 24. A separate security workflow also runs weekly and scans the git history for committed secrets with gitleaks.
Changes are recorded in the changelog.
Releasing
Releases are published to npm from GitHub, because npm's trusted publishing only accepts GitHub, GitLab and CircleCI's hosted runners. No npm token is stored anywhere: the publish job proves who it is to npm with a short-lived OIDC token, and npm attaches a provenance attestation to each release.
-
Bump the version in
package.json,package-lock.json(npm version --no-git-tag-version <version>),SERVER_VERSIONinsrc/server.tsand both versions inserver.json, and add aCHANGELOG.mdentry. The tests fail if these disagree. -
Commit, then tag and push the tag to code.squarecows.com:
git tag v1.2.0 git push origin main v1.2.0 -
The push mirror copies the tag to github.com/richarvey/mastodon-mcp, where
.github/workflows/publish.ymlchecks the tag matches the version, runsnpm run test:all, publishes to npm, then lists the new version in the official MCP Registry asio.github.richarvey/mastodon-mcp. -
If the npm or registry step fails, fix the cause on
mainand run the workflow from GitHub's Actions tab (Publish to npm and the MCP Registry → Run workflow). It skips whatever is already published and finishes the rest.
License
Mastodon and the Mastodon logo are trade marks of Mastodon GmbH. This project is not affiliated with or endorsed by Mastodon GmbH.
@ric_/mastodon-mcpnpm install @ric_/mastodon-mcp