Skip to main content
Glama
ZLeventer

linkedin-campaign-manager-mcp

li_get_audience_insights

Retrieve DMP segments attached to a LinkedIn ad account to audit available audiences before campaign creation. Displays segment name, type, source, estimated size, and status for matched audiences and company lists.

Instructions

List DMP (Data Management Platform) segments attached to a LinkedIn ad account. Segments represent matched audiences (USER type: contact list uploads, website retargeting, lookalike audiences) and company lists (COMPANY type: for account-based marketing). Returns segment name, type, source, estimated size (where LinkedIn reports it), and status. Use to audit available audiences before building campaigns, or to confirm a matched audience uploaded successfully and has enough members to serve ads.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ad_account_idNo
typeNoFilter segment type: USER (contact list / matched audience), COMPANY (company list for ABM), COMBINED (combined / lookalike segment).
page_sizeNo

Implementation Reference

  • src/index.ts:162-169 (registration)
    Registration of the 'li_get_audience_insights' tool on the MCP server, wiring the schema and handler.
    // ─── Audiences ───────────────────────────────────────────────────────────────
    
    server.tool(
      "li_get_audience_insights",
      "List DMP (Data Management Platform) segments attached to a LinkedIn ad account. Segments represent matched audiences (USER type: contact list uploads, website retargeting, lookalike audiences) and company lists (COMPANY type: for account-based marketing). Returns segment name, type, source, estimated size (where LinkedIn reports it), and status. Use to audit available audiences before building campaigns, or to confirm a matched audience uploaded successfully and has enough members to serve ads.",
      getAudienceInsightsSchema,
      async (args) => { try { return ok(await getAudienceInsights(args)); } catch (e) { return err(e); } }
    );
  • Zod input schema for 'li_get_audience_insights': accepts optional ad_account_id, type filter (USER/COMPANY/COMBINED), and page_size (default 50).
    export const getAudienceInsightsSchema = {
      ad_account_id: z.string().optional(),
      type: z
        .enum(SEGMENT_TYPES)
        .optional()
        .describe(
          "Filter segment type: USER (contact list / matched audience), " +
          "COMPANY (company list for ABM), COMBINED (combined / lookalike segment)."
        ),
      page_size: z.number().int().min(1).max(100).default(50),
    };
  • Handler function 'getAudienceInsights' that resolves the ad account, builds query params, and calls liGet('/dmpSegments', params) to fetch DMP segments from LinkedIn.
    export async function getAudienceInsights(args: {
      ad_account_id?: string;
      type?: string;
      page_size?: number;
    }) {
      const account = resolveAdAccount(args.ad_account_id);
      const params: Record<string, string | number> = {
        q: "account",
        account,
        count: args.page_size ?? 50,
      };
      if (args.type) {
        params["type"] = args.type;
      }
      return liGet("/dmpSegments", params);
    }
  • Helper 'resolveAdAccount' used by the handler to resolve ad account ID to a full LinkedIn URN, falling back to LINKEDIN_DEFAULT_AD_ACCOUNT env var.
    export function resolveAdAccount(override?: string): string {
      const v = (override ?? process.env.LINKEDIN_DEFAULT_AD_ACCOUNT ?? "").trim();
      if (!v) {
        throw new LinkedInError(
          "No ad account provided. Pass ad_account_id or set LINKEDIN_DEFAULT_AD_ACCOUNT in .env."
        );
      }
      return urn("sponsoredAccount", v);
    }
  • Helper 'liGet' making authenticated GET requests to LinkedIn REST API, used to call /dmpSegments endpoint.
    export async function liGet<T = unknown>(
      path: string,
      query?: Record<string, string | number | boolean | undefined>
    ): Promise<T> {
      const url = new URL(BASE_URL + path);
      if (query) {
        for (const [k, v] of Object.entries(query)) {
          if (v !== undefined && v !== null) url.searchParams.set(k, String(v));
        }
      }
      return liFetch<T>("GET", url.toString());
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Describes return fields (name, type, source, estimated size, status) and the 'where LinkedIn reports it' nuance. Without annotations, this provides necessary behavioral insight, though pagination is not mentioned (implied by page_size parameter).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, front-loaded with the main action, no redundancy. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, the description adequately explains return fields and usage. It lacks error handling details but covers essential aspects for a list operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 33% (only 'type' has schema description). The description reinforces the 'type' enum values from the schema but adds no extra meaning for 'ad_account_id' or 'page_size'. It partially compensates by explaining the tool's output context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'List DMP segments attached to a LinkedIn ad account' and explains segment types (USER, COMPANY). This verb-resource pair is specific and distinct from sibling tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly provides two use cases: auditing audiences before campaigns and confirming upload success. It gives context but does not exclude alternatives or mention when not to use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ZLeventer/linkedin-campaign-manager-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server