MCP HubMCP Hub
alinaqi

mcp-linkedin-server

by: alinaqi

LinkedIn MCP Server for local automation

16created 18/02/2025
Visit
LinkedIn
automation

📌Overview

Purpose: To provide a robust and secure server for automating LinkedIn interactions and data extraction while adhering to LinkedIn’s terms of service.

Overview: The LinkedIn Browser MCP Server is powered by FastMCP and enables users to programmatically engage with LinkedIn. It facilitates secure authentication and various profile and post operations, ensuring compliance with LinkedIn's rate limits and security protocols.

Key Features:

  • Secure Authentication: Implements environment-based credential management, session persistence with encrypted cookie storage, and protections against rate limiting, with automatic session recovery to maintain a steady operation.

  • Profile Operations: Allows users to view and extract profile information, search for profiles using keywords, browse the LinkedIn feed, and visit profiles, enhancing user engagement and data acquisition.

  • Post Interactions: Users can like and comment on posts, as well as read content and engagement metrics, fostering interaction with LinkedIn content seamlessly.


LinkedIn Browser MCP Server

A FastMCP-based server for LinkedIn automation and data extraction using browser automation. This server provides tools for interacting with LinkedIn programmatically while respecting LinkedIn's terms of service and rate limits.

Features

  • Secure Authentication

    • Environment-based credential management
    • Session persistence with encrypted cookie storage
    • Rate limiting protection
    • Automatic session recovery
  • Profile Operations

    • View and extract profile information
    • Search for profiles based on keywords
    • Browse LinkedIn feed
    • Profile visiting capabilities
  • Post Interactions

    • Like posts
    • Comment on posts
    • Read post content and engagement metrics

Prerequisites

  • Python 3.8+
  • Playwright
  • FastMCP library
  • LinkedIn account

Installation

  1. Clone the repository:
git clone [repository-url]
cd mcp-linkedin-server
  1. Create and activate a virtual environment:
python -m venv env
source env/bin/activate  # On Windows: env\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
playwright install chromium
  1. Set up environment variables:
    Create a .env file in the root directory with:
LINKEDIN_USERNAME=your_email@example.com
LINKEDIN_PASSWORD=your_password
COOKIE_ENCRYPTION_KEY=your_encryption_key  # Optional: auto-generated if not provided

Usage

  1. Start the MCP server:
python linkedin_browser_mcp.py
  1. Available Tools:
  • login_linkedin_secure: Securely log in using environment credentials
  • browse_linkedin_feed: Browse and extract posts from feed
  • search_linkedin_profiles: Search for profiles matching criteria
  • view_linkedin_profile: View and extract data from specific profiles
  • interact_with_linkedin_post: Like, comment, or read posts

Example Usage

from fastmcp import FastMCP

# Initialize client
client = FastMCP.connect("http://localhost:8000")

# Login
result = await client.login_linkedin_secure()
print(result)

# Search profiles
profiles = await client.search_linkedin_profiles(
    query="software engineer",
    count=5
)
print(profiles)

# View profile
profile_data = await client.view_linkedin_profile(
    profile_url="https://www.linkedin.com/in/username"
)
print(profile_data)

Security Features

  • Encrypted cookie storage
  • Rate limiting protection
  • Secure credential management
  • Session persistence
  • Browser automation security measures

Best Practices

  • Rate Limiting
    Maximum 5 login attempts per hour, automatic session reuse, and cookie persistence to minimize login needs

  • Error Handling
    Handles network issues, authentication failures, LinkedIn security challenges, invalid URLs or parameters

  • Session Management
    Automatic cookie encryption, session persistence, and secure storage practices

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

MIT

Disclaimer

This tool is for educational purposes only. Ensure compliance with LinkedIn's terms of service and rate limiting guidelines when using this software.