Skip to main content
Glama
linkedin-mcp

linkedin-mcp

linkedin-mcp

An MCP (Model Context Protocol) server that lets an AI agent post, comment, and read analytics on LinkedIn — for your personal profile, and optionally a company page you administer.

Point Claude (or any MCP-compatible agent) at this server and it can:

  • post_to_profile — publish a post to your personal LinkedIn profile

  • post_to_company_page — publish a post to a company page you administer

  • comment_on_post — comment on a post as your profile or a company page

  • get_recent_posts — list recent posts with their URNs, so the agent can find something to comment on or check analytics for

  • get_post_analytics — impressions, reactions, comments, shares, and clicks for a post

Nothing here talks to LinkedIn except LinkedIn's own official REST API. Your access token stays local, in a .env file you control.


1. Create a LinkedIn Developer App

  1. Go to linkedin.com/developers/apps and create a new app.

  2. Under Products, add:

    • Sign In with LinkedIn using OpenID Connect — lets you look up your own person URN

    • Share on LinkedIn — gives you w_member_social, the scope that lets you post and comment as yourself

  3. If you also want company page posting and analytics, add the product that grants w_organization_social / r_organization_social on your app (LinkedIn calls this the Community Management API in newer developer accounts, Marketing Developer Platform in older ones). This product is gated — you apply for access from the app's Products tab, and LinkedIn reviews the request. Skip this if you only want personal posting; post_to_profile, comment_on_post, and get_recent_posts/get_post_analytics for your profile all work without it.

Related MCP server: Facebook MCP Server

2. Run the OAuth 2.0 flow to get an access token

LinkedIn uses the standard OAuth 2.0 authorization code flow.

Authorize (open in a browser, replace CLIENT_ID and REDIRECT_URI with your app's values):

https://www.linkedin.com/oauth/v2/authorization
  ?response_type=code
  &client_id=CLIENT_ID
  &redirect_uri=REDIRECT_URI
  &scope=openid%20profile%20w_member_social

Add %20r_organization_social%20w_organization_social to the scope if you added company page access in step 1.

LinkedIn redirects you to REDIRECT_URI?code=AUTH_CODE. Grab AUTH_CODE from that URL.

Exchange the code for an access token:

curl -X POST https://www.linkedin.com/oauth/v2/accessToken \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=authorization_code" \
  -d "code=AUTH_CODE" \
  -d "redirect_uri=REDIRECT_URI" \
  -d "client_id=CLIENT_ID" \
  -d "client_secret=CLIENT_SECRET"

The response includes access_token. It's valid for 60 days — after that, repeat this flow to refresh it.

3. Get your person URN

curl https://api.linkedin.com/v2/userinfo \
  -H "Authorization: Bearer ACCESS_TOKEN"

The sub field in the response is your person ID. Your person URN is urn:li:person:SUB_VALUE.

4. (Optional) Get your organization URN

Only needed for company page features:

curl "https://api.linkedin.com/v2/organizationalEntityAcls?q=roleAssignee" \
  -H "Authorization: Bearer ACCESS_TOKEN"

Find your organization's ID in the response; the URN is urn:li:organization:ORG_ID.

5. Install

Option A — npm package:

npm install -g @sindhujaks/linkedin-mcp

Option B — clone and build:

git clone https://github.com/sindhujaIBM/linkedin-mcp.git
cd linkedin-mcp
npm install
npm run build

6. Configure your credentials

If you installed via npm, create a .env file in the directory you'll run the server from (see .env.example in this repo for the template). If you cloned the repo:

cp .env.example .env

Fill in LINKEDIN_ACCESS_TOKEN and LINKEDIN_PERSON_URN from steps 2–3. Add LINKEDIN_ORGANIZATION_URN if you did step 4.

7. Add it to Claude

Claude Code (npm install):

claude mcp add linkedin -- linkedin-mcp

Claude Code (cloned repo):

claude mcp add linkedin -- node /absolute/path/to/linkedin-mcp/dist/index.js

Claude Desktop — add this to your claude_desktop_config.json:

{
  "mcpServers": {
    "linkedin": {
      "command": "linkedin-mcp"
    }
  }
}

(Or "command": "node", "args": ["/absolute/path/to/linkedin-mcp/dist/index.js"] if you cloned the repo instead of installing via npm.)

Restart Claude, and the five tools above will be available. You can then just ask, in plain language: "post this to my LinkedIn profile," or "comment 'thanks for reading' on my most recent post," or "how did my last post do?"


Notes

  • Access tokens expire after 60 days. When yours does, tool calls will fail with an auth error — re-run the OAuth flow in step 2 and update .env.

  • post_to_company_page, and using as: "company" on the other tools, all require LINKEDIN_ORGANIZATION_URN to be set — otherwise they return a clear error telling you what's missing.

  • This uses LinkedIn's /v2/ugcPosts and related endpoints. LinkedIn occasionally changes API versioning requirements for newer developer apps; if a call fails with a version-related error, check LinkedIn's API versioning docs for the current required header.

License

MIT

Available Tools

5 tools
comment_on_postA

Comment on a LinkedIn post, as your profile or a company page. Useful right after publishing — LinkedIn's feed algorithm weighs early engagement heavily.

Inputs: as (required), post_urn (required), comment_text (required).

get_post_analyticsA

Get performance stats (impressions, reactions, comments, shares, clicks) for a specific LinkedIn post.

Inputs: as (required), post_urn (required).

get_recent_postsA

List the most recent posts for your profile or company page, with their URNs and basic stats. Useful for finding post URNs to comment on.

Inputs: as (required), count.

post_to_company_pageA

Post to a LinkedIn company page you administer. Requires LINKEDIN_ORGANIZATION_URN to be set. Returns the post URN and URL.

Inputs: text (required), article_url.

post_to_profileA

Post to your personal LinkedIn profile. Returns the post URN and URL.

Inputs: text (required), article_url.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool targets a clearly different action and resource: posting to a profile, posting to a company page, commenting, listing recent posts, and fetching analytics. There is no meaningful overlap or ambiguity between the tools.

    Naming Consistency5/5

    All tool names follow the same snake_case verb-first convention, with clear patterns like post_to_* and get_*. The naming is predictable and makes the purpose of each tool immediately obvious.

    Tool Count5/5

    Five tools is well-scoped for a LinkedIn content publishing and engagement server. Each tool covers a distinct core operation without unnecessary bloat or missing essentials.

    Completeness4/5

    The set covers the main lifecycle for LinkedIn posting: create posts, comment, retrieve recent posts, and view analytics. Delete and update operations are absent, but they are not core to the apparent purpose of publishing and measuring engagement.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to manage Facebook Pages through Meta's Graph API, including posting, scheduling, drafts, reading insights, and moderating comments.
      15
      48 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to publish, edit, delete, comment on, and analyze posts across LinkedIn, Facebook Pages, and Instagram professional accounts, including cross-posting and local scheduling. Runs locally with user-supplied credentials and no third-party token routing.
      1
      MIT