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
-
Create an app at LinkedIn Developers with access to the Advertising API product (requires LinkedIn's approval — see their docs, no published SLA).
-
Add
http://localhost:3000/callback(or your ownLINKEDIN_REDIRECT_URI) to the app's authorized redirect URLs. -
Set the following environment variables (e.g. in a
.envfile 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
-
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.jsonby default and refreshed automatically when a refresh token is available. -
Run the server:
uvx --from linkedin-ads-mcp-py linkedin-ads-mcp
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 callsget_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 serverauth/token_store.py— persistent token storage with automatic refreshapi/client.py—LinkedInClient, async wrapper around the LinkedIn Marketing REST APIapi/types.py— Pydantic models for API entities and responsescontext.py—ServerContextsingleton holding the active client and name→ID cachetools/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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| linkedin_ads_mcp_py-0.1.0.tar.gz | 24.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| linkedin_ads_mcp_py-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 56.8 kB
Release files / linkedin_ads_mcp_py-0.1.0.tar.gz
| Download URL | linkedin_ads_mcp_py-0.1.0.tar.gz |
|---|---|
| Size | 24.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
02a53d6fb26dea9974cc7a602142db001f87f4e802206fce36f9e8e7d083b4cd
|
|
BLAKE2b-256 checksum How to use checksums |
0b9951549017e4c819ccc2eac6a36aa6c786760ad5004029307c8b3fe576ddb9
|
| 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 logRelease files / linkedin_ads_mcp_py-0.1.0-py3-none-any.whl
| Download URL | linkedin_ads_mcp_py-0.1.0-py3-none-any.whl |
|---|---|
| Size | 32.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e674c2ceab253c0256803d09f8f7ede6303501a6e932f8ad4fd4753df9855ff7
|
|
BLAKE2b-256 checksum How to use checksums |
f4b8457cbd73c58b155ae845b6c6483035398f1892dcfa45d6682ded64ad769e
|
| 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