mcp-server-linkedin

mcp-server-linkedin

Enables AI agents to publish posts, images, videos, and articles to LinkedIn.

Category
访问服务器

README

<h1 align="center">LinkedIn MCP Server</h1>

<p align="center"> <a href="https://pypi.org/project/mcp-server-linkedin/"><img src="https://img.shields.io/pypi/v/mcp-server-linkedin.svg" alt="PyPI"></a> <a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python 3.10+"></a> <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License: MIT"></a> <a href="https://modelcontextprotocol.io"><img src="https://img.shields.io/badge/MCP-compatible-purple.svg" alt="MCP"></a> <a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff"></a> </p>

<p align="center"> <img src="assets/banner.png" alt="LinkedIn MCP Server — Plug AI into LinkedIn" width="600" /> </p>

<p align="center"> <strong>Publish posts, images, videos, and articles to LinkedIn from any AI agent.</strong><br> Works with Claude, Cursor, Kiro, VS Code Copilot, Windsurf, and more. </p>


Use Cases

  • Content Publishing: Draft and publish LinkedIn posts from your AI assistant without switching context.
  • Media Sharing: Upload images and videos alongside your posts in a single command.
  • Link Previews: Share articles with auto-generated link preview cards.
  • Multi-Format Workflow: Compose text-only updates, visual content, or article shares through one unified interface.
  • Account Management: Authenticate, check your profile, and manage your session without leaving your editor.

Built for developers and content creators who want their AI tools to publish directly to LinkedIn.


Quick Start

Prerequisites

  1. Python 3.10+
  2. LinkedIn App — Follow the step-by-step setup guide or the quick version below:
    • Create an app at LinkedIn Developer Portal
    • Products: "Share on LinkedIn" + "Sign In with LinkedIn using OpenID Connect"
    • OAuth 2.0 scopes: openid, profile, email, w_member_social
    • Redirect URL: http://localhost:3000/callback

Install

uvx mcp-server-linkedin

Or with pip:

pip install mcp-server-linkedin

Configuration

Set these environment variables:

LINKEDIN_CLIENT_ID=your_client_id        # From LinkedIn Developer Portal
LINKEDIN_CLIENT_SECRET=your_secret_here  # From LinkedIn Developer Portal
LINKEDIN_REDIRECT_URI=http://localhost:3000/callback  # Optional, this is the default

Claude Desktop

Add to your claude_desktop_config.json:

<details> <summary>macOS: ~/Library/Application Support/Claude/claude_desktop_config.json</summary>

{
  "mcpServers": {
    "linkedin": {
      "command": "uvx",
      "args": ["mcp-server-linkedin"],
      "env": {
        "LINKEDIN_CLIENT_ID": "your_client_id",
        "LINKEDIN_CLIENT_SECRET": "your_secret_here"
      }
    }
  }
}

</details>

<details> <summary>Windows: %APPDATA%\Claude\claude_desktop_config.json</summary>

{
  "mcpServers": {
    "linkedin": {
      "command": "uvx",
      "args": ["mcp-server-linkedin"],
      "env": {
        "LINKEDIN_CLIENT_ID": "your_client_id",
        "LINKEDIN_CLIENT_SECRET": "your_secret_here"
      }
    }
  }
}

</details>

VS Code + Copilot

Add to .vscode/mcp.json in your workspace:

{
  "servers": {
    "linkedin": {
      "command": "uvx",
      "args": ["mcp-server-linkedin"],
      "env": {
        "LINKEDIN_CLIENT_ID": "your_client_id",
        "LINKEDIN_CLIENT_SECRET": "your_secret_here"
      }
    }
  }
}

Cursor

Add to .cursor/mcp.json in your project root:

{
  "mcpServers": {
    "linkedin": {
      "command": "uvx",
      "args": ["mcp-server-linkedin"],
      "env": {
        "LINKEDIN_CLIENT_ID": "your_client_id",
        "LINKEDIN_CLIENT_SECRET": "your_secret_here"
      }
    }
  }
}

Kiro

Add to .kiro/settings/mcp.json:

{
  "mcpServers": {
    "linkedin": {
      "command": "uvx",
      "args": ["mcp-server-linkedin"],
      "env": {
        "LINKEDIN_CLIENT_ID": "your_client_id",
        "LINKEDIN_CLIENT_SECRET": "your_secret_here"
      }
    }
  }
}

Claude Code

claude mcp add linkedin -- uvx mcp-server-linkedin

Then set LINKEDIN_CLIENT_ID and LINKEDIN_CLIENT_SECRET in your environment.

Windsurf

Add to your Windsurf MCP configuration:

{
  "mcpServers": {
    "linkedin": {
      "command": "uvx",
      "args": ["mcp-server-linkedin"],
      "env": {
        "LINKEDIN_CLIENT_ID": "your_client_id",
        "LINKEDIN_CLIENT_SECRET": "your_secret_here"
      }
    }
  }
}

Running from Source

Replace "command": "uvx", "args": ["mcp-server-linkedin"] with:

{
  "command": "uv",
  "args": ["--directory", "/path/to/mcp-server-linkedin", "run", "mcp-server-linkedin"]
}

Authentication

  1. Start your MCP client (Claude Desktop, Kiro, etc.)
  2. Ask: "Authenticate with LinkedIn"
  3. Browser opens → authorize the app → callback captured automatically
  4. Token saved to ~/.mcp-server-linkedin/token.json
  5. Token lasts 2 months. Re-run linkedin_auth when it expires.

Tools

Tool Description
linkedin_auth OAuth 2.0 browser-based authentication
linkedin_get_profile Get your name, email, and person URN
linkedin_logout Remove stored token
linkedin_post_text Publish a text-only post
linkedin_post_image Publish a post with an image
linkedin_post_video Publish a post with a video (up to 200 MB)
linkedin_post_article Publish a post with a link preview
linkedin_delete_post Delete a post by ID
linkedin_get_post_stats Get post analytics (requires Community Management API)
linkedin_get_all_stats Get aggregated analytics (requires Community Management API)

Tool Details

<details> <summary><b>linkedin_post_text</b></summary>

Parameter Type Default Description
text string required Post content (up to ~3000 chars)
visibility string "PUBLIC" "PUBLIC" or "CONNECTIONS"

</details>

<details> <summary><b>linkedin_post_image</b></summary>

Parameter Type Default Description
text string required Post caption
image_path string required Absolute path to image (JPEG, PNG, GIF)
visibility string "PUBLIC" "PUBLIC" or "CONNECTIONS"

</details>

<details> <summary><b>linkedin_post_video</b></summary>

Parameter Type Default Description
text string required Post caption
video_path string required Absolute path to video (MP4, max 200 MB)
visibility string "PUBLIC" "PUBLIC" or "CONNECTIONS"

</details>

<details> <summary><b>linkedin_post_article</b></summary>

Parameter Type Default Description
text string required Post commentary
url string required Article URL (generates link preview)
title string "" Optional link preview title
description string "" Optional link preview description
visibility string "PUBLIC" "PUBLIC" or "CONNECTIONS"

</details>

<details> <summary><b>linkedin_delete_post</b></summary>

Parameter Type Default Description
post_id string required Post URN (e.g., urn:li:ugcPost:123456)

</details>


Architecture

src/mcp_server_linkedin/
├── config.py            # Constants, API URLs, settings dataclass
├── exceptions.py        # Typed exception hierarchy
├── server.py            # FastMCP entrypoint + tool registration
├── models/              # Frozen dataclass API response models
├── services/            # Async API client with connection pooling
├── tools/               # MCP tool implementations (validate → delegate → format)
│   ├── auth.py          # OAuth flow, profile, logout
│   ├── posting.py       # Text, image, video, article, delete
│   └── analytics.py     # Stubbed (pending API access)
└── utils/               # Token persistence

Rate Limits

Limit Value
API requests per member per day 150
Token duration 2 months
Max video file size 200 MB

The server relays LinkedIn's rate limit errors clearly but does not enforce limits internally.


Security

  • Tokens stored locally at ~/.mcp-server-linkedin/token.json
  • No credentials in code — all secrets via environment variables
  • Official API only — uses w_member_social scope
  • Local OAuth callback — authorization code never leaves your machine
  • No data collection — this server sends nothing except LinkedIn API calls

Development

git clone https://github.com/Huzaifa-ali/mcp-server-linkedin.git
cd mcp-server-linkedin
uv sync --all-extras
pre-commit install
uv run mcp-server-linkedin                    # Run the server
uv run ruff check src/                        # Lint
uv run ruff format src/                       # Format
uv run mypy src/                              # Type check
uv run pytest                                 # Test

Test with MCP Inspector:

npx @modelcontextprotocol/inspector uv run mcp-server-linkedin

Contributing

See CONTRIBUTING.md for guidelines. In short:

  1. Fork the repo and create a feature branch
  2. Make your changes with type hints and docstrings
  3. Run pre-commit run --all-files (must pass)
  4. Open a pull request

License

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选