Abhirajsinghchandrawat/linkedin-mcp-server
If you are the rightful owner of linkedin-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A comprehensive Model Context Protocol (MCP) server designed for automating LinkedIn tasks.
LinkedIn Automation MCP Server
A complete end-to-end Model Context Protocol (MCP) server for LinkedIn automation tasks. This server provides tools for automating various LinkedIn activities including login, search, connection requests, messaging, posting, and data extraction.
Features
- Authentication: Secure LinkedIn login with session management
- People Search: Search for LinkedIn users with various filters
- Connection Management: Send connection requests with custom messages
- Messaging: Send direct messages to connections
- Content Creation: Create and publish LinkedIn posts
- Engagement: Like and comment on posts
- Data Extraction: Extract profile and company information
- Rate Limiting: Built-in rate limiting to avoid detection
- Error Handling: Comprehensive error handling and logging
Installation
Prerequisites
- Python 3.8 or higher
- Chrome browser installed
- LinkedIn account
Setup
-
Clone or download the project files
-
Install dependencies:
pip install -r requirements.txt -
Install Chrome WebDriver (automatically handled by webdriver-manager)
Usage
Starting the Server
python linkedin_mcp_server.py
Available Tools
1. LinkedIn Login
{
"name": "linkedin_login",
"arguments": {
"email": "your-email@example.com",
"password": "your-password",
"headless": false
}
}
2. Search People
{
"name": "linkedin_search_people",
"arguments": {
"keywords": "software engineer",
"location": "San Francisco",
"company": "Google",
"max_results": 50
}
}
3. Send Connection Request
{
"name": "linkedin_connect_with_person",
"arguments": {
"profile_url": "https://www.linkedin.com/in/username/",
"message": "Hi, I'd like to connect!",
"note": "I saw your profile and thought we could connect."
}
}
4. Send Message
{
"name": "linkedin_send_message",
"arguments": {
"profile_url": "https://www.linkedin.com/in/username/",
"message": "Hello! How are you?",
"subject": "Greeting"
}
}
5. Create Post
{
"name": "linkedin_post_content",
"arguments": {
"content": "Excited to share my latest project!",
"visibility": "public",
"hashtags": ["automation", "linkedin", "networking"]
}
}
6. Like Post
{
"name": "linkedin_like_post",
"arguments": {
"post_url": "https://www.linkedin.com/posts/activity-123"
}
}
7. Comment on Post
{
"name": "linkedin_comment_on_post",
"arguments": {
"post_url": "https://www.linkedin.com/posts/activity-123",
"comment": "Great post! Thanks for sharing."
}
}
8. Extract Profile Information
{
"name": "linkedin_get_profile_info",
"arguments": {
"profile_url": "https://www.linkedin.com/in/username/"
}
}
9. Extract Company Information
{
"name": "linkedin_scrape_company_info",
"arguments": {
"company_url": "https://www.linkedin.com/company/company-name/"
}
}
10. Logout
{
"name": "linkedin_logout",
"arguments": {}
}
Configuration
The server uses config.json for configuration settings:
- Browser Settings: Headless mode, user agent, window size
- Automation Settings: Delays, retries, rate limiting
- LinkedIn URLs: Various LinkedIn page URLs
- CSS Selectors: Element selectors for automation
Security and Best Practices
Rate Limiting
- Built-in rate limiting to avoid LinkedIn's detection
- Configurable delays between actions
- Maximum requests per minute setting
Session Management
- Secure login handling
- Automatic session cleanup on logout
- Browser instance management
Error Handling
- Comprehensive error catching and reporting
- Graceful failure handling
- Detailed logging for debugging
Troubleshooting
Common Issues
-
Login Failed
- Check credentials
- Ensure 2FA is disabled or handled
- Try headless mode
-
Element Not Found
- LinkedIn may have updated their UI
- Check selectors in config.json
- Add delays between actions
-
Rate Limiting
- Reduce request frequency
- Increase delays between actions
- Use headless mode
-
Browser Issues
- Update Chrome browser
- Clear browser cache
- Check ChromeDriver compatibility
Debug Mode
Enable debug logging by modifying the logging level in the code:
logging.basicConfig(level=logging.DEBUG)
Legal and Ethical Considerations
⚠️ Important: This tool is for educational and legitimate business purposes only.
- Respect LinkedIn's Terms of Service
- Don't spam or harass users
- Use reasonable delays between actions
- Don't exceed LinkedIn's rate limits
- Respect user privacy and consent
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For issues and questions:
- Check the troubleshooting section
- Review the logs for error details
- Create an issue with detailed information
Changelog
Version 1.0.0
- Initial release
- Complete LinkedIn automation functionality
- MCP server implementation
- Comprehensive tool set
- Configuration management