LinkedIn MCP Server

LinkedIn MCP Server

A production-ready MCP server for interacting with the LinkedIn API, enabling profile lookup, post creation and deletion, image posting, and organization page management through a secure tool-based interface.

Category
Visit Server

README

LinkedIn MCP Server

A production-ready Model Context Protocol (MCP) server for interacting with the LinkedIn API through a secure, tool-based interface. This project is designed for developers who want to use LinkedIn from MCP-compatible clients such as Claude Desktop, Cursor, VS Code, or custom agents.

The server supports profile lookup, publishing posts, uploading image posts, deleting posts, and managing organization page feeds when the appropriate LinkedIn partner permissions are enabled.

Why this project exists

LinkedIn exposes powerful APIs, but integrating them into MCP workflows usually requires writing a fair amount of boilerplate for authentication, token storage, callback handling, and request retry logic. This project packages those concerns into a small, maintainable server so you can focus on using the tools rather than building the plumbing yourself.

Key features

  • OAuth 2.0 authentication flow with local callback handling
  • Automatic token caching and refresh support
  • Profile retrieval via LinkedIn OpenID Connect
  • Text post creation and deletion
  • Image post creation with upload and status polling
  • Organization page support for partner-tier applications
  • Clear error handling and structured logging
  • Ready-to-use MCP tool definitions for client integration

Supported capabilities

Personal profile tools

  • get_profile: retrieve your profile details and Person URN
  • create_post: publish a text post to your personal feed
  • upload_image_post: upload an image and publish it as a post
  • delete_post: remove a published post by URN

Organization tools

  • get_organization_pages: list organization pages you can manage
  • create_company_post: publish a post to a company page feed
  • list_recent_posts: inspect recent posts on an organization page

Organization features require the correct LinkedIn partner-tier permissions and app scopes. If those permissions are missing, the server raises explicit errors that guide you toward the correct setup steps.

Architecture overview

The project is organized into a few simple layers:

  • server.py: starts the FastMCP server and registers tools
  • tools.py: exposes MCP tool implementations
  • auth.py: manages OAuth flows, redirect handling, and token exchange
  • linkedin_client.py: wraps LinkedIn HTTP requests and error handling
  • config.py: loads configuration from environment variables and .env
  • tests/: contains automated tests for the core behavior

Prerequisites

Before you begin, make sure you have:

  • Python 3.11 or newer
  • pip installed
  • A LinkedIn developer app created in the LinkedIn Developer Portal
  • A valid redirect URI configured for local development

LinkedIn developer app setup

To use this server, you need to create a LinkedIn app and configure it correctly.

  1. Go to the LinkedIn Developer Portal.
  2. Create a new app.
  3. Under the Products tab, enable:
    • Share on LinkedIn
    • Sign In with LinkedIn using OpenID Connect
  4. Under the Auth tab, copy your Client ID and Client Secret.
  5. Add a redirect URI such as http://localhost:8000/callback.
  6. Save the app and keep the credentials safe.

Installation

From the project root, install the dependencies:

pip install -r requirements.txt

If you use a virtual environment, activate it first:

python -m venv .venv
source .venv/bin/activate  # macOS/Linux
.venv\Scripts\activate   # Windows PowerShell
pip install -r requirements.txt

Configuration

Create a local environment file from the sample:

copy .env.example .env

On Linux or macOS, use:

cp .env.example .env

Then edit .env and set the values:

LINKEDIN_CLIENT_ID=your_linkedin_client_id_here
LINKEDIN_CLIENT_SECRET=your_linkedin_client_secret_here
LINKEDIN_REDIRECT_URI=http://localhost:8000/callback
LINKEDIN_SCOPES=w_member_social,openid,profile,email
LINKEDIN_TOKEN_CACHE_PATH=~/.linkedin_mcp_token.json
LINKEDIN_API_VERSION=202406

Environment variable reference

  • LINKEDIN_CLIENT_ID: your LinkedIn app client ID
  • LINKEDIN_CLIENT_SECRET: your LinkedIn app client secret
  • LINKEDIN_REDIRECT_URI: the locally served callback URL
  • LINKEDIN_SCOPES: the scopes required by the app
  • LINKEDIN_TOKEN_CACHE_PATH: where access tokens are cached
  • LINKEDIN_API_VERSION: LinkedIn API version header value

Running the server

Start the MCP server with:

python server.py

When the server starts, it will expose the available tools to whichever MCP client is connected to it.

OAuth flow walkthrough

The server handles OAuth automatically:

  1. It checks whether a cached access token already exists.
  2. If no valid token is available, it starts a temporary local callback listener.
  3. It opens the LinkedIn authorization page in your browser.
  4. After you authorize the app, LinkedIn redirects back to the callback URL.
  5. The server exchanges the authorization code for tokens and stores them locally.

This makes the authentication experience much smoother than manually wiring the callback flow for each integration.

Integrating with MCP clients

Claude Desktop

Add a server entry similar to the following in your Claude Desktop config:

{
  "mcpServers": {
    "linkedin-mcp": {
      "command": "python",
      "args": [
        "C:/path/to/linkedin_mcp/server.py"
      ],
      "env": {
        "LINKEDIN_CLIENT_ID": "your_linkedin_client_id_here",
        "LINKEDIN_CLIENT_SECRET": "your_linkedin_client_secret_here",
        "LINKEDIN_REDIRECT_URI": "http://localhost:8000/callback",
        "LINKEDIN_SCOPES": "w_member_social,openid,profile,email",
        "LINKEDIN_TOKEN_CACHE_PATH": "C:/Users/YourName/.linkedin_mcp_token.json",
        "LINKEDIN_API_VERSION": "202406"
      }
    }
  }
}

Cursor or other MCP clients

Most MCP-compatible clients support a command-based server definition. Point them to the server.py file and provide the same environment variables shown above.

Docker deployment

You can also run the server in Docker.

docker compose up --build -d

The compose configuration mounts a local data directory so the token cache can persist between container restarts.

Testing

Run the test suite with:

pytest

Security notes

  • Never commit your real .env file or any real credentials.
  • Keep your LinkedIn client secret private.
  • Use placeholders in sample configuration files.
  • If you publish this repository publicly, make sure the real secrets are removed from your local environment before pushing.

Project structure

linkedin_mcp/
├── auth.py
├── config.py
├── linkedin_client.py
├── server.py
├── tools.py
├── tests/
├── .env.example
├── .gitignore
├── README.md
└── requirements.txt

Troubleshooting

  • If the OAuth flow fails, confirm that the redirect URI in LinkedIn matches the value in .env exactly.
  • If the server cannot publish posts, verify that your LinkedIn app has the correct products enabled.
  • If organization tools fail, confirm that your app has the necessary partner-tier permissions.
  • If you see 401 or 403 errors, refresh the token cache or re-run the authorization flow.

Contributing

Pull requests are welcome. If you make changes, please keep the documentation up to date and avoid committing secrets or local environment files.

License

This project is provided as-is for educational and development purposes. Review LinkedIn's developer terms and API usage policies before deploying it publicly or in production.

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
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

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