LinkedIn influencer automation with MCP
Project description
LinkedIn Influencer MCP 🎯
A powerful MCP server for automating LinkedIn interactions and content analysis.
Diagram
This Model Context Protocol (MCP) server provides tools and resources for automating LinkedIn interactions, analyzing profiles, and managing content. Built with FastMCP, it enables AI assistants to perform complex LinkedIn operations including profile analysis, content creation, and network building.
Table of Contents
Installation
We recommend installing with uv:
# Clone the repository
git clone git@github.com:shahshrey/linkedin_influencer_mcp.git
cd linkedin_influencer_mcp
# Install dependencies
uv sync
Dependencies
Key dependencies include:
fastmcp~=0.4.1: Core MCP functionalitylangchain_core&langchain_community: LangChain integrationplaywright~=1.49.1: Browser automationpython-dotenv~=1.0.1: Environment managementbeautifulsoup4~=4.12.3: HTML parsingpydantic~=2.10.6: Data validation
Features
-
Profile Analysis:
- Extract comprehensive LinkedIn profile data including name, headline, experience, education
- Analyze profile strength and engagement metrics
- Track profile changes over time
- Generate insights about professional background
-
Content Management:
- Create and schedule LinkedIn posts with optimal timing
- Scrape and analyze posts from target profiles
- Track post performance and engagement
- Generate content from YouTube video transcripts
- Repurpose content across platforms
-
Network Building:
- Send personalized connection requests at scale
- Search and connect with specific professional groups
- Automated recruiter outreach with customized messaging
- Track connection request status and responses
- Build targeted professional networks
-
Content Generation:
- AI-powered post creation using multiple LLM options
- Content repurposing from various sources (YouTube, articles, etc.)
- Writing style mimicking based on successful profiles
- SEO optimization for maximum visibility
- Hashtag optimization and trend analysis
-
Automation Tools:
- Headless browser automation with Playwright
- Robust session management and cookie handling
- Rate limiting protection
- Comprehensive error handling and recovery
- Detailed logging and monitoring
Usage
- Set up your environment variables:
cp .env.example .env
# Edit .env with your credentials:
LINKEDIN_EMAIL=your-email
LINKEDIN_PASSWORD=your-password
GROQ_API_KEY=your-groq-api-key
USER_LINKEDIN_PROFILE_ID=your-profile-id
- Run the MCP server:
fastmcp install linkedin_influencer.py
- Available Tools:
# Get profile information
await get_linkedin_profile_info(linkedin_profile_id="profile_id")
# Scrape posts
await get_linkedin_profile_posts(linkedin_profile_id="profile_id", max_posts=5)
# Create a post
await create_linkedin_post(content="Your post content")
# Send connection requests
await send_linkedin_connection_requests(connection=ConnectionRequest(...))
Configuration
Required environment variables:
LINKEDIN_EMAIL: Your LinkedIn account emailLINKEDIN_PASSWORD: Your LinkedIn passwordGROQ_API_KEY: Groq API key for AI operationsUSER_LINKEDIN_PROFILE_ID: Your LinkedIn profile IDGOOGLE_API_KEY: If you prefer to use GeminiOPENAI_API_KEY: If you prefer to use OpenAILANGCHAIN_API_KEY: For LangSmith tracking operationsLANGCHAIN_PROJECT: LangChain project nameLANGCHAIN_TRACING_V2: Enable LangChain tracing
Project Structure
linkedin_influencer_mcp/
├── src/ # Source code
│ ├── browser/ # Browser automation
│ │ ├── feed_page.py
│ │ ├── profile_page.py
│ │ └── search_page.py
├── tests/ # Test suite
├── linkedin_influencer.py # Main MCP server
├── requirements.txt # Dependencies
├── pyproject.toml # Project configuration
└── .env # Environment variables
Development
Prerequisites
- Python 3.10+
- uv package manager
- LinkedIn account
- Required API keys (see below)
Getting Your API Keys
1. Groq API Key
- Visit Groq Cloud
- Sign up for an account
- Navigate to API Keys section
- Generate a new API key
2. Google API Key (Optional - for Gemini)
- Visit Google AI Studio
- Create a project
- Enable the Gemini API
- Generate API credentials
3. OpenAI API Key (Optional)
- Visit OpenAI Platform
- Sign up/Login
- Navigate to API section
- Create a new API key
Note on API Usage:
- Groq: Pay-as-you-go pricing
- Google: Free tier available with quotas
- OpenAI: Usage-based pricing
Choose APIs based on your needs and budget. Groq is recommended for optimal performance.
Configure as MCP Server
To add this tool as an MCP server, modify your Claude desktop configuration file:
- MacOS:
~/Library/Application\ Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%/Claude/claude_desktop_config.json
Add the following configuration:
{
"linkedin-influencer-mcp": {
"command": "uv",
"args": [
"--directory",
"/Users/YOUR_USERNAME/path/to/linkedin_influencer_mcp",
"run",
"linkedin_influencer"
],
"env": {
"LINKEDIN_EMAIL": "your_email",
"LINKEDIN_PASSWORD": "your_password",
"GROQ_API_KEY": "your_groq_key",
"USER_LINKEDIN_PROFILE_ID": "your_profile_id"
}
}
}
Alternatively, you can also give Claude access to the server by running:
fastmcp install linkedin_influencer.py
⚠️ IMPORTANT:
- Replace placeholders with your actual credentials
- Ensure directory path matches your installation
- Never commit this file with real credentials
Local Development
- Install development dependencies:
uv pip install -r requirements.txt
- Set up pre-commit hooks:
pre-commit install
- Run tests:
pytest tests/
- Use the MCP Inspector for testing:
fastmcp dev linkedin_influencer.py
Code Style
The project uses:
- Black for code formatting
- Flake8 for linting
- isort for import sorting
- pre-commit hooks for automated checks
Debugging
Since MCP servers run over stdio, we recommend using the MCP Inspector for debugging:
npx @modelcontextprotocol/inspector uv --directory /path/to/linkedin_influencer_mcp run linkedin_influencer
The Inspector provides:
- Real-time request/response monitoring
- Input/output validation
- Error tracking
- Performance metrics
Tools and Prompts
Available Tools
get_linkedin_profile_info: Extract profile informationget_linkedin_profile_posts: Scrape posts from profilescreate_linkedin_post: Create and publish postssend_linkedin_connection_requests: Automated networking
Prompt Templates
connection_requests_to_recruiters_prompt: Generate personalized outreach messages to recruiters based on job preferences and experienceconnection_requests_with_custom_note: Create tailored connection requests with context-aware messagingresearch_and_create_post: Leverage Brave/Perplexity MCP for research, then generate content using Claude's writing style for authentic LinkedIn posts and post to linkedin directly from claudescrape_linkedin_posts_and_post_to_linkedin: Analyze successful content from influencers, extract key themes, and create unique postscreate_linkedin_post_from_youtube: Convert YouTube video content into engaging LinkedIn posts with proper attribution
Use Cases
Example #1: Automated Recruiter Outreach
Use the recruiter outreach template to automatically connect with relevant recruiters:
Example prompt to Claude:
Connect with tech recruiters in the San Francisco Bay Area who are hiring for senior software engineering roles. Personalize the message based on my experience with Python and distributed systems.
Example #2: Content Creation from Research
Use the research and post creation template to generate engaging content:
Example prompt:
Research the latest trends in AI and create a LinkedIn post about the impact of large language models on software development. Include relevant statistics and tag key influencers in the space.
Error Handling
The service includes robust error handling for:
- LinkedIn rate limiting
- Authentication failures
- Network timeouts
- API quota exceeded
- Invalid input parameters
- Session management issues
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file linkedin_influencer_mcp-0.1.1.tar.gz.
File metadata
- Download URL: linkedin_influencer_mcp-0.1.1.tar.gz
- Upload date:
- Size: 22.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3bfbbc5fdf33903ebbf01755d2d1d98e376bebd866331f6371fa1171e647333
|
|
| MD5 |
6c5e9e20d1bcf28598dc7c5010ee216a
|
|
| BLAKE2b-256 |
1a01fdfdf5db664ad7756dc9fa0fb2a6cdb454b998a76e9fea67b3cf98c359b7
|
File details
Details for the file linkedin_influencer_mcp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: linkedin_influencer_mcp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 22.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9880de5d2fcc18c9aa0e8fff732baf8bd2ad89ca377ced2739303fe72506856b
|
|
| MD5 |
2fe419941ce126268c1fa763b11f24c8
|
|
| BLAKE2b-256 |
ba3c9ea01f318d446eb09ff268aab3ed4d38a3408e23ddd75796bd6b5edf881b
|