# LinkedIn Lead Automation MCP Server - Production Deployment Guide
## System Overview
This is a PRODUCTION-GRADE LinkedIn automation MCP server that provides:
- Real-time LinkedIn lead search
- Complete profile analysis and data extraction
- AI-powered lead scoring (0-100 scale)
- Hyper-personalized message generation
- Automated message sending
- Multi-stage follow-up sequences
- API key authentication with usage tracking
**All functionality is REAL - no mocks, no placeholders, no demo code.**
## Prerequisites
1. **Node.js 18+** installed
2. **Chrome/Chromium browser** installed
3. **LinkedIn account** with li_at cookie
4. **Anthropic API key** for AI features
5. **Valid internet connection**
## Installation
```bash
cd linkedin-lead-mcp
npm install
```
## Configuration
1. Copy environment template:
```bash
cp .env.example .env
```
2. Edit `.env`:
```env
ANTHROPIC_API_KEY=sk-ant-xxxxx # Your Anthropic API key
CDP_URL=http://localhost:9222 # Chrome DevTools Protocol URL
PORT=3000
NODE_ENV=production
```
## Step 1: Launch Chrome with Remote Debugging
The system connects to your existing Chrome browser via CDP (Chrome DevTools Protocol).
### On macOS:
```bash
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--remote-debugging-port=9222 \
--user-data-dir="/tmp/chrome-debug"
```
### On Linux:
```bash
google-chrome \
--remote-debugging-port=9222 \
--user-data-dir="/tmp/chrome-debug"
```
### On Windows:
```cmd
"C:\Program Files\Google\Chrome\Application\chrome.exe" ^
--remote-debugging-port=9222 ^
--user-data-dir="C:\temp\chrome-debug"
```
**IMPORTANT:** Chrome will open with a clean profile. You MUST:
1. Navigate to linkedin.com
2. Log in to your LinkedIn account
3. Complete any verification prompts
4. Keep Chrome running throughout automation
## Step 2: Get Your li_at Cookie
1. In Chrome (with remote debugging), go to LinkedIn.com
2. Open DevTools (F12)
3. Go to Application → Cookies → https://www.linkedin.com
4. Find the `li_at` cookie
5. Copy its **Value** (long string starting with "AQ...")
**IMPORTANT:** This cookie authenticates all LinkedIn operations. Keep it secure.
## Step 3: Generate API Key
Generate an API key for your tier:
```bash
npm run generate-key starter
# or: professional, agency, enterprise
```
Save the generated API key immediately - you can't retrieve it later.
**Pricing Tiers:**
- **Starter ($97/mo):** 500 profiles, 200 messages, 2 sequences
- **Professional ($297/mo):** 2,000 profiles, 1,000 messages, 10 sequences
- **Agency ($697/mo):** 10,000 profiles, 5,000 messages, unlimited sequences
- **Enterprise (Custom):** Unlimited everything
## Step 4: Start the MCP Server
```bash
npm start
```
The server communicates via stdio (standard input/output) for MCP protocol.
## Step 5: Start the Background Worker (Optional)
For automatic follow-up messages:
```bash
npm run worker
```
This checks for pending follow-ups every hour and sends them automatically.
## Using the MCP Server
### Tool 1: Connect to Browser
```json
{
"tool": "connect_browser",
"arguments": {
"cdp_url": "http://localhost:9222"
}
}
```
**Response:**
```json
{
"success": true,
"message": "Connected to browser"
}
```
### Tool 2: Setup LinkedIn Session
```json
{
"tool": "setup_session",
"arguments": {
"api_key": "your-api-key-here",
"li_at_cookie": "AQEDATxxxxxxxxx..."
}
}
```
**Response:**
```json
{
"success": true,
"message": "Session authenticated"
}
```
### Tool 3: Search for Leads
```json
{
"tool": "search_leads",
"arguments": {
"api_key": "your-api-key",
"keywords": "CEO technology",
"location": "San Francisco Bay Area",
"limit": 25
}
}
```
**Response:**
```json
{
"success": true,
"profiles": [
{
"name": "John Smith",
"profile_url": "https://www.linkedin.com/in/johnsmith/",
"headline": "CEO at TechCorp",
"location": "San Francisco, CA"
}
]
}
```
### Tool 4: Analyze Profile
```json
{
"tool": "analyze_profile",
"arguments": {
"api_key": "your-api-key",
"profile_url": "https://www.linkedin.com/in/johnsmith/"
}
}
```
**Response:**
```json
{
"success": true,
"data": {
"name": "John Smith",
"headline": "CEO at TechCorp",
"about": "Leading innovation in enterprise software...",
"location": "San Francisco, CA",
"connections": 500,
"experience": [
{
"title": "CEO",
"company": "TechCorp",
"duration": "2020 - Present"
}
],
"education": [
{
"school": "Stanford University",
"degree": "MBA"
}
],
"skills": ["Leadership", "Strategy", "SaaS"]
}
}
```
### Tool 5: Score Lead (AI-Powered)
```json
{
"tool": "score_lead",
"arguments": {
"api_key": "your-api-key",
"profile_url": "https://www.linkedin.com/in/johnsmith/"
}
}
```
**Response:**
```json
{
"success": true,
"score": 87,
"reasoning": "High-quality lead: C-level executive at established company, complete profile, strong network, relevant industry experience",
"strengths": [
"Decision-maker position (CEO)",
"Tech industry alignment",
"Strong educational background"
],
"weaknesses": [
"Limited recent activity",
"No mutual connections"
],
"recommended_approach": "Reference their company's recent funding round and position your solution as scaling infrastructure"
}
```
### Tool 6: Generate Personalized Message (AI-Powered)
```json
{
"tool": "generate_message",
"arguments": {
"api_key": "your-api-key",
"profile_url": "https://www.linkedin.com/in/johnsmith/",
"value_proposition": "We help SaaS companies reduce infrastructure costs by 40% while scaling",
"message_type": "connection"
}
}
```
**Response:**
```json
{
"success": true,
"subject": "Scaling TechCorp's Infrastructure",
"message": "Hi John, saw TechCorp raised Series B recently. As you scale from 50 to 200+ team members, infrastructure costs typically explode. We've helped similar companies cut cloud spend 40% while handling 10x traffic. Worth a quick chat?",
"personalization_elements": [
"References Series B funding",
"Mentions specific team size",
"Industry-specific pain point"
]
}
```
### Tool 7: Send Message
```json
{
"tool": "send_message",
"arguments": {
"api_key": "your-api-key",
"profile_url": "https://www.linkedin.com/in/johnsmith/",
"message": "Hi John, saw TechCorp raised Series B...",
"is_connection_request": true
}
}
```
**Response:**
```json
{
"success": true,
"message": "Connection request sent with message"
}
```
### Tool 8: Create Follow-Up Sequence (AI-Powered)
```json
{
"tool": "create_followup_sequence",
"arguments": {
"api_key": "your-api-key",
"profile_url": "https://www.linkedin.com/in/johnsmith/",
"initial_message": "Hi John, saw TechCorp raised Series B...",
"num_followups": 3
}
}
```
**Response:**
```json
{
"success": true,
"sequence": [
{
"days_after": 3,
"message": "John, following up on infrastructure scaling. TechCorp's growth trajectory reminds me of DataCo before they hit scaling issues. Quick 15-min call?",
"angle": "Social proof with similar company"
},
{
"days_after": 7,
"message": "John, noticed your recent post about team expansion. That's exactly when infrastructure becomes critical. Here's a case study from a similar-stage company: [link]. Thoughts?",
"angle": "Recent activity reference + value content"
},
{
"days_after": 14,
"message": "John, last note - we're running a scaling workshop for Series B CTOs next week. Reserved you a spot if interested. No strings attached.",
"angle": "Low-pressure invitation + scarcity"
}
]
}
```
The background worker automatically sends these follow-ups at the specified intervals if no response is received.
## Production Deployment
### Using Docker
```bash
# Build image
docker build -t linkedin-lead-mcp .
# Run server
docker run -d \
-e ANTHROPIC_API_KEY=sk-ant-xxxxx \
-e CDP_URL=http://host.docker.internal:9222 \
-v $(pwd)/data:/app/data \
--name linkedin-mcp \
linkedin-lead-mcp
# Run worker
docker run -d \
-e ANTHROPIC_API_KEY=sk-ant-xxxxx \
-e CDP_URL=http://host.docker.internal:9222 \
-v $(pwd)/data:/app/data \
--name linkedin-worker \
linkedin-lead-mcp npm run worker
```
### Using PM2 (Process Manager)
```bash
npm install -g pm2
# Start server
pm2 start npm --name "linkedin-mcp" -- start
# Start worker
pm2 start npm --name "linkedin-worker" -- run worker
# Save configuration
pm2 save
# Setup startup script
pm2 startup
```
## Rate Limiting & Safety
The system includes built-in safety features:
1. **Human-like delays:** Random delays between actions (1-5 seconds)
2. **Usage limits:** Monthly limits per tier enforced automatically
3. **Session management:** Automatic cookie validation and refresh
4. **Error handling:** Graceful handling of LinkedIn blocks/timeouts
5. **Response detection:** Automatically stops follow-ups when lead responds
**Recommended Daily Limits:**
- Profile views: Max 100/day
- Connection requests: Max 50/day
- Messages: Max 50/day
## Monitoring & Logs
### Check usage for a user:
```bash
cat data/usage.json | jq '.[] | select(.user_id == "USER_ID")'
```
### Check pending follow-ups:
```bash
cat data/sequences.json | jq '.[] | select(.is_active == true)'
```
### View all leads:
```bash
cat data/leads.json | jq '.[] | {name, score, profile_url}'
```
## Troubleshooting
### "Browser not connected"
- Ensure Chrome is running with `--remote-debugging-port=9222`
- Check CDP_URL in .env matches Chrome's debugging port
- Verify firewall isn't blocking port 9222
### "Invalid li_at cookie"
- Cookie may have expired - log in to LinkedIn again in Chrome
- Ensure you copied the entire cookie value
- Check for extra spaces or quotes
### "Monthly limit reached"
- Usage resets on 1st of each month
- Upgrade tier or wait for reset
- Check `data/usage.json` for current usage
### "Session authentication failed"
- LinkedIn may require 2FA verification
- Complete verification in Chrome browser
- Try logging out and back in to LinkedIn
### Follow-ups not sending
- Ensure background worker is running (`npm run worker`)
- Check worker logs for errors
- Verify leads have active sequences in `data/sequences.json`
## Security Best Practices
1. **Never commit** `.env` file or `data/` directory
2. **Rotate API keys** if compromised
3. **Use HTTPS** for production deployments
4. **Limit API key access** to trusted team members only
5. **Monitor usage** for suspicious activity
6. **Keep li_at cookies secure** - they provide full account access
## Support & Issues
For production issues:
- Check logs: `data/` directory
- Review tool responses for error messages
- Verify Chrome debugging connection
- Confirm Anthropic API key is valid
## License
MIT License - See LICENSE file for details.
---
**Built by Agentic AI AMRO Ltd**
**Production-Grade LinkedIn Automation - No Mocks, No Placeholders**