Connect LinkedIn to Claude: Automate Content and Lead Generation
Learn how to connect LinkedIn to Claude using a managed MCP server. Automate content generation, B2B lead enrichment, and ad campaign workflows securely.
If your team uses ChatGPT, check out our guide on /connect-linkedin-to-chatgpt-manage-ad-campaigns-and-audience-data/ or explore our broader architectural overview on /connect-linkedin-to-ai-agents-manage-creatives-and-dmp-audiences/.
Giving a Large Language Model (LLM) read and write access to LinkedIn is an engineering challenge. LinkedIn's APIs are notoriously complex, utilizing an internal protocol that deviates significantly from standard REST conventions. You have to handle short-lived OAuth 2.0 tokens, map intricate payload schemas to MCP tool definitions, and deal with strict endpoint specificities. Every time LinkedIn updates a permission scope or modifies an endpoint, you have to update your server code, redeploy, and test the integration.
This guide breaks down exactly how to use Truto to generate a secure, managed MCP server for LinkedIn, connect it natively to Claude, and execute complex marketing and lead generation workflows using natural language.
The Engineering Reality of the LinkedIn API
A custom MCP server is a self-hosted integration layer. While the open MCP standard provides a predictable way for models to discover tools, the reality of implementing it against LinkedIn's API is painful.
If you decide to build a custom MCP server for LinkedIn, you own the entire API lifecycle. Here are the specific challenges you will face:
The Rest.li Protocol and Partial Updates
LinkedIn does not use standard REST. It uses an internal protocol called Rest.li. This means standard HTTP methods behave unexpectedly. If you want to update an ad campaign, you do not send a standard PATCH or PUT request with the updated fields. Instead, you send a POST request with an X-RestLi-Method: PARTIAL_UPDATE header, and your JSON payload must contain a specific patch object using a $set notation. An LLM has no context on how to construct a Rest.li patch. Your MCP server must strictly define these JSON schemas so Claude knows exactly how to format the tool arguments.
Uniform Resource Names (URNs)
LinkedIn does not use simple integer or UUID identifiers for its resources. It relies entirely on URNs. An ad account is not ID 12345; it is urn:li:sponsoredAccount:12345. When making API calls, these URNs must be URL-encoded (e.g., urn%3Ali%3AsponsoredAccount%3A12345). If Claude attempts to pass an unencoded URN or a raw ID to an endpoint, the request will fail immediately. The MCP tool definitions must explicitly instruct the model on how to handle these composite keys.
Multi-Step Media and Creative Workflows Creating a simple image ad on LinkedIn requires a complex orchestration of multiple API calls. You cannot simply upload an image and publish an ad in one request. You must first register the upload to get a temporary upload URL, PUT the binary file to that URL, wait for processing, create a post referencing the uploaded asset URN, and finally create a sponsored creative referencing the post URN. Exposing this raw process to Claude directly often leads to hallucinations and broken state logic. A managed MCP layer provides standardized tools that abstract these multi-step sequences.
Generating a LinkedIn MCP Server
Truto eliminates the need to build a custom MCP server. It dynamically generates a fully authenticated, self-contained MCP server directly from LinkedIn's API documentation and your connected OAuth account.
You can create this server through the Truto dashboard or programmatically via the API.
Method 1: Via the Truto UI
For teams managing integrations manually, generating an MCP server takes less than a minute:
- Log into your Truto dashboard and navigate to your Integrated Accounts.
- Select your connected LinkedIn account.
- Click the MCP Servers tab.
- Click Create MCP Server.
- Select your desired configuration (e.g., restrict to
readmethods only, or filter by specific tags likeads). - Copy the generated secure MCP URL (e.g.,
https://api.truto.one/mcp/a1b2c3d4e5f6...).
Method 2: Via the Truto API
For platform engineers embedding this functionality into an existing application, you can generate MCP servers programmatically. This is ideal for provisioning dedicated servers for different AI agents on the fly.
Make a POST request to /integrated-account/:id/mcp with your desired configuration:
curl -X POST https://api.truto.one/integrated-account/<LINKEDIN_ACCOUNT_ID>/mcp \
-H "Authorization: Bearer <TRUTO_API_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"name": "LinkedIn Campaign Auditor",
"config": {
"methods": ["read", "update"]
},
"expires_at": "2025-12-31T23:59:59Z"
}'The API validates the configuration, hashes the token securely in a distributed edge key-value store, and returns a ready-to-use URL:
{
"id": "mcp_8a7b6c5d",
"name": "LinkedIn Campaign Auditor",
"config": {
"methods": ["read", "update"]
},
"expires_at": "2025-12-31T23:59:59.000Z",
"url": "https://api.truto.one/mcp/a1b2c3d4e5f6..."
}Connecting the MCP Server to Claude
Once you have your Truto MCP URL, you can connect it directly to Claude. Because the URL contains an embedded, securely hashed token, no additional OAuth configuration is required on the client side.
Method A: Via the Claude UI (Desktop/Web)
If you are using Claude's enterprise or desktop interfaces that support custom connectors:
- Open Claude and navigate to Settings.
- Select Integrations or Connectors.
- Click Add MCP Server (or Add Custom Connector).
- Paste your Truto MCP URL into the Server URL field.
- Click Add.
Claude will immediately execute the MCP initialize handshake, discover all available LinkedIn tools, and make them available in your chat context.
Method B: Via Manual Config File
If you are running Claude Desktop locally or deploying a custom agent framework that consumes MCP configuration files, you can map the server using the official Server-Sent Events (SSE) transport.
Update your claude_desktop_config.json file to include the Truto endpoint:
{
"mcpServers": {
"linkedin-automation": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-sse",
"https://api.truto.one/mcp/a1b2c3d4e5f6..."
]
}
}
}Restart Claude Desktop. The application will boot the SSE proxy, connect to Truto's edge runtime, and fetch the LinkedIn schema definitions dynamically.
Security and Access Control
Exposing a massive platform like LinkedIn to an LLM requires strict boundary controls. Truto enforces security at the MCP server level using four core mechanisms:
- Method Filtering: You can strictly limit the server to safe operations. By passing
methods: ["read"]during creation, the server will only generate tools forgetandlistendpoints. Write operations (create,update,delete) are physically excluded from the tool list, making it impossible for Claude to hallucinate a destructive action. - Tag Filtering: If your integration includes dozens of resource types, you can filter tools by tag. Creating a server with
tags: ["ads"]ensures Claude only sees tools related to campaign management, hiding unrelated endpoints like organic posts or messaging. - Additional API Authentication: By enabling
require_api_token_auth: true, possession of the MCP URL is no longer sufficient. The connecting client must also pass a valid Truto API token in theAuthorizationheader, providing a second layer of enterprise security. - Time-to-Live (TTL): Setting an
expires_attimestamp ensures the MCP server automatically self-destructs. Background cleanup workers will purge the token from the edge store at the exact expiration time, making it ideal for temporary contractor access or ephemeral agent tasks.
Hero Tools for LinkedIn Automation
The Truto MCP server dynamically generates tools based on LinkedIn's actual API endpoints. Here are the highest-leverage tools available for automating your marketing and lead generation workflows.
list_all_linked_in_ad_campaigns
Retrieves a paginated list of ad campaigns associated with a specific ad account. This is the foundational tool for auditing performance and account structure.
Usage Notes: You must provide the ad_account_id. The response includes budget details, bid strategies, scheduling, targeting parameters, and current status. Truto automatically injects pagination arguments (limit, next_cursor) into the schema, instructing Claude to pass cursor values back unchanged for continuous fetching.
"Fetch all ad campaigns in the account urn:li:sponsoredAccount:1234567. Filter the list to show only campaigns currently in an ACTIVE status, and summarize their daily budgets."
update_a_linked_in_ad_campaign_by_id
Executes a Rest.li partial update on a specific ad campaign. This is heavily used by AI agents to optimize poorly performing campaigns or pause creatives based on external triggers.
Usage Notes: Requires the URL-encoded campaign URN as the id and the ad_account_id. The body must strictly follow the Rest.li patch schema, which is explicitly detailed in the tool's body_schema.
"The Q3 awareness campaign (urn:li:sponsoredCampaign:98765) is severely underperforming our target CPA. Execute an update to change its status to PAUSED immediately."
list_all_linked_in_ad_analytics
Fetches comprehensive reporting data for ad accounts, campaigns, or creatives over a specific date range.
Usage Notes: You must specify a pivot (e.g., CAMPAIGN, CREATIVE), a timeGranularity (e.g., DAILY, MONTHLY), and a dateRange. The API returns chargeable clicks, impressions, spend, and conversion metrics.
"Pull the daily ad analytics for all campaigns under account urn:li:sponsoredAccount:1234567 for the last 14 days. Calculate the average cost per click (CPC) and identify the top three campaigns driving the most impressions."
create_a_linked_in_dmp_segments_user
Adds or removes users from a Matched Audience (DMP) segment in batch. This is critical for synchronizing external CRM lists or intent data with LinkedIn targeting.
Usage Notes: Requires the dmp_segment_id. The payload accepts an array of elements specifying an action (ADD or REMOVE) and hashed user identifiers.
"Take this list of high-intent email addresses we extracted from our CRM, hash them using SHA-256, and add them to the Matched Audience segment urn:li:dmpSegment:55555."
create_a_linked_in_text_ad
Creates a simple text ad creative within a TEXT_AD campaign.
Usage Notes: You must provide the campaign URN, the intended status, and the content.textAd object containing the headline, description, and landing page URL.
"Draft three variations of a text ad for our new AI agent product. Use an urgent, professional tone. Once drafted, create the ads in campaign urn:li:sponsoredCampaign:112233 with an intended status of DRAFT."
list_all_linked_in_posts
Retrieves organic posts authored by a specific organization or individual.
Usage Notes: Requires the author parameter (an organization or person URN). This tool is essential for content managers looking to audit organic engagement or recycle successful social copy.
"Retrieve the last 20 organic posts published by our company page (urn:li:organization:445566). Extract the text content and identify any recurring themes that resulted in high engagement."
For the complete inventory of LinkedIn tools, schemas, and required parameters, visit the Truto LinkedIn integration page.
Workflows in Action
Connecting Claude to LinkedIn via MCP allows you to string together complex, multi-endpoint workflows that traditionally required dedicated scripts or middleware. Here is how specific personas use these tools.
1. The Autonomous Campaign Auditor
Performance marketers spend hours pulling reports, identifying wasted spend, and manually pausing failing campaigns. Claude can execute this entire audit loop autonomously.
"Audit my LinkedIn ad campaigns for account urn:li:sponsoredAccount:1234567. Pull the analytics for the last 7 days. If any campaign has spent more than $500 without generating a conversion, pause it immediately and summarize the actions taken."
Step-by-step execution:
- Claude calls
list_all_linked_in_ad_campaignsto retrieve the active campaign URNs. - Claude calls
list_all_linked_in_ad_analyticsusing those URNs, pivoting by CAMPAIGN for the past week. - The model analyzes the returned JSON, identifying campaigns crossing the $500 threshold with zero conversions.
- For each failing campaign, Claude calls
update_a_linked_in_ad_campaign_by_id, passing a Rest.li patch object to setstatus: PAUSED. - Claude outputs a formatted summary of the paused campaigns and the total spend saved.
sequenceDiagram
participant User as User
participant Claude as Claude Desktop
participant Truto as Truto MCP Server
participant LinkedIn as LinkedIn API
User->>Claude: "Audit campaigns and pause underperformers"
Claude->>Truto: tools/call (list_all_linked_in_ad_campaigns)
Truto->>LinkedIn: GET /rest/adAccounts/{id}/adCampaigns
LinkedIn-->>Truto: JSON Campaign List
Truto-->>Claude: Tool Result (Active Campaigns)
Claude->>Truto: tools/call (list_all_linked_in_ad_analytics)
Truto->>LinkedIn: GET /rest/adAnalytics?q=analytics
LinkedIn-->>Truto: JSON Performance Data
Truto-->>Claude: Tool Result (Spend & Conversions)
Claude->>Truto: tools/call (update_a_linked_in_ad_campaign_by_id)
Truto->>LinkedIn: POST /rest/adCampaigns/{id} (X-RestLi-Method: PARTIAL_UPDATE)
LinkedIn-->>Truto: 204 No Content
Truto-->>Claude: Tool Result (Success)
Claude-->>User: "I have paused 3 campaigns saving $1,500/wk."2. The Dynamic Lead Enrichment Loop
B2B sales teams rely heavily on Matched Audiences (DMP segments) to retarget high-value accounts. Keeping these lists synced dynamically is a major pain point.
"Review the list of target accounts we identified from our internal CRM tool. Create a new Matched Audience segment named 'Q4 High Intent Accounts' in our LinkedIn ad account, and add the identified company domains to it."
Step-by-step execution:
- Claude calls
create_a_linked_in_dmp_segmentproviding the account URN and naming the segment "Q4 High Intent Accounts". - The API returns the new segment ID.
- Claude calls
create_a_linked_in_dmp_segments_company, passing the segment ID and the list of domains extracted from the previous context, using theADDaction. - Claude confirms the audience has been created and populated.
A Factual Note on Rate Limits
LinkedIn enforces strict API rate limits across its endpoints. It is crucial to understand that Truto does not retry, throttle, or apply backoff on rate limit errors.
When the upstream LinkedIn API returns an HTTP 429 Too Many Requests error, Truto passes that exact error back to the caller. However, Truto does normalize the upstream rate limit information into standardized headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset) per the IETF specification.
The caller - whether that is the Claude Desktop application or your custom agent framework - is entirely responsible for reading these headers, implementing its own retry logic, and respecting the required backoff periods.
Moving Beyond Manual Scripts
Integrating LinkedIn with AI agents fundamentally changes how marketing and sales operations function. You no longer need to write custom Python scripts to parse Rest.li responses or manage complex cron jobs for audience syncing.
By leveraging an MCP server, Claude becomes a native operator within your LinkedIn ecosystem - capable of auditing spend, modifying campaigns, and managing audiences with full contextual awareness of the API's constraints. It turns raw endpoints into executable actions driven entirely by natural language.
FAQ
- How do I give Claude access to my LinkedIn ad accounts?
- You can connect Claude to LinkedIn by generating a Model Context Protocol (MCP) server URL using Truto. This URL acts as a bridge, translating Claude's natural language tool calls into authenticated LinkedIn API requests.
- Can Claude update LinkedIn ad campaigns automatically?
- Yes. By exposing LinkedIn's Rest.li update endpoints as MCP tools, Claude can execute partial updates (like pausing a campaign or adjusting a budget) based on your natural language instructions.
- How does Truto handle LinkedIn API rate limits?
- Truto passes HTTP 429 Too Many Requests errors directly to the caller and normalizes upstream rate limit information into standardized IETF headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset). The client framework is responsible for implementing retry and backoff logic.
- Do I need to write integration code to connect LinkedIn to Claude?
- No. Truto dynamically generates the MCP server and tool schemas directly from LinkedIn's API documentation, meaning you only need to provide the MCP URL to Claude to begin executing workflows.