An MCP server that exposes Facebook Messenger as a tool suite for AI assistants. It connects to your Facebook account and lets MCP clients send messages, react, manage threads, share media, and use end-to-end-encrypted chats.
Runs on both Node.js and Bun.
| Category | Tools |
|---|---|
| Messaging | sendMessage, sendReaction, editMessage, unsendMessage, sendTypingIndicator, markAsRead |
| Users | getUserInfo, searchUsers |
| Threads | createThread, renameThread, deleteThread, muteThread, unmuteThread |
| Media | uploadMedia, sendImage, sendVideo, sendVoice, sendFile, sendSticker, setGroupPhoto |
| E2EE | sendE2EEMessage, sendE2EEReaction, sendE2EETyping, editE2EEMessage, unsendE2EEMessage, sendE2EEImage, sendE2EEVideo, sendE2EEAudio, sendE2EEDocument, sendE2EESticker, downloadE2EEMedia |
| Device | getDeviceData, registerPushNotifications |
- Node.js >= 22.12 or Bun >= 1.0 (required by the
meta-messenger.jsFFI layer) - A Facebook account with a valid session (see Configuration)
With npm:
npm install -g fb-chat-mcpOr run without installing:
npx -y fb-chat-mcp@latestWith bun:
bun add -g fb-chat-mcp
# or
bunx fb-chat-mcp@latestbun users: bun blocks package postinstall scripts by default. The native library is fetched by
fb-chat-mcp's postinstall, so trust it (and its native dependency) first:bun pm trust fb-chat-mcp meta-messenger.js && bun install
The server needs your Facebook session cookies to connect. Point it at a cookies file with the FB_COOKIES_PATH environment variable:
export FB_COOKIES_PATH=/path/to/cookies.json
fb-chat-mcpThe file must contain the cookie values (not headers) for facebook.com:
{
"c_user": "100012345678901",
"xs": "abcdefgh...",
"datr": "xyz...",
"fr": "1abc...Z"
}If FB_COOKIES_PATH is unset, the server looks for .tmp/cookies.json relative to the current working directory.
Cookie persistence. The server stores the cookies it uses (refreshed periodically from the session) in place, at the resolved cookies path:
- If
FB_COOKIES_PATHis set, that file is used exclusively for both reading and writing. - Otherwise,
.tmp/cookies.json(relative to the current working directory) is used. - The file is refreshed automatically, so you generally only need to provide cookies once.
- If there are no valid cookies at the resolved path, the server exits with a
No cookies founderror.
Migrating from an older version? Previously the server also kept a copy at
~/.config/fb-chat-mcp/cookies.json. Copy that file toFB_COOKIES_PATHor.tmp/cookies.jsonto keep using it.
To get the values: log in to facebook.com in a browser, open DevTools → Application → Cookies, and copy the c_user, xs, datr, and fr cookie values.
Point your MCP client at the server with stdio. Example for Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"fb-chat-mcp": {
"command": "npx",
"args": ["-y", "fb-chat-mcp@latest"],
"env": {
"FB_COOKIES_PATH": "/absolute/path/to/cookies.json"
}
}
}
}With bun:
{
"mcpServers": {
"fb-chat-mcp": {
"command": "bunx",
"args": ["fb-chat-mcp@latest"],
"env": {
"FB_COOKIES_PATH": "/absolute/path/to/cookies.json"
}
}
}
}bun install # install dependencies
bun run build # compile src/ to Node-compatible dist/index.js
bun run test # run the test suite
bun run lint # prettier + eslintRelease a new version (bumps package.json, pushes main, creates release/v*):
bun scripts/release.ts patch # major | minor | patchA GitHub workflow publishes to npm when a release/v* branch is pushed.
Native library not found ... Run: npm run build:go
The messagix native binary failed to download during install. Re-run the install, or fetch it explicitly:
npm install # npm will re-run the postinstall
bun pm trust fb-chat-mcp meta-messenger.js && bun installCookies file not found at ...
Point FB_COOKIES_PATH at a valid cookies file (see Configuration), or drop one at .tmp/cookies.json.
No cookies found ...
The server couldn't find valid cookies at the resolved path (FB_COOKIES_PATH, or .tmp/cookies.json when unset). Drop a cookies JSON there and restart.
AGPL-3.0-or-later — this project depends on meta-messenger.js, which is licensed under the GNU Affero General Public License v3.