Skip to main content

A FastMCP-based server for LinkedIn automation and data extraction using browser automation

Project description

LinkedIn Browser MCP Server

A FastMCP-based server for LinkedIn automation and data extraction using browser automation. This server provides a set of 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: will be 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

  1. Rate Limiting: The server implements rate limiting to prevent excessive requests:

    • Maximum 5 login attempts per hour
    • Automatic session reuse
    • Cookie persistence to minimize login needs
  2. Error Handling: Comprehensive error handling for:

    • Network issues
    • Authentication failures
    • LinkedIn security challenges
    • Invalid URLs or parameters
  3. Session Management:

    • Automatic cookie encryption
    • Session persistence
    • 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_mcp_linkedin_server-1.0.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iflow_mcp_mcp_linkedin_server-1.0.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_mcp_linkedin_server-1.0.0.tar.gz.

File metadata

File hashes

Hashes for iflow_mcp_mcp_linkedin_server-1.0.0.tar.gz
Algorithm Hash digest
SHA256 56a2fd357702ef48859b7dc76366eb34bc5e0e2fa30137b879f2f8c86268a3e1
MD5 7fdbd7af7af8e0a7644feb348f232ef6
BLAKE2b-256 bba730f82124eda93785554495a2def16f537be08c21fba9cd4f0fe60f7449ce

See more details on using hashes here.

File details

Details for the file iflow_mcp_mcp_linkedin_server-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for iflow_mcp_mcp_linkedin_server-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 49890f52fa87ccaae8301f9858b345bcbd8947a584b7594275a1667fad2d8981
MD5 01e1602078f7ba2e3f1f9a077f9d7ff3
BLAKE2b-256 cf9bd03494f627613cb9cfc3a9e6a19d68672bc53dc1a10d20cab7f406684e75

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page