Facebook MCP Server & CLI

A free, open source Facebook MCP server and CLI that lets Claude Code, Codex, Cursor and other AI agents read your Page insights, schedule posts and moderate comments.

Navid Moazzezby Navid Moazzez·Updated Oct 5, 2026·13 min read·
Rate this tool

This free Facebook MCP server and CLI gives your AI real access to your Facebook Pages: posts, drafts and scheduled posts, comments and insights. It reads your posts and comments, shows how each post and your Page are doing, and once you turn writing on, it posts, schedules, replies to comments and hides spam.

It's one install with two ways in. Claude, Codex, Cursor or any other MCP app calls its 15 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.

In this guide, I'll show you:

  • What the Facebook MCP server & CLI is, and what you can ask it
  • How to install it and check that it works
  • When to use the MCP server, and when the CLI
  • Every tool, and how to keep your account safe

Every tool on this page comes from the server itself, and every cost was measured in Claude Code.

key_takeaways.mdTL;DR

Key takeaways

It gives Claude, Codex, Cursor and any other MCP app 15 tools for your Facebook Pages: posts, drafts and scheduling, comments, and Page and post insights.
Reading works as soon as a Page is connected, and posting stays off until you turn it on yourself.
It uses your own Meta app with Standard Access, so your own Pages need no App Review and no Business Verification.
The same tools run as a CLI, which costs your AI nothing until it runs.

What is the Facebook MCP server & CLI?

The Facebook MCP server & CLI is a free, open source program that lets AI agents work with your Facebook Pages for you, in two 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 Meta's own Graph API.

The CLI is the same program as commands. facebook-cli list-posts runs the same code your AI runs when you ask how your latest posts did, whether an agent like Claude Code runs it or you do.

In an AI OS, the layer that connects your AI to your context, your data and your tools, a server like this is how your AI reaches Facebook. My guide to building an AI operating system names Facebook among the tools it reaches, and here's how I use AI myself.

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 asking
Which post this month got the most reach, and what was different about it?
Schedule this for Tuesday at 9am, and draft two alternatives I can pick from.
Read the comments on my last five posts and tell me what people keep asking.
Draft a reply to each comment that deserves one, in my voice, and don't post them.
Hide the spam on that post, but leave the criticism.
How many followers did I gain this month?

The first one shows why this is useful. Facebook's own tools show you the numbers, and your AI compares the posts behind them and tells you what made the difference.

It works well next to my Facebook Ad Library MCP server and Buffer MCP server, so your AI can see which ads others run and schedule posts across your channels in the same chat. Every server I've made is on my MCP servers page.

For the posts themselves, my free Facebook post analyzer and Facebook Page bio generator help too.

How to install the Facebook MCP server

Pick your app in the box at the top of this page. Each one is a single command or a pasted block, and they all run through npx, so there's nothing to install first.

Windsurf, Zed and Cline take the same server, though they don't have a tab in the box yet. Follow the box's Cursor tab, and put its block here instead:

AppWhere the block goes
WindsurfIn the Cascade panel, open the Actions menu (…) and choose Open MCP config file, then paste the block.
ClineClick the MCP Servers icon in the Cline panel, open the Configure tab, click Configure MCP Servers, and paste the block.
ZedGo to Settings, then AI, then MCP Servers, and choose Add Server, then Add Local Server. Enter the block's command, arguments and variables, and Zed saves them under context_servers.
Before you start0/3

Watch out: Facebook only lets apps post to Pages, not to personal profiles. Meta removed profile posting from its API in 2018, so no tool here can post to your profile.

Set up your Meta app and Page

Facebook has no personal API keys, so you make one Meta app of your own, once. It takes about 10 minutes, and for your own Pages you need no App Review and no Business Verification.

Create your Meta app0/4
PermissionWhat it's for
pages_show_listSeeing which Pages you run
pages_read_engagementReading posts, comments and followers
pages_manage_postsCreating, editing and deleting posts
pages_manage_engagementReplying to, hiding and deleting comments
read_insightsReach, impressions and engagement
Get your Page tokens0/4
npx -y @thenavidm/facebook-mcp-cli login YOUR_EXPLORER_TOKEN

Your Page must be in the business portfolio you picked for the app, or login finds no Pages. Check it under Business settings, then Accounts, then Pages.

The permission people miss is pages_read_engagement. Without it, reading breaks while posting still works.

Check that it works

Run the doctor. It names every Page it can reach, with its follower count, and if something's wrong, it says which link in the chain broke. It doesn't post anything.

npx -y @thenavidm/facebook-mcp-cli doctor

When it lists your Pages, restart your app and ask how your last five posts did. If a token stopped working overnight, set your app's ID and secret and run login again.

In Claude Code, /mcp also shows whether the Facebook server is connected. It's one of the Claude Code commands worth knowing.

Use the Facebook CLI

The CLI is the same 15 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 list_posts runs as facebook-cli list-posts.

npm install -g @thenavidm/facebook-mcp-cli
facebook-cli
facebook-cli list-pages
facebook-cli list-posts --limit 5
facebook-cli get-page-insights --since 2026-09-01 --until 2026-09-30

The bare facebook-cli lists every command, facebook-cli which <words> finds the command for a task, and facebook-cli <command> --help shows what a command takes. Posting, editing, replying and hiding work once FACEBOOK_ALLOW_WRITE=true is set. Deleting also needs FACEBOOK_ALLOW_DELETE=true, plus --confirm, the terminal's version of your approval.

facebook-cli install <app> adds the server to Claude Code, Codex, Claude Desktop, Cursor, VS Code or Gemini CLI, in each app's own format.

These are the flags you'll use most:

FlagWhat it does
--jsonPrints JSON
--compactPrints the JSON on one line
--select a,b.cKeeps only those fields, and a dotted path goes deeper
--agentMachine mode: compact JSON, no prompts, and it never confirms anything
--confirmLets a write that asks first go ahead
--dry-runShows what a write would do, without doing it

A script can branch on the exit code:

Exit codeWhat it means
0It worked
1Something unexpected went wrong
2The command was typed wrong, or a write needed --confirm
3It wasn't found
4Facebook rejected the credentials
5Facebook failed or couldn't be reached
7You hit a rate limit, so wait and try again
10Nothing is set up yet

MCP server or CLI: which one?

Both are the same program with the same 15 tools. The difference is when your AI pays for them, in the tokens it reads.

Every message, in an app that loads every tool
MCP server
1,200 tokens
CLI
Nothing
Every message, in Claude Code
MCP server
300 tokens
CLI
Nothing
When Facebook comes up
MCP server
Nothing more, or in Claude Code the tools it picks
CLI
1,500 tokens, once
20 messages with Facebook in one, every tool loaded
MCP server
23,000 tokens
CLI
1,500 tokens
Works in Claude Desktop's chat
MCP server
Yes
CLI
No, there's no terminal there
Works in a script, a cron job or CI
MCP server
No
CLI
Yes

An app that loads every tool up front sends the full list with every message, whether you mention Facebook 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 Facebook 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 80 tokens.

When the whole conversation is about Facebook, 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.

How to spend less

In Claude Code, leave tool search on, which it is unless you've set ENABLE_TOOL_SEARCH=false.

These numbers are for the default install, with writing off. Turning writing on adds the posting and comment tools to the list, so it costs a little more. In Claude Code, the /mcp panel turns the server off when you aren't working on your Pages.

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 October 5, 2026 in Claude Code 2.1.286 with Claude Opus 5.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.

Drafts, scheduling and comments

create_post does three jobs. With just a message it posts now, with draft it saves a draft, and with publish_at it schedules the post. Facebook takes a schedule from 10 minutes to 6 months ahead, and the server checks that first, because Facebook's own error doesn't say which rule you broke.

publish_draft sends a draft or scheduled post out right away, and update_post changes a published post's text, which shows viewers an edit history.

hide_comment hides a comment from everyone except its author and their friends, and it can be undone. That's the usual answer to spam, and deleting stays a separate, permanent step.

Insights lag a few hours behind, so this morning's post looks quieter than it is.

Watch out: Meta's rate limits are per app, not per Page, so heavy use across several Pages shares one budget. Reads wait and try again, and writes never retry, because a retry could post twice.

Every Facebook tool

The tables below list all 15 tools, grouped by what they're for. Of these, seven only read, and eight change something on your Pages once you turn writing on.

Posts, drafts and scheduling

create_post
What it does
Posts now, saves a draft or schedules a text post, with a link if you like.
Kind
Writes
create_photo_post
What it does
Posts, drafts or schedules a photo from a public link, with a caption.
Kind
Writes
list_posts
What it does
Lists a Page's published posts, newest first, with reactions, comments and shares.
Kind
Reads
list_scheduled_posts
What it does
Lists the drafts and scheduled posts that haven't gone out yet.
Kind
Reads
publish_draft
What it does
Publishes a draft or scheduled post right away.
Kind
Writes
update_post
What it does
Changes a published post's text, which shows viewers an edit history.
Kind
Writes
delete_post
What it does
Deletes a post for good.
Kind
Asks first

Comments

list_comments
What it does
Lists the comments on a post, with who wrote each one and when.
Kind
Reads
reply_to_comment
What it does
Replies to a comment publicly, as the Page.
Kind
Writes
hide_comment
What it does
Hides a comment from everyone but its author and their friends, and can be undone.
Kind
Writes
delete_comment
What it does
Deletes a comment for good.
Kind
Asks first

Insights

get_page_insights
What it does
Shows a Page's impressions, reach, engaged users and follower change over a date range.
Kind
Reads
get_post_insights
What it does
Shows one post's impressions, reach, clicks and reactions.
Kind
Reads

Your Pages

list_pages
What it does
Lists every Facebook Page the server can act as.
Kind
Reads
get_page
What it does
Reads a Page's profile: name, category, followers, about text and website.
Kind
Reads

Is the Facebook MCP server safe?

A Page post is public the moment it lands, and a deleted one can't come back. So writing stays off until you set FACEBOOK_ALLOW_WRITE=true, and the two delete tools also need FACEBOOK_ALLOW_DELETE=true and ask first.

Until writing is on, posting, editing, replying and hiding aren't even on the tool list, so a default install can't publish anything.

When your AI calls one of them, the call needs a yes first. Where you use it decides who gives it:

  • Claude Code (2.1.246 and later) asks you before every call, in every one of its permission modes.
  • An app that can show forms asks you in a form.
  • Any other app takes your AI's confirm: true as the yes, so tell your AI to check with you first.
  • An agent with no person to ask needs FACEBOOK_CONFIRM=model, so its confirm: true counts in every app.
  • In a terminal, you add --confirm to the command.

If the answer is no, nothing reaches Facebook.

Make it read-only

FACEBOOK_READ_ONLY=1 turns writing off again, whatever else is set, leaving the seven reading tools.

Keep a log of every write

Set FACEBOOK_AUDIT_LOG to a file path. The server writes one line per attempted write, allowed or blocked, with what it was about to do and who approved it.

Watch out: Comments are written by strangers, and one can try to give your AI orders. The server marks comment text as data, and an agent working on its own is safest with writing off.

Your data

Your requests go straight to Meta's Graph API, with no server of ours in between and no tracking. Login saves your Page tokens in a private file on your computer, readable by you alone.

To cut access, delete the Meta app at developers.facebook.com, which ends every token it made, then remove the server from your app's config.

Connect more than one Facebook Page

Login saves a token for every Page you run, and list_pages shows them. Every tool takes a page argument to name one.

Without a name, it uses the first Page, which is rarely the one you want. Set FACEBOOK_PREFERRED_PAGES to your Page names, in order, to choose the default.

Facebook MCP server settings

Every setting is an environment variable, in your app's config or your shell.

FACEBOOK_ALLOW_WRITE
Default
off
What it does
true allows posting, editing, replying and hiding
FACEBOOK_ALLOW_DELETE
Default
off
What it does
true allows deleting posts and comments, with writing on too
FACEBOOK_PAGE_ID
Default
none
What it does
Holds a single Page's ID, with its token
FACEBOOK_PAGE_TOKEN
Default
none
What it does
Holds that Page's token
FACEBOOK_PAGE_NAME
Default
none
What it does
Holds that Page's name, so you can pick it by name
FACEBOOK_PAGES
Default
none
What it does
Lists several Pages as JSON, instead of what login saves
FACEBOOK_PREFERRED_PAGES
Default
none
What it does
Lists Page names, comma separated, in the order that picks the default
FACEBOOK_APP_ID
Default
none
What it does
Holds your Meta app's ID, so login saves tokens that don't expire
FACEBOOK_APP_SECRET
Default
none
What it does
Holds your Meta app's secret
FACEBOOK_TIMEOUT_MS
Default
30000
What it does
Gives up on a Graph API request after this many milliseconds
FACEBOOK_READ_ONLY
Default
on, until writing is allowed
What it does
0 allows writing, and 1 turns it off whatever else is set
FACEBOOK_ALLOW_DESTRUCTIVE
Default
off, until deleting is allowed
What it does
1 allows deleting, and 0 refuses it whatever else is set
FACEBOOK_AUDIT_LOG
Default
none
What it does
Names a file that gets one line per attempted write
FACEBOOK_SURFACE
Default
full
What it does
search lists three tools that find, describe and run the rest
FACEBOOK_TOOL_TIMEOUT_MS
Default
none
What it does
Gives up on any tool after this many milliseconds
FACEBOOK_CONFIRM
Default
human
What it does
model lets your AI's confirm: true approve on its own, for an agent with no person to ask
FACEBOOK_HTTP_PORT
Default
8787
What it does
Sets the port for --http
FACEBOOK_HTTP_HOST
Default
127.0.0.1
What it does
Sets the address for --http, and any other needs a token
FACEBOOK_HTTP_TOKEN
Default
none
What it does
Sets the bearer token every --http request needs
FACEBOOK_HTTP_ALLOWED_ORIGINS
Default
none
What it does
Lists other websites allowed to call --http, comma separated
FACEBOOK_DEBUG
Default
off
What it does
1 prints debug lines

Troubleshooting

Run the doctor first. It names the step that failed and the fix.

What you seeWhat to do
The Page token is invalid or expiredIt was a short-lived token. Set FACEBOOK_APP_ID and FACEBOOK_APP_SECRET, then run login again
The token is missing a permissionGenerate a new token with all five permissions. pages_read_engagement is the one people miss
Login finds no PagesAdd pages_show_list, check that you're an admin of the Page, and that the Page is in the app's business portfolio
Posting is missing or refusedThat's the default. Set FACEBOOK_ALLOW_WRITE=true to turn writing on
A schedule is refusedFacebook takes schedules from 10 minutes to 6 months ahead
"…so it will not run without confirm: true"That's the safety check working on a delete. Approve it when your app asks

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.

FAQs about the Facebook MCP server & CLI

Here are the questions people ask most about the Facebook MCP server and CLI.

The Facebook MCP server & CLI is a free, open source program that lets an AI app like Claude, Codex or Cursor work with your Facebook Pages.

It has 15 tools for posts, drafts, scheduling, comments and insights on your Facebook Pages, 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.

Every server I've made is on my MCP servers page.

The Facebook CLI is the same program as the Facebook 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.

One npm package installs both.

Use the Facebook 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 Facebook MCP server is free and open source under the MIT license.

Meta's Graph API costs nothing for your own Pages, so the only thing you pay for is your own AI app.

No, you don't need either for your own Pages.

Standard Access covers Pages where you have a role on the app, and Meta grants it as soon as you add the permissions.

No, Meta removed profile posting from its API in 2018.

The server works with Pages only.

Tokens made without your app's ID and secret expire with the short-lived token they came from.

Set FACEBOOK_APP_ID and FACEBOOK_APP_SECRET before you run login, and the Page tokens it saves never expire.

Yes, once you turn writing on.

It saves drafts, schedules posts from 10 minutes to 6 months ahead, and lists everything that hasn't gone out yet.

Yes, login saves every Page you run, and every tool takes a page argument.

FACEBOOK_PREFERRED_PAGES sets which Page is the default.

The Facebook MCP server works with any app that speaks MCP.

That includes Claude Code, Claude Desktop, Codex, Cursor, VS Code, Windsurf, Zed, Cline, GitHub Copilot CLI, Gemini CLI, OpenCode, OpenClaw, Antigravity and Hermes.

I did.

I'm Navid Moazzez, and I made the Facebook MCP server & CLI as one of my free tools on navid.me.

You can read more about me.

The code is on GitHub under the MIT license, and the package is on npm.

Navid Moazzez

AI business strategist & AI OS builder

Navid Moazzez helps creators and founders master AI and build their own AI Operating System (AI OS) to automate their business and life.

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

Related free tools

Free AI newsletter

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.

Loved by 10,000+ readers