mcp-servers/mcp-gateway/linkedin-mcp/SETUP.md

3.6 KiB

LinkedIn MCP Server Setup

Prerequisites

  1. Python 3.12+ on your host machine
  2. LinkedIn account with valid credentials
  3. Create LinkedIn profile locally (one-time setup)

Step 1: Install LinkedIn MCP (Host Machine)

Run this on your host machine (not in Docker):

pip install linkedin-scraper-mcp

Step 2: Create LinkedIn Profile (One-time Authentication)

Run this command to authenticate and create your profile:

linkedin-mcp-server --login

Or use the alternate command:

linkedin-scraper-mcp --login

This will:

  • Open a browser window
  • Ask you to log into LinkedIn
  • Handle captcha challenges (manual solving required)
  • Save your session at ~/.linkedin-mcp/profile/

Important: Only one active LinkedIn session is supported. If you need to re-authenticate:

rm -rf ~/.linkedin-mcp/profile
linkedin-mcp-server --login

Step 3: Build Docker Image

cd /mnt/NVME/Docker/mcp-gateway
docker compose build linkedin-mcp

Step 4: Start the Service

docker compose up linkedin-mcp

The service is already configured in your docker-compose.yml with:

  • Python 3.12 slim image
  • LinkedIn profile mounted from ~/.linkedin-mcp/profile
  • LOG_LEVEL environment variable from .env
  • Automatic restart

Configuration Options

Environment Variables (in .env)

# LinkedIn MCP Server
LINKEDIN_LOG_LEVEL=INFO
LINKEDIN_TIMEOUT=10000

Available Log Levels

  • DEBUG - Detailed logging
  • INFO - Standard logging (recommended)
  • WARNING - Only warnings and errors
  • ERROR - Only errors

Docker Integration

The Dockerfile:

  • Uses python:3.12-slim as base image
  • Clones the GitHub repository
  • Installs dependencies with pip
  • Mounts profile from host at ~/.linkedin-mcp/profile:/root/.linkedin-mcp/profile

Troubleshooting

Profile Not Found

# Verify profile exists on host
ls ~/.linkedin-mcp/profile

# Create new profile if missing
linkedin-mcp-server --login

Build Fails - Git Clone Issues

  • Ensure you have internet access
  • Check git is installed: git --version
  • Try manual clone first: git clone https://github.com/stickerdaniel/linkedin-mcp-server.git

Container Won't Start

Check the logs:

docker logs mcp-linkedin

# Restart container
docker compose restart mcp-linkedin

Session Expired

LinkedIn sessions may expire. To refresh:

# Delete old profile
rm -rf ~/.linkedin-mcp/profile

# Create new profile
linkedin-mcp-server --login

# Restart container
docker compose restart mcp-linkedin

Captcha Loop

If you keep hitting captchas:

  1. Create profile manually on your machine first
  2. Mount that profile into Docker
  3. Run with --no-headless temporarily to debug

Integration with Gateway Proxy

The gateway proxy (gateway_proxy.py) should have:

MCP_BACKEND_LINKEDIN=http://mcp-linkedin:3000/mcp

This is already configured in the docker-compose.yml.

Verification

Test the connection:

# Check if container is running
docker ps | grep mcp-linkedin

# View logs
docker logs mcp-linkedin

# Check gateway can reach it
docker exec mcp-gateway curl http://mcp-linkedin:3000/mcp/tools

Entry Point

The container runs:

linkedin-mcp-server --log-level INFO

This starts the MCP server that communicates with the gateway proxy via HTTP.

Performance Notes

  • First run may be slower as Patchright downloads browser dependencies
  • Profile authentication takes 30-60 seconds
  • Subsequent tool calls should respond in 1-5 seconds
  • Browser automation is CPU-intensive; allocate resources accordingly