Mastodon MCP Server & CLI
A free, open source Mastodon MCP server and CLI that lets Claude Code, Codex, Cursor and other AI agents post, edit, read your timelines and manage your account on any instance.
This free Mastodon MCP server and CLI gives your AI real access to your Mastodon account, on any instance. It posts, edits, reads your timelines, follows hashtags and keeps your lists in order.
It's one install with 2 ways in. Claude, Codex, Cursor or any other MCP app calls its 76 tools for you, and the same tools work as a CLI that agents like Claude Code, Codex and OpenCode run, or that you type yourself.
Here's what the Mastodon MCP server is, how to set it up in each app, and every tool it has.
What is the Mastodon MCP server & CLI?
The Mastodon MCP server & CLI is a free, open source program that lets AI agents act on Mastodon for you, in 2 ways. The MCP server is what an AI app like Claude, Codex or Cursor connects to, through MCP (Model Context Protocol), the open standard AI apps use to call outside tools.
You ask in plain language. Your AI picks the right tool, and the server makes the call to your instance.
The CLI is the same program as commands. mastodon-cli get-home-timeline runs the same code your AI runs when you ask about your timeline, whether an agent like Claude Code runs it or you do.
What can you ask it?
Once it's set up, you ask the way you'd ask an assistant. These are real prompts it handles:
Try askingPost this, and put a content warning on it.
There's a typo in Tuesday's post. Fix it without losing the boosts.
What did my timeline talk about in the last 12 hours?
Find people posting about local-first software and tell me who's worth following.
Make a list called "rust people" and put everyone I follow who posts about Rust on it.
Turn these notes into a thread. My instance allows 11,000 characters, so check before you split it.
The second one shows why this is useful. Mastodon lets you edit a published post and keeps its boosts, replies and favorites, so fixing a typo doesn't mean starting over.
How to install the Mastodon MCP server
Pick your app in the box at the top of this page. You log in once in a terminal, then add the server to your app with a single command or a pasted block. Nothing about your account goes in the app's config.
Set up your Mastodon account
Mastodon has no central developer portal, because every instance is its own server. So the login does the setup for you, on your instance.
npx -y @thenavidm/mastodon-mcp-cli login mastodon.socialBehind that one command, the login registers itself as an app on your instance, catches the answer on your own computer and checks the token. It doesn't ask for push notifications, because nothing here uses them.
Or let your AI set it up
Paste this into Claude Code, Codex or any agent that can run commands:
Set up the Mastodon MCP serverSet up the Mastodon MCP server for me.
1. Ask me which instance my account is on, e.g. mastodon.social. Do not guess.
2. Run: npx -y @thenavidm/mastodon-mcp-cli login <instance>
It opens my browser and waits. Tell me to approve the request there, and wait for it to finish. It asks for read, write and follow; that is correct. If there is no browser available, re-run it with --oob and I will paste the code back to you.
3. Register the server with my MCP client. For Claude Code that is:
claude mcp add mastodon -- npx -y @thenavidm/mastodon-mcp-cli
No environment variables: step 2 already stored the token.
4. Run: npx -y @thenavidm/mastodon-mcp-cli doctor
Show me the output. Pay attention to the line about scopes: if it says the account cannot post, the token is read-only and step 2 needs redoing.
5. Tell me to restart the client. Do not post anything.
If I have more than one account, repeat step 2 per account and per instance.
It stops at step 2 and waits, because only you can approve the request in your browser.
Other ways to log in
With no browser, login mastodon.social --oob prints the address and takes a pasted code. If you already made an app on your instance by hand, login mastodon.social --token=YOUR_ACCESS_TOKEN stores it.
If you make that app yourself, tick read, write and follow, and copy "Your access token", not the client secret.
Check that it works
Run the doctor. It reports your instance's real limits, checks the token and checks what the token is allowed to do.
npx -y @thenavidm/mastodon-mcp-cli doctorThat last check matters most. A read-only token passes everything else, then fails on the first post with an error that never mentions why.
Use the Mastodon CLI
The CLI is the same 76 tools as commands. AI agents that run commands, like Claude Code, Codex and OpenCode, use it on their own, and you can type the same commands in a terminal or a script. Every tool name becomes a command with dashes, so post_status runs as mastodon-cli post-status.
npm install -g @thenavidm/mastodon-mcp-cli
mastodon-cli
mastodon-cli get-home-timeline --limit 50
mastodon-cli search --q "model context protocol"
mastodon-cli post-status --status "Shipped." --confirmThe bare mastodon-cli lists every command, and mastodon-cli <command> --help shows what a command takes. Posting, editing, deleting and blocking need --confirm, the terminal's version of the check your AI has to pass.
These flags work on every command:
| Flag | What it does |
|---|---|
--json | Prints JSON |
--compact | Prints the JSON on one line |
--agent | Machine mode: JSON, compact, no prompts and no color |
--select a,b.c | Keeps only those fields, and a dotted path goes deeper |
--confirm | Lets a write that asks first go ahead |
A script can branch on the exit code:
| Exit code | What it means |
|---|---|
| 0 | It worked |
| 2 | The command was typed wrong, or a write needed --confirm |
| 3 | It wasn't found |
| 4 | Your instance rejected the token |
| 5 | Your instance's API failed |
| 7 | You hit a rate limit, so wait and try again |
| 10 | Nothing is set up yet, so run the login |
MCP server or CLI: which one?
Both are the same program with the same 76 tools. The difference is when your AI pays for them, in the tokens it reads.
- MCP server
- 24,400 tokens
- CLI
- Nothing
- MCP server
- 1,700 tokens
- CLI
- Nothing
- MCP server
- Nothing more, or in Claude Code the tools it picks
- CLI
- 3,600 tokens, once
- MCP server
- 487,000 tokens
- CLI
- 3,600 tokens
- MCP server
- Yes
- CLI
- No, there's no terminal there
- MCP server
- No
- CLI
- Yes
An app that loads every tool up front sends the full list with every message, whether you mention Mastodon or not. Claude Code doesn't by default: its tool search sends only the tool names and the server's instructions, and loads a tool's full definition when your AI reaches for it.
The CLI costs nothing until Mastodon comes up. Then your agent reads its skill file once and runs the commands it needs. With the skill added, Claude Code also lists its one-line description with every message, about 140 tokens.
When the whole conversation is about Mastodon, the gap closes. Then the MCP server is the better experience, because you ask in plain language and your AI never has to look up a command.
Where the MCP server's tokens go
| Part of the tool list | Share |
|---|---|
| JSON Schema structure, like types, required lists and nesting | 59% |
| Argument descriptions | 29% |
| Tool descriptions | 12% |
59% of it is MCP writing every tool out as JSON Schema, which any server with this many tools pays. The rest is the wording that lets your AI use each tool without guessing.
How to spend less
In Claude Code, leave tool search on, which it is unless you've set ENABLE_TOOL_SEARCH=false.
Turn the server off when you aren't using Mastodon. In Claude Code that's the /mcp panel, and every AI app has its own switch. MASTODON_READ_ONLY=1 cuts it to the 39 reading tools.
Or install the CLI and connect the server later, on the days it earns its place. Every tool stays in reach, and the standing cost drops to nothing.
Every number here was measured on September 27, 2026 in Claude Code 2.1.257 with Claude Opus 5. It's the same one-line prompt with and without the server connected, once with tool search off so every tool loads, and once with Claude Code's default. The skill was measured the same way, and other apps and models count tokens a little differently.
What makes Mastodon different
Mastodon isn't one website. Thousands of independent instances talk to each other, and yours decides your limits, what it can show you and which servers it connects to.
A post that seems not to exist may just not have reached your instance yet. Searching for its link with resolve on makes your instance go and fetch it.
Search is usually not full text, because most instances only index your own posts and ones you interacted with. A thin result is the instance's choice, not a bad search.
Timelines have no algorithm, so hashtags, trends, lists and the directory are how you find people. Following a hashtag puts every public post with it into your home timeline.
The server works on Pleroma, Akkoma, GoToSocial and other software that speaks the same API. get_instance_info tells you which one your instance runs, and the doctor warns you when edits or trends may be missing.
Every Mastodon tool
All 76 tools, grouped the way the repo groups them. 39 only read, and 37 change something on your account.
Posting and editing
post_status- What it does
- Publish a status.
- Kind
- Asks first
post_thread- What it does
- Publish several statuses as one thread, each replying to the last.
- Kind
- Asks first
edit_status- What it does
- Change the text, content warning, media alt text or poll of a status that is already published.
- Kind
- Asks first
get_status_source- What it does
- The plain-text source of one of your own statuses, exactly as it was typed, plus its content warning.
- Kind
- Reads
get_status_history- What it does
- Every published version of a status, oldest first.
- Kind
- Reads
delete_status- What it does
- Delete one of your own statuses.
- Kind
- Asks first
get_status- What it does
- A single status by id, with its media, poll, link preview and engagement counts.
- Kind
- Reads
get_thread- What it does
- A status together with everything above and below it, nested into the real reply tree.
- Kind
- Reads
list_scheduled_statuses- What it does
- Statuses queued with scheduled_at that have not published yet.
- Kind
- Reads
reschedule_status- What it does
- Change when a scheduled status will publish.
- Kind
- Writes
cancel_scheduled_status- What it does
- Cancel a status that was scheduled but has not published.
- Kind
- Writes
get_favourites- What it does
- Statuses a connected account has favourited, newest first.
- Kind
- Reads
get_bookmarks- What it does
- Statuses a connected account has bookmarked.
- Kind
- Reads
Timelines
get_home_timeline- What it does
- Statuses from the accounts and hashtags you follow, newest first.
- Kind
- Reads
get_local_timeline- What it does
- Everything public posted by accounts on your own instance.
- Kind
- Reads
get_federated_timeline- What it does
- Everything public your instance has federated in from the rest of the network.
- Kind
- Reads
get_hashtag_timeline- What it does
- Public statuses carrying a hashtag.
- Kind
- Reads
get_list_timeline- What it does
- Statuses from the accounts on one of your lists.
- Kind
- Reads
get_account_statuses- What it does
- Statuses by one account, newest first.
- Kind
- Reads
Favorites, boosts and polls
favourite_status- What it does
- Favourite a status.
- Kind
- Writes
unfavourite_status- What it does
- Remove your favourite from a status.
- Kind
- Writes
boost_status- What it does
- Boost a status to your followers.
- Kind
- Writes
unboost_status- What it does
- Undo a boost.
- Kind
- Writes
bookmark_status- What it does
- Bookmark a status.
- Kind
- Writes
unbookmark_status- What it does
- Remove a bookmark.
- Kind
- Writes
pin_status- What it does
- Pin one of your own statuses to the top of your profile.
- Kind
- Writes
unpin_status- What it does
- Unpin a status from your profile.
- Kind
- Writes
mute_conversation- What it does
- Stop being notified about replies to this thread, without leaving it.
- Kind
- Writes
unmute_conversation- What it does
- Start being notified about this thread again.
- Kind
- Writes
vote_poll- What it does
- Vote in a poll by option index, counting from zero.
- Kind
- Asks first
translate_status- What it does
- Translate a status into your language using the instance's translation backend.
- Kind
- Reads
get_favourited_by- What it does
- The accounts that favourited a status.
- Kind
- Reads
get_boosted_by- What it does
- The accounts that boosted a status, as far as your instance knows.
- Kind
- Reads
report- What it does
- Report an account, optionally with specific statuses, to your instance's moderators.
- Kind
- Asks first
Search and hashtags
search- What it does
- Search for accounts, statuses or hashtags.
- Kind
- Reads
get_trends- What it does
- What is trending on this instance right now: hashtags, statuses, or links.
- Kind
- Reads
get_followed_hashtags- What it does
- Hashtags you follow.
- Kind
- Reads
follow_hashtag- What it does
- Follow a hashtag, so every public post carrying it appears in your home timeline.
- Kind
- Writes
unfollow_hashtag- What it does
- Stop a hashtag's posts appearing in your home timeline.
- Kind
- Writes
browse_directory- What it does
- Accounts that have opted into being discoverable, newest or most recently active first.
- Kind
- Reads
get_suggested_follows- What it does
- Accounts the instance suggests you follow, with the reason for each suggestion.
- Kind
- Reads
get_conversations- What it does
- Direct conversations, newest first, each with its participants and last message.
- Kind
- Reads
Follows, mutes and blocks
get_account- What it does
- Full profile for any account: bio, counts, the metadata fields with their verification state, and whether you follow each other.
- Kind
- Reads
get_followers- What it does
- Accounts that follow a given account.
- Kind
- Reads
get_following- What it does
- Accounts a given account follows.
- Kind
- Reads
get_relationships- What it does
- For each account named, whether you follow them, whether they follow you, and whether either of you has muted or blocked the other.
- Kind
- Reads
follow_account- What it does
- Follow an account.
- Kind
- Writes
unfollow_account- What it does
- Stop following an account.
- Kind
- Writes
mute_account- What it does
- Hide an account from your timelines without them knowing.
- Kind
- Writes
unmute_account- What it does
- Stop hiding an account.
- Kind
- Writes
block_account- What it does
- Block an account.
- Kind
- Asks first
unblock_account- What it does
- Remove a block.
- Kind
- Writes
block_domain- What it does
- Hide every account on an entire instance and remove their followers.
- Kind
- Asks first
unblock_domain- What it does
- Lift a domain block.
- Kind
- Writes
get_mutes- What it does
- Accounts you have muted.
- Kind
- Reads
get_blocks- What it does
- Accounts you have blocked.
- Kind
- Reads
get_endorsements- What it does
- Accounts you feature on your own profile.
- Kind
- Reads
get_blocked_domains- What it does
- Whole instances you have blocked.
- Kind
- Reads
get_follow_requests- What it does
- Accounts waiting for you to approve their follow.
- Kind
- Reads
answer_follow_request- What it does
- Approve or reject a pending follow request.
- Kind
- Writes
Notifications and lists
get_notifications- What it does
- Mentions, boosts, favourites, follows, poll results and edits to posts you interacted with.
- Kind
- Reads
get_read_position- What it does
- The last notification and home-timeline entry you marked read, shared across every client on this account.
- Kind
- Reads
mark_read- What it does
- Record how far you have read, so the next get_notifications with since_id returns only what is new.
- Kind
- Writes
dismiss_notification- What it does
- Remove a single notification from the list.
- Kind
- Writes
clear_notifications- What it does
- Delete all notifications permanently.
- Kind
- Asks first
get_lists- What it does
- Your curated lists.
- Kind
- Reads
create_list- What it does
- Create a curated list.
- Kind
- Writes
delete_list- What it does
- Delete a list.
- Kind
- Asks first
get_list_members- What it does
- The accounts on one of your lists.
- Kind
- Reads
add_to_list- What it does
- Add accounts to a list.
- Kind
- Writes
remove_from_list- What it does
- Remove accounts from a list.
- Kind
- Writes
get_announcements- What it does
- Announcements from the people who run your instance: downtime, rule changes, moderation decisions.
- Kind
- Reads
Accounts and your instance
list_accounts- What it does
- Every Mastodon account this server can act as, and which instance each lives on.
- Kind
- Reads
whoami- What it does
- Authenticate against the instance and return the live profile.
- Kind
- Reads
get_instance_info- What it does
- What this instance actually allows: the character limit, how many attachments and poll options, media size ceilings, the software version, and the server rules.
- Kind
- Reads
update_profile- What it does
- Change your display name, bio, or the four metadata fields on your profile.
- Kind
- Asks first
Is the Mastodon MCP server safe?
A post is public the moment it lands, and deleting it doesn't pull it back off the instances that already have it. So 11 tools refuse to run until your AI passes confirm: true. They're the ones marked Asks first in the tool tables above.
vote_poll asks because a Mastodon vote can't be changed. report asks because it goes to human moderators.
Favorites, boosts, follows and mutes don't ask, because each is one call to undo. Asking on every favorite would only train your AI to pass the check without thinking.
Make it read-only
Set MASTODON_READ_ONLY=1 and every write disappears from the tool list, leaving 39 reading tools. Your AI can't call a tool it can't see.
MASTODON_ALLOW_DESTRUCTIVE=0 is the middle setting. Favorites and follows still work, and posting and deleting don't.
Keep a log of every write
Set MASTODON_AUDIT_LOG to a file path. The server writes one line per attempted write, allowed or blocked.
Watch out: On an open network, anyone can put text in front of your AI, and a post can try to give it orders. The server tells your AI to treat it as data, but MASTODON_READ_ONLY=1 is the real defense for an agent reading other people's posts.
Your instance's admin can read your direct messages, and so can the admin at the other end. Mastodon DMs aren't encrypted.
Your data
Nothing goes anywhere but your instance. Your token is stored in ~/.mastodon-mcp/accounts.json, readable only by your user account, and there's no tracking of any kind.
To disconnect, open https://your-instance/oauth/authorized_applications and remove the app, which cuts access right away. mastodon-cli logout <handle> only forgets the token on your computer.
Connect more than one Mastodon account
On Mastodon, an account is a token plus an instance, and a personal account and a project account often live on different instances. Run the login once for each:
mastodon-cli login mastodon.social
mastodon-cli login fosstodon.orgBoth are stored. Every tool that acts as you takes an optional account, so you can say which one posts, and list_accounts shows them all.
Mastodon MCP server settings
The login is all most people need. These environment variables cover the rest, in your app's config or your shell.
MASTODON_URL- Default
- none
- What it does
- Sets your instance when you skip the login
MASTODON_ACCESS_TOKEN- Default
- none
- What it does
- Holds a token for it when you skip the login
MASTODON_ACCOUNTS- Default
- none
- What it does
- Lists several accounts across instances, as JSON
MASTODON_DEFAULT_ACCOUNT- Default
- the first one
- What it does
- Picks the account that acts when a tool names none
MASTODON_MCP_HOME- Default
~/.mastodon-mcp- What it does
- Sets where the login keeps accounts
MASTODON_READ_ONLY- Default
0- What it does
1hides every write
MASTODON_ALLOW_DESTRUCTIVE- Default
1- What it does
0blocks posting, editing and deleting
MASTODON_AUDIT_LOG- Default
- none
- What it does
- Logs every attempted write to a file
MASTODON_REQUEST_TIMEOUT_MS- Default
30000- What it does
- Sets how long a request can take
MASTODON_MAX_RETRIES- Default
3- What it does
- Retries after a rate limit or a server error
Troubleshooting
Run the doctor first. It names the step that failed and the fix.
| What you see | What to do |
|---|---|
| Reading works, but the first post fails | The token can't write. Run the login again |
| "rejected the access token" | It was revoked, or it belongs to another instance |
| "No account found for …" | Use the full @user@instance form |
| A post that exists comes back not found | Your instance hasn't seen it yet. Search its link with resolve on |
| Search returns almost nothing | Most instances don't index every public post |
| "Status is N characters" | Your instance sets its own limit. get_instance_info shows it |
| "will not run without confirm: true" | That's the safety check working. Say you want it posted |
If the server doesn't show up in your app at all, run the command your app runs, in a terminal, and read the error.
More free Mastodon tools
Check a post's length against your instance before your AI sends it, or turn a post into an image to share.
Mastodon MCP Server FAQs
Here are the questions people ask most about the Mastodon MCP server and CLI.
The Mastodon MCP server & CLI is a free, open source program that lets an AI app like Claude, Codex or Cursor act on your Mastodon account, on any instance.
It has 76 tools for posting, editing, threads, timelines, search, lists, notifications and follows, and the same tools run as a CLI that agents like Claude Code and Codex use, or that you type yourself.
An MCP server is a standard way to give an AI app real access to a tool, so it can act instead of guessing.
MCP stands for Model Context Protocol, and Claude, Codex, Cursor and many other AI apps speak it.
The Mastodon CLI is the same program as the Mastodon MCP server, run as commands.
AI agents like Claude Code, Codex and OpenCode run them for you, and you can type them in a terminal or a script.
Every tool is a command with dashes, so post_status runs as mastodon-cli post-status, and one npm package installs both.
Use the Mastodon MCP server in an AI app with no terminal, like Claude Desktop's chat, and the CLI in a terminal, a script or a cron job.
In an AI app that can run commands, like Claude Code, Codex or Cursor, the CLI is the lighter choice, because it costs nothing until it runs.
Yes, the Mastodon MCP server is free and open source under the MIT license.
Mastodon's API is free too, so the only thing you pay for is your own AI app.
The Mastodon MCP server works on any Mastodon instance, and on Pleroma, Akkoma, GoToSocial and other software that speaks the same API.
The login registers it on your instance for you.
No, the Mastodon MCP server's login registers the app on your instance for you.
You only approve the request in your browser.
Yes, the Mastodon MCP server edits published posts with edit_status, which keeps their boosts, replies and favorites.
Editing asks for a confirm check first, like posting does.
The Mastodon MCP server posts when you ask it to.
Posting, editing, deleting, voting, reporting and blocking only run once your AI passes a confirm check, and read-only mode removes every write so your AI can't see them at all.
The Mastodon MCP server works with any app that speaks MCP.
That includes Claude Code, Claude Desktop, Codex, Cursor, VS Code, GitHub Copilot CLI, Gemini CLI, OpenCode, OpenClaw, Antigravity and Hermes.
Yes, the Mastodon MCP server connects as many accounts as you log in, on as many instances as you like.
Every tool takes an optional account, and a default decides which one acts when you don't say.
Navid.me is reader-supported. When you buy through links on this site, I may earn an affiliate commission. Learn more.
More MCP servers & CLIs
The most actionable AI newsletter for founders
Every week, get proven AI strategies, curated tools, and step-by-step systems to grow your audience, create better content, and build a profitable creator business.
No fluff, no filler, no BS. Just five minutes each week that might level up your online business and life.
P.S. Sign up now to get free access to my ultimate AI tools guide for creators.

