Skip to main content
Glama
linkedin-campaign-manager-mcp

linkedin-campaign-manager-mcp

LinkedIn Campaign Manager MCP

npm version npm downloads Node.js MCP License: MIT

MCP server for the LinkedIn Marketing API — query campaigns, performance, and Lead Gen Forms from Claude in plain English.

19 read-only tools covering ad accounts, campaigns, creatives, performance analytics, demographics, video analytics, budget pacing, period comparisons, conversions, Lead Gen Forms, audiences, and targeting facets. Built for B2B paid social teams running Sponsored Content, Lead Gen Forms, and account-based campaigns on LinkedIn.


Why this exists

The LinkedIn Marketing API is notoriously painful to work with: monthly Rosetta versioning, undocumented field mappings, Rest.li-style nested query params for analytics, and 60-day access tokens that silently expire. This server handles all of that under the hood so you can ask questions in plain English instead of hand-writing dateRange=(start:(year:...)).

No other open-source MCP server for LinkedIn Ads ships this depth. Most stop at "list campaigns." This one includes demographics, video completion funnel, budget pacing, period comparisons, and Lead Gen Form responses with PII so you can reconcile leads against Marketo or Salesforce.


Example prompts

Once installed, ask Claude things like:

  • "What's our LinkedIn Ads spend trend the last 28 days, broken down by campaign group?"

  • "Compare CPL on the competitor-conquest campaigns this month vs. last — which creatives moved the number?"

  • "Pull demographics for our top-spending campaign — what seniority and industry are converting?"

  • "Which Lead Gen Forms had the highest submit rate last month, and what did each cost per lead?"

  • "Show the video completion funnel for our awareness campaign — where are people dropping off?"

  • "Are any campaigns at risk of overspending? Show budget pacing across all active ones."

  • "Pull yesterday's Lead Gen Form responses so I can spot-check them against Marketo."


Demo

🎥 Walkthrough video coming soon — querying LinkedIn campaign performance from Claude Code in under 60 seconds.


Tools

Tool

What it does

li_list_ad_accounts

All ad accounts the user can access, with status + currency.

li_get_account

Single account detail: currency, status, type, billing info.

li_list_campaigns

Campaigns in an account; filter by status or campaign group.

li_get_campaign

Full campaign detail: targeting criteria, bid, budget, objective.

li_list_campaign_groups

Campaign groups (shared budget/objective containers).

li_list_creatives

Ad creatives; filter by campaign or status.

li_get_creative

Full creative detail: headline, copy, URL, image/video URNs.

li_get_campaign_performance

Impressions/clicks/spend/conversions/leads over a date range. DAILY/MONTHLY/YEARLY/ALL granularity.

li_get_demographics_report

Performance by company / company size / industry / job function / job title / seniority / region / country.

li_compare_periods

WoW/MoM/YoY with per-entity _current/_prior/_delta/_pct_change columns computed server-side.

li_get_video_analytics

Video completion funnel per creative: starts → 25% → 50% → 75% → completions + completion rate.

li_get_budget_pacing

Spend vs. budget utilization % for active campaigns over a configurable period.

li_get_conversion_events

Insight Tag conversion event definitions: type, attribution windows, enabled status.

li_get_conversion_performance

Performance by conversion event (CONVERSION pivot): post-click vs. view-through breakdown.

li_get_audience_insights

DMP segments: matched audiences, company lists, combined/lookalike segments + sizes.

li_search_targeting_facets

Typeahead search for targeting values (job titles, skills, companies, industries, locations, seniorities).

li_get_leadgen_forms

Lead Gen Forms + question config + state.

li_get_leadgen_responses

Actual form submissions with PII (name, email, company, job title).

li_get_leadgen_form_performance

LGF metrics per creative: form open rate, submit rate, cost per lead.


Setup

1. Install

npm install -g linkedin-campaign-manager-mcp

Or clone + build locally:

git clone https://github.com/ZLeventer/linkedin-campaign-manager-mcp
cd linkedin-campaign-manager-mcp
npm install
npm run build

2. Create a LinkedIn Developer App

The Marketing API is gated. You need a LinkedIn Developer App with specific product approvals:

  1. Go to developer.linkedin.com → Create App (associate with your company page).

  2. Products tab — request access to:

    • Marketing Developer Platform (covers r_ads, r_ads_reporting)

    • Lead Gen Forms or Community Management API (covers r_ads_leadgen_automation)

  3. LinkedIn reviews app access manually — typically 2–6 weeks.

  4. Auth tab → Authorized Redirect URLs — add: http://127.0.0.1:53123 (change 53123 if you set a different LINKEDIN_OAUTH_PORT).

  5. Copy Client ID and Client Secret from the Auth tab.

Without product approval every API call returns 403. The server compiles and starts cleanly — the 403 is an app-level permission issue, not a code issue.

3. Configure environment

cp .env.example .env
# edit .env with your LINKEDIN_CLIENT_ID, LINKEDIN_CLIENT_SECRET,
# LINKEDIN_DEFAULT_AD_ACCOUNT (numeric ID from Campaign Manager URL)

4. Authorize (one-time OAuth flow)

npm run auth

This opens a local HTTP server on port 53123 (or LINKEDIN_OAUTH_PORT), prints an auth URL to your terminal, and waits for the OAuth callback. After you approve in the browser, it exchanges the code for an access token + 365-day refresh token and saves them to token.json (mode 0600).

You only need to re-run npm run auth if the refresh token expires (after 365 days).

5. Wire into Claude Code (or any MCP client)

Add to ~/.claude.json under mcpServers:

{
  "mcpServers": {
    "linkedin": {
      "command": "linkedin-campaign-manager-mcp",
      "env": {
        "LINKEDIN_CLIENT_ID": "your_client_id",
        "LINKEDIN_CLIENT_SECRET": "your_client_secret",
        "LINKEDIN_TOKEN_PATH": "/absolute/path/to/token.json",
        "LINKEDIN_DEFAULT_AD_ACCOUNT": "123456789",
        "LINKEDIN_API_VERSION": "202504"
      }
    }
  }
}

Or if running from source:

{
  "mcpServers": {
    "linkedin": {
      "command": "node",
      "args": ["/path/to/linkedin-campaign-manager-mcp/dist/index.js"],
      "env": {
        "LINKEDIN_CLIENT_ID": "...",
        "LINKEDIN_CLIENT_SECRET": "...",
        "LINKEDIN_TOKEN_PATH": "/path/to/token.json",
        "LINKEDIN_DEFAULT_AD_ACCOUNT": "123456789"
      }
    }
  }
}

Restart Claude Code. The 19 tools appear under the linkedin server.


Environment variables

Variable

Required

Default

Description

LINKEDIN_CLIENT_ID

Yes

—

OAuth app client ID

LINKEDIN_CLIENT_SECRET

Yes

—

OAuth app client secret

LINKEDIN_TOKEN_PATH

No

./token.json

Path to read/write the token file

LINKEDIN_DEFAULT_AD_ACCOUNT

Recommended

—

Numeric account ID; tools fall back to this when ad_account_id is not passed

LINKEDIN_OAUTH_PORT

No

53123

Loopback port for OAuth redirect

LINKEDIN_API_VERSION

No

202504

LinkedIn Rosetta API version (YYYYMM)


URN handling

LinkedIn resources are identified by URNs: urn:li:sponsoredAccount:123, urn:li:sponsoredCampaign:456, etc.

All tool inputs accept either the bare numeric ID or the full URN — the client wraps bare IDs automatically. Numeric IDs appear in Campaign Manager URLs (/accounts/<id>/, /campaigns/<id>/).


Date inputs

All date parameters accept:

Input

Meaning

2024-10-01

Literal ISO date

today / yesterday

Self-explanatory

7daysAgo, 28daysAgo, 90daysAgo

N calendar days before today

Default range: 28daysAgo → yesterday.


LinkedIn-specific gotchas

API version churn

LinkedIn Rosetta uses monthly versions (202504 = April 2025). Versions deprecate ~12 months after release — you'll get 410 Gone errors when that happens. Bump LINKEDIN_API_VERSION quarterly. See the versioning docs.

Analytics query shape

/adAnalytics uses Rest.li-style nested params, not plain ISO strings:

dateRange=(start:(year:2024,month:10,day:1),end:(year:2024,month:10,day:31))
campaigns=List(urn:li:sponsoredCampaign:123,urn:li:sponsoredCampaign:456)

This is handled internally by dateRangeParam() and liGetRaw(). If you extend the server, route analytics calls through liGetRaw() with a manually-built URL — do not use liGet() for analytics endpoints as URLSearchParams will mangle the nested parens.

Analytics data lag

LinkedIn analytics typically lag 2–6 hours for most metrics, and up to 24 hours for conversion data. Yesterday's numbers are usually complete; today's are partial.

60-day access tokens, 365-day refresh tokens

Access tokens expire in 60 days; refresh tokens in 365 days. The client auto-refreshes the access token on every request when needed. If the refresh token expires, run npm run auth again.

Lead Gen response PII

li_get_leadgen_responses returns actual lead PII — name, email, company, job title. Treat output as sensitive: do not write to shared logs, unencrypted storage, or public channels. LinkedIn's data-use policy requires deleting lead responses within 90 days of receipt unless the lead is actively consented. This tool is intended for authorized CRM reconciliation (Marketo/SFDC).

Rate limits

LinkedIn does not publish hard rate-limit numbers. In practice, expect throttling around 100 analytics calls/minute per app. No retry-on-429 is built in — if you hit limits, reduce call frequency or cache results client-side.


When NOT to use this server

  • Creating or editing campaigns, budgets, or creatives — read-only by design. Campaign creation has too many failure modes to automate safely; use the Campaign Manager UI.

  • Real-time impression data — use the LinkedIn Insight Tag + GA4 for near-realtime.

  • Audience size estimation for arbitrary targeting criteria — use the Campaign Manager audience builder UI for ad-hoc sizing. li_get_audience_insights only returns sizes of saved/uploaded segments.


License

MIT © 2026 Zach Leventer

Available Tools

19 tools
li_compare_periodsA

Compare LinkedIn campaign performance across two time periods. wow (week-over-week): last 7d vs prior 7d. mom (month-over-month): last 30d vs prior 30d. yoy (year-over-year): last 30d vs same 30d last year. Returns per-entity rows (keyed by campaign/creative URN) with _current, _prior, _delta, and _pct_change columns for every requested metric. Deltas are computed server-side so you do not need to post-process. Useful for weekly/monthly performance reports and anomaly detection.

Inputs: pivot, fields, comparison, campaign_ids, +1 more.

li_get_accountA

Get full details for a single LinkedIn ad account, including currency code, status, account type (BUSINESS/ENTERPRISE), total budget, billing info, and the associated organization URN. Useful for confirming account currency before interpreting spend data, or checking billing status before troubleshooting ad delivery issues.

Inputs: ad_account_id.

li_get_audience_insightsA

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.

Inputs: ad_account_id, type, page_size.

li_get_budget_pacingA

Calculate budget utilization for active LinkedIn campaigns. Compares spend over the specified period_days window against total or estimated period budget, and returns a utilization_pct for each campaign. Useful for mid-flight pacing checks: if utilization is below 80% near the end of a month, the campaign may be under-delivering; above 100% means it is over-pacing. Accepts optional campaign_ids to limit scope; defaults to all ACTIVE campaigns in the account.

Inputs: ad_account_id, campaign_ids, period_days.

li_get_campaignA

Get complete detail for a single LinkedIn campaign, including the full targetingCriteria object (all included/excluded facets), bid strategy, unit cost, daily/total budget, run schedule, objective, optimization target, format, and locale. Use this when you need to audit targeting setup, diagnose budget configuration, or confirm campaign structure before pulling performance data.

Inputs: campaign_id (required), ad_account_id.

li_get_campaign_performanceA

Fetch performance metrics for LinkedIn campaigns over a date range. Returns impressions, clicks, spend (USD and local currency), website conversions, one-click lead form submissions, landing-page clicks, video views, follows, reactions, comments, and shares. Pass campaign_ids for specific campaigns or use ad_account_id for account-level totals. Supports DAILY/MONTHLY/YEARLY/ALL time granularity and CAMPAIGN/CAMPAIGN_GROUP/CREATIVE/ACCOUNT pivots. Default range: last 28 days.

Inputs: campaign_ids, ad_account_id, start_date, end_date, +3 more.

li_get_conversion_eventsA

List LinkedIn conversion event definitions on an ad account. Returns each event's name, type (URL/FILE_DOWNLOAD/SIGN_UP/etc.), enabled status, attributionType, post-click and view-through attribution window sizes, and associated Insight Tag. These are the events tracked by the LinkedIn Insight Tag on your website. Use to audit conversion event setup, confirm event names before pulling conversion performance, or verify attribution window configuration.

Inputs: ad_account_id, enabled_only, page_size.

li_get_conversion_performanceA

Fetch conversion performance broken down by conversion event (CONVERSION pivot). Returns externalWebsiteConversions, externalWebsitePostClickConversions, externalWebsitePostViewConversions, impressions, clicks, and spend per conversion event. Use to compare cost-per-conversion across event types, diagnose which Insight Tag events are driving value, or build a funnel from impression → click → conversion. Scope to specific campaigns or report at account level.

Inputs: campaign_ids, ad_account_id, start_date, end_date, +1 more.

li_get_creativeA

Get full detail for a single LinkedIn ad creative, including the creative content (headline, body copy, destination URL, image/video URNs, call-to-action label), intendedStatus, associated campaign URNs, and creative type. Use when auditing ad copy and creative assets, debugging a rejected creative, or pulling the landing page URL to cross-reference with GA4 UTM data.

Inputs: creative_id (required), ad_account_id.

li_get_demographics_reportA

Break down LinkedIn campaign performance by a demographic dimension of the people who saw or clicked your ads. Pivot options: MEMBER_JOB_TITLE (which titles engage most), MEMBER_JOB_FUNCTION, MEMBER_SENIORITY (director vs. manager vs. C-suite), MEMBER_COMPANY (which accounts clicked), MEMBER_COMPANY_SIZE, MEMBER_INDUSTRY, MEMBER_COUNTRY_V2, MEMBER_REGION_V2. Returns impressions, clicks, spend, leads, and conversions per dimension value. Useful for buyer-persona fit analysis and ABM account-list validation.

Inputs: pivot (required), campaign_ids, ad_account_id, start_date, +2 more.

li_get_leadgen_form_performanceA

Fetch LinkedIn Lead Gen Form performance analytics broken down by creative. Returns impressions, clicks, Lead Gen Form opens (oneClickLeadFormOpens), lead submissions (oneClickLeads), spend, and computed metrics: formOpenRate (opens / clicks), leadSubmitRate (submissions / opens), costPerLead (spend / submissions), and CTR. Use to identify high-performing LGF creatives, diagnose drop-off between form open and submission, or compare cost-per-lead across campaigns.

Inputs: end_date, start_date, campaign_ids, ad_account_id.

li_get_leadgen_formsA

List LinkedIn Lead Gen Forms on an ad account. Returns form name, state (ACTIVE/DRAFT/ARCHIVED), the list of questions asked (field type, label, pre-fill source), the thank-you page URL and message, and the associated landing page (if any). Use to audit form question setup, confirm form state before troubleshooting lead delivery, or verify which forms are attached to active campaigns.

Inputs: ad_account_id, state, page_size.

li_get_leadgen_responsesA

Retrieve actual Lead Gen Form submission data from LinkedIn. Each response includes questionResponses with field-by-field values (first name, last name, email, company, job title, phone, etc.) and submission timestamp. Filter by lead_form_id and/or submitted_after/before date range. Use for lead-to-CRM reconciliation against SFDC or Marketo, for auditing lead quality, or for confirming that a form integration is capturing the right fields. NOTE: This endpoint returns PII — handle output as sensitive data.

Inputs: ad_account_id, lead_form_id, submitted_after, submitted_before, +1 more.

li_get_video_analyticsA

Fetch video-specific performance metrics for LinkedIn campaigns, broken down by creative. Returns videoStarts, videoViews, videoFirstQuartileCompletions, videoMidpointCompletions, videoThirdQuartileCompletions, videoCompletions, plus a computed videoCompletionRate (completions / starts × 100). Use to evaluate video ad quality — high completion rates indicate compelling content; low rates signal drop-off. Scope to specific campaigns via campaign_ids or report at account level.

Inputs: campaign_ids, ad_account_id, start_date, end_date, +1 more.

li_list_ad_accountsA

List all LinkedIn ad accounts the authenticated user has access to. Returns account ID, name, status, currency, type (BUSINESS/ENTERPRISE), and reference organization URN. Use this first to discover the ad_account_id needed by other tools. Filter by status (ACTIVE/CANCELED/DRAFT/PENDING_DELETION/REMOVED) or omit to see all accounts.

Inputs: status, page_size.

li_list_campaign_groupsA

List campaign groups in a LinkedIn ad account. Campaign groups are containers that group related campaigns under a shared name and optional total budget cap. Returns group name, status, total budget, run schedule, and the campaigns count. Use to understand account structure before pulling campaign-level data.

Inputs: ad_account_id, status, page_size.

li_list_campaignsA

List campaigns in a LinkedIn ad account. Returns campaign name, status, objectiveType (WEBSITE_VISITS/LEAD_GENERATION/BRAND_AWARENESS/etc.), optimizationTargetType, bid amount, daily/total budget, run schedule, and targeting criteria summary. Filter by status or campaign_group_id. Use li_get_campaign for full targeting detail on a specific campaign.

Inputs: ad_account_id, status, campaign_group_id, page_size.

li_list_creativesA

List ad creatives in a LinkedIn ad account. Returns creative content type (SPONSORED_STATUS_UPDATE/MESSAGE/etc.), intendedStatus, associated campaigns, and content URNs. Filter by campaign_id to see all creatives on a specific campaign, or by status to find paused/archived ads. Use li_get_creative for full content detail on a specific creative.

Inputs: ad_account_id, campaign_id, status, page_size.

li_search_targeting_facetsA

Search LinkedIn targeting facet values to find the correct URNs for audience targeting. Facets include: jobTitles (e.g., 'Supply Chain Director'), skills (e.g., 'S&OP'), companies, industries, seniorities, locations, and more. Returns matching facet values with their LinkedIn URNs, which can then be used to configure campaign targeting via the Campaign Manager UI. Useful for researching targeting options, confirming exact category names, or building audience documentation.

Inputs: facet (required), query (required), locale, count.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 19 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: listing vs. getting details vs. performance reports vs. conversion/leadgen analytics vs. targeting research. Even similar-looking tools like li_get_campaign_performance, li_get_leadgen_form_performance, and li_get_conversion_performance target different metric types and dimensions, so an agent can reliably pick the right one.

    Naming Consistency5/5

    All tools follow a consistent snake_case pattern with the li_ prefix and verb-noun structure (list_, get_, search_, compare_). The naming is highly predictable: li_list_* for enumeration, li_get_* for details or reports, and specific modifiers like _performance, _analytics, _insights. No mixed conventions or irregular verbs.

    Tool Count4/5

    At 19 tools, this is slightly above the typical 3-15 range but still well-justified for the complexity of LinkedIn advertising. Each tool covers a distinct aspect (accounts, campaigns, creatives, performance, demographics, video, conversions, audiences, leadgen, targeting, pacing, comparison) without redundancy. The count feels reasonable for the domain's depth.

    Completeness3/5

    The toolset is heavily read/analytics-focused: it covers listing, getting details, and detailed performance/reporting for all major entities, but lacks any create, update, or delete operations for campaigns, creatives, or account settings. For a 'campaign manager' one might expect lifecycle management, but as a monitoring/analytics surface it is fairly complete. The gaps are significant if the intended scope includes editing, but for reporting and optimization analysis it works well.

    Maintenance

    ActivityNo data
    ResponsivenessSyncing

    Related MCP Connectors