Skip to main content
Glama
anthonyjbolo

io.github.anthonyjbolo/mcp-fb-publisher

by anthonyjbolo

mcp-fb-publisher

An MCP server that lets Claude (or any MCP-compatible LLM) safely publish posts to multiple Facebook Pages through the Meta Graph API, with built-in guardrails: brand-voice config, banned-topic blocklists, image-required enforcement, and anti-duplication checks across recent feed posts.

Tests License: MIT Python 3.12+ #BuiltOnClaudeCode

Why this exists

Letting an LLM agent post directly to your Facebook Pages is a footgun unless you put guardrails in front. Common failure modes I have hit running 5+ pages:

  1. Token expired silently — post fails at midnight, nobody notices for 3 days.

  2. Same angle posted twice in 14 days — audience tunes out, reach drops.

  3. Text-only post when the brand voice mandates an image — engagement craters.

  4. Banned topic leaked — competitor name, internal codename, or deprecated product mentioned.

mcp-fb-publisher ships an MCP server that wraps the Meta Graph API behind 4 deterministic tools, all driven by a single config.yaml. Every publish call goes through validation by default. Validation is pure-Python (no LLM), reproducible in CI, and runs offline.

Related MCP server: social0-mcp

What it does

4 MCP tools:

Tool

What it does

fb_publish_post

Publishes (or schedules) a post on a configured page. Runs full validation by default; pass skip_validation=True to bypass.

fb_validate_pre_publish

Dry-run all guardrails. Returns `verdict: go

fb_anti_duplicate_check

Compares a candidate message against the page's recent posts using Jaccard similarity over word 4-grams.

fb_generate_post_with_image

Generates an image via OpenAI (gpt-image-1) or fal.ai (flux-pro) and returns a URL ready for fb_publish_post.

5-minute quickstart

# 1. Install
pip install mcp-fb-publisher

# 2. Copy and edit the example config
cp config.example.yaml config.yaml
# -> set page_id values, brand voices, banned_topics

# 3. Set required env
export META_USER_TOKEN="<your long-lived Meta page/user token>"
export MCP_FB_PUBLISHER_CONFIG="$PWD/config.yaml"

# 4. (Optional) for image generation
export OPENAI_API_KEY="sk-..."        # or
export FAL_KEY="..."

# 5. Run the MCP server (stdio transport)
mcp-fb-publisher

Wire it into Claude Desktop / Claude Code

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "fb-publisher": {
      "command": "mcp-fb-publisher",
      "env": {
        "META_USER_TOKEN": "your_token_here",
        "MCP_FB_PUBLISHER_CONFIG": "/absolute/path/to/config.yaml",
        "OPENAI_API_KEY": "sk-..."
      }
    }
  }
}

Then ask Claude things like:

"Post on the marketing page: 'New collection drops Friday'. Generate an image first, validate, then publish."

Claude will call fb_generate_post_with_imagefb_validate_pre_publishfb_publish_post.

Architecture

flowchart LR
  A[Claude / MCP client] -->|tool call| B[FastMCP server]
  B --> C{tool}
  C -->|generate| D[OpenAI / fal.ai]
  C -->|validate| E[Validator<br/>pure Python]
  C -->|anti-dup| F[Meta Graph API<br/>fetch_recent_posts]
  C -->|publish| G[Meta Graph API<br/>POST /feed or /photos]
  E -.reads.-> H[(config.yaml<br/>per-page rules)]
  G -.reads.-> H
  F -.reads.-> H

The split between generation, validation and publish is intentional: it lets the LLM iterate on the visual without burning Meta API quota, and it makes the guardrails inspectable in CI without a Meta account.

Anti-duplication strategy

We compare the candidate message against every post within anti_duplicate_lookback_days (per-page, default 14) using Jaccard similarity over word 4-grams:

  1. Normalize: lowercase, strip accents (NFKD), drop URLs, drop punctuation, collapse whitespace.

  2. Build the set of word-level 4-grams for both texts.

  3. similarity = |A ∩ B| / |A ∪ B|

  4. If similarity >= similarity_threshold (default 0.5), block.

Why this and not embeddings: deterministic, free, no extra API key, fast enough for 50 candidates per call. If you want LLM-grade semantic comparison, add another layer on top — the fb_validate_pre_publish tool returns the score so your agent can decide.

Brand voice config

defaults:
  language: en
  brand_voice: |
    Direct, professional, no fluff.
  banned_topics: []
  image_required: true
  anti_duplicate_lookback_days: 14

pages:
  marketing_main:
    page_id: "0000000000000000"
    name: "My Brand — Main"
    brand_voice: |
      Confident, concise, customer-first.
    banned_topics:
      - competitor_brand_a
      - leaked_codename
    image_required: true

  community:
    page_id: "0000000000000002"
    name: "Community"
    image_required: false

Note: the brand_voice field is informational — it's surfaced to the calling LLM via the tool description but the server itself does not LLM-validate against it. This is by design (tests must run offline). Layer your own LLM check on top if you want enforcement.

Use cases

1. Multi-page agency

You manage 5 Facebook pages for clients. Each has its own brand voice, banned topics (competitor names), and image policy. Configure them all in one config.yaml, give Claude the tool, and let the agent draft + validate + publish across all of them with safety rails.

2. Solo founder

You run a single product page and want Claude to schedule the next 30 days of posts. Set image_required: true, give the agent your product brief, and use fb_anti_duplicate_check to make sure no two posts land on the same angle within a fortnight.

3. E-commerce

You rotate flash promos. Set anti_duplicate_lookback_days: 7 for the promo page and 14 for the evergreen content page. Combine with scheduled_at to queue a week's worth of posts in one shot.

Development

git clone https://github.com/anthonyjbolo/mcp-fb-publisher.git
cd mcp-fb-publisher

python3.12 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev,openai,fal]"

# Run the test suite (offline, no Meta credentials needed)
pytest

# Lint
ruff check .

All tests use httpx.MockTransport and pytest-mock. No real Meta API calls in tests.

Security

  • The Meta token is read from META_USER_TOKEN only. Never hard-code it.

  • Token strings are redacted from error messages (***REDACTED***) before they leave the process.

  • The validator is sync and offline — safe to run in CI without exposing credentials.

  • config.yaml is in .gitignore. Only config.example.yaml is committed.

Roadmap

  • Instagram Graph API support (the validator already works, only the meta_client publish path needs adapting).

  • Optional ntfy webhook on publish failure.

  • LLM-grade brand-voice scoring as an opt-in tool.

  • Token rotation helper (fb_check_token_expiry).

En français — pourquoi ce projet

Construit en Nouvelle-Calédonie pour gérer 5 pages FB en parallèle (auto-école, marketplace de bingo, atelier d'apps, marque de tee-shirts, page média). Tous les écueils ci-dessus sont des bugs que j'ai vraiment vécus. Le serveur MCP est la couche que j'aurais aimé avoir le premier jour — maintenant elle est libre.

License

MIT — see LICENSE.

Contributing

Issues + PRs welcome. Please run pytest and ruff check . before opening a PR. For substantial features, open an issue first to discuss.

#BuiltOnClaudeCode

Available Tools

4 tools
fb_anti_duplicate_checkA

Compare a candidate message against recent posts on the page.

Args: page_id: Numeric Meta Page ID. message: Candidate text to score. lookback_days: Max age of posts to compare against (default 14). similarity_threshold: Jaccard threshold above which it's "too similar" (default 0.5; 0.0=identical, 1.0=nothing in common — careful, that's inverted intuitively. 0.5 = ~half the 4-grams overlap). page_access_token: Optional page-scoped token.

Returns: Dict with is_duplicate, closest_post_id, closest_similarity, posts_compared, lookback_days.

ParametersJSON Schema
NameRequiredDescriptionDefault
page_idYes
messageYes
lookback_daysNo
similarity_thresholdNo
page_access_tokenNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. Discloses inverted similarity threshold and Jaccard method, but does not mention read-only nature or when page_access_token is required.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-structured with Args/Returns, front-loaded main purpose. Some verbosity around threshold is justified but could be tightened.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers all parameters and return values (output schema exists). Minor gaps: missing behavior for empty recent posts and auth token necessity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

All 5 parameters are described with details beyond schema (e.g., 'numeric Meta Page ID', Jaccard explanation). Schema coverage is 0%, so description compensates fully.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states 'compare a candidate message against recent posts on the page', specifying action and resource. Distinct from sibling tools (generating, publishing, validating).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied (pre-publish duplicate check) but no explicit when-to-use or alternatives. Sibling tools are different, so no direct competition, but guidance could be stronger.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

fb_generate_post_with_imageA

Generate an image for a candidate post and return a usable URL.

Does NOT publish. Caller is expected to take the returned image_url and pass it to fb_publish_post (or further validate via fb_validate_pre_publish). This separation lets the LLM iterate on the visual without burning Meta API quota.

Args: page_id: Numeric Meta Page ID (used only to resolve provider defaults). prompt: Image generation prompt (English recommended). image_provider: "openai" | "fal". Defaults to config.image_providers.default.

Returns: Dict with image_url, provider, model, prompt.

ParametersJSON Schema
NameRequiredDescriptionDefault
page_idYes
promptYes
image_providerNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Given no annotations, the description covers key behaviors: no publishing, returns URL, allows iteration. It lacks rate limit or error details but is sufficient for a read-like generation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear summary, usage note, parameter details, and return description. Every sentence is concise and purposeful.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers purpose, workflow, parameters, and return values. It could mention error handling or limits, but for the complexity it is complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Despite 0% schema description coverage, the description's 'Args' section thoroughly explains each parameter, including defaults and recommended input, adding significant value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool generates an image for a candidate post and returns a usable URL, explicitly distinguishing it from publishing tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides explicit guidance: 'Does NOT publish' and directs the caller to use fb_publish_post or fb_validate_pre_publish next, including rationale about quota management.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

fb_publish_postA

Publish a post on a Facebook Page via Meta Graph API.

Args: page_id: Numeric Meta Page ID. message: Post message body. image_url: Optional public URL of an image. If config requires images, this MUST be provided (validation will block otherwise). scheduled_at: Optional unix timestamp (seconds). If set, the post is scheduled instead of published immediately. Meta requires 10 minutes <= delta <= 6 months. page_access_token: Optional page-scoped token. Required by Meta in production for posting on a Page (the env-level token is usually a user token; you can derive a page token from /me/accounts). skip_validation: If True, bypasses the pre-publish validator (image required, banned topics, anti-duplicate). Default False — strongly recommended to keep validation on.

Returns: Dict with ok, post_id (if success), error (if failure), and a validation block when validation ran.

ParametersJSON Schema
NameRequiredDescriptionDefault
page_idYes
messageYes
image_urlNo
scheduled_atNo
page_access_tokenNo
skip_validationNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses key behaviors: skip_validation bypasses checks, scheduled_at time constraints, image required conditionally, and the return structure. It also explains the need for page_access_token in production. However, it does not mention rate limits or detailed error scenarios beyond the return block.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured as a docstring with clear sections for each parameter and the return value. It is verbose but every line adds value. Minor improvement possible by shortening some explanations, but overall efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 6 parameters (2 required), no annotations, and an output schema mentioned, the description covers all parameters, their constraints, and the return value. It does not mention sibling tools explicitly but the purpose is clear. Missing error handling examples or advanced edge cases, but still sufficiently complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description provides rich details for each parameter: image_url's conditional requirement, scheduled_at's time delta constraints, page_access_token's derivation and necessity, and skip_validation's default/impact. This fully compensates for the missing schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Publish a post on a Facebook Page via Meta Graph API.' It uses a specific verb ('Publish') and resource ('post on a Facebook Page'), and the sibling tools (anti-duplicate check, generate with image, validate) are distinct, so there is no confusion.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

While the description explains parameters in detail, it does not explicitly state when to use this tool versus the sibling tools (fb_anti_duplicate_check, fb_generate_post_with_image, fb_validate_pre_publish). The context implies that this is the main publishing tool, but no when-not-to-use or alternative guidance is given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

fb_validate_pre_publishA

Run all guard-rails BEFORE publishing.

Checks: - image_required (per-page config) - banned_topics (substring, accent-insensitive) - length (10..63206 chars) - anti_duplicate (Jaccard 4-grams vs recent posts, lookback per config)

Args: page_id: Numeric Meta Page ID. message: Candidate post text. image_url: Optional candidate image URL. fetch_recent: If True (default), fetches recent posts from Meta to run the anti-duplicate check. Set False to skip network. page_access_token: Optional page-scoped token (used only if fetch_recent).

Returns: Dict with verdict ("go"|"block"), per-check details, errors.

ParametersJSON Schema
NameRequiredDescriptionDefault
page_idYes
messageYes
image_urlNo
fetch_recentNo
page_access_tokenNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses network call dependency (fetch_recent, page_access_token) and details of checks (e.g., Jaccard index). No annotation support; description carries burden well, though potential side effects are not fully covered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Efficient structure: intro line, bulleted checks, parameter list. Every sentence adds value. No fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers checks, parameters, return value. Given no annotations and 0% schema coverage, description is thorough. Minor omission: no details on error handling or exact output dict keys.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema coverage, detailed parameter descriptions compensate fully: values, defaults, purpose (e.g., fetch_recent 'Set False to skip network'). Adds meaning beyond schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clear verb+resource: validates pre-publish. Lists four specific checks, differentiating from sibling tools like fb_anti_duplicate_check which only performs one check.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states 'BEFORE publishing', giving clear usage context. Describes optional fetch_recent behavior, but doesn't explicitly contrast with siblings or state when not to use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv0.1.1
    • First observedfb_anti_duplicate_check
    • First observedfb_generate_post_with_image
    • First observedfb_publish_post
    • First observedfb_validate_pre_publish

TDQS

A4.4/5.0

Scored across 4 tools

Disambiguation5/5

Each tool has a distinct purpose: duplicate checking, image generation, publishing, and pre-publish validation. Descriptions clearly differentiate their roles with no overlap.

Naming Consistency5/5

All tools follow the 'fb_verb_noun' pattern in snake_case, e.g., fb_anti_duplicate_check, fb_publish_post, maintaining a predictable and consistent naming convention.

Tool Count5/5

With 4 tools covering validation, duplicate check, image generation, and publishing, the count is well-scoped for a Facebook publishing server—neither too few nor excessive.

Completeness4/5

Core publishing workflow is covered: validate, generate image, check duplicates, publish. Missing edit/delete tools are not critical for the stated purpose, so only minor gaps exist.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    A
    quality
    D
    maintenance
    A Model Context Protocol (MCP) server implementation that provides Facebook Page interaction and management capabilities. This server enables automated posting, comment moderation, and content retrieval.
    7
    75
    -
  • A
    license
    A
    quality
    B
    maintenance
    MCP server to manage social media accounts from AI assistants, enabling post creation, scheduling, publishing, and media uploads across multiple platforms.
    13
    182
    1
    MIT
  • A
    license
    A
    quality
    A
    maintenance
    A TypeScript MCP server for the Meta Graph API focused on Facebook Pages, enabling publishing, reading, insights, and moderation tasks.
    30
    28
    1
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    MCP server for Facebook Pages organic analytics and management using Meta Graph API v25.0. Enables AI assistants to read page insights, posts, comments, and publish content via natural language.
    9
    37
    MIT

Appeared in Searches