get_campaign
Retrieve a single Meta Ads campaign by its ID for deep inspection, including all default fields and any specified custom fields.
Instructions
Get a single campaign by ID. Returns all default fields plus anything in fields. Use this for deep inspection of one campaign.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| campaign_id | Yes | Meta Campaign ID | |
| fields | No | Override default field list |
Implementation Reference
- src/tools/campaigns.ts:70-73 (handler)The actual handler for the 'get_campaign' tool. Makes a GET request to Meta Graph API using the campaign_id as the path, with optional fields parameter.
handler: async (args) => metaGet(`/${String(args.campaign_id)}`, { fields: args.fields ?? DEFAULT_CAMPAIGN_FIELDS, }), - src/tools/campaigns.ts:66-69 (schema)Input schema for get_campaign: requires campaign_id (string), optional fields (string).
inputSchema: { campaign_id: z.string().describe("Meta Campaign ID"), fields: z.string().optional().describe("Override default field list"), }, - src/tools/campaigns.ts:61-74 (registration)The tool definition object for 'get_campaign' in the campaignTools array, including name, description, inputSchema, and handler.
{ name: "get_campaign", description: "Get a single campaign by ID. Returns all default fields plus anything in `fields`. " + "Use this for deep inspection of one campaign.", inputSchema: { campaign_id: z.string().describe("Meta Campaign ID"), fields: z.string().optional().describe("Override default field list"), }, handler: async (args) => metaGet(`/${String(args.campaign_id)}`, { fields: args.fields ?? DEFAULT_CAMPAIGN_FIELDS, }), }, - src/tools/campaigns.ts:31-32 (helper)Default field list used by get_campaign (and other campaign tools) when no custom fields are specified.
const DEFAULT_CAMPAIGN_FIELDS = "id,name,status,effective_status,objective,buying_type,daily_budget,lifetime_budget,bid_strategy,budget_remaining,special_ad_categories,start_time,stop_time,created_time,updated_time"; - src/index.ts:65-90 (registration)Registration loop in the MCP server entrypoint that registers all tools (including 'get_campaign' from campaignTools) with the McpServer.
for (const tool of allTools) { server.registerTool( tool.name, { description: tool.description, inputSchema: tool.inputSchema, }, // The SDK's ToolCallback type infers the arg shape from inputSchema, but // our shared ToolDef uses a generic Record<string, unknown> signature for // portability. The cast here is intentional and isolated to the bridge. async (args: unknown) => { try { const result = await tool.handler(args as Record<string, unknown>); return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }], }; } catch (err) { const message = err instanceof Error ? err.message : String(err); return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; } }, ); }