get-audience-insights
Retrieve aggregated audience insights including demographics, behavior, psychographics, and socioeconomic data for marketing analysis.
Instructions
Retrieves aggregated insights for a given audience ID, providing statistical distributions across various attributes. Available insights include demographics (e.g., gender, age, country), behavioral traits (e.g., active hours, platform usage), psychographics (e.g., personality traits, interests), and socioeconomic factors (e.g., income, education status).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| audience_insights_id | Yes | The ID of the audience insights. | |
| insights | No | Optional list of insight names to filter. |
Implementation Reference
- src/index.ts:98-138 (registration)Registration of the MCP 'get-audience-insights' tool, including multi-line description, Zod input schema (audience_insights_id and optional insights), and handler that fetches data and formats it as structured text responseserver.tool( "get-audience-insights", `Retrieves aggregated insights for a given audience ID, providing statistical distributions across various attributes. Available insights include demographics (e.g., gender, age, country), behavioral traits (e.g., active hours, platform usage), psychographics (e.g., personality traits, interests), and socioeconomic factors (e.g., income, education status).`, { audience_insights_id: z.string().describe("The ID of the audience insights."), insights: z.array(z.string()).optional().describe("Optional list of insight names to filter."), }, async ({ audience_insights_id, insights }) => { const data = await getAudienceInsights(audience_insights_id, insights); if (!data || !data.insights.length) { return { content: [ { type: "text", text: `No insights found for audience ${audience_insights_id}.`, }, ], }; } const insightsText = data.insights .map( (insight) => `**${insight.name}**:\n${insight.values .map((val) => `- ${val.key}: ${val.value}%`) .join("\n")}` ) .join("\n\n"); return { content: [ { type: "text", text: `Audience Insights for ${audience_insights_id}:\n\n${insightsText}`, }, ], }; } );
- src/audienseClient.ts:101-109 (handler)Core handler logic for fetching audience insights from the Audiense API. Constructs query params if insights filter provided and calls the generic makeAudienseRequest to the /audience_insights/{id} endpoint with authentication.export async function getAudienceInsights( audience_insights_id: string, insights?: string[] ): Promise<{ insights: { name: string; values: { key: string; value: string }[] }[] } | null> { const queryParams = insights ? `?insights=${insights.join(",")}` : ""; return makeAudienseRequest<{ insights: { name: string; values: { key: string; value: string }[] }[] }>( `/audience_insights/${audience_insights_id}${queryParams}` ); }
- src/index.ts:102-105 (schema)Zod schema for tool inputs: required string audience_insights_id and optional array of strings for insights to filter.{ audience_insights_id: z.string().describe("The ID of the audience insights."), insights: z.array(z.string()).optional().describe("Optional list of insight names to filter."), },