MCP
MCP, or Model Context Protocol, is a standard for connecting external tools with AI models.
Bookface comes with a built-in MCP server that allows your AI agents to interact with the Facebook API.
You need to be authenticated before you can use the MCP. If you haven't set up authentication yet, start with the getting started and authentication guides.
If you're launching the MCP from a different process (IDEs, desktop apps, remote shells), you'll also want to make your credentials are available globally and skip to the stdio section.
Prerequisites
Log in and, if needed, store credentials globally.
Starting the MCP
There are two ways to run the server: Streamable HTTP (recommended for most GUI agents) and stdio (for CLI/agent runtimes that speak MCP over the terminal).
While Streamable HTTP is often more convenient, stdio is more widely supported by MCP clients (like Claude Desktop).
For more information on these different methods, check out the MCP transport documentation.
stdio
Specify a profile (defaults to page
), or run both with dual
.
stdio is the more widely supported method for transport, so it's likely what you need.
To run stdio in clients like Claude Desktop or Cursor, you can use the following command.
The above command is probably the command you're looking for.
This runs the MCP server directly though npm so that the package is installed as it is run. This is useful for running the MCP in isolated environments, where clients like Cursor or Claude Desktop like to work.
Streamable HTTP
Start a local HTTP server. The CLI will automatically pick an available port and print the URLs.
To expose both page and user tools on a single endpoint, run the following.
Once the MCP server is running, you'll see different endpoints for the different profiles.
http://127.0.0.1:<port>/mcp/page
- page toolshttp://127.0.0.1:<port>/mcp/user
- user toolshttp://127.0.0.1:<port>/mcp/main
- combined tools (when using--dual
)
You can then use these endpoints to plug into any MCP-compatible agent.
You can check whether the server is running by fetching the health endpoint, /mcp/page
, /mcp/user
, or /mcp/main
.
If your agent cannot access files in your current directory, use
facebook credentials store
first so the MCP can read credentials from a
global config directory.
Profiles
The MCP exposes tools in three modes.
- page: Act as a Facebook Page (recommended)
- user: Act as a personal profile
- dual: Expose both page and user tools on one endpoint
Meta has deprecated most user publishing operations. Prefer the page
profile
for creating content. User tools may return errors depending on your app's
permissions/status.
Programmatic Usage
If you need to mount the MCP inside your own server, you can use the same handlers the CLI uses.
This allows you handle more advanced, custom use cases.
import express from "express";
import { MCPHandler, sessionHandler } from "bookface/mcp";
const app = express();
app.use(express.json());
app.get(["/mcp/user", "/mcp/page", "/mcp/main"], (req, res) => {
res.send("MCP Running");
});
// Choose one profile per endpoint, or mount a dual endpoint
app.post("/mcp/page", (req, res) => MCPHandler(req, res, "page"));
app.post("/mcp/user", (req, res) => MCPHandler(req, res, "user"));
app.post("/mcp/main", (req, res) => MCPHandler(req, res, "dual"));
// Session management used by MCP clients
app.get("/mcp", (req, res) => sessionHandler(req, res));
app.delete("/mcp", (req, res) => sessionHandler(req, res));
app.listen(3000);
For more information on how to use these handlers, you can see the source code/documentation below.
Loading documentation...