LinkedIn MCP Server

repository·main·Indexed 25 days ago

https://github.com/stickerdaniel/linkedin-mcp-server

An MCP server (version 4.20.1) that enables AI assistants like Claude to interact with LinkedIn using a user's local browser session. It provides tools for accessing profiles, messaging, company research, job searching, and feed monitoring. Supports installation via uvx or as a Claude Desktop MCP bundle, with features for session import from Chromium browsers and configurable HTTP transport mode.

Tokens
7.4K
Snippets
12
Records
37
Agent score
78%

What's inside linkedin-mcp-server

  1. Overview of LinkedIn MCP Server

    main
    The LinkedIn MCP Server is an Model Context Protocol (MCP) server that enables AI assistants (such as Claude) to interact with LinkedIn data using your own local, logged-in browser session. It allows for reading profiles, accessing company information, searching for jobs, and managing messages through your existing authentication.
  2. Verify browser compatibility for session import

    main

    Before attempting to import a session from a specific browser, use this checklist to ensure the server can successfully decrypt the cookies:

    1. User-data root: Ensure the user-data root resolves on your OS and contains a Local State file.
    2. Cookies DB: Confirm the Cookies database is found (preferred path: Default/Network/Cookies, fallback: Default/Cookies).
    3. Metadata: Verify that li_at metadata can be read without keychain access (expiry and last-access should be available from SQLite columns).
    4. Keychain/Keystore: Confirm the OS Keychain service name actually decrypts a real cookie. Note that browser forks often rename the service (e.g., Helium uses Helium Storage Key instead of <name> Safe Storage).
    5. End-to-end test: Sign into LinkedIn in that browser, then run the server with --import-from-browser <key> and verify it can access /feed/.
  3. Install and configure the LinkedIn MCP Server via uvx

    main

    The recommended way to run the LinkedIn MCP server is using uvx. This ensures you always run the latest version (via the @latest tag) and avoids version rot caused by LinkedIn's frequent UI changes.

    Prerequisites: Install uv (version 0.4.0 or higher).

    Client Configuration (JSON): Add the following to your MCP client configuration file:

    {
      "mcpServers": {
        "mcp-server-linkedin": {
          "command": "uvx",
          "args": ["mcp-server-linkedin@latest"],
          "env": { "UV_HTTP_TIMEOUT": "300" }
        }
      }
    }

    Note: Setting UV_HTTP_TIMEOUT to 300 is recommended to prevent timeouts during initial dependency downloads on slow connections.

  4. Quick Start: Run LinkedIn MCP Server via Docker

    main

    To use the LinkedIn MCP server in a Docker container, you must first create a browser profile on your host machine to handle authentication. Docker containers cannot open a browser window for manual login.

    Step 1: Create a profile on your host

    You need uv installed on your host. Run the following command to open a browser window and log in to LinkedIn manually. The session will be saved to ~/.linkedin-mcp/.

    uvx mcp-server-linkedin@latest --login

    Alternative: Import an existing session If you are already logged into LinkedIn in a local browser (Chrome, Brave, Edge, etc.), you can reuse that session instead of performing a new login:

    uvx mcp-server-linkedin@latest --import-from-browser

    Note: This does not work for Chrome 127+ if app-bound encryption is used. In that case, use --login.

    Step 2: Configure Claude Desktop

    {
      "mcpServers": {
        "mcp-server-linkedin": {
          "command": "docker",
          "args": [
            "run", "--rm", "-i",
            "-v", "~/.linkedin-mcp:/home/pwuser/.linkedin-mcp",
            "stickerdaniel/linkedin-mcp-server:latest"
          ]
        }
      }
    }
  5. Set up the LinkedIn MCP Server locally for development

    main

    To develop or contribute to the project, follow these steps to clone the repository and install dependencies using uv.

    Prerequisites:

    Steps:

    1. Clone the repository and enter the directory.
    2. Install the uv package manager.
    3. Synchronize dependencies for both the main project and development group.
    4. Install pre-commit hooks.
    5. Start the server using the module flag.

    Note: The local server manages the Patchright Chromium browser cache automatically. You can explicitly create a session by running the server with the --login flag.

    # 1. Clone repository
    git clone https://github.com/stickerdaniel/linkedin-mcp-server
    cd linkedin-mcp-server
    
    # 2. Install UV package manager (if not already installed)
    curl -LsSf https://astral.sh/uv/install.sh | sh
    
    # 3. Install dependencies
    uv sync
    uv sync --group dev
    
    # 4. Install pre-commit hooks
    uv run pre-commit install
    
    # 5. Start the server
    uv run -m linkedin_mcp_server
  6. Install the Claude Desktop MCP Bundle

    main

    For Claude Desktop users, you can perform a one-click installation using the .mcpb artifact.

    Prerequisites: Claude Desktop.

    Steps:

    1. Download the latest .mcpb artifact from the releases page.
    2. Click the downloaded .mcpb file to install it into Claude Desktop.
    3. Call any LinkedIn tool to begin.

    Note: On startup, the bundle prepares the Patchright Chromium browser cache in the background. If you call a tool before this is finished, Claude will surface a setup-in-progress error. On the first tool call requiring authentication, the server will open a LinkedIn login browser window; you must sign in and then retry the tool call.

  7. Set up the LinkedIn MCP Server with Docker

    main

    To run the LinkedIn MCP server in Docker, you must first create a browser profile on your host machine because Docker runs headless and cannot open a browser window for manual login.

    1. Create a profile on the host: Run uvx mcp-server-linkedin@latest --login. This opens a browser for manual login. Profiles are saved to ~/.linkedin-mcp/.
    2. Configure Claude Desktop: Add the Docker configuration to your mcpServers settings, mounting the host profile directory into the container.

    Note: Docker creates a fresh session on each startup. If authentication fails, re-run the --login command on your host.

    # Step 1: Create profile on host
    uvx mcp-server-linkedin@latest --login
    // Step 2: Claude Desktop Configuration
    {
      "mcpServers": {
        "mcp-server-linkedin": {
          "command": "docker",
          "args": [
            "run", "--rm", "-i",
            "-v", "~/.linkedin-mcp:/home/pwuser/.linkedin-mcp",
            "stickerdaniel/linkedin-mcp-server:latest"
          ]
        }
      }
    }
  8. Authenticate with LinkedIn

    main

    The server requires a LinkedIn session to function. You can establish a session in two ways:

    1. Manual Login (Recommended for new setups): Run the following command to open a browser window where you can sign in manually and solve any CAPTCHAs: uvx mcp-server-linkedin@latest --login

    2. Import from an existing browser session: If you are already logged into LinkedIn in a local browser (Chrome, Brave, Edge, etc.), you can import that session to skip manual login:

      • Auto-pick the most recent session: uvx mcp-server-linkedin@latest --import-from-browser
      • Target a specific browser: uvx mcp-server-linkedin@latest --import-from-browser <browser_name> (e.g., brave, edge, chrome).

    Important: If you use a proxy, configure it before running --login or --import-from-browser to avoid triggering LinkedIn security checkpoints.

    uvx mcp-server-linkedin@latest --login
    # OR
    uvx mcp-server-linkedin@latest --import-from-browser brave
  9. Import LinkedIn session from a browser

    main

    Use the --import-from-browser <key> flag to read and decrypt the LinkedIn session cookie from a locally installed Chromium-based browser. This allows you to reuse an existing LinkedIn session without manual login.

    Requirements for successful import:

    1. The browser must have a valid Local State file in its user-data root.
    2. The Cookies database must be accessible (typically at Default/Network/Cookies or Default/Cookies).
    3. The OS keystore (e.g., macOS Keychain) must contain the correct decryption key for the cookie value.

    Note on User Agents: When importing a session, the server reconstructs the source browser's User Agent to match the session fingerprint. This is done using the OS platform token and the Chromium major version read from the browser's files. You can override this behavior using the USER_AGENT environment variable or the --user-agent flag.

  10. Configure Proxy Settings for LinkedIn MCP Server

    main

    To route browser traffic through a proxy, use the PROXY_SERVER environment variable with the format scheme://host:port. You can also provide credentials via PROXY_USERNAME and PROXY_PASSWORD.

    Important Notes:

    • Chromium cannot authenticate to a SOCKS proxy; use http(s) endpoints for proxy authentication.
    • Inside a Docker container, 127.0.0.1 refers to the container itself. To use a proxy running on your host, use host.docker.internal. On native Linux Docker, you must add the flag --add-host=host.docker.internal:host-gateway to your docker run command.
    • Only browser traffic is routed through the proxy, not the MCP transport.
  11. Troubleshoot LinkedIn MCP Server issues

    main

    Login & Session Issues

    • Manual Login: If automated login fails, use the --login command to open a browser window where you can manually solve captchas or handle mobile app confirmations.
    • Clearing Sessions: If your session is corrupted, use --logout to clear the profile stored at ~/.linkedin-mcp/profile/.
    • Docker Detection: If running on a non-containerized Linux host and receiving "No valid LinkedIn session is available in Docker" errors, set the environment variable LINKEDIN_MCP_CONTAINER=false.

    Scraping & Timeout Issues

    • Debugging Scraping: Use --no-headless to watch the browser actions and --log-level DEBUG for detailed logs.
    • Page Operation Timeouts: If elements aren't being found or navigation hangs, increase the page timeout using --timeout 10000 (milliseconds).
    • Tool Execution Timeouts: For heavy scrapes or slow networks, increase the per-tool timeout using --tool-timeout 300 (seconds).

    Proxy Configuration

    • Setup Order: Always set up your proxy before creating a session. Run --login with the proxy already configured. Switching to a proxy with an existing profile will likely trigger a LinkedIn security checkpoint.
    • Authentication: Use PROXY_USERNAME and PROXY_PASSWORD environment variables. Chromium does not support SOCKS proxy authentication; use an http(s) endpoint.
    • Localhost Access: If using a proxy, you may need to set PROXY_BYPASS=localhost,127.0.0.1,::1 to ensure local targets are reached directly.
  12. Override Docker detection with LINKEDIN_MCP_CONTAINER

    main

    If you are not running in a container but receive the error "No valid LinkedIn session is available in Docker", the runtime may have been misdetected (common on Linux hosts with Docker daemons).

    Use the LINKEDIN_MCP_CONTAINER environment variable to override this:

    • Set LINKEDIN_MCP_CONTAINER=false to indicate you are on a host machine.
    • Set LINKEDIN_MCP_CONTAINER=true to force container mode.