meta-ads
Meta Ads MCP
Meta(Facebook)広告 Graph API を MCP サーバーとしてラップし、Claude(Desktop / Claude Code)から直接呼び出せるようにします。会社の同僚は会話形式で広告の効果やクリエイティブを確認できるようになります。
PDF 仕様に対応する 2 つの API:
Tool | Endpoint | 用途 |
|
| 費用、インプレッション、リーチ、クリック、CTR/CPC/CPM、actions、動画視聴率などを取得 |
|
| 単一広告のクリエイティブ(画像、コピー、CTA、投稿リンク)を取得 |
2 つの実行方法
モード | 適用 | Transport |
stdio(デフォルト) | ローカル / 個人利用 / 開発 | Claude Desktop が子プロセスを spawn |
http | EC2 / コンテナ / 全社共有 | streamable-http + Bearer auth |
A. ローカル(stdio)
Related MCP server: Meta Ads MCP Server
インストール
cd C:\Users\bexo6\OneDrive\桌面\mcp_meta_claude
uv sync
Copy-Item .env.example .env # 然後填好 META_ACCESS_TOKEN 等Claude Desktop に接続
%APPDATA%\Claude\claude_desktop_config.json を編集:
{
"mcpServers": {
"meta-ads": {
"command": "uv",
"args": [
"--directory",
"C:\\Users\\bexo6\\OneDrive\\桌面\\mcp_meta_claude",
"run",
"python",
"server.py"
]
}
}
}Claude Desktop を再起動 → Settings → Developer に meta-ads が表示されるはずです。
B. EC2 にデプロイして全社で利用(http)
すでに EC2 + nginx + HTTPS が
https://ai.gastom.com.twで稼働している前提です。 Caddy は追加でインストールせず、MCP コンテナ(127.0.0.1:8000にバインド)だけを実行し、既存の nginx でhttps://ai.gastom.com.tw/meta-ads/*を転送します。
1. 共有 Bearer token を生成
python3 -c "import secrets; print(secrets.token_urlsafe(32))"文字列を保存しておきます(パスワード管理ツール / 社内 vault)。後で:
EC2 の
.envに書き込む同僚に配布して Claude Desktop に記入してもらう
2. コードを EC2 に配置
ssh your-user@ec2-host
git clone <你的 repo 位置> meta-ads-mcp
cd meta-ads-mcp
cat > .env <<'EOF'
META_ACCESS_TOKEN=<長效 Graph API token>
META_AD_ACCOUNT_ID=act_870176260326362
MCP_BEARER_TOKEN=<上一步產生的字串>
EOF
chmod 600 .env3. MCP コンテナを起動
docker compose up -d --build
docker compose logs -f mcp # 看到 "Uvicorn running on http://0.0.0.0:8000" 就 OKEC2 ローカルから検証(まだ nginx 経由ではない):
curl -i http://127.0.0.1:8000/healthz # 200
curl -i -X POST http://127.0.0.1:8000/mcp # 401(沒 token)4. nginx に location を追加
deploy/nginx-meta-ads.conf の内容を既存の
server { listen 443 ssl; server_name ai.gastom.com.tw; ... } ブロックに貼り付けて、次に:
sudo nginx -t # 語法檢查
sudo systemctl reload nginx # 套用外部ネットワークから検証:
curl -i https://ai.gastom.com.tw/meta-ads/healthz # 200
curl -i -X POST https://ai.gastom.com.tw/meta-ads/mcp # 401
curl -i -X POST -H "Authorization: Bearer <你的token>" \
-H "Accept: application/json, text/event-stream" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"t","version":"1"}}}' \
https://ai.gastom.com.tw/meta-ads/mcp # 200 + serverInfo5. 同僚の Claude Desktop 設定
各同僚は %APPDATA%\Claude\claude_desktop_config.json(macOS:~/Library/Application Support/Claude/claude_desktop_config.json)に追加:
{
"mcpServers": {
"meta-ads": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://ai.gastom.com.tw/meta-ads/mcp",
"--header",
"Authorization: Bearer 上面產生的_MCP_BEARER_TOKEN"
]
}
}
}同僚の PC には Node.js(
npxを実行するため)が必要です。mcp-remoteが stdio と HTTPS エンドポイントの間を中継するため、Python / uv / あなたのコードをインストールする必要はありません。
アップグレード / 更新手順
cd /path/to/meta-ads-mcp
git pull
docker compose up -d --build停止
docker compose downToken のローテーション
token が漏洩した場合や定期的に更新する場合:
EC2 で
.envのMCP_BEARER_TOKENを変更docker compose up -d(mcp コンテナが recreate されます)新しい token を同僚に配布し、彼らの
claude_desktop_config.jsonを更新
会話例
「2026-03-23 から 2026-03-25 までの広告データを取得して、費用上位 3 つの広告をリストアップして」
「広告 ID
120228265609960545のクリエイティブがどんなものか見せて」
Claude は自動的に get_ad_insights を呼び、その後特定の ad_id に対して get_ad_creative を呼びます。
セキュリティ上の注意事項
.envは絶対に commit しない:.gitignoreで除外済み。MCP_BEARER_TOKENは会社の予算の鍵:誰でも Meta API を呼び出して会社の広告費を使えます。パスワードと同等の扱いで保管してください。HTTPS は必須:Bearer token を HTTP で送信すると平文で転送されることになります。
EC2 Security Group:80/443 以外のポート(特に 22)は社内 IP 範囲に制限することを推奨します。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Conversational access to advertising performance data, creative analysis, and campaign insights
Conversational access to advertising performance data, creative analysis, and campaign insights
Query Meta Ads performance data — accounts, campaigns, ad sets, ads, metrics & settings.
Ask AI about your ads — query Meta, TikTok, and Google Ads performance in natural language.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceWraps the Meta Marketing API to enable creating, modifying, viewing, and deleting Instagram ads via natural language.27MIT
- AlicenseNot gradedqualityDmaintenancePython MCP server that exposes Meta Marketing API data, providing tools to manage ad accounts, campaigns, and analytics through natural language interfaces.MIT
- AlicenseNot gradedqualityDmaintenanceEnables management and analysis of Meta (Facebook/Instagram) ads through natural language conversations, with 30 tools for reading and writing ad data.MIT
- AlicenseNot gradedqualityDmaintenanceEnables full read/write management of Facebook ad campaigns, ad sets, ads, and creatives via the Meta Marketing API through natural language, with AI creative generation, performance analytics, and PDF reporting.MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/vitahuang629/mcp_meta_ads_claude'
If you have feedback or need assistance with the MCP directory API, please join our Discord server