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

linkedin-campaign-manager-mcp

LinkedIn 广告系列管理器 MCP

npm version npm downloads Node.js MCP License: MIT

用于 LinkedIn Marketing API 的 MCP 服务器 — 可通过 Claude 用纯英语查询广告系列、效果和潜在客户开发表单。

包含 19 个只读工具,涵盖广告账户、广告系列、创意、效果分析、受众特征、视频分析、预算进度、周期对比、转化、潜在客户开发表单、受众和定向维度。专为在 LinkedIn 上运行赞助内容、潜在客户开发表单和基于账户的广告系列的 B2B 付费社交团队打造。


为什么存在此项目

LinkedIn Marketing API 的使用体验非常糟糕:每月一次的 Rosetta 版本更新、缺乏文档的字段映射、用于分析的 Rest.li 风格嵌套查询参数,以及会静默过期的 60 天访问令牌。此服务器在后台处理了所有这些复杂性,因此您可以用纯英语提问,而无需手动编写 dateRange=(start:(year:...))。

目前没有其他开源的 LinkedIn 广告 MCP 服务器能达到这种深度。大多数服务器仅止步于“列出广告系列”。本项目包含受众特征、视频完成漏斗、预算进度、周期对比以及带有 PII(个人身份信息)的潜在客户开发表单响应,以便您可以将潜在客户与 Marketo 或 Salesforce 进行核对。


示例提示词

安装后,您可以向 Claude 询问如下问题:

  • “过去 28 天我们的 LinkedIn 广告支出趋势如何,按广告系列组细分?”

  • “对比本月与上月竞争对手征服广告系列的 CPL(潜在客户获取成本)——哪些创意推动了数据增长?”

  • “提取我们支出最高的广告系列的受众特征——哪些资历和行业的人在转化?”

  • “上个月哪些潜在客户开发表单的提交率最高,每个潜在客户的成本是多少?”

  • “展示我们品牌认知广告系列的视频完成漏斗——用户在哪里流失了?”

  • “是否有任何广告系列面临超支风险?显示所有活跃广告系列的预算进度。”

  • “提取昨天的潜在客户开发表单响应,以便我可以将其与 Marketo 进行抽查核对。”


演示

🎥 演示视频即将推出 — 在 60 秒内通过 Claude Code 查询 LinkedIn 广告系列效果。


工具

工具

功能

li_list_ad_accounts

用户可访问的所有广告账户,包含状态和货币。

li_get_account

单个账户详情:货币、状态、类型、账单信息。

li_list_campaigns

账户中的广告系列;可按状态或广告系列组筛选。

li_get_campaign

完整的广告系列详情:定向标准、出价、预算、目标。

li_list_campaign_groups

广告系列组(共享预算/目标容器)。

li_list_creatives

广告创意;可按广告系列或状态筛选。

li_get_creative

完整的创意详情:标题、文案、URL、图片/视频 URN。

li_get_campaign_performance

指定日期范围内的展示次数/点击次数/支出/转化次数/潜在客户数。支持 DAILY/MONTHLY/YEARLY/ALL 粒度。

li_get_demographics_report

按公司/公司规模/行业/职能/职位/资历/地区/国家划分的效果。

li_compare_periods

WoW/MoM/YoY 对比,服务器端计算每个实体的 _current/_prior/_delta/_pct_change 列。

li_get_video_analytics

每个创意的视频完成漏斗:开始 → 25% → 50% → 75% → 完成 + 完成率。

li_get_budget_pacing

在可配置周期内,活跃广告系列的支出与预算使用百分比。

li_get_conversion_events

Insight Tag 转化事件定义:类型、归因窗口、启用状态。

li_get_conversion_performance

按转化事件(CONVERSION 维度)划分的效果:点击后转化与浏览后转化细分。

li_get_audience_insights

DMP 分段:匹配受众、公司列表、组合/类似受众分段 + 大小。

li_search_targeting_facets

定向值的即时搜索(职位、技能、公司、行业、地点、资历)。

li_get_leadgen_forms

潜在客户开发表单 + 问题配置 + 状态。

li_get_leadgen_responses

包含 PII(姓名、电子邮件、公司、职位)的实际表单提交数据。

li_get_leadgen_form_performance

每个创意的 LGF 指标:表单打开率、提交率、每个潜在客户成本。


设置

1. 安装

npm install -g linkedin-campaign-manager-mcp

或者克隆并本地构建:

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

2. 创建 LinkedIn 开发者应用

Marketing API 是受限的。您需要一个具有特定产品批准的 LinkedIn 开发者应用:

  1. 前往 developer.linkedin.com → 创建应用(关联到您的公司主页)。

  2. 产品选项卡 — 请求访问:

    • Marketing Developer Platform(涵盖 r_ads, r_ads_reporting)

    • Lead Gen Forms 或 Community Management API(涵盖 r_ads_leadgen_automation)

  3. LinkedIn 会手动审核应用访问权限 — 通常需要 2–6 周。

  4. Auth 选项卡 → 授权重定向 URL — 添加:http://127.0.0.1:53123 (如果您设置了不同的 LINKEDIN_OAUTH_PORT,请相应更改 53123)。

  5. 从 Auth 选项卡复制 Client ID 和 Client Secret。

如果没有产品批准,每个 API 调用都会返回 403。服务器可以正常编译和启动 — 403 是应用级别的权限问题,而非代码问题。

3. 配置环境变量

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. 授权(一次性 OAuth 流程)

npm run auth

这会在端口 53123(或 LINKEDIN_OAUTH_PORT)上打开一个本地 HTTP 服务器,将授权 URL 打印到您的终端,并等待 OAuth 回调。在浏览器中批准后,它会将代码交换为访问令牌 + 365 天刷新令牌,并将其保存到 token.json(模式 0600)。

只有在刷新令牌过期(365 天后)时,才需要重新运行 npm run auth。

5. 连接到 Claude Code(或任何 MCP 客户端)

在 ~/.claude.json 的 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"
      }
    }
  }
}

或者如果从源码运行:

{
  "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"
      }
    }
  }
}

重启 Claude Code。19 个工具将出现在 linkedin 服务器下。


环境变量

变量

必需

默认

描述

LINKEDIN_CLIENT_ID

是

—

OAuth 应用客户端 ID

LINKEDIN_CLIENT_SECRET

是

—

OAuth 应用客户端密钥

LINKEDIN_TOKEN_PATH

否

./token.json

读取/写入令牌文件的路径

LINKEDIN_DEFAULT_AD_ACCOUNT

推荐

—

数字账户 ID;当未传递 ad_account_id 时,工具将回退到此 ID

LINKEDIN_OAUTH_PORT

否

53123

OAuth 重定向的环回端口

LINKEDIN_API_VERSION

否

202504

LinkedIn Rosetta API 版本 (YYYYMM)


URN 处理

LinkedIn 资源由 URN 标识:urn:li:sponsoredAccount:123, urn:li:sponsoredCampaign:456 等。

所有工具输入都接受纯数字 ID 或完整 URN — 客户端会自动包装纯数字 ID。数字 ID 出现在广告系列管理器 URL 中 (/accounts/<id>/, /campaigns/<id>/)。


日期输入

所有日期参数接受:

输入

含义

2024-10-01

字面 ISO 日期

today / yesterday

不言自明

7daysAgo, 28daysAgo, 90daysAgo

今天之前的 N 个日历日

默认范围:28daysAgo → yesterday。


LinkedIn 特有的注意事项

API 版本更迭

LinkedIn Rosetta 使用月度版本(202504 = 2025 年 4 月)。版本在发布约 12 个月后弃用 — 届时您会收到 410 Gone 错误。请每季度更新 LINKEDIN_API_VERSION。请参阅 版本控制文档。

分析查询格式

/adAnalytics 使用 Rest.li 风格的嵌套参数,而非纯 ISO 字符串:

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)

这在内部由 dateRangeParam() 和 liGetRaw() 处理。如果您扩展服务器,请通过 liGetRaw() 使用手动构建的 URL 路由分析调用 — 不要对分析端点使用 liGet(),因为 URLSearchParams 会破坏嵌套的括号。

分析数据延迟

LinkedIn 分析数据对于大多数指标通常有 2–6 小时的延迟,对于转化数据则长达 24 小时。昨天的数字通常是完整的;今天的数字是部分的。

60 天访问令牌,365 天刷新令牌

访问令牌在 60 天后过期;刷新令牌在 365 天后过期。客户端在需要时会在每次请求时自动刷新访问令牌。如果刷新令牌过期,请再次运行 npm run auth。

潜在客户开发响应 PII

li_get_leadgen_responses 返回实际的潜在客户 PII — 姓名、电子邮件、公司、职位。请将输出视为敏感信息:不要写入共享日志、未加密的存储或公共渠道。LinkedIn 的数据使用政策要求在收到潜在客户后的 90 天内删除响应,除非潜在客户明确同意。此工具旨在用于授权的 CRM 核对(Marketo/SFDC)。

速率限制

LinkedIn 不发布硬性速率限制数字。在实践中,预计每个应用每分钟约 100 次分析调用会受到限制。未内置 429 重试机制 — 如果达到限制,请降低调用频率或在客户端缓存结果。


何时不应使用此服务器

  • 创建或编辑广告系列、预算或创意 — 设计上为只读。广告系列创建有太多的失败模式,无法安全自动化;请使用广告系列管理器 UI。

  • 实时展示数据 — 使用 LinkedIn Insight Tag + GA4 获取近乎实时的数据。

  • 针对任意定向标准的受众规模估算 — 使用广告系列管理器受众构建器 UI 进行临时估算。li_get_audience_insights 仅返回已保存/上传分段的规模。


许可证

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