linkedin-mcp
Enables AI agents to publish posts, images, comments, and reactions to LinkedIn as the authenticated user, with built-in safety features like daily budgets and deduplication.
README
linkedin-mcp
An MCP (Model Context Protocol) server that lets AI agents publish to LinkedIn as the authenticated member — text posts, link shares, single/multi-image posts, reshares, comments, and reactions — with built-in safety rails for autonomous operation: daily budget limits, engagement deduplication, compact TOON-encoded responses, and self-describing errors with typo suggestions.
Authentication is OAuth 2.0 (3-legged) with a cluster-hosted callback protected by HTTP Basic Auth, so you never have to copy tokens onto a server by hand. Tokens, budgets, and dedup state live in a single JSON file you can back with a Kubernetes PVC.
Works with Claude Code, Claude Desktop, OpenAI Codex, Cursor, Windsurf, Cline, and any other MCP-compatible client — run it locally or via Docker.
Scope (Phase 1). LinkedIn's public API only allows member write actions plus reading your own profile. There is no public API to read the feed, search posts, list followers/connections, or follow people. This MCP is therefore publish-and-engage oriented. See
spec.mdfor the full design and rationale.
What Can It Do?
| Category | Tools | What You Can Say |
|---|---|---|
| Identity | get_me |
"Who am I posting as?" |
| Publish | create_post, create_image_post, create_multi_image_post, reshare_post |
"Post 'hello world' on LinkedIn" / "Share this image with a caption" |
| Media | upload_media |
"Upload this image and post it" |
| Engage | comment_on_post, react_to_post |
"Comment 'congrats' on this post" / "Like this post" |
| Lifecycle | delete_post |
"Delete that post" |
Post-targeting tools accept either a LinkedIn URN (urn:li:share:... /
urn:li:ugcPost:... / urn:li:activity:...) or a post URL interchangeably.
Safety Features
Daily budget limits
Hard per-action limits per day. The server refuses when exhausted — even if the LLM ignores every instruction.
LI_MCP_MAX_POSTS=5 # Max posts/reshares per day (default)
LI_MCP_MAX_COMMENTS=10 # Max comments per day
LI_MCP_MAX_REACTIONS=30 # Max reactions per day
LI_MCP_MAX_DELETES=3 # Max post deletions per day
Set to 0 to disable an action entirely. Set to -1 for unlimited.
Budget counters in every response
Every response includes the remaining budget, so the LLM sees its limits proactively:
li_budget: "1/5 posts used, 0/10 comments used, 2/30 reactions used, 0/3 deletes used | last action: 3m ago"
Engagement deduplication (default on)
Never comment on or react to the same post twice. Set LI_MCP_DEDUP=false to disable.
TOON + compact responses (default on)
Responses use TOON and drop verbose fields to
save tokens. Set LI_MCP_TOON=false for JSON, LI_MCP_COMPACT=false to keep full shapes.
Self-describing errors
Tools validate parameters and return actionable hints with fuzzy-matched suggestions for typos, so the LLM learns from mistakes instead of getting opaque errors.
Text formatting (automatic)
You pass post text as plain text — the server handles LinkedIn's quirks for you:
- LinkedIn parses
commentaryas "Little Text", where\ | { } @ [ ] ( ) < > # * _ ~are reserved. An unescaped one (notably() silently truncates the post. The server escapes them automatically. #hashtagsare preserved as clickable hashtags.- Images are only attached once LinkedIn finishes processing them, so posts never render as "This post cannot be displayed".
Setup
1. Clone, install, build
git clone https://github.com/2060-io/linkedin-mcp.git
cd linkedin-mcp
npm install
npm run build
2. Create a LinkedIn app
- Go to the LinkedIn Developer Portal and create an app (it must be linked to a Company Page).
- On the Products tab, request Sign In with LinkedIn using OpenID Connect and
Share on LinkedIn. This grants the
openid,profile,email, andw_member_socialscopes. - On the Auth tab, copy the Client ID and Client Secret, and add your Redirect URL (see below).
3. Configure credentials
cp .env.example .env
Fill in LINKEDIN_CLIENT_ID, LINKEDIN_CLIENT_SECRET, and LINKEDIN_REDIRECT_URI
(must EXACTLY match a Redirect URL on the app). See .env.example for
every option.
Authorize (get a member token)
OAuth tokens are minted once, then refreshed automatically until the refresh token expires (~1 year), at which point you re-authorize.
Option A — Local dev CLI
# LINKEDIN_REDIRECT_URI=http://localhost:8000/oauth/callback
npm run auth
Open the printed URL, approve, and the tokens are written to the local state file.
Option B — Cluster-hosted callback (recommended for k8s)
With MCP_TRANSPORT=http and LI_MCP_ADMIN_USER / LI_MCP_ADMIN_PASSWORD set, the
server exposes Basic-Auth-protected OAuth routes:
GET /oauth/start # redirects to LinkedIn consent
GET /oauth/callback # LinkedIn returns here; tokens persisted to state file
GET /oauth/status # shows whether a valid token is stored
Visit https://<public-host>/oauth/start, authenticate with Basic Auth, approve on
LinkedIn, and the member tokens land on the PVC. See charts/README.md.
Run
# stdio (for local MCP clients)
MCP_TRANSPORT=stdio npm start
# http (for cluster / remote)
MCP_TRANSPORT=http MCP_PORT=8000 npm start
HTTP endpoints: /mcp (StreamableHTTP), /healthz, and /oauth/*.
Connect a client (stdio example)
{
"mcpServers": {
"linkedin": {
"command": "node",
"args": ["/absolute/path/to/linkedin-mcp/dist/index.js"],
"env": { "MCP_TRANSPORT": "stdio" }
}
}
}
Deploy to Kubernetes
A Helm chart is provided in charts/. It provisions a PVC for token/budget
state, runs a single replica with the Recreate strategy, and wires LinkedIn + Basic
Auth credentials through a Secret. See charts/README.md for
install and authorization steps.
State persistence
All durable state — OAuth tokens (the source of truth), daily budget counters, and
engagement dedup — lives in one JSON file (LI_MCP_STATE_FILE, default
{cwd}/linkedin-mcp-state.json). On Kubernetes, back it with a PVC so tokens survive
restarts; otherwise a restart forces re-authorization and resets budgets.
Development
npm run build # tsc
npm test # vitest
npm run dev # build + start
Credits
TOON encoder vendored from @toon-format/toon (MIT). Architecture mirrors the sibling x-autonomous-mcp.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。