Labsco
timkulbaev logo

mcp-linkedin

โ˜… 1

from timkulbaev

Publish LinkedIn posts, comments, and reactions via Unipile โ€” dry_run by default for safety.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredNeeds API keys

mcp-linkedin

An MCP server that lets AI assistants publish to LinkedIn on your behalf.

mcp-linkedin MCP server

What it does

This is a Model Context Protocol (MCP) server that wraps the Unipile API to give AI assistants (Claude Code, Claude Desktop, or any MCP-compatible client) the ability to create posts, comments, and reactions on LinkedIn. The AI writes the content; this tool handles the publishing. All publishing actions default to preview mode โ€” nothing goes live without explicit confirmation.

Features

  • 3 tools: publish, comment, react
  • Dry run by default (preview before publishing)
  • Auto-likes posts immediately after publishing
  • Media attachments (local files or URLs โ€” images and video)
  • Company @mentions (auto-resolved via Unipile)
  • Works with Claude Code, Claude Desktop, and any MCP client

Tools

linkedin_publish

Creates an original LinkedIn post.

dry_run defaults to true. Call with dry_run: true first to get a preview, then call again with dry_run: false to actually publish.

ParameterTypeRequiredDefaultDescription
textstringyesโ€”Post body, max 3000 characters
mediastring[]no[]Local file paths or URLs (jpg, png, gif, webp, mp4)
mentionsstring[]no[]Company names to @mention (auto-resolved)
dry_runbooleannotruePreview without publishing

Preview response (dry_run: true):

{
  "status": "preview",
  "post_text": "Hello LinkedIn!",
  "character_count": 16,
  "character_limit": 3000,
  "media": [],
  "mentions": [],
  "warnings": [],
  "ready_to_publish": true
}

Publish response (dry_run: false):

{
  "status": "published",
  "post_id": "7437514186450104320",
  "post_text": "Hello LinkedIn!",
  "posted_at": "2026-03-11T15:06:04.849Z",
  "auto_like": "liked"
}

After publish, save the post_id and construct the post URL:

https://www.linkedin.com/feed/update/urn:li:activity:{post_id}/

linkedin_comment

Posts a comment on an existing LinkedIn post.

dry_run defaults to true.

ParameterTypeRequiredDefaultDescription
post_urlstringyesโ€”LinkedIn post URL or raw URN (urn:li:activity:... or urn:li:ugcPost:...)
textstringyesโ€”Comment text
dry_runbooleannotruePreview without posting

linkedin_react

Reacts to a LinkedIn post. This action is immediate โ€” there is no dry_run.

ParameterTypeRequiredDefaultDescription
post_urlstringyesโ€”LinkedIn post URL or raw URN
reaction_typestringno"like"One of: like, celebrate, support, love, insightful, funny

How it works

                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚           mcp-linkedin            โ”‚
AI Assistant  โ”€โ”€โ–บ   โ”‚                                  โ”‚
(via MCP stdio)     โ”‚  Posts/Comments/Reactions  โ”€โ”€โ–บ  Unipile API  โ”€โ”€โ–บ  LinkedIn
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  • The AI assistant calls tools via MCP's JSON-RPC protocol over stdio
  • Calls Unipile API which handles LinkedIn OAuth โ€” no token management needed

Safe publishing workflow

The dry_run default exists to prevent accidental publishing. The intended flow:

  1. AI calls the tool with dry_run: true (the default)
  2. You see the preview: final text, character count, media validation, resolved mentions, warnings
  3. You confirm or ask for changes
  4. AI calls again with dry_run: false
  5. Post goes live

dry_run is true by default. The AI cannot publish without explicitly setting it to false, which requires going through the preview step first.

Media handling

  • Pass local file paths (/path/to/image.jpg) or URLs (https://example.com/img.png)
  • URLs are downloaded to /tmp/mcp-linkedin-media/ and cleaned up after publish (whether it succeeds or fails)
  • Supported formats: jpg, jpeg, png, gif, webp (images), mp4 (video)
  • Each file is validated before upload: must exist, be non-empty, and be a supported type
  • Failed files appear in the preview's media array with "valid": false and an error message

Company @mentions

  • Pass company names as strings: mentions: ["Microsoft", "OpenAI"]
  • The server slugifies each name and looks it up via Unipile's LinkedIn company search
  • Resolved companies are injected as {{0}}, {{1}} placeholders in the post text โ€” LinkedIn renders these as clickable @mentions
  • If a company name appears in the post text, it gets replaced in place; if not, the placeholder is appended
  • Unresolved names appear as warnings in the preview. The post can still be published without them.

Testing

npm test       # 28 unit tests, zero extra dependencies (Node.js built-in test runner)
npm run lint   # Biome linter

Project structure

mcp-linkedin/
  index.js                    Entry point (stdio transport)
  package.json
  src/
    server.js                 MCP server and tool registration
    unipile-client.js         Unipile API wrapper (posts, comments, reactions)
    media-handler.js          URL download and file validation
    tools/
      publish.js              linkedin_publish handler
      comment.js              linkedin_comment handler
      react.js                linkedin_react handler
  tests/
    unit.test.js              28 unit tests

Getting a Unipile account

  1. Sign up for a Unipile account
  2. In the dashboard, connect your LinkedIn account
  3. Copy your API key and DSN from the dashboard settings
  4. Paste them into the MCP config (see Configuration above)

Unipile has a free tier that covers basic usage.