Provides tools to manage Facebook advertising campaigns, including creating and updating campaigns, ad sets, and ads, as well as accessing performance insights and reporting.
Allows for the management of Instagram ads through the Meta Marketing API, enabling users to create ad sets, manage targeting, and analyze creative performance.
Integrates with the Meta Marketing API to provide full management of advertising resources across Meta platforms, including campaign creation, audience targeting, budget management, and comprehensive reporting.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Meta Ads MCP ServerShow me the ROI and spend for my active campaigns this week."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π Meta Ads MCP Server
Server MCP completo per gestire campagne pubblicitarie Facebook/Instagram
Quick Start β’ Tools Disponibili β’ Configurazione β’ Esempi
β¨ Caratteristiche
π Analisi & Reporting
π Metriche performance complete
π― Report avanzati con breakdown
π° Insights su spend, ROI, ROAS
π Date personalizzate o preset
π¨ Gestione Campagne
βοΈ Crea campagne e ad set
π― Modifica targeting e budget
π Analizza creative e annunci
π Gestisci stato (attiva/pausa)
π₯ FunzionalitΓ Principali
graph LR
A[Account] --> B[Campagne]
B --> C[Ad Set]
C --> D[Annunci]
D --> E[Creative]
B -.-> F[Insights]
C -.-> F
D -.-> F
F --> G[Report]β 10 Tools Completi - Dalla creazione alla reportistica
β System User Compatible - Funziona con token permanenti
β Error Handling Avanzato - Messaggi di errore dettagliati Meta API
β Date Flessibili - Preset o range personalizzati (fino a 37 mesi)
β Validazione Automatica - Controlli Pydantic per parametri corretti
β‘ Quick Start
# 1οΈβ£ Clona il repository
git clone https://github.com/mikdeangelis/mcp-meta-ads.git
cd mcp-meta-ads
# 2οΈβ£ Crea ambiente virtuale
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 3οΈβ£ Installa dipendenze
pip install -r requirements.txt
# 4οΈβ£ Configura token (vedi guida sotto)
export META_ACCESS_TOKEN="your_token_here"
# 5οΈβ£ Aggiungi al tuo MCP client
# Vedi sezione "Configurazione" per istruzioni specificheπ‘ Primo utilizzo? Segui la guida completa per ottenere il token piΓΉ sotto.
π οΈ Tools Disponibili
π Gestione Risorse
Tool | Descrizione | Esempio |
| Lista tutti gli account pubblicitari | "Mostrami i miei account Meta" |
| Lista campagne di un account | "Campagne dell'account act_123456" |
| Lista ad set di una campagna | "Ad set della campagna 789" |
| Lista annunci di un ad set | "Annunci dell'ad set 456" |
βοΈ Creazione & Modifica
Tool | Descrizione | Parametri Chiave |
| Crea nuova campagna |
|
| Crea nuovo ad set |
|
| Modifica targeting |
|
| Modifica budget |
|
| Attiva/pausa ad set |
|
β οΈ Nota:
create_adsetrichiedebid_amountper LINK_CLICKS etargeting_automation.advantage_audience(0 o 1)
π Analytics & Insights
Tool | Descrizione | Dettagli |
| Metriche performance | Impressions, clicks, spend, CTR, CPC, conversions |
| Dettagli creative | Testi, immagini, link, CTA |
| Report con breakdown | EtΓ , genere, paese, placement |
π Ottenere il Token Meta
Metodo Rapido: Graph API Explorer
1οΈβ£ Crea App Meta Developer
Vai su Facebook Developers
My Apps β Create App β Business
Completa i dettagli dell'app
2οΈβ£ Aggiungi Marketing API
Dashboard app β trova Marketing API
Clicca Set Up
La Marketing API apparirΓ nel menu
3οΈβ£ Genera Token
Opzione A: Graph API Explorer (raccomandato)
Vai su Graph API Explorer
Seleziona la tua app
Get User Access Token β Seleziona permessi:
β
ads_management(gestione completa)β
ads_read(lettura)β
read_insights(metriche)
Generate Access Token β Autorizza β Copia token
Opzione B: System User Token (non scade)
Per produzione, usa System User nel Business Manager.
4οΈβ£ Converti in Long-Lived Token (60 giorni)
curl -X GET "https://graph.facebook.com/v21.0/oauth/access_token" \
-d "grant_type=fb_exchange_token" \
-d "client_id=YOUR_APP_ID" \
-d "client_secret=YOUR_APP_SECRET" \
-d "fb_exchange_token=YOUR_SHORT_LIVED_TOKEN"Sostituisci:
YOUR_APP_ID: Dashboard β Settings β BasicYOUR_APP_SECRET: Dashboard β Settings β BasicYOUR_SHORT_LIVED_TOKEN: Token generato al punto 3
5οΈβ£ Verifica Token
curl "https://graph.facebook.com/v21.0/me?access_token=YOUR_TOKEN"Dovresti vedere i dettagli del tuo profilo Facebook.
Configurazione Token
Opzione 1: File .env (raccomandato)
Crea .env nella directory del progetto:
META_ACCESS_TOKEN=your_token_hereOpzione 2: Variabile d'ambiente
# Linux/macOS
export META_ACCESS_TOKEN="your_token_here"
# Windows PowerShell
$env:META_ACCESS_TOKEN="your_token_here"
# Persistente: aggiungi a ~/.bashrc o ~/.zshrc
echo 'export META_ACCESS_TOKEN="your_token_here"' >> ~/.bashrc
source ~/.bashrcβοΈ Configurazione
Per Claude Code
Metodo Automatico
claude mcp add meta-ads \
--command "$(pwd)/.venv/bin/python" \
--arg "$(pwd)/meta_ads_mcp.py"Metodo Manuale
Modifica ~/.config/claude-code/config.json:
{
"mcpServers": {
"meta-ads": {
"command": "/path/to/mcp-meta-ads/.venv/bin/python",
"args": ["/path/to/mcp-meta-ads/meta_ads_mcp.py"],
"env": {
"META_ACCESS_TOKEN": "your_token_here"
}
}
}
}Per Claude Desktop
Modifica claude_desktop_config.json:
macOS/Linux: ~/.config/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"meta-ads": {
"command": "python",
"args": ["/path/to/mcp-meta-ads/meta_ads_mcp.py"],
"env": {
"META_ACCESS_TOKEN": "your_token_here"
}
}
}
}π‘ Esempi Pratici
π― Creare una Campagna Completa
// 1. Crea campagna
meta_ads_create_campaign({
"account_id": "act_123456789",
"name": "Estate 2025 - Promozione",
"objective": "OUTCOME_SALES",
"daily_budget": 5000, // β¬50/giorno
"status": "PAUSED"
})
// β
Campagna creata: ID 120236574531090062
// 2. Crea ad set con targeting
meta_ads_create_adset({
"campaign_id": "120236574531090062",
"name": "Italia 25-55 anni",
"optimization_goal": "LINK_CLICKS",
"billing_event": "LINK_CLICKS",
"bid_amount": 150, // β¬1.50 per click
"targeting": {
"geo_locations": {"countries": ["IT"]},
"age_min": 25,
"age_max": 55,
"targeting_automation": {
"advantage_audience": 0 // β οΈ OBBLIGATORIO
}
},
"status": "PAUSED"
// β οΈ NON specificare daily_budget se campagna ha giΓ budget
})
// β
Ad set creato: ID 120236575096660062π Analisi Performance
// Metriche ultimi 30 giorni
meta_ads_get_insights({
"object_id": "act_123456789",
"level": "campaign",
"date_preset": "last_30d"
})
// Metriche con date personalizzate
meta_ads_get_insights({
"object_id": "120236574531090062",
"level": "campaign",
"since": "2025-01-01",
"until": "2025-01-31"
})
// Report breakdown per etΓ e genere
meta_ads_generate_report({
"object_id": "120236575096660062",
"breakdowns": ["age", "gender"],
"date_preset": "last_7d"
})π¨ Analisi Creative
// Dettagli creative di un annuncio
meta_ads_get_creative({
"ad_id": "123456789"
})
// Restituisce: titolo, body, link, CTA, immagini/videoπ Gestione Stato e Budget
// Modifica targeting
meta_ads_update_adset_targeting({
"adset_id": "120236575096660062",
"age_min": 30,
"age_max": 50,
"genders": [2] // Solo donne
})
// Aumenta budget
meta_ads_update_adset_budget({
"adset_id": "120236575096660062",
"daily_budget": 3000 // β¬30/giorno
})
// Attiva ad set
meta_ads_update_adset_status({
"adset_id": "120236575096660062",
"status": "ACTIVE"
})π Struttura Meta Ads
Account Pubblicitario (act_XXXXX)
β
βββ π Campagna (Campaign)
β βββ π― Obiettivo: OUTCOME_SALES, OUTCOME_TRAFFIC, ecc.
β βββ π° Budget: Giornaliero o Lifetime
β βββ β±οΈ Schedule: Data inizio/fine
β β
β βββ π¦ Ad Set
β βββ π― Targeting
β β βββ Geo: Paesi, regioni, cittΓ
β β βββ Demografia: EtΓ , genere
β β βββ Advantage Audience: 0 o 1
β βββ π΅ Bid Amount (per alcuni goals)
β βββ π Optimization Goal: LINK_CLICKS, CONVERSIONS, ecc.
β β
β βββ π¨ Annuncio (Ad)
β βββ πΌοΈ Creative
β βββ π Headline & Body
β βββ πΌοΈ Immagine/Video
β βββ π Link URL
β βββ π¬ Call-to-Actionβ οΈ Requisiti Importanti
Per meta_ads_create_adset
Parametro | Obbligatorio? | Note |
| β SΓ¬ | Almeno paesi, regioni o cittΓ |
| β SΓ¬ | 0 (disabilitato) o 1 (abilitato) |
| β οΈ Dipende | OBBLIGATORIO per LINK_CLICKS, LANDING_PAGE_VIEWS, ecc. |
| β οΈ Dipende | NON usare se campagna ha giΓ budget |
Budget: Regole
β Budget solo campagna: OK
β Budget solo ad set: OK (se campagna senza budget)
β Budget campagna + budget ad set: ERRORE (subcode 1885621)
π Troubleshooting
Causa: Variabile d'ambiente non configurata
Soluzione:
export META_ACCESS_TOKEN="your_token_here"
# Oppure crea file .env nella directory del progettoCausa: Token scaduto (short-lived durano poche ore)
Soluzione:
Genera nuovo token da Graph API Explorer
Converti in long-lived (60 giorni)
Oppure usa System User token (permanente)
Causa: Token senza permessi necessari
Soluzione: Rigenera token includendo:
ads_management(gestione completa)ads_read(minimo per lettura)read_insights(per metriche)
Causa: Manca bid_amount per LINK_CLICKS
Soluzione: Aggiungi bid_amount in centesimi (es. 100 = β¬1.00)
Causa: Campagna ha giΓ budget, non puoi specificarlo anche nell'ad set
Soluzione: Ometti daily_budget/lifetime_budget dall'ad set
Causa: Manca targeting_automation.advantage_audience
Soluzione: Aggiungi al targeting:
"targeting_automation": {
"advantage_audience": 0 // o 1
}Causa: Troppe richieste API in poco tempo
Soluzione: Attendi 5-10 minuti prima di riprovare
π Risorse Utili
π§ͺ Graph API Explorer
π API Error Reference
π€ Contributi
Contributi, issues e feature requests sono benvenuti!
Fork del progetto
Crea il tuo feature branch (
git checkout -b feature/AmazingFeature)Commit delle modifiche (
git commit -m 'Add some AmazingFeature')Push al branch (
git push origin feature/AmazingFeature)Apri una Pull Request
π Licenza
Questo progetto Γ¨ rilasciato sotto licenza MIT. Vedi il file LICENSE per i dettagli.
π Riconoscimenti
Basato su Meta Marketing API v21.0
Costruito con FastMCP
Validazione con Pydantic v2
β Se questo progetto ti Γ¨ utile, lascia una stella su GitHub!
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.