LinkedinMCP

FarmerBob869/LinkedinMCP

3.2

If you are the rightful owner of LinkedinMCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A professional, lightweight MCP (Model Context Protocol) server for LinkedIn automation, designed for developers to enhance their LinkedIn presence through intelligent automation.

Tools
  1. linkedin_login

    Authenticate with LinkedIn

  2. linkedin_post

    Create a text post

  3. linkedin_comment

    Comment on a post

  4. linkedin_analyze_trends

    Analyze keyword trends

  5. linkedin_status

    Get server status

LinkedIn MCP Server

Python 3.11+ License: MIT MCP Compatible

A professional, lightweight MCP (Model Context Protocol) server for LinkedIn automation. Built for developers who want to automate their LinkedIn presence with intelligent posting, community engagement, and trend analysis.

šŸš€ Features

Core Automation

  • Smart Login: Anti-detection browser automation with session persistence
  • Content Posting: Text posts with hashtag support
  • Community Engagement: Automated commenting on posts
  • Trend Analysis: Keyword-based trend monitoring and engagement metrics

Professional Features

  • Rate Limiting: Built-in protection against LinkedIn restrictions
  • Session Management: Persistent sessions across restarts
  • Anti-Detection: Realistic browser fingerprinting and human-like behavior
  • Error Handling: Comprehensive error recovery and logging
  • File-Based Storage: No external dependencies - everything runs locally

šŸ“‹ Requirements

  • Python: 3.11 or higher
  • Memory: 512MB RAM minimum (1GB recommended)
  • Storage: 1GB free space
  • OS: Linux, macOS, or Windows

šŸ›  Quick Start

1. Installation

# Clone the repository
git clone https://github.com/your-username/linkedin-mcp-server.git
cd linkedin-mcp-server

# Install dependencies
pip install -r requirements.txt

# Install Playwright browser
playwright install chromium

2. Configuration

# Copy environment template
cp .env.example .env

# Edit configuration (optional)
nano .env

3. Run the Server

# Direct execution
python -m src.linkedin_mcp_server.main

# Or with Docker
docker-compose up -d

šŸŽÆ Usage Examples

Basic MCP Client Usage

import asyncio
from mcp_client import MCPClient

async def main():
    client = MCPClient("linkedin-mcp-server")
    
    # Login to LinkedIn
    await client.call_tool("linkedin_login", {
        "email": "your-email@example.com",
        "password": "your-password"
    })
    
    # Create a post
    await client.call_tool("linkedin_post", {
        "content": "šŸš€ Just deployed my new FastAPI service with 40% better performance!",
        "hashtags": ["FastAPI", "Python", "Performance", "Backend"]
    })
    
    # Analyze trends
    trends = await client.call_tool("linkedin_analyze_trends", {
        "keyword": "Python",
        "max_posts": 20
    })
    
    print(trends)

if __name__ == "__main__":
    asyncio.run(main())

Available Tools

ToolDescriptionParameters
linkedin_loginAuthenticate with LinkedInemail, password
linkedin_postCreate a text postcontent, hashtags (optional)
linkedin_commentComment on a postpost_url, comment
linkedin_analyze_trendsAnalyze keyword trendskeyword, max_posts (optional)
linkedin_statusGet server statusNone

āš™ļø Configuration

Environment Variables

# Application Settings
LOG_LEVEL=INFO                    # Logging level
HEADLESS=true                     # Run browser in headless mode
DATA_DIR=./data                   # Data storage directory

# Rate Limiting (per hour)
RATE_LIMIT_POSTS=10              # Maximum posts per hour
RATE_LIMIT_COMMENTS=20           # Maximum comments per hour  
RATE_LIMIT_SEARCHES=15           # Maximum searches per hour

# Browser Settings
BROWSER_TIMEOUT=30000            # Browser timeout in milliseconds

Rate Limiting

The server includes built-in rate limiting to comply with LinkedIn's usage policies:

  • Posts: 10 per hour (default)
  • Comments: 20 per hour (default)
  • Searches: 15 per hour (default)
  • Login Attempts: 3 per hour (default)

These limits reset every hour and are stored locally in files.

🐳 Docker Deployment

Quick Deploy

# Build and run
docker-compose up -d

# View logs
docker-compose logs -f

# Stop
docker-compose down

Production Deployment

# Set environment variables
export LOG_LEVEL=WARNING
export RATE_LIMIT_POSTS=8

# Deploy with custom settings
docker-compose up -d

šŸ“Š Monitoring

Health Checks

# Check server status
curl -X POST localhost:8080 -d '{"tool": "linkedin_status", "arguments": {}}'

# View logs
tail -f logs/linkedin_mcp.log

# Monitor container resources
docker stats linkedin-mcp-server

Status Response

{
  "server": "linkedin-mcp-server",
  "version": "1.0.0", 
  "status": "healthy",
  "logged_in": true,
  "rate_limits": {
    "post": 8,
    "comment": 18,
    "search": 12
  },
  "timestamp": "2024-01-15T10:30:00Z"
}

šŸ”’ Security Features

Anti-Detection

  • Realistic user agents and browser fingerprinting
  • Human-like typing delays and mouse movements
  • Random delays between actions
  • Proper browser context management

Data Protection

  • Local file-based storage (no external databases)
  • Session data encryption
  • No credential logging
  • Automatic cleanup of temporary data

Rate Limiting

  • Hourly limits on all actions
  • Automatic throttling
  • LinkedIn ToS compliance
  • Graceful degradation

šŸ—ļø Architecture

linkedin-mcp-server/
ā”œā”€ā”€ src/linkedin_mcp_server/
│   ā”œā”€ā”€ main.py              # MCP server implementation
│   ā”œā”€ā”€ config.py            # Configuration management
│   ā”œā”€ā”€ models.py            # Data models
│   ā”œā”€ā”€ storage.py           # File-based storage
│   ā”œā”€ā”€ rate_limiter.py      # Rate limiting logic
│   ā”œā”€ā”€ browser.py           # Browser management
│   ā”œā”€ā”€ linkedin_client.py   # LinkedIn automation
│   └── utils.py             # Utility functions
ā”œā”€ā”€ data/                    # Session and rate limit data
ā”œā”€ā”€ logs/                    # Application logs
ā”œā”€ā”€ requirements.txt         # Python dependencies
ā”œā”€ā”€ Dockerfile              # Container configuration
└── docker-compose.yml      # Service orchestration

šŸ“ˆ Performance

Resource Usage

  • Memory: ~200-400MB during operation
  • CPU: Low usage, spikes during browser operations
  • Storage: ~50MB for application, variable for data
  • Network: Minimal, only LinkedIn requests

Optimization Features

  • Lazy browser initialization
  • Efficient session management
  • Memory-conscious data structures
  • Automatic resource cleanup

šŸ¤ Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 style guide
  • Add type hints to all functions
  • Write tests for new features
  • Update documentation as needed

šŸ“„ License

This project is licensed under the MIT License - see the file for details.

āš ļø Disclaimer

This tool is for educational and personal use only. Users are responsible for complying with LinkedIn's Terms of Service and applicable laws. The authors are not responsible for any misuse or consequences resulting from the use of this software.

šŸ†˜ Support

šŸ™ Acknowledgments


Built with ā¤ļø for the developer community