harsha148/LinkedIn-MCP
If you are the rightful owner of LinkedIn-MCP 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 FastMCP server that provides tools for LinkedIn automation, including job search and feed monitoring capabilities.
LinkedIn MCP Server
A FastMCP server that provides tools for LinkedIn automation, including job search and feed monitoring capabilities.
Prerequisites
- Python 3.10 or higher
- Docker (optional, for containerized deployment)
- LinkedIn account credentials
Environment Setup
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
export LINKEDIN_EMAIL="your-email@example.com"
export LINKEDIN_PASSWORD="your-password"
Running the Server
Local Development
- Start the MCP server:
python main.py
The server will start on http://localhost:8000
with SSE transport.
Docker Deployment
- Build the Docker image:
docker build -t linkedin-mcp .
- Run the container:
docker run -p 8000:8000 \
-e LINKEDIN_EMAIL="your-email@example.com" \
-e LINKEDIN_PASSWORD="your-password" \
linkedin-mcp
Testing the Server
Using the Client Scripts
- Test job search functionality:
python client.py
- Test feed monitoring:
# Basic usage (fetches 5 posts by default)
python client_feed.py "Python"
# Specify number of posts to fetch
python client_feed.py "Machine Learning" --max-posts 10
Available Tools
1. Login Tool
@mcp.tool()
async def login() -> Dict[str, str]
Authenticates with LinkedIn using credentials from environment variables.
- Returns: Dictionary with login status and message
- Requires: LINKEDIN_EMAIL and LINKEDIN_PASSWORD environment variables
2. Search Jobs Tool
@mcp.tool()
async def search_jobs(query: str, location: str, max_jobs: int = 3) -> List[Dict[str, str]]
Searches LinkedIn jobs with enhanced data extraction.
- Parameters:
- query: Job search keywords
- location: Location to search in
- max_jobs: Maximum number of jobs to return (default: 3)
- Returns: List of job details including title, company, location, and description
3. Fetch Feed Tool
@mcp.tool()
async def fetch_feed(topic: str, max_posts: int = 5) -> List[str]
Scrapes recent LinkedIn feed posts related to a specific topic.
- Parameters:
- topic: The topic to search for in feed posts
- max_posts: Maximum number of posts to return (default: 5)
- Returns: List of post contents matching the topic
Error Handling
The server includes comprehensive error handling for:
- Authentication failures
- Network issues
- Page loading timeouts
- Content extraction errors
Security Notes
- Never commit your LinkedIn credentials to version control
- Use environment variables for sensitive information
- The server uses secure storage for authentication state
- All tools require authentication before use
Troubleshooting
-
If login fails:
- Verify your credentials
- Check if LinkedIn is blocking automated access
- Try clearing the storage.json file
-
If feed fetching fails:
- Ensure you're properly authenticated
- Check the feed_debug.png screenshot for visual debugging
- Verify your network connection
-
If job search fails:
- Verify the search parameters
- Check if the location is valid
- Ensure you're properly authenticated
Contributing
Feel free to submit issues and enhancement requests!