I asked claude to help me do the set up to connect my meta business manager to claude.
I installed node js - v24.13.1
Created a folder for meta-ads-mcp
installed project dependencies
npm init -y npm install u/modelcontextprotocol/sdk axios
Created a server file “server.js”
import { McpServer } from “@modelcontextprotocol/sdk/server/mcp.js”; import { StdioServerTransport } from “@modelcontextprotocol/sdk/server/stdio.js”; import { z } from “zod”; import axios from “axios”; const ACCESS_TOKEN = process.env.META_ACCESS_TOKEN; const BUSINESS_ID = process.env.META_BUSINESS_ID; const BASE_URL = “https://graph.facebook.com/v19.0”; const server = new McpServer({ name: “meta-ads”, version: “1.0.0” }); server.tool( “get_ad_accounts”, { limit: z.number().optional().default(25) }, async ({ limit }) => { const res = await axios.get(${BASE_URL}/${BUSINESS_ID}/owned_ad_accounts, { params: { access_token: ACCESS_TOKEN, fields: “id,name,account_status,currency,amount_spent”, limit, }, }); return { content: [{ type: “text”, text: JSON.stringify(res.data, null, 2) }] }; } ); server.tool( “get_campaigns”, { ad_account_id: z.string(), limit: z.number().optional().default(10), }, async ({ ad_account_id, limit }) => { const res = await axios.get(${BASE_URL}/${ad_account_id}/campaigns, { params: { access_token: ACCESS_TOKEN, fields: “id,name,status,objective,daily_budget”, limit, }, }); return { content: [{ type: “text”, text: JSON.stringify(res.data, null, 2) }] }; } ); server.tool( “get_insights”, { campaign_id: z.string(), date_preset: z.string().optional().default(“last_7d”), }, async ({ campaign_id, date_preset }) => { const res = await axios.get(${BASE_URL}/${campaign_id}/insights, { params: { access_token: ACCESS_TOKEN, fields: “impressions,clicks,spend,ctr,cpc,reach”, date_preset, }, }); return { content: [{ type: “text”, text: JSON.stringify(res.data, null, 2) }] }; } ); const transport = new StdioServerTransport(); await server.connect(transport);
Fixed Package File to tell Node.js to use modern JavaScript
{ “name”: “meta-ads-mcp”, “version”: “1.0.0”, “type”: “module”, “main”: “index.js”, … } ```
Then created a “Claude” folder in %APPDATA% and added a file “claude_desktop_config.json”
{ “preferences”: { “sidebarMode”: “chat”, “coworkScheduledTasksEnabled”: false }, “mcpServers”: { “meta-ads”: { “command”: “node”, “args”: [“C:\Users\Me\OneDrive\Documents\meta-ads-mcp\server.js”], “env”: { “META_ACCESS_TOKEN”: “META_ACCESS_TOKEN”: “token_here”, “META_BUSINESS_ID”: “business_id_here” } } } }
^replaced the token and business id respectively.
Went on meta business manager and there was an existing system user “Conversions API System User” so i just gave him access to my ad accounts and generated token from there.
i had an existing app created as well used that and gave permissions to
✅ ads_read
✅ ads_management
✅ business_management
✅ read_insights
Now claude is just going around in circles. Saying quit claude, then you’ll see hammer icon. I dont see the hammer icon and in developer settings i dont see any Local MCP servers. When i click “edit config”. it opens the file explorer and shows me where my “claude_desktop_config.json” file is. And then i can only edit it. Which is again the same code i mentioned earlier
What do i do?
submitted by
/u/Loud_Measurement_151
Originally posted by u/Loud_Measurement_151 on r/ClaudeCode
