meta-ads
Meta Ads MCP
Verpackt die Meta (Facebook) Ads Graph API als MCP-Server, damit Claude (Desktop / Claude Code) sie direkt aufrufen kann. Kollegen können so per Dialog Werbeerfolge und Creatives abfragen.
Die beiden APIs gemäß PDF-Spezifikation:
Tool | Endpoint | Zweck |
|
| Ausgaben, Impressions, Reichweite, Klicks, CTR/CPC/CPM, Actions, Video-View-Rate usw. abrufen |
|
| Creatives einzelner Anzeigen abrufen (Bild, Text, CTA, Post-Link) |
Zwei Ausführungsmodi
Modus | Geeignet für | Transport |
stdio (Standard) | Lokal / Einzelperson / Entwicklung | Claude Desktop startet Unterprozess |
http | EC2 / Container / Firmenweit | streamable-http + Bearer-Auth |
A. Lokal (stdio)
Related MCP server: Meta Ads MCP Server
Installation
cd C:\Users\bexo6\OneDrive\桌面\mcp_meta_claude
uv sync
Copy-Item .env.example .env # 然後填好 META_ACCESS_TOKEN 等Anbindung an Claude Desktop
Bearbeiten Sie %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"meta-ads": {
"command": "uv",
"args": [
"--directory",
"C:\\Users\\bexo6\\OneDrive\\桌面\\mcp_meta_claude",
"run",
"python",
"server.py"
]
}
}
}Nach dem Neustart von Claude Desktop → Settings → Developer sollte meta-ads sichtbar sein.
B. Deployment auf EC2 für die ganze Firma (http)
Angenommen, du hast bereits EC2 + nginx + HTTPS unter
https://ai.gastom.com.twlaufen. Wir installieren kein zusätzliches Caddy, sondern betreiben nur den MCP-Container (gebunden an127.0.0.1:8000), damit dein bestehendes nginxhttps://ai.gastom.com.tw/meta-ads/*dorthin weiterleitet.
1. Gemeinsames Bearer-Token erzeugen
python3 -c "import secrets; print(secrets.token_urlsafe(32))"String sicher speichern (Passwortmanager / Firmen-Vault). Danach:
In die
.envauf der EC2 schreibenAn Kollegen verteilen, damit sie es in Claude Desktop eintragen
2. Code auf die EC2 übertragen
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-Container starten
docker compose up -d --build
docker compose logs -f mcp # 看到 "Uvicorn running on http://0.0.0.0:8000" 就 OKLokal auf der EC2 verifizieren (noch ohne 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. Einen Location-Block in nginx hinzufügen
Füge den Inhalt von deploy/nginx-meta-ads.conf in deinen bestehenden
server { listen 443 ssl; server_name ai.gastom.com.tw; ... }-Block ein, dann:
sudo nginx -t # 語法檢查
sudo systemctl reload nginx # 套用Von außerhalb des Netzwerks verifizieren:
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-Konfiguration der Kollegen
Jeder Kollege fügt in %APPDATA%\Claude\claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json) hinzu:
{
"mcpServers": {
"meta-ads": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://ai.gastom.com.tw/meta-ads/mcp",
"--header",
"Authorization: Bearer 上面產生的_MCP_BEARER_TOKEN"
]
}
}
}Die Computer der Kollegen benötigen Node.js (damit
npxfunktioniert).mcp-remotevermittelt zwischen stdio und deinem HTTPS-Endpoint – sie müssen kein Python / uv / deinen Code installieren.
Upgrade-/Update-Prozess
cd /path/to/meta-ads-mcp
git pull
docker compose up -d --buildHerunterfahren
docker compose downToken-Rotation
Wenn das Token kompromittiert wurde oder regelmäßig erneuert werden soll:
MCP_BEARER_TOKENin der.envauf der EC2 änderndocker compose up -d(erstellt den MCP-Container neu)Neues Token an Kollegen verteilen und deren
claude_desktop_config.jsonaktualisieren
Dialogbeispiele
„Hole mir die Anzeigendaten vom 23.03.2026 bis 25.03.2026 und liste die drei Anzeigen mit den höchsten Ausgaben auf."
„Zeig mir, wie das Creative der Anzeige mit der ID
120228265609960545aussieht."
Claude entscheidet selbst, zuerst get_ad_insights aufzurufen und dann für die jeweilige ad_id get_ad_creative aufzurufen.
Sicherheitshinweise
.envniemals committen:.gitignoreist bereits entsprechend konfiguriert.MCP_BEARER_TOKENist der Schlüssel zum Firmenbudget: Wer es besitzt, kann die Meta-API aufrufen und das Werbebudget der Firma verbrennen. Wie ein Passwort behandeln.HTTPS ist Pflicht: Bearer-Token über HTTP wäre Klartext-Übertragung.
EC2-Security-Group: Neben 80/443 nach außen sollten andere Ports (insbesondere 22) auf den Firmen-IP-Bereich beschränkt werden.
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