LinkedIn Ads MCP Toolkit
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@LinkedIn Ads MCP Toolkit compare last month's campaigns by spend and conversions"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
LinkedIn Ads MCP Toolkit
A configurable Model Context Protocol server for querying LinkedIn advertising data, generating performance reports, and managing campaigns from an MCP-compatible client.
Repository · Issue Tracker · CI Runs
Use natural-language requests such as “Compare last month's campaigns” or “Show lead acquisition costs,” while the client translates those requests into typed MCP tool calls. The server also provides standalone HTML dashboard and console report generators.
This project requires your own LinkedIn developer application, approved API products, and access to the advertising accounts you query. It cannot grant permissions that your LinkedIn account or developer application does not have.
Table of Contents
Related MCP server: Meta Ads MCP Server
Features
28 MCP tools: account discovery, performance analysis, demographic reporting, conversion tracking, lead generation, ad library searches, campaign administration, image uploads, custom analytics, and local diagnostics.
Client-independent integration: standard MCP over stdin/stdout; compatible with clients that support locally launched stdio servers.
Account discovery: enumerate accessible accounts, inspect account settings, and optionally include test accounts.
Campaign and creative reports: impressions, clicks, landing-page clicks, spend, CTR, CPC, CPM, engagements, conversion metrics, video metrics, reach estimates, and supported dwell-time and penetration metrics.
Audience reporting: job function, seniority, industry, company size, job title, company, country, and region pivots, subject to API permissions and reporting availability.
Conversion and lead analysis: tracking definitions, attribution breakdowns, form submissions, qualified leads, and acquisition costs.
Comparative reporting: time-period, campaign-set, and campaign-group comparisons with absolute and percentage changes.
Daily trends: date-level records, aggregate statistics, peak/lowest days, and UTC weekday summaries.
Custom analytics: select raw metrics, reporting dimensions, entity filters, and daily/monthly/yearly/all-time granularity.
Metric batching: large selections are split into bounded requests and merged by reporting dimensions; mismatched dimensions produce an explicit error.
Complete collection traversal: cursor pagination for account-structure searches and offset/link pagination for supported collection endpoints.
Pagination safeguards: repeated cursors, untrusted pagination URLs, and configured page limits fail explicitly instead of silently returning incomplete data.
Campaign administration: create groups and campaigns, update budgets and targeting, manage creative statuses, create inline ads, and delete supported entities.
Account-aware budgets: omitted budget currencies use the advertising account's currency; conflicting currencies are rejected before writes.
Optional read-only operation: hide write tools from discovery and reject mutation requests at both MCP and API boundaries.
Validated inputs: JSON Schema validation plus calendar-date, identifier, monetary-value, URL, range, and upload-path checks.
Resilient reads: per-attempt timeouts, bounded concurrency, selected transient-error retries, exponential backoff, jitter for HTTP retries, and
Retry-Aftersupport.Safe mutation behavior: write requests are issued once; ambiguous network failures explain that remote state should be checked before another attempt.
Concurrent GET deduplication: identical reads in flight share one request without retaining completed account data in a response cache.
OAuth lifecycle management: loopback callback server, random state validation, configurable scopes, local token storage, refresh handling, forced login, status, and logout.
Reliable token persistence: validated token payloads, atomic file replacement, restricted creation modes where supported, and serialized writes within a process.
Standalone reporting: configurable HTML dashboard and a console performance summary.
Dashboard content handling: escaped text/attributes, protected embedded JSON, and HTTP(S)-only links and image URLs.
Operational tooling: strict TypeScript compilation, automated regression tests, MCP protocol integration tests, cross-platform CI configuration, and a non-root Docker image definition.
Metric availability depends on the selected API version, pivot, date range, app products, and account permissions. An empty successful result can mean there was no eligible activity; a failed API request is reported separately.
Tech Stack & Architecture
Component | Technology | Responsibility |
Runtime | Node.js 22+ | ESM execution, native HTTP/fetch, cancellation, filesystem, test runner |
Language | TypeScript with strict checking | Source types and compile-time validation |
MCP |
| Protocol handling and stdio transport |
Input validation | Ajv | Compile and apply tool JSON Schemas |
Configuration | Environment variables and | CLI configuration and |
OAuth callback | Native | Temporary loopback authorization listener |
Browser launch |
| Optional platform-independent authorization/dashboard opening |
Dashboard charts | Chart.js | Browser-side charts loaded from a versioned CDN URL |
Tests |
| Regression, HTTP, OAuth, and MCP integration coverage |
Project Structure
.
├── .github/workflows/ci.yml # Linux/Windows, Node.js 22/24 checks
├── .dockerignore
├── .env.example # Documented configuration template
├── .gitignore
├── CHANGELOG.md
├── Dockerfile # Multi-stage build; non-root runtime
├── LICENSE
├── README.md
├── package.json
├── package-lock.json
├── tsconfig.json
├── src/
│ ├── index.ts # Process entry point and stdio lifecycle
│ ├── server.ts # Tool registry, validation, dispatch
│ ├── auth-cli.ts # Login/status/logout CLI
│ ├── auth/
│ │ ├── oauth.ts # Authorization and callback exchange
│ │ └── token-store.ts # Atomic persistence and token refresh
│ ├── lib/
│ │ ├── config.ts # Validated transport configuration
│ │ ├── dates.ts # Calendar and range validation
│ │ ├── html.ts # HTML, script JSON, and URL helpers
│ │ ├── http.ts # Timeouts, retries, concurrency, errors
│ │ ├── linkedin-api.ts # LinkedIn endpoints and pagination
│ │ ├── types.ts # API and tool interfaces
│ │ └── validation.ts # Schema and semantic input checks
│ ├── tools/
│ │ ├── accounts.ts
│ │ ├── ad-library.ts
│ │ ├── analytics.ts
│ │ ├── campaign-management.ts
│ │ ├── conversions.ts
│ │ ├── demographics.ts
│ │ └── performance.ts
│ └── scripts/
│ ├── generate-dashboard.ts
│ └── list_performance.ts
├── test/
│ ├── auth.test.mjs
│ ├── core.test.mjs
│ └── mcp.test.mjs
└── linkedin-ads-mcp-main/ # Compatibility launcher for the former nested copydist/ is generated by the build and is not source-controlled. The root project is the canonical source tree; the legacy nested launcher forwards commands to it.
Key Design Decisions
Stdio as the transport: the MCP client owns the server process. Protocol messages use stdout; operational server messages use stderr.
Separate startup and server construction:
createMcpServer()can be exercised using in-memory transports without starting a subprocess or touching LinkedIn.Validation before dispatch: malformed tool arguments fail before API handlers execute. Unknown top-level arguments are rejected to catch misspelled configuration.
One shared API client per server: tool calls use the same concurrency limiter and in-flight read map.
No automatic write retries: an upstream operation may have committed even if its response was lost. The caller must inspect the account before repeating that action.
No completed-response cache: subsequent reads obtain fresh data; only overlapping identical reads are coalesced.
Bounded collection traversal: retrieving a large account cannot loop indefinitely on a repeated cursor.
Local OAuth persistence: tokens stay on the machine running the server. The application does not provide a hosted token service.
flowchart TD
A[MCP client] -->|JSON-RPC over stdio| B[Server registry]
B --> C[JSON Schema and semantic validation]
C --> D[Read-only policy]
D --> E[Tool handler]
E --> F[LinkedIn API client]
F --> G[Token store and refresh coordination]
F --> H[Pagination and metric batching]
H --> I[HTTP concurrency limiter]
I --> J[Timeout and GET retry policy]
J --> K[LinkedIn Marketing API]
K --> L[Result or structured error]
L --> ACollection and entity authorization failures propagate to the caller. A missing entity is represented as absent only where the relevant lookup receives HTTP 404. Tool errors use an MCP result with isError: true; API errors may include HTTP status and a LinkedIn requestId when available.
get_server_status reads local metadata only. It does not refresh tokens or verify network access, granted scopes, app approval, or advertising-account membership.
Getting Started
Prerequisites
Node.js 22 or newer and npm. Verify with
node --versionandnpm --version.A LinkedIn account that has access to the advertising account you want to query.
A LinkedIn developer application associated with the appropriate organization/company page.
Approved API products and OAuth scopes for the operations you intend to use.
An MCP client with local stdio support to invoke the tools interactively.
Git, if cloning rather than using an extracted source archive.
Docker is optional. Python, a database, and a separate web server are not required.
1. Download and Build
Clone the repository and install the locked dependencies:
git clone https://github.com/adops-tool/linkedin-ads-mcp-toolkit.git
cd linkedin-ads-mcp-toolkit
npm ci --ignore-scripts
npm run buildIf you already extracted the repository, open a terminal in the folder containing package.json and run the final two commands there.
2. Create Your Environment File
macOS / Linux:
cp .env.example .envWindows PowerShell:
Copy-Item .env.example .envEdit .env locally:
LINKEDIN_CLIENT_ID=replace_with_your_client_id
LINKEDIN_CLIENT_SECRET=replace_with_your_client_secret
LINKEDIN_REDIRECT_URI=http://localhost:3000/callback
# Optional: expose reporting tools only.
LINKEDIN_READ_ONLY=true.env, token files, generated dashboards, and exported reports may contain credentials or confidential advertising data. Keep them out of public repositories and shared attachments. The supplied ignore rules cover the default paths; custom output paths require your own ignore rules.
3. Configure the LinkedIn Developer Application
Open the LinkedIn Developer Portal.
Create or select your application and associate the required company page.
In Products, request the advertising/reporting API access required by your use case. Approval and available products depend on LinkedIn's review process.
In Auth, add the exact redirect URI:
http://localhost:3000/callback.Copy the application's Client ID and Client Secret into
.env.Check the scopes granted to the application. The default requested scopes are:
Scope | Used for |
| Advertising-account and campaign management |
| Advertising analytics and reporting |
| Reading organization post content for creative enrichment |
| Organization-owned content/image workflows where required |
If your application has a different approved scope set, configure LINKEDIN_SCOPES as a space-separated list. Reporting-only installations may request approved read scopes such as r_ads r_ads_reporting; content enrichment may require additional permissions.
LINKEDIN_READ_ONLY=true restricts this server's operations. It does not change OAuth grants. Set LINKEDIN_SCOPES separately when you want a different authorization request.
4. Authenticate
npm run authThe CLI starts a temporary loopback listener, prints the LinkedIn authorization URL, and attempts to open your browser. Sign in and authorize the application. A successful callback stores tokens in:
~/.linkedin-ads-mcp/tokens.jsonOn Windows, ~ denotes your user profile directory. Set TOKEN_STORAGE_PATH to choose a different absolute path.
Verify the saved state:
npm run auth -- --statusAccess-token validity comes from LinkedIn's token response. Automatic refresh is available only when a usable refresh token was issued and client credentials are available to the server process. When no refresh token is available, authenticate again after expiration.
5. Connect an MCP Client
Add a server entry using your client's local MCP configuration. Merge it with existing servers:
{
"mcpServers": {
"linkedin-ads": {
"command": "node",
"args": ["/absolute/path/to/linkedin-ads-mcp-toolkit/dist/index.js"],
"env": {
"LINKEDIN_CLIENT_ID": "your_client_id",
"LINKEDIN_CLIENT_SECRET": "your_client_secret",
"TOKEN_STORAGE_PATH": "/absolute/path/to/tokens.json",
"LINKEDIN_READ_ONLY": "true"
}
}
}
}Use an actual absolute path. On Windows, JSON paths can use forward slashes, for example C:/Projects/linkedin-ads-mcp-toolkit/dist/index.js, or escaped backslashes. If the desktop client cannot resolve node, provide the full path to node.exe.
Restart or reconnect the client, then request:
Show the LinkedIn Ads server status.
List my LinkedIn advertising accounts..env is loaded relative to the process working directory. Desktop MCP clients may launch the process from another directory. Supplying environment variables directly in the client configuration and an absolute TOKEN_STORAGE_PATH makes the runtime configuration explicit.
For clients using a mcpServers JSON configuration, the preceding example supplies the process definition. Some clients use a different wrapper or configuration format; retain the command, absolute argument path, and environment values.
Common desktop configuration locations include:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%/Claude/claude_desktop_config.json
The project does not edit these files automatically.
For manual browser opening, set LINKEDIN_AUTH_NO_BROWSER=true before npm run auth, then open the printed URL yourself. Authorization must return to the machine running the callback listener; a remote host's localhost is a different machine.
Symptom | Resolution |
| Install Node.js, reopen the terminal, and verify PATH. Desktop applications may need a restart or an absolute executable path. |
| Run |
Missing OAuth credentials | Replace placeholders in |
Callback | Choose a free loopback port in |
Redirect URI mismatch | Match scheme, hostname, port, and path exactly between the application and |
Invalid OAuth scope | Request only scopes approved for your developer application. |
Authorization times out | Run the command again, open the new URL, and complete consent before the configured timeout. |
No advertising accounts | Check account membership, selected LinkedIn identity, app access, and whether the account is a test account. Try |
HTTP 401 | Inspect local expiration and reauthenticate with |
HTTP 403 | Check API product approval, granted scopes, and advertising-account roles. Repeating the same request does not add permissions. |
HTTP 429 | Reduce concurrent requests or report scope. Reads honor a valid bounded |
JSON-RPC parsing error | Launch |
Token save fails | Check directory permissions and available disk space; use a writable absolute token directory. |
API version is rejected | Choose a supported |
Dashboard charts do not render | Check browser developer tools and network access to the versioned Chart.js CDN. |
Testing
Run the complete static-check and test gate:
npm run checkIndividual commands:
Command | Purpose |
| Strict TypeScript validation without emitting files |
| Build and execute all test files |
| Build and run core/API/OAuth regression tests |
| Build and test MCP discovery, dispatch, read-only behavior, and a real stdio subprocess |
| Query the npm advisory database for the installed dependency tree |
| Compile runtime JavaScript, declarations, and source maps |
The test suite uses mocked LinkedIn responses and temporary local HTTP servers. It does not require LinkedIn credentials, spend advertising budget, or call the real LinkedIn API. OAuth tests exercise state validation, callback paths, port conflicts, token exchange, and timeout cleanup locally.
The repository uses TypeScript checking as its static-analysis gate; no separate ESLint configuration is included.
Report reproducible problems through the GitHub issue tracker. Include your Node.js version, operating system, failing command or tool name, and a sanitized error message.
To request native Node.js coverage output after building:
npm run build
node --test --experimental-test-coverage test/*.test.mjsCovered scenarios include permanent/transient HTTP errors, failed writes, timeouts, concurrency limits, request coalescing, pagination, metric merging, token corruption and refresh races, HTML escaping, input validation, account currencies, and reporting edge cases.
Local and mocked tests verify application behavior. They do not establish that your developer application has the necessary LinkedIn access or that every endpoint is available in your account. After deployment, first use get_server_status, list_ad_accounts, and a small reporting request against an account you control. Test write workflows against a suitable test account before enabling them for production accounts.
Deployment
Local Production Process
Build and verify before removing development dependencies:
npm ci --ignore-scripts
npm run check
npm prune --omit=dev --ignore-scripts
node dist/index.jsNormally your MCP client launches the final command. An idle terminal process is expected: the stdio server waits for MCP messages and does not expose a browser interface or network health endpoint.
Use a dedicated writable token directory, explicit environment variables, and the operating-system identity intended to own the credentials. Start with LINKEDIN_READ_ONLY=true when deploying reporting workflows. The process handles SIGINT and SIGTERM by closing its MCP transport.
Continuous Integration
The included CI workflow installs the committed lockfile, runs type checking and tests, and checks high-or-critical npm advisories on Linux and Windows with Node.js 22 and 24. Configure it in your repository's Actions environment; adding the workflow does not mean a hosted run has already passed.
Container Deployment
docker build -t linkedin-ads-mcp-toolkit:local .Authenticate on the host first, then mount the token directory into the non-root container:
docker run --rm -i \
--env-file .env \
-e LINKEDIN_READ_ONLY=true \
-e TOKEN_STORAGE_PATH=/home/node/.linkedin-ads-mcp/tokens.json \
--mount type=bind,source=/absolute/path/to/.linkedin-ads-mcp,target=/home/node/.linkedin-ads-mcp \
linkedin-ads-mcp-toolkit:localThe directory must be writable by the container's node user when token refresh is required. The runtime image defaults to read-only tool operation; explicitly set LINKEDIN_READ_ONLY=false only when writes are part of your intended workflow.
Keep stdin attached with
-i; allocating a terminal with-tis unnecessary for MCP stdio.No port mapping is required for the MCP server. Authenticate on the host; the temporary OAuth callback is a separate local CLI workflow.
Mounting a single
tokens.jsonfile can interfere with atomic rename. Mount the containing directory instead.Do not bake
.envor token files into an image. The supplied.dockerignoreexcludes the default sensitive paths.Relative file uploads resolve inside the container; MCP uploads require absolute paths that exist in that runtime.
After pruning development dependencies, run the compiled server directly. Development/build scripts require the TypeScript compiler.
Prefer one active process per token file, or use separate
TOKEN_STORAGE_PATHvalues. Refresh coordination and write serialization are process-local.The Dockerfile is an optional deployment definition. Verify the build and mount permissions in your Docker environment before use.
Usage
Basic Workflow
Ask the client to run
get_server_statusto inspect local settings and token expiration.Run
list_ad_accountsand select an account ID.Start with a short reporting range.
Request comparisons or more detailed pivots as needed.
Example MCP tool-call parameters:
{
"name": "get_campaign_performance",
"arguments": {
"accountId": "123456789",
"startDate": "2026-09-01",
"endDate": "2026-09-30",
"timeGranularity": "ALL"
}
}These are the params supplied to an MCP tools/call request; your client provides the JSON-RPC envelope and request identifier.
Natural-language examples:
Show campaign performance for the last 30 days.
Which job functions have the highest click-through rate?
Compare September with August for account 123456789.
Show daily conversion trends for the previous two weeks.
Which creatives have the best video completion rate?
List draft and paused campaigns, including those without impressions.
Search the public ad library for a competitor's advertisements.Available Tools
Tool | Operation | Purpose |
| Local | Configuration, local token expiration, tool count; no network request |
| Read | Accessible accounts; status/type/test filtering |
| Read | Account currency, settings, status, and notifications |
| Read | Campaign KPIs and optional time buckets |
| Read | Creative KPIs, engagement breakdown, and optional video metrics |
| Read | Campaign groups, campaign counts, optional performance when a start date is supplied |
| Read | Performance by supported demographic pivot |
| Read | Member reach, frequency, and supported penetration metrics |
| Read | Saved/matched audience configuration and status |
| Read | Conversion-action metrics and attribution breakdown |
| Read | Conversion tracking definitions |
| Read | Leads, form opens, qualified leads, and acquisition costs |
| Read | Lead form configuration |
| Read | Period, campaign-set, or campaign-group-set comparisons |
| Read | Daily records, totals, weekday summaries, peak and lowest days |
| Read | Raw custom metrics, pivots, time granularity, and entity filters |
| Read | All matching campaigns, including drafts and zero-impression entities |
| Read | Keyword, advertiser, country, dates, targeting facets, and impression filters |
| Write | Create a campaign group; defaults to draft |
| Write | Change group name, status, budget, or end date |
| Write | Delete a resolved draft or request deletion for a resolved non-draft group |
| Write | Create a campaign with budget, objective, bidding, and targeting |
| Write | Update campaign settings and supported targeting/budget fields |
| Write | Delete a resolved draft or request deletion for a resolved non-draft campaign |
| Write | Sponsor an existing content reference |
| Write | Create an ad with inline post content |
| Write | Change intended creative status |
| Write | Validate and upload a local PNG, JPEG, or GIF |
Read-only mode exposes 18 tools, including the local status tool. All tools provide operation hints in MCP discovery. Discover schemas through tools/list for exact fields, required arguments, and enums.
Generate an HTML Dashboard
Set the account ID and optional presentation settings in .env:
LINKEDIN_ADS_ACCOUNT_ID=123456789
LINKEDIN_ADS_ACCOUNT_NAME=My advertising account
DASHBOARD_START_DATE=2026-09-01
DASHBOARD_END_DATE=2026-09-30
DASHBOARD_OUTPUT_PATH=dashboard.html
DASHBOARD_OPEN=falseThen run:
npm run dashboardThe dashboard includes campaign and creative tables, trends, demographic breakdowns, conversions, and interactive filters. Open the generated HTML file locally. Chart rendering requires network access to the pinned Chart.js CDN asset. The default reporting range is the preceding 90 days through today; the explicit dashboard range must not exceed 92 inclusive calendar days because reach metrics are included.
If an optional demographic or conversion-breakdown request fails, the generated dashboard displays a partial-report notice with the affected sections. Required campaign/report requests still fail the command.
For a console summary across accessible accounts:
npm run performanceCustom analytics preserves the raw API record structure, with metric values directly on each record:
{
"name": "get_analytics",
"arguments": {
"accountId": "123456789",
"pivot": "CAMPAIGN",
"startDate": "2026-09-01",
"endDate": "2026-09-30",
"timeGranularity": "DAILY",
"campaigns": ["987654321"],
"metrics": ["impressions", "clicks", "costInUsd", "videoViews"]
}
}The raw analytics tool accepts up to 100 distinct metric names. LinkedIn must support each requested metric for the chosen pivot/version. Selections exceeding the per-request field budget are split, then merged by pivotValues and dateRange. Upstream dimension changes between batches result in an error to avoid joining unrelated rows.
Time-period comparison:
{
"name": "compare_performance",
"arguments": {
"accountId": "123456789",
"comparisonType": "TIME_PERIOD",
"periodA": { "startDate": "2026-08-01", "endDate": "2026-08-31" },
"periodB": { "startDate": "2026-09-01", "endDate": "2026-09-30" }
}
}For CAMPAIGNS or CAMPAIGN_GROUPS, supply nonempty numeric entityIds for both sets. The comparison uses the common date range defined by periodA (or the handler's default start range).
Direct API use after compilation:
import 'dotenv/config';
import { TokenStore } from './dist/auth/token-store.js';
import { LinkedInApiClient } from './dist/lib/linkedin-api.js';
const store = new TokenStore();
const api = new LinkedInApiClient(store);
// Retrieve all pages before selecting the account.
const accounts = await api.listAdAccounts();
if (!accounts.length) throw new Error('No accessible advertising accounts');
const rows = await api.getAnalytics({
accountId: String(accounts[0].id),
pivot: 'ACCOUNT',
startDate: '2026-09-01',
endDate: '2026-09-30',
metrics: ['impressions', 'clicks', 'costInUsd'],
});
console.log(rows);MCP validation normalizes matching account/campaign/group/creative URNs for the corresponding ...Id and ...Ids arguments. Direct low-level API consumers should pass the numeric IDs expected by each method. The raw get_analytics filter arrays use numeric IDs.
Write tools require LINKEDIN_READ_ONLY=false, the correct LinkedIn scopes, and sufficient account roles. New campaign groups, campaigns, and creatives default to DRAFT where the corresponding status is omitted.
Example campaign group:
{
"name": "create_campaign_group",
"arguments": {
"accountId": "123456789",
"name": "Product launch",
"startDate": "2026-11-01",
"endDate": "2026-11-30",
"totalBudgetAmount": "5000.00",
"status": "DRAFT"
}
}Budget amounts are positive decimal strings. The account currency is used when a budget/bid currency is omitted; explicit currencies must match the account. Group creation with a total budget requires an end date. Targeting criteria are LinkedIn API objects whose business rules are validated by LinkedIn.
For existing content, use create_creative with a contentReference such as urn:li:share:123456789. For inline content, use create_inline_ad with an organization, commentary, and optional media, destination, and call-to-action fields.
Image upload requires an absolute local path:
{
"name": "upload_image",
"arguments": {
"organizationId": "urn:li:organization:123456",
"filePath": "/absolute/path/to/creative.png"
}
}organizationId can also be an explicit urn:li:sponsoredAccount:... owner when supported by your permissions. Provide both accountId and assetName for media-library registration. Use the returned imageUrn as the media identifier in a subsequent ad request.
The server checks the extension, file signature, regular-file status, nonzero size, and configured byte limit before initializing an upload. LinkedIn may apply stricter dimensions, format, and size restrictions.
Activating campaigns or creatives can affect advertising delivery and spend. Write requests are not automatically retried. If a write times out, inspect the account's current state before submitting it again. LinkedIn's create/delete workflows can have partial or asynchronous effects.
Metric | Interpretation |
Spend / | Cost denominated in USD |
| Cost denominated in the advertising account's currency |
Impressions / clicks | API-reported delivery and clicks |
CTR | Clicks divided by impressions, multiplied by 100 |
CPC / CPM | USD spend per click / per 1,000 impressions in standard USD reports |
Engagement rate | Total engagements divided by impressions, multiplied by 100 |
Conversion rate | Conversions divided by clicks, multiplied by 100 |
Cost per conversion / lead | Spend divided by the corresponding eligible result count |
Reach | Approximate member reach; availability and privacy limits apply |
Frequency | Impressions divided by the relevant reach estimate |
Audience penetration | API-supported reached share of target audience |
Average dwell time | API-reported dwell-time metric; availability depends on reporting context |
Conversion value | Local-currency conversion value, separate from USD cost |
Important interpretation details:
Percentage change from a zero baseline is
null, because the relative growth rate is undefined.Undefined cost-per-result metrics are returned as
nullwhere their handlers support nullable values; other standard zero-denominator rates may be reported as zero.Campaign/creative reports preserve API time dimensions when a time-based granularity is requested.
Missing reach in MCP performance/demographic reports is
null; it is never fabricated from impression counts. Dashboard numeric aggregates include reported reach only, and mark unavailable campaign/creative reach.Summed reach across campaigns or time buckets is not deduplicated account reach. Use an account-level reach query for that purpose.
Demographic metrics may be delayed, suppressed, or incomplete due to LinkedIn privacy thresholds. Static demographic-name mappings may fall back to IDs.
Reach reports enforce a maximum of 92 inclusive calendar days. Other metrics can have their own LinkedIn restrictions.
Analytics responses at the 15,000-row safety threshold fail explicitly; narrow the date range or filter scope. Analytics traversal does not assume ordinary collection pagination.
Custom campaign-performance selections can omit fields used by standard derived metrics. Use
get_analyticsfor raw custom results, or request all required base metrics.get_daily_trendsreturns the rawrecordswhen custom metrics are supplied, alongside its standard daily summary.Account/group/creative names may be unavailable when the linked content was deleted or inaccessible.
Local status can show an unexpired token even if LinkedIn has revoked it. A real reporting request is required to verify authorization.
Reference the official reporting documentation, cursor pagination documentation, and API versioning documentation when selecting metrics or updating API versions.
Configuration
CLI entry points load .env from the working directory. Existing process environment variables take precedence. loadConfig() validates API transport settings when the API client is constructed; invalid values fail startup instead of being silently coerced.
The compatibility default API version is 202601; explicitly select another supported version with LINKEDIN_API_VERSION after validating your endpoints and app access. A correctly formatted version value does not establish that LinkedIn still supports it.
Variable | Default | Accepted values / purpose |
| Unset | Developer application client ID; required for login and refresh |
| Unset | Developer application secret; required for login and refresh |
|
| HTTP loopback URL with a registered host, port, and path; no credentials, query, or fragment |
|
| Space-separated approved OAuth scope names |
|
| Authorization flow deadline; integer 1–1,800,000 ms |
| Unset | Exact value |
|
| Token-file path; an absolute path is recommended |
|
| Marketing API version in |
|
| Exact |
|
| Per-attempt request/body deadline; integer 1–300,000 ms |
|
| Extra GET attempts; integer 0–10. |
|
| Initial retry delay; integer 1–60,000 ms |
|
| Maximum retry delay; integer from the base delay to 60,000 ms |
|
| Simultaneous API attempts per client; integer 1–50 |
|
| Collection request page size; integer 1–100 |
|
| Maximum pages per collection traversal; integer 1–10,000 |
|
| Local upload byte limit; integer 1–104,857,600. LinkedIn restrictions also apply |
| Unset | Positive numeric account ID; required for dashboard generation |
|
| Dashboard display name |
| 90 days before today | Dashboard start date in |
| Today | Dashboard end date in |
|
| Generated HTML output path |
| Unset | Exact value |
The retry policy covers GET network/timeout failures and HTTP 408, 429, 500, 502, 503, and 504. Other HTTP failures are returned immediately. A Retry-After beyond the configured wait budget produces an error instead of retrying early.
Concurrency queue time and separate pagination/batching requests are additional to the per-attempt timeout; the timeout is not a deadline for an entire multi-request report.
Command | Behavior |
| Reuse usable local authentication or start OAuth when necessary |
| Start a new authorization flow even when a token is present |
| Show local authentication/expiration metadata without network access |
| Remove local tokens |
| Display available flags |
Choose one authentication flag at a time. Logout removes this machine's saved credentials; it does not revoke grants at LinkedIn.
The token store checks access-token expiration with a five-minute refresh window. If refresh is unavailable or temporarily fails, an otherwise unexpired access token remains usable until its actual expiry. Failed refresh attempts are throttled for 30 seconds within a process.
When refresh succeeds, an omitted replacement refresh token is preserved. A supplied refresh-token lifetime is tracked separately. Existing token files without a valid absolute access-token expiration are not treated as authenticated.
Token writes use a temporary file, flush, and atomic replacement. Creation modes are 0700 for directories and 0600 for token files where the operating system supports those modes. Windows access control follows the user's filesystem ACLs. The files are local plaintext credentials and should be stored in a protected user directory.
License
Distributed under the Apache-2.0 license. See LICENSE for the complete terms.
Redistribution must retain the existing copyright and permission notices required by that license.
Support the Project
If you find this tool useful, consider leaving a star on GitHub or supporting the author directly.
Available Tools
28 toolscompare_performanceBRead-onlyIdempotent
Compares performance between two time periods, campaigns, or campaign groups. Calculates percentage changes and highlights significant differences. Essential for reporting on performance trends.
Inputs: periodA (required), periodB (required), accountId (required), comparisonType (required).
create_campaignBDestructive
Creates a new LinkedIn ad campaign within a campaign group. Requires targeting criteria, budget, and objective type.
Inputs: name (required), accountId (required), objectiveType (required), unitCostAmount (required), +18 more.
create_campaign_groupBDestructive
Creates a new LinkedIn campaign group for organizing campaigns. Campaign groups manage status, budget, and performance across multiple related campaigns.
Inputs: name (required), accountId (required), startDate (required), status, +6 more.
create_creativeADestructive
Creates a new LinkedIn creative/ad under a campaign. Requires a content reference (post/share URN) or will be created as a reference to existing content.
Inputs: accountId (required), campaignId (required), contentReference (required), name, +3 more.
create_inline_adBDestructive
Creates a new LinkedIn ad with inline content directly (without needing a pre-existing post). This creates the ad content (text, image/video, landing page, CTA) and the creative in a single call. Use this to create sponsored content ads from scratch.
Inputs: accountId (required), campaignId (required), commentary (required), organizationId (required), +8 more.
delete_campaignADestructive
Deletes a LinkedIn campaign. Draft campaigns are deleted immediately. Non-draft campaigns are set to PENDING_DELETION status.
Inputs: accountId (required), campaignId (required).
delete_campaign_groupADestructive
Deletes a LinkedIn campaign group. Draft groups are deleted immediately. Non-draft groups are set to PENDING_DELETION status.
Inputs: accountId (required), campaignGroupId (required).
get_account_detailsARead-onlyIdempotent
Retrieves detailed information about a specific LinkedIn Ad Account including status, currency, notification settings, and linked organization.
Inputs: accountId (required).
get_analyticsARead-onlyIdempotent
Query raw LinkedIn analytics with custom metrics, entity or demographic pivots, filters, and time granularity. Large metric selections are split and merged automatically.
Inputs: pivot (required), accountId (required), startDate (required), endDate, +5 more.
get_audience_demographicsARead-onlyIdempotent
Retrieves demographic breakdown of who saw or interacted with your ads. Shows performance segmented by job function, seniority, industry, company size, or geographic location. Essential for understanding if you're reaching your target audience. Note: Demographic data has a 12-24 hour delay.
Inputs: accountId (required), startDate (required), demographicType (required), limit, +3 more.
get_audience_reachARead-onlyIdempotent
Shows unique member reach and native audience penetration for campaigns. Returns LinkedIn's native audiencePenetration metric (approximate unique members reached / total target audience size). Helps understand what percentage of your target audience you've reached. Note: Date range must be 92 days or less.
Inputs: accountId (required), startDate (required), endDate, campaignIds, +1 more.
get_campaign_groupsBRead-onlyIdempotent
Lists all campaign groups for an account with their configuration and optionally aggregated performance. Campaign groups help organize campaigns and control budget at a higher level.
Inputs: accountId (required), status, endDate, startDate, +1 more.
get_campaign_performanceARead-onlyIdempotent
Retrieves performance metrics for campaigns within a specified date range. Returns key metrics like impressions, clicks, spend, CTR, conversions, audience penetration, and average dwell time. The primary tool for daily campaign monitoring and optimization decisions.
Inputs: accountId (required), startDate (required), endDate, metrics, +3 more.
get_conversion_performanceBRead-onlyIdempotent
Retrieves conversion metrics broken down by conversion type/action. Shows which conversions are being driven by which campaigns, with cost per conversion and conversion value.
Inputs: accountId (required), startDate (required), endDate, campaignIds, +2 more.
get_creative_performanceBRead-onlyIdempotent
Retrieves performance metrics for individual ad creatives. Shows which specific ads are performing best, including engagement metrics (likes, comments, shares), video metrics, and average dwell time. Essential for creative optimization.
Inputs: accountId (required), startDate (required), endDate, campaignIds, +3 more.
get_daily_trendsARead-onlyIdempotent
Retrieves daily performance trends over a specified period. Returns time-series data for visualizing performance patterns, identifying anomalies, and understanding day-of-week effects.
Inputs: accountId (required), startDate (required), endDate, metrics, +2 more.
get_lead_gen_performanceBRead-onlyIdempotent
Retrieves lead generation form performance including form submissions, qualified leads, and cost per lead. Essential for B2B marketers running lead gen campaigns.
Inputs: accountId (required), startDate (required), endDate, campaignIds, +1 more.
get_server_statusARead-only
Returns local configuration and token expiration status without exposing secrets or making API calls.
Inputs: no named parameters.
list_ad_accountsARead-onlyIdempotent
Lists all LinkedIn Ad Accounts accessible to the authenticated user. Returns account names, IDs, status, currency, and serving statuses. Use this to get an overview of all accounts or find a specific account ID.
Inputs: type, status, includeTest.
list_campaignsARead-onlyIdempotent
Lists campaigns for a LinkedIn Ad Account. Unlike get_campaign_performance (which only returns campaigns with analytics data), this tool returns ALL campaigns including DRAFT and PAUSED campaigns with zero impressions. Supports filtering by campaign group and status.
Inputs: accountId (required), status, campaignGroupIds.
list_conversionsBRead-onlyIdempotent
Lists all conversion tracking rules configured for an account. Shows conversion names, types, attribution windows, and enabled status.
Inputs: accountId (required), enabledOnly.
list_lead_formsBRead-onlyIdempotent
Lists all lead generation forms configured for an account with their questions and settings. Helps understand what forms are available and their configuration.
Inputs: accountId (required), status, includeQuestions.
list_saved_audiencesARead-onlyIdempotent
Lists saved/matched audiences available in the account for targeting. Shows audience names, sizes, and statuses to help plan campaign targeting.
Inputs: accountId (required), status, audienceType.
search_ad_libraryARead-onlyIdempotent
Searches the LinkedIn Ad Library for ads matching criteria. Find and analyze real ads from any advertiser across different countries and time periods. Supports filtering by keyword, advertiser name, country, date range, targeting facets, and impression range. Returns ad preview URLs, advertiser details, targeting information, and impression statistics. Maximum 25 results per request (use pagination).
Inputs: count, start, endDate, keyword, +10 more.
update_campaignADestructive
Updates an existing LinkedIn campaign. Can change status (ACTIVE/PAUSED/ARCHIVED), budget, name, targeting, bid amount, and other settings. Uses partial update - only specified fields are changed.
Inputs: accountId (required), campaignId (required), name, status, +11 more.
update_campaign_groupBDestructive
Updates an existing LinkedIn campaign group. Can change status (ACTIVE/PAUSED/ARCHIVED/DRAFT), budget, name, or end date.
Inputs: accountId (required), campaignGroupId (required), name, status, +3 more.
update_creative_statusADestructive
Updates the intended status of a LinkedIn creative/ad. Can activate, pause, or archive creatives.
Inputs: accountId (required), creativeId (required), intendedStatus (required).
upload_imageADestructive
Uploads an image file to LinkedIn for use in ads. Supports PNG, JPG, and GIF formats. Returns the image URN that can be used as the mediaId when creating inline ads. The image is uploaded in two steps: initialize upload (get URL + URN), then upload binary.
Inputs: filePath (required), organizationId (required), accountId, assetName.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 28 tools
Most tools have clearly distinct purposes (CRUD on campaigns/groups vs. specialized performance retrievals), and descriptions proactively distinguish look-alikes like get_campaign_performance vs. list_campaigns. However, the cluster of performance tools (get_campaign_performance, get_creative_performance, get_audience_demographics, get_conversion_performance, get_lead_gen_performance, get_daily_trends, get_analytics) has overlapping boundaries where an agent could easily pick the wrong one.
Nearly every tool follows a clean snake_case verb_noun pattern (get_, list_, create_, update_, delete_, upload_, compare_, search_). The convention is applied consistently across all 28 tools with no camelCase or naming-style deviations.
28 tools is a large surface that sits just above the comfortable 15-25 range, and several performance tools could plausibly be consolidated under get_analytics. The broad LinkedIn Ads domain (campaigns, creatives, audiences, conversions, lead gen, ad library) does justify most of them, so it's borderline rather than bloated.
Core lifecycle coverage is strong: full CRUD for campaigns and campaign groups, creative creation and status changes, plus extensive read/analytics for audiences, conversions, and lead gen. Minor gaps exist (no create/update for lead forms, audiences, or conversions; no creative delete beyond status), but agents can work around these.
Maintenance
Related MCP Connectors
Meta Ads MCP: Facebook and Instagram reports, campaigns, creatives, audiences. Approval on writes.
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Unified ad and marketing data from 30+ platforms: query it, build reports, manage campaigns.
Meta Ads MCP server: run Facebook and Instagram campaigns, ad sets, ads and reports from AI.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients to read ad account, campaign, ad group, and ad data plus performance insights, and optionally create, pause, activate, or update paused campaigns, ad groups, and ads through a secured Streamable HTTP endpoint.MIT
- AlicenseNot gradedqualityAmaintenanceEnables managing Meta advertising accounts, campaigns, ad sets, creatives, audiences, reporting, and batch workflows through an authenticated MCP endpoint with per-workspace OAuth connections.39 npmMIT
- AlicenseBqualityBmaintenanceEnables MCP clients to read Snapchat Ads campaigns and performance and to prepare preview-first changes for selected ad accounts, with opt-in write tools and explicit confirmation before applying updates.2187 npmApache 2.0
- AlicenseAqualityBmaintenanceEnables MCP clients to inspect ad account structure, campaign performance, demographic breakdowns, and revenue attribution, and to prepare opt-in, preview-first draft campaigns, ads, and media uploads for explicitly selected accounts.1884 npmApache 2.0