Skip to main content

linkedin-ads-mcp

MCP server for the LinkedIn Marketing API, with built-in MCC-style client switching across every ad account your LinkedIn login can access.

Installation

Once published to PyPI:

uv tool install linkedin-ads-mcp-py

This installs the linkedin-ads-mcp and linkedin-ads-auth commands. Or run it directly without installing:

uvx --from linkedin-ads-mcp-py linkedin-ads-mcp

Point your MCP client (e.g. .mcp.json or Claude Desktop's config) at the linkedin-ads-mcp command.

Setup

  1. Create an app at LinkedIn Developers with access to the Advertising API product (requires LinkedIn's approval — see their docs, no published SLA).

  2. Add http://localhost:3000/callback (or your own LINKEDIN_REDIRECT_URI) to the app's authorized redirect URLs.

  3. Set the following environment variables (e.g. in a .env file in your working directory, or directly in your MCP client's server config):

    LINKEDIN_CLIENT_ID=your_client_id
    LINKEDIN_CLIENT_SECRET=your_client_secret
    # Optional overrides:
    # LINKEDIN_REDIRECT_URI=http://localhost:3000/callback
    # LINKEDIN_TOKEN_PATH=/path/to/tokens.json
    
  4. Authenticate (opens a browser for the LinkedIn OAuth consent screen):

    uvx --from linkedin-ads-mcp-py linkedin-ads-auth
    

    Tokens are saved to ~/.linkedin-ads-mcp/tokens.json by default and refreshed automatically when a refresh token is available.

  5. Run the server:

    uvx --from linkedin-ads-mcp-py linkedin-ads-mcp
    

Headless / remote deployments

Hosts that can't open a browser or receive the local OAuth callback (e.g. MCP Anywhere) can't run linkedin-ads-auth themselves. Instead, run it once locally as above, then read the refresh_token value out of the saved token file (~/.linkedin-ads-mcp/tokens.json by default) and set it as LINKEDIN_REFRESH_TOKEN alongside LINKEDIN_CLIENT_ID/LINKEDIN_CLIENT_SECRET in that host's environment variables. On first tool call, the server exchanges it for a live access token automatically, no browser needed at runtime.

MCC / multi-account support

Unlike the original TypeScript linkedin-ads-mcp, this server exposes every ad account your LinkedIn login can access and lets you switch between them by name or ID:

  • list_clients — list all accessible ad accounts (call this first)
  • set_active_client — select a default account (by name or numeric ID) for subsequent calls
  • get_active_client — show which account is currently active

Every account-specific tool also accepts an optional account argument to target a client directly without changing the active selection.

Tools

Tool Notes
list_clients MCC view — call first
set_active_client select account by name or ID
get_active_client show current selection
get_account_details account metadata
list_campaign_groups
list_campaigns
get_campaign_performance report
get_campaign_groups_performance report
get_creative_performance report
get_audience_demographics report
get_audience_reach reach / frequency
compare_performance compare two time windows or entity sets
get_daily_trends daily time series
list_creatives
get_conversion_performance report
list_conversions
get_lead_gen_performance report
list_lead_forms
list_saved_audiences

Architecture

  • auth/oauth.py — OAuth 2.0 authorization-code flow, browser + local callback server
  • auth/token_store.py — persistent token storage with automatic refresh
  • api/client.py — LinkedInClient, async wrapper around the LinkedIn Marketing REST API
  • api/types.py — Pydantic models for API entities and responses
  • context.py — ServerContext singleton holding the active client and name→ID cache
  • tools/accounts.py — MCC tools (list_clients, set_active_client, get_active_client)
  • server.py — MCP stdio server, tool registration

Development

uv sync
uv run pre-commit install

uv run ruff format
uv run ruff check
uv run mypy src/
uv run pytest

Building and publishing

uv build

Publishing to PyPI is handled by .github/workflows/pypi-publish.yml via PyPI trusted publishing whenever a GitHub release is published — no API token needed once the trusted publisher is configured on the PyPI project.

License

MIT License - see LICENSE file for details.

Release files for linkedin-ads-mcp-py 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for linkedin-ads-mcp-py 0.1.1
File Size Uploaded
linkedin_ads_mcp_py-0.1.1.tar.gz 24.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for linkedin-ads-mcp-py 0.1.1
File Interpreter ABI Platform
linkedin_ads_mcp_py-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 57.8 kB

Release files / linkedin_ads_mcp_py-0.1.1.tar.gz

Download URL linkedin_ads_mcp_py-0.1.1.tar.gz
Size 24.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d38165e8d09e986cc9bd9a9b8936282359ced8e11e2ee096074076b800f7a63a
BLAKE2b-256 checksum
How to use checksums
19c3ff9c6b96239e1196906144ae3f6d379dac0b83a62d9ffadd24a0bc01d73a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release files / linkedin_ads_mcp_py-0.1.1-py3-none-any.whl

Download URL linkedin_ads_mcp_py-0.1.1-py3-none-any.whl
Size 33.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d223656abea2803586368b254ca5c3d90a01979472860fabfa32f7638d4acef
BLAKE2b-256 checksum
How to use checksums
a2ed02c56683adfa43a8a7c79993ddb7691c1c1e91d2d5955a4049636e2bd8f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page