Facebook Publisher

io.github.anthonyjbolo由 GitHub 账号 anthonyjbolo 发布v0.1.1更新于 Oct 24, 2026

Safe Facebook Pages publishing with brand-voice, image-required & anti-duplication checks.

概览

AI 生成的概览

本地 MCP 服务器,让助手通过 Meta Graph API 校验、生成配图,并向多个 Facebook 主页发布或定时发布帖子。

可以做什么
在已配置的 Facebook 主页上发布或定时发布帖子,默认执行校验,也可选择跳过。发布前试运行全部防护规则,返回放行或拦截的结论及各项检查详情。用词 4-gram 相似度将草稿与主页近期帖子比对,避免重复角度。通过 OpenAI 或 fal.ai 生成配图并返回可直接发布的图片地址。所有行为由按主页配置的文件驱动,包含品牌语气、禁用话题和图片策略。
适用场景
适合让助手起草、检查并发布一个或多个 Facebook 主页内容,例如代运营客户主页的机构、需要排期一个月帖子的独立创业者,或按不同回溯窗口轮换促销的电商。
运行要求
以 stdio 在本地运行,从 PyPI 安装(例如用 uvx)并在 MCP 客户端中配置。需要长期有效的 Meta Graph API 用户或主页令牌,放在 META_USER_TOKEN;配置文件路径放在 MCP_FB_PUBLISHER_CONFIG,或使用 MCP_FB_PUBLISHER_CONFIG_JSON 内联 JSON。图片生成可选,需要 OPENAI_API_KEY 或 FAL_KEY。需能访问 Meta Graph API 网络。
安装前请注意
发布会向公开的 Facebook 主页写入真实内容,skip_validation 会绕过防护规则。META_USER_TOKEN 中的 Meta 令牌具有发帖权限,应避免提交到版本库。brand_voice 字段仅供参考,服务器不会据此校验。图片生成会把提示词发送给 OpenAI 或 fal.ai,可能产生费用。防重复是确定性的文本相似度检查,并非语义比对。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Facebook Publisher,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

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.

What it does

4 MCP tools:

ToolWhat it does
fb_publish_postPublishes (or schedules) a post on a configured page. Runs full validation by default; pass skip_validation=True to bypass.
fb_validate_pre_publishDry-run all guardrails. Returns `verdict: go
fb_anti_duplicate_checkCompares a candidate message against the page's recent posts using Jaccard similarity over word 4-grams.
fb_generate_post_with_imageGenerates an image via OpenAI (gpt-image-1) or fal.ai (flux-pro) and returns a URL ready for fb_publish_post.

5-minute quickstart

bash
# 1. Installpip install mcp-fb-publisher
# 2. Copy and edit the example configcp config.example.yaml config.yaml# -> set page_id values, brand voices, banned_topics
# 3. Set required envexport META_USER_TOKEN="<your long-lived Meta page/user token>"export MCP_FB_PUBLISHER_CONFIG="$PWD/config.yaml"
# 4. (Optional) for image generationexport OPENAI_API_KEY="sk-..."        # orexport 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:

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_image → fb_validate_pre_publish → fb_publish_post.

Architecture

mermaid
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

yaml
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

bash
git clone https://github.com/anthonyjbolo/mcp-fb-publisher.gitcd mcp-fb-publisher
python3.12 -m venv .venvsource .venv/bin/activatepip install -e ".[dev,openai,fal]"
# Run the test suite (offline, no Meta credentials needed)pytest
# Lintruff 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

来源:README.md,提交 fba681d

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分