Skip to main content
Glama
mastodon-mcp

mastodon-mcp

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

Related MCP server: ActivityPub MCP Server

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:

  1. mastodon_add_account registers the app on your instance and returns an authorization link.

  2. You open the link, log in, approve access, and copy the code Mastodon shows you.

  3. mastodon_complete_auth exchanges 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 account returns 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.

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

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+)

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

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

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+)

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+)

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

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

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

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. 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. 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.

  1. Bump the version in package.json, package-lock.json (npm version --no-git-tag-version <version>), SERVER_VERSION in src/server.ts and both versions in server.json, and add a CHANGELOG.md entry. The tests fail if these disagree.

  2. Commit, then tag and push the tag to code.squarecows.com:

    git tag v1.2.0
    git push origin main v1.2.0
  3. The push mirror copies the tag to github.com/richarvey/mastodon-mcp, where .github/workflows/publish.yml checks the tag matches the version, runs npm run test:all, publishes to npm, then lists the new version in the official MCP Registry as io.github.richarvey/mastodon-mcp.

License

MIT

Mastodon and the Mastodon logo are trade marks of Mastodon GmbH. This project is not affiliated with or endorsed by Mastodon GmbH.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A fully working MCP server built from scratch in plain Node.js, implementing tools, resources, prompts, notifications, and sampling according to the MCP specification, designed to connect to Claude Desktop or any MCP client.
      37
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      A comprehensive MCP server that enables LLMs like Claude to explore and interact with the existing Fediverse through standardized MCP tools, resources, and prompts.
      18
      91 npm
      17
      MIT
    • A
      license
      C
      quality
      B
      maintenance
      Comprehensive MCP server for Mastodon integration, enabling AI assistants to read timelines, post statuses, manage accounts, search, and more on any Mastodon instance.
      54
      3
      MIT
    • F
      license
      A
      quality
      B
      maintenance
      Lets AI agents schedule and publish social media posts through LazyRelay, then check that each post is really live and return a public proof link. Works with Claude, ChatGPT, Gemini and Cursor. 27 tools; the MCP server and REST API are on every plan, including the free one.
      27
      -