facebook-web-mcp
The facebook-web-mcp server enables safe, human-paced interaction with your Facebook account via a real Chrome browser, offering read-only research tools and staged write operations that require explicit confirmation. Key capabilities include:
Session & login management:
check_facebook_sessionverifies login state;open_facebook_loginopens a browser for manual login (no password storage). Human handles CAPTCHAs/2FA.Search & discovery:
search_facebook,search_groups,search_pagesfind posts, groups, pages, people.Reading content:
open_group,search_in_group,open_page,open_post,read_post,read_comments,get_post_details, andbrowse_feed(home or groups feed) fetch structured posts and comments.Lead research:
find_relevant_postsscans groups/feed for help requests, scoring relevance with explanations;draft_commentprovides post context to craft replies.Staged write (safety-gated):
post_comment,create_post,react_to_post,share_postonly stage actions, returning previews and confirmation tokens.confirm_actionis the sole executor, using single-use tokens, TTL, and a write budget. All writes are verified post-execution.list_pending_actionsandcancel_actionmanage staged items.Maintenance & diagnostics:
selector_healthcheckmonitors DOM selector health;debug_page_structureinspects live page markup for selector repair.
Provides tools to interact with Facebook through the website, including searching groups and pages, reading posts and comments, posting comments, creating posts, reacting, and sharing content using your own Facebook account.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@facebook-web-mcp check my Facebook feed and summarize new posts"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Facebook Web MCP
A local MCP server that lets Claude Code use your Facebook account through the normal Facebook website, in a real Chrome window you can watch.
Not a Graph API integration. There is no app id, no access token, and no password stored anywhere. Authentication is a persistent Chrome profile that you log into by hand, once.
Setup
Requirements: Node ≥ 20.11, Google Chrome, and an MCP client (Claude Code, Claude Desktop, or anything else that speaks MCP over stdio).
git clone https://github.com/Mrshahidali420/facebook-web-mcp.git
cd facebook-web-mcp
npm install
npm run build
claude mcp add facebook-web -- node "$PWD/dist/index.js"Or install straight from GitHub without cloning — it compiles itself on install:
npm install github:Mrshahidali420/facebook-web-mcp
claude mcp add facebook-web -- node "$PWD/node_modules/facebook-web-mcp/dist/index.js"Clone if you intend to fix a selector or send a pull request; the shorter form is enough if you only want to run it.
Installing this way, set FB_MCP_PROFILE_DIR to somewhere stable:
claude mcp add facebook-web \
--env FB_MCP_PROFILE_DIR="$HOME/.facebook-web-mcp/profile" \
-- node "$PWD/node_modules/facebook-web-mcp/dist/index.js"Without it the profile defaults to inside node_modules/, and reinstalling or
updating the package deletes your session and logs you out.
Install into a project directory, not globally.
npm install -gfails on a git install: npm builds the package in a temporary clone, and for global installs it skips devDependencies, sotscis missing and the build exits 1. A local install gets them and builds correctly.
Then just ask Claude to log you in — it calls open_facebook_login, which
raises a Chrome window at Facebook and watches while you sign in. It types
nothing and submits nothing; the polling exists only so it can confirm the
profile was saved. If you need longer than the wait window (a 2FA code, a
checkpoint), the call simply returns — the window stays open and your progress
is not lost, so calling it again picks up where you were.
There is also a standalone equivalent that does not need Claude running:
npm run loginIt opens a Chrome window at Facebook and then waits. You do the
typing. Complete any 2FA prompt or security check in that same window. When the
session goes live it confirms and exits, and the session is saved to .fb-profile/.
If Chrome is not where Playwright expects it:
npx playwright install chromeCheck the server registered:
claude mcp list # facebook-web should report ✔ ConnectedStart every session with check_facebook_session.
Related MCP server: facebook-lyr
The safety model
Tools split cleanly in two.
Read-only — run immediately. check_facebook_session, open_facebook_login, search_facebook,
search_groups, search_pages, open_group, search_in_group, open_page,
open_post, read_post, read_comments, get_post_details, browse_feed,
find_relevant_posts, draft_comment, list_pending_actions, cancel_action,
selector_healthcheck.
Write — staged, never immediate. post_comment, create_post,
react_to_post, share_post.
A write tool does not write. It returns a preview and a token:
ACTION: Post a public comment on a Facebook post
TARGET: https://www.facebook.com/groups/…/posts/…
GROUP: UK WordPress & Web Development
AUTHOR: Jane Smith
POSTED: 3h
THE POST YOU ARE REPLYING TO:
Anyone know why my product pages dropped out of Google last week?
YOUR COMMENT, EXACTLY AS IT WILL BE PUBLISHED:
Sounds like an indexing issue rather than a ranking one — worth checking
Search Console's Pages report for "Crawled – currently not indexed".
This will be visible to everyone who can see the post, under your own name.confirm_action(token) is the only tool in the server that changes anything.
Four things enforce that, in code rather than in prose:
Guard | What it stops |
Single-use tokens | One approval can never execute twice. |
Payload binding | Editing the text supersedes the old token, so text you approved is the only text that can be sent. |
TTL (10 min default) | Yesterday's approval cannot fire today. |
Write budget (3 per process) | A loop cannot fan out into bulk posting. It hard-fails and needs a restart. |
require_confirmation: false is refused unless FB_MCP_ALLOW_UNCONFIRMED=1 is
set in the server's environment. The switch lives in your environment, not in a
parameter the model fills in.
It will not claim success it cannot prove
After every write, the server goes and looks:
Comment — polls the post's comment list for your comment.
Post — polls your feed for the published post.
Reaction — re-reads the reaction control's state.
Share — polls your feed for the shared post.
If it cannot confirm within the timeout, the result is status: "unverified"
with what was actually observed, never "ok". "I clicked submit" and "the
comment exists" are different facts and stay different all the way to Claude.
What it will not do
No CAPTCHA solving, no 2FA entry, no checkpoint clicking, no bot-detection
evasion, no stealth plugins, no user-agent spoofing. There is no code path that
types into a challenge — src/facebook/auth.ts only detects them and hands
the browser back to you.
When Facebook signals a rate limit, the server stops and backs off. It does not retry harder.
Lead research
find_relevant_posts({
group_urls: ["https://www.facebook.com/groups/wordpressuk"],
topics: ["wordpress", "seo", "indexing", "search console"],
posts_per_group: 30
})Scoring is deliberately strict: a post needs both a service topic and a request-for-help signal to score well. "We migrated to WordPress last year" is discussion, not a lead. Self-promotion and already-resolved threads are scored down hard, and recency is a multiplier rather than a bonus.
Every lead carries a plain-English relevance sentence explaining its score, so
the ranking can be audited rather than trusted:
{
"post_url": "https://www.facebook.com/groups/…/posts/…",
"group_name": "UK WordPress & Web Development",
"score": 0.78,
"relevance": "Asking for help (can anyone recommend); about wordpress, dropped out of google; posted in the last day; phrased as a question.",
"matched_keywords": ["wordpress", "dropped out of google"],
"matched_intent": ["can anyone recommend"],
"negative_signals": []
}Then draft_comment returns the post plus its existing comments and anti-spam
guidance, you write the reply, post_comment stages it, and nothing reaches
Facebook until you say so.
When Facebook changes its markup
It will. The design assumes it.
All DOM knowledge lives in exactly one file: src/facebook/selectors.ts.
Nothing else in the project contains a CSS selector.
Each element is an ordered candidate list rather than one selector:
tier 1 ARIA role + accessible name survives class churn and rewrites
tier 2 structural attributes internal contracts, fairly stable
tier 3 structural relationships shape of the tree
tier 4 visible text locale-dependent, last resortThe resolver records which tier actually matched. When a tier-1 candidate stops
matching and extraction quietly falls through to a text heuristic, everything
still works — and selector_healthcheck reports it as degraded. That is the
early warning, before the last candidate dies too and tools start returning
empty arrays.
A total miss throws SelectorMissError naming the strategy. It never returns
null, and never an empty array that looks like "no results".
{ "posts": [], "reason": "no_posts_visible" } is a real answer and is kept
distinct from a failure to read the page. Silent failure is the bug class this
design refuses.
Layout
src/
├── index.ts stdio server entry
├── login.ts one-time interactive login helper
├── config.ts env config — contains no credential fields, by design
├── logger.ts JSONL to logs/, human lines to stderr, never stdout
├── errors.ts typed failures carrying an instruction for the human
├── types.ts Zod schemas for Post, Comment, Group, Page
├── browser/ session lifecycle, pacing, navigation — knows nothing about Facebook
├── facebook/
│ ├── selectors.ts ← the only file with DOM knowledge
│ ├── resolve.ts strategy resolver + health tracking
│ ├── auth.ts login / challenge detection
│ ├── urls.ts search URLs, tracking-param stripping, id extraction
│ ├── extract/ post, comment, entity, parsing helpers
│ ├── pages/ search, group, page, post, feed, home
│ └── actions/ comment, createPost, engage — each verifies afterwards
├── approvals/ token store + preview rendering
├── leads/ keyword sets and pure scoring
└── tools/ MCP tool definitions — never import PlaywrightConfiguration
Everything is optional; defaults are used with no .env at all. See
.env.example for the full list. The ones worth knowing:
Variable | Default | Why you would change it |
|
| Raise only if you genuinely need more writes in one session. |
|
| How long a confirmation token stays valid. |
| unset | Leave it unset. |
|
| Where the logged-in session lives. |
|
| Keep it false — headed is how you handle challenges. |
|
| Pacing between navigations. |
.fb-profile/ is your Facebook session and is gitignored. Deleting it logs
you out. Never commit it, and never copy it anywhere.
Development
npm run typecheck
npm test # 107 unit tests, no browser required
npm run buildTests cover the parts where being wrong is expensive: lead scoring calibration,
the approval store's four guards, the require_confirmation gate, timestamp and
count parsing, and URL normalisation.
ARCHITECTURE.md covers the design in depth, and
docs/facebook-dom-notes.md records what has actually been observed in
Facebook's markup.
Contributing
Contributions are welcome — particularly selector fixes, which are the most common thing that breaks and the most useful thing to receive.
Read CONTRIBUTING.md first. It covers the three rules that are not negotiable (DOM knowledge lives in one file; writes stage rather than execute; never claim success you cannot prove) and the list of changes that will not be merged — CAPTCHA solving, bot-detection evasion, credential storage, and anything that weakens the confirmation gate.
By participating you agree to the Code of Conduct. Security issues go through SECURITY.md, never a public issue.
Disclaimer
This is an independent project. It is not affiliated with, endorsed by, or sponsored by Meta Platforms, Inc.
It automates a browser against a site whose terms of service restrict automated access. Using it may violate those terms and could result in your account being restricted or disabled. That risk is yours, and it is the reason the write budget, the confirmation gate, and the human-paced delays exist rather than being tunable away.
Use it on your own account. Do not use it to scrape, mass-message, harass, or impersonate anyone.
Provided without warranty of any kind — see sections 15 and 16 of the LICENSE.
Licence
Copyright (C) 2026 Shahid Ali
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Available Tools
24 toolsbrowse_feedBrowse a feedARead-only
Read the logged-in account's own Facebook feed. source: "groups" reads every joined group's posts in one stream instead of the home timeline — each post still names the group it came from. Read-only.
Inputs: limit, source, expand_text, scroll_rounds.
cancel_actionCancel a staged actionARead-only
Discard a staged write action so its token can never be used. Use this when the user rejects or changes a draft.
Inputs: confirmation_token (required).
check_facebook_sessionCheck Facebook sessionARead-only
Report whether the persistent browser profile is logged into Facebook. Launches the browser on first use. Never logs in, and never answers a security challenge — if one is present it says so and leaves the window open for the user to handle. Run this before anything else in a session.
Inputs: no named parameters.
confirm_actionConfirm and execute a staged actionA
Execute a previously staged write action. This is the ONLY tool in this server that changes anything on Facebook. Call it only after the user has seen the preview and explicitly approved that exact content. Tokens are single-use and expire. The result reports whether the action was verified on Facebook afterwards — a status of "unverified" means it may or may not have gone through, and must not be reported to the user as success.
Inputs: confirmation_token (required), fingerprint.
create_postCreate a post (staged)A
Stage a new post on your own timeline, optionally with one local image or video. This does NOT publish anything: it validates any attachment, builds a preview of the exact text, and returns a confirmation_token. Show the preview to the user and call confirm_action only after explicit approval.
Inputs: text (required), image_path, video_path, require_confirmation.
debug_page_structureInspect live page structure (maintenance)ARead-only
Report what is actually rendered on the page the browser is currently showing: how many elements match each probe selector, plus their tag, attribute names, text length and a short text preview. Use this to repair src/facebook/selectors.ts against real markup after a Facebook redesign, instead of guessing. Read-only, and it does not navigate — point the browser somewhere with a read tool first.
Inputs: sample, selectors, show_attributes, text_preview_chars.
draft_commentPrepare a comment draft briefARead-only
Open a post and return everything needed to write a genuinely useful reply to it: the full post text, its context, and the existing comments so you do not repeat advice someone has already given. Returns a brief for YOU to write the comment from — it does not generate text, and it does not post anything.
Inputs: post_url (required), tone, intent.
find_relevant_postsFind relevant posts across groupsARead-only
Omit group_urls to sweep the combined feed of every group you have joined — the fastest way to see what is actually being asked across all of them, and which groups are producing nothing. Point this at groups where CLIENTS post ("I need a website for my business", "I need a web developer") rather than developer or freelancer groups. Measured 2026-08-01: a 24K-member WordPress developer group returned zero leads from 12 posts, and correctly so — every post was someone selling. Demand-side groups are where the requests are. Scan one or more Facebook Groups and return the posts most likely to be genuine requests for help with the services you offer, ranked with a plain-English reason for each score. A post must both mention a relevant topic AND read as asking for help to score well; self-promotion and already-resolved threads are scored down hard. Read-only — it finds leads, it does not contact anyone.
Inputs: limit, since, until, topics, +6 more.
get_post_detailsGet full post detailsARead-only
Everything about one post in a single call: the post itself plus a sample of its comments. Use this when deciding whether a post is worth replying to. Read-only.
Inputs: post_url (required), comment_sample.
list_pending_actionsList staged actionsARead-only
Show write actions that are staged and waiting for confirmation, with their previews and expiry times. Read-only.
Inputs: no named parameters.
open_facebook_loginOpen the Facebook login windowARead-only
Launch the browser, bring the window to the front on Facebook, and wait for the user to log in by hand. Types nothing and submits nothing — it only watches for the session to go live so it can confirm the profile was saved. Safe to call when already logged in: it reports that immediately without disturbing the page. If the user needs longer than wait_seconds (a 2FA code, a checkpoint), the call returns and you simply call it again or run check_facebook_session — the window stays open and their progress is not lost.
Inputs: wait_seconds.
open_groupOpen a Facebook GroupARead-only
Open a group and read its visible posts, newest first by default. Returns the group's metadata plus each post with its URL, author, text and timestamp. Read-only — it will not join the group. Private groups you are not a member of will return group metadata and no posts, which is reported explicitly rather than as an error.
Inputs: group_url (required), sort, limit, expand_text, +1 more.
open_pageOpen a Facebook PageARead-only
Open a Facebook Page and read its visible posts. Returns Page metadata plus posts. Read-only — it will not follow or like the Page.
Inputs: page_url (required), limit, expand_text, scroll_rounds.
open_postOpen a postARead-only
Open a single post by URL and return its full content: author, text (expanded), timestamp, engagement counts, group or Page attribution, and any external link. Read-only.
Inputs: post_url (required).
post_commentComment on a post (staged)A
Stage a comment on a Facebook post. This does NOT post anything: it opens the post, builds a preview showing the post and your exact comment text, and returns a confirmation_token. Show the preview to the user and call confirm_action only after they explicitly approve it.
Inputs: post_url (required), comment_text (required), require_confirmation.
react_to_postReact to a post (staged)A
Stage a reaction on a post. Does NOT react yet — returns a preview and a confirmation_token. Reactions are public and attributed to you, so they go through the same approval step as comments.
Inputs: post_url (required), reaction, require_confirmation.
read_commentsRead a post's commentsARead-only
Read the comment thread on a post. Attempts to switch the thread out of Facebook's "Most relevant" ordering into "All comments" and says in the result whether that succeeded — so you know whether you are seeing the whole thread or a filtered selection. Read-only.
Inputs: post_url (required), limit, sort_all, expand_replies, +1 more.
read_postRead a postBRead-only
Identical to open_post: fetch one post by URL and return its full content. Read-only.
Inputs: post_url (required).
search_facebookSearch FacebookARead-only
Search Facebook and return structured results. result_type picks the search tab: posts, groups, pages or people. Read-only. Results are limited to what the Facebook UI actually renders for your account.
Inputs: query (required), limit, location, result_type, +1 more.
search_groupsSearch Facebook GroupsARead-only
Find Facebook Groups matching a query. Returns each group's name, URL, privacy setting, member count and, where visible, whether this account is already a member. Read-only — it never sends a join request.
Inputs: query (required), limit, location, scroll_rounds.
search_in_groupSearch within a GroupARead-only
Use Facebook's own in-group search to find posts matching a query inside one group. Much cheaper than scrolling the whole feed when you already know the keyword. Read-only.
Inputs: query (required), group_url (required), limit, expand_text, +1 more.
search_pagesSearch Facebook PagesARead-only
Find Facebook Pages matching a query. Returns name, URL, category, follower label and verification badge. Read-only.
Inputs: query (required), limit, location, scroll_rounds.
selector_healthcheckSelector health checkARead-only
Report which Facebook DOM strategies have been matching, and which have fallen back to a lower-tier candidate or missed entirely. A degraded strategy is the early warning that Facebook changed its markup — it means extraction still works but is running on a more brittle fallback.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 24 tools
read_post and open_post are explicitly documented as identical, creating a clear ambiguity. get_post_details and draft_comment also overlap in fetching post content and comments, making it difficult to choose the right tool at a glance.
Names mix styles: verb_noun (open_group, create_post), preposition phrases (react_to_post, search_in_group), and noun-like names (selector_healthcheck, browse_feed). Some have inconsistent prefixing (open_facebook_login vs check_facebook_session). No uniform convention is applied.
24 tools is at the high end of the acceptable range for a feature-rich Facebook client, but the presence of redundant tools (read_post/open_post) and overlapping fetch-comment tools inflates the count. A tighter set could achieve the same functionality with fewer entries.
The tool set covers the core Facebook read and write workflows comprehensively, including staged approvals and session management. Missing operations like editing or deleting posts/comments are minor gaps given the read-heavy focus and safety-conscious write design.
Maintenance
Related MCP Connectors
Hosted Web Crawler MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Hosted X (Twitter) MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Browser MCP for logged-in tasks. Uses your Chrome — credentials stay local. Zero-token replay.
Hosted Meta Ads MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA Chrome browser automation MCP server. Connect Claude (or any MCP client) to a real Chrome session — using your existing profiles with their cookies, saved passwords, and history.3-
- AlicenseAqualityBmaintenanceA Facebook/Messenger MCP server that lets AI agents read and engage with profiles, pages, posts, comments, groups, Messenger conversations, notifications, and events using the user's existing browser session cookies — no Graph API app, tokens, or browser automation required. It supports multi-account and Page switching, write operations (posting, commenting, messaging) with per-identity limits and cooldowns, and honest error reporting where Meta has decommissioned cookie-era endpoints.411MIT
- AlicenseNot gradedqualityAmaintenanceA local MCP server that lets AI coding tools drive the user's actual, already-logged-in Chrome browser — snapshotting pages, clicking, typing, navigating, reading content, taking screenshots, and inspecting cookies, network traffic, and console output. Browser automation happens through a Chrome extension using Native Messaging, so no remote-debugging port is exposed and all communication stays on the local machine.1 npmISC
- AlicenseNot gradedqualityAmaintenanceA local MCP server that enables AI coding tools to drive the user's real, already-logged-in Chrome browser — reading pages, clicking, typing, navigating tabs, screenshots, and cookie, network, and storage access — without opening a remote-debugging port.1 npmISC