search_targeting_map
Map targeting IDs to their full details (names, types, paths). Use this when you have targeting IDs from other endpoints and need to resolve them.
Instructions
Map targeting IDs to their full details (names, types, paths). Useful for resolving IDs obtained from other endpoints.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| targeting_list | Yes | JSON array of targeting IDs to look up |
Implementation Reference
- src/tools/targeting.ts:57-65 (handler)The async handler function that executes the 'search_targeting_map' tool logic. It calls Meta's targetingsearchmap API endpoint with a JSON array of targeting IDs.
async ({ targeting_list }) => { try { const { data, rateLimit } = await client.get(`${client.accountPath}/targetingsearchmap`, { targeting_list }); return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - src/tools/targeting.ts:54-56 (schema)Input schema for the 'search_targeting_map' tool: expects a single 'targeting_list' parameter (string, described as JSON array of targeting IDs).
{ targeting_list: z.string().describe("JSON array of targeting IDs to look up"), }, - src/tools/targeting.ts:51-65 (registration)Registration of the 'search_targeting_map' tool with the MCP server via server.tool(), including its name, description, input schema, and handler.
server.tool( "search_targeting_map", "Map targeting IDs to their full details (names, types, paths). Useful for resolving IDs obtained from other endpoints.", { targeting_list: z.string().describe("JSON array of targeting IDs to look up"), }, async ({ targeting_list }) => { try { const { data, rateLimit } = await client.get(`${client.accountPath}/targetingsearchmap`, { targeting_list }); return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - src/services/ads-client.ts:180-185 (helper)The AdsClient.get() method used by the handler to call the Meta Ads API.
async get( path: string, params?: Record<string, unknown> ): Promise<ClientResponse> { return this.request("GET", path, params); } - src/index.ts:62-62 (registration)Top-level registration call in index.ts that registers targeting tools (including 'search_targeting_map') with the main server.
registerTargetingTools(server, client);