
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
@dsroden/meta-marketing-api-mcp
Advanced tools
A personal MCP Server implementation for the Meta Marketing API, designed for both stdio (Claude, etc.) and SSE (n8n) workflows. This is not an official Meta product.
# Global installation (recommended for n8n usage)
npm install -g @dro-ff/meta-mcp
# Or run directly with npx (recommended for stdio usage)
npx @dro-ff/meta-mcp
Set the following environment variables for Meta API authentication:
META_APP_ID=your_app_id
META_APP_SECRET=your_app_secret
META_ACCESS_TOKEN=your_access_token
META_BUSINESS_ID=your_business_id
META_SYSTEM_USER_ID=your_system_user_id
META_PAGE_ID=your_page_id
META_ACCOUNT_ID=your_account_id
META_API_VERSION=v22.0 # Optional, defaults to v22.0
Optional environment variables for SSE server configuration:
MCP_TRANSPORT=sse # 'sse' or 'stdio' (defaults to 'sse' if not specified)
MCP_HOST=localhost # Server host (defaults to localhost)
MCP_PORT=3000 # Server port (defaults to 3000)
NODE_ENV=development # or production
This MCP server supports two transport methods:
Add the following to your application's configuration (e.g., claude_desktop_config.json):
{
"mcpServers": {
"meta-marketing": {
"command": "npx",
"args": ["@dro-ff/meta-mcp"],
"env": {
"META_APP_ID": "your_app_id",
"META_APP_SECRET": "your_app_secret",
"META_ACCESS_TOKEN": "your_access_token",
"META_BUSINESS_ID": "your_business_id",
"META_SYSTEM_USER_ID": "your_system_user_id",
"META_PAGE_ID": "your_page_id",
"META_ACCOUNT_ID": "your_account_id",
"META_API_VERSION": "v22.0"
}
}
}
}
meta-mcp
# Server will start at http://localhost:3000 by default
http://localhost:3000 (or your server address)/connectThe server automatically handles both transport methods based on how it's initiated. No additional configuration is needed to switch between them.
git clone https://github.com/DSRoden/meta-mcp-server.git
cd meta-mcp-server
npm install
npm run build
# Development mode with hot reload
npm run dev
# Production mode
npm start
# Run with specific transport
MCP_TRANSPORT=sse npm start
# One-time inspection
npm run inspect
# Development mode with inspector
npm run dev:inspect
When running in SSE mode, the following endpoints are available:
GET /health - Health check endpointGET /connect - Initial SSE connectionGET /mcp?sessionId={sessionId} - SSE stream endpointPOST /mcp?sessionId={sessionId} - JSON-RPC endpoint for commands| Variable | Required | Default | Description |
|---|---|---|---|
| META_APP_ID | Yes | - | Meta App ID |
| META_APP_SECRET | Yes | - | Meta App Secret |
| META_ACCESS_TOKEN | Yes | - | Meta Access Token |
| META_BUSINESS_ID | Yes | - | Meta Business ID |
| META_SYSTEM_USER_ID | Yes | - | Meta System User ID |
| META_PAGE_ID | Yes | - | Meta Page ID |
| META_ACCOUNT_ID | Yes | - | Meta Ad Account ID |
| META_API_VERSION | No | v22.0 | Meta API Version |
| MCP_TRANSPORT | No | sse | Transport type (sse/stdio) |
| MCP_HOST | No | localhost | Server host (SSE mode) |
| MCP_PORT | No | 3000 | Server port (SSE mode) |
| NODE_ENV | No | development | Environment mode |
MIT
You can integrate the MCP server into your existing Express.js backend:
import express from "express";
import { Server } from "@dro-ff/meta-mcp";
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
import dotenv from "dotenv";
// ... rest of server code as before ...
To interact with the MCP server from another Node.js application, use the MCP client:
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
async function main() {
// Initialize the client
const client = new Client(
{
name: "meta-marketing-client",
version: "1.0.0",
},
{
capabilities: {},
}
);
try {
// Connect to MCP server using SSE transport
const transport = new SSEClientTransport({
baseUrl: "http://localhost:3000", // Your MCP server URL
connectPath: "/connect",
});
await client.connect(transport);
console.log("Connected to MCP server");
// Example: Create a campaign
const result = await client.request({
method: "tools/call",
params: {
name: "mcp_meta_mcp_meta_campaign_create",
arguments: {
name: "Test Campaign",
objective: "OUTCOME_AWARENESS",
status: "PAUSED",
special_ad_categories: [],
},
},
});
console.log("Campaign created:", result);
// Example: Get campaign insights
const insights = await client.request({
method: "tools/call",
params: {
name: "mcp_meta_mcp_meta_campaign_insights",
arguments: {
campaign_id: result.id,
date_preset: "last_7d",
},
},
});
console.log("Campaign insights:", insights);
} catch (error) {
console.error("Error:", error);
}
}
main();
For stdio transport (useful for CLI tools or desktop apps):
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
async function main() {
const client = new Client(
{
name: "meta-marketing-client",
version: "1.0.0",
},
{
capabilities: {},
}
);
try {
// Connect using stdio transport
const transport = new StdioClientTransport({
command: "npx",
args: ["@dro-ff/meta-mcp"],
env: {
META_APP_ID: process.env.META_APP_ID,
META_APP_SECRET: process.env.META_APP_SECRET,
META_ACCESS_TOKEN: process.env.META_ACCESS_TOKEN,
META_BUSINESS_ID: process.env.META_BUSINESS_ID,
META_SYSTEM_USER_ID: process.env.META_SYSTEM_USER_ID,
META_PAGE_ID: process.env.META_PAGE_ID,
META_ACCOUNT_ID: process.env.META_ACCOUNT_ID,
META_API_VERSION: process.env.META_API_VERSION,
},
});
await client.connect(transport);
console.log("Connected to MCP server via stdio");
// Make requests as in the SSE example
} catch (error) {
console.error("Error:", error);
}
}
main();
Here's a complete example combining both server and client in an Express application:
import express from "express";
import { Server } from "@dro-ff/meta-mcp";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
import dotenv from "dotenv";
dotenv.config();
const app = express();
const port = process.env.PORT || 3000;
// Initialize Express middleware
app.use(express.json());
// Initialize MCP Server
const mcpServer = new Server(
{
name: "meta-marketing-server",
version: "1.0.0",
},
{
capabilities: {
tools: { list: true, call: true },
resources: { list: true, read: true, templates: true },
prompts: { list: true, get: true },
},
}
);
// Initialize MCP Client
const mcpClient = new Client(
{
name: "meta-marketing-client",
version: "1.0.0",
},
{
capabilities: {},
}
);
// Example API endpoint using MCP client
app.post("/api/campaigns", async (req, res) => {
try {
const result = await mcpClient.request({
method: "tools/call",
params: {
name: "mcp_meta_mcp_meta_campaign_create",
arguments: req.body,
},
});
res.json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
});
// Mount MCP server endpoints
app.get("/mcp/connect", async (req, res) => {
// ... SSE connection handling as before ...
});
app.post("/mcp", async (req, res) => {
// ... MCP message handling as before ...
});
// Start the server
app.listen(port, async () => {
console.log(`Server running at http://localhost:${port}`);
// Connect MCP client to the server
try {
const transport = new SSEClientTransport({
baseUrl: `http://localhost:${port}`,
connectPath: "/connect",
});
await mcpClient.connect(transport);
console.log("MCP client connected successfully");
} catch (error) {
console.error("Failed to connect MCP client:", error);
}
});
// ... rest of existing deployment content ...
FAQs
MCP Server implementation for Meta Marketing API
We found that @dsroden/meta-marketing-api-mcp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.

Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.

Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.