linkedin-mcp-server

linkedin-mcp-server

A production-ready MCP server that enables AI agents to autonomously create, manage, and engage with LinkedIn content through the official LinkedIn REST API.

Category
Visit Server

README

LinkedIn MCP Server

License: MIT Node.js Version MCP Version Tests

A production-ready Model Context Protocol (MCP) server connecting AI agents (Google Gemini Spark, OpenAI Codex, Claude Desktop, Cursor, Windsurf) to the official LinkedIn REST API.

Enables AI agents to autonomously draft and publish text updates, share rich link previews, upload images, create interactive polls, manage existing posts, and engage with reactions and threaded comments.

https://github.com/user-attachments/assets/cda965be-d6a2-4a37-8d3c-29a68a9959e1


Features

  • Dual-Mode MCP Transport:
    • Server-Sent Events (SSE) via GET /mcp and POST /messages for clients like Google Gemini Spark and Claude.
    • Streamable HTTP via POST /mcp for modern command-line and agent runtimes like OpenAI Codex (rmcp).
  • 12 Comprehensive Tools:
    • Content Creation: Text updates, article link preview cards, binary image uploads (3-step pipeline), and multi-option polls.
    • Content Management: Delete posts by URN, fetch engagement statistics (likes, comments, shares), and verify account profile connections.
    • Social Engagement: Add reactions (LIKE, CELEBRATE, LOVE, INSIGHTFUL, FUNNY, EMPATHY), delete reactions, add comments, reply in threads, and remove comments.
  • Robust Validation: Powered by Zod schemas for all tool input parameters.
  • Enterprise-Ready: Automated unit and integration test suite with 100% endpoint coverage.

Tool Reference

Tool Category Description Parameters
create_text_post Content Publish a standard text post to your LinkedIn feed content (string, required)
create_link_post Content Publish a post with a clickable preview card content (string), url (string, URL), title (string)
create_image_post Content Download an image from a URL, upload it to LinkedIn, and publish content (string), image_url (string, URL)
create_poll_post Content Create a poll with customizable duration question (string), options (string array, 2-4 items), duration (ONE_DAY, THREE_DAYS, ONE_WEEK, TWO_WEEKS)
delete_post Management Delete a post using its Post URN post_urn (string, e.g. urn:li:ugcPost:...)
get_user_profile Management Retrieve authenticated profile details (name, member ID) None
get_post_stats Management Fetch engagement metrics (likes, comments, shares) post_urn (string)
react_to_post Engagement Add a reaction to a post post_urn (string), reaction_type (LIKE, CELEBRATE, LOVE, INSIGHTFUL, FUNNY, EMPATHY)
remove_reaction Engagement Remove your reaction from a post post_urn (string)
comment_on_post Engagement Add a top-level comment on a post post_urn (string), comment_text (string)
delete_comment Engagement Delete a comment you made post_urn (string), comment_id (string)
reply_to_comment Engagement Post a threaded reply to an existing comment post_urn (string), parent_comment_urn (string), reply_text (string)

Setup & Authentication

1. LinkedIn Developer Portal Setup

  1. Create a LinkedIn application in the LinkedIn Developer Portal.
  2. Under the Products tab, request access to:
    • Share on LinkedIn (provides w_member_social permission)
    • Sign In with LinkedIn using OpenID Connect (provides openid and profile permissions)
  3. In the Auth tab, add a redirect URL (e.g. https://httpbin.org/get or your domain).

2. Generate a User Access Token

  1. Construct the authorization URL in your browser:
    https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&scope=openid%20profile%20w_member_social
    
  2. Authorize the application and copy the code query parameter from the redirection URL.
  3. Exchange the code for a 60-day access token:
    curl -X POST https://www.linkedin.com/oauth/v2/accessToken \
      -d "grant_type=authorization_code" \
      -d "code=YOUR_AUTHORIZATION_CODE" \
      -d "client_id=YOUR_CLIENT_ID" \
      -d "client_secret=YOUR_CLIENT_SECRET" \
      -d "redirect_uri=YOUR_REDIRECT_URI"
    
  4. Fetch your member ID:
    curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" https://api.linkedin.com/v2/userinfo
    
    The sub field is your member identifier (e.g., urn:li:person:<sub_id>).

Configuration

Copy the sample environment file:

cp .env.example .env

Configure your .env variables:

LINKEDIN_ACCESS_TOKEN=your_oauth2_access_token
LINKEDIN_AUTHOR_URN=urn:li:person:your_member_sub_id
PORT=3000

Running Locally

# Install dependencies
npm install

# Run unit and integration tests
npm test

# Start the server
npm start

# Start in development mode (with live reload)
npm run dev

Client Integration

OpenAI Codex CLI

Add the server using the Codex CLI:

codex mcp add linkedin --url https://your-server-domain.com/mcp

Or add it directly to ~/.codex/config.toml:

[mcp_servers.linkedin]
url = "https://your-server-domain.com/mcp"

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "linkedin": {
      "command": "node",
      "args": ["/path/to/linkedin-mcp-server/server.js"],
      "env": {
        "LINKEDIN_ACCESS_TOKEN": "your_access_token",
        "LINKEDIN_AUTHOR_URN": "urn:li:person:your_sub_id"
      }
    }
  }
}

Google Gemini Spark

In your Gemini Spark custom applications settings, enter your public SSE endpoint URL:

https://your-server-domain.com/mcp

Deployment

Deploy to Railway

  1. Install the Railway CLI: npm i -g @railway/cli
  2. Link or create a project:
    railway init
    railway up
    
  3. Set environment variables:
    railway variable set LINKEDIN_ACCESS_TOKEN="your_token" LINKEDIN_AUTHOR_URN="urn:li:person:your_sub_id"
    
  4. Generate a public domain:
    railway domain
    

Development & Testing

The test suite includes 62 automated unit and integration tests covering the LinkedIn API client, all 12 tool registrations and execution handlers, and SSE / Streamable HTTP transports.

# Run tests once
npm test

# Run tests in watch mode
npm run test:watch

License

This project is licensed under the MIT License.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured