#
tokens: 1071/50000 5/5 files
lines: on (toggle) GitHub
raw markdown copy reset
# Directory Structure

```
├── .gitignore
├── .python-version
├── pyproject.toml
├── README.md
├── server.py
└── uv.lock
```

# Files

--------------------------------------------------------------------------------
/.python-version:
--------------------------------------------------------------------------------

```
1 | 3.12
2 | 
```

--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------

```
 1 | # Python-generated files
 2 | __pycache__/
 3 | *.py[oc]
 4 | build/
 5 | dist/
 6 | wheels/
 7 | *.egg-info
 8 | 
 9 | # Virtual environments
10 | .venv
11 | .env
12 | 
```

--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------

```markdown
 1 | # LinkedIn Profile Scraper
 2 | This project is a LinkedIn Profile Scraper built using FastMCP and httpx to fetch LinkedIn profile data via the RapidAPI LinkedIn Profile Scraper API.
 3 | ## Features
 4 | + Retrieves LinkedIn profile data asynchronously.
 5 | + Allows selective inclusion of data like skills, certifications, and more.
 6 | + Uses FastMCP for structured execution.
 7 | + Integrated with Claude Desktop for AI-powered processing.
 8 | ## Prerequisites
 9 | + A RapidAPI account with access to the LinkedIn Profile Scraper API.
10 | + A valid RAPIDAPI_KEY.
11 | + Installed dependencies from requirements.txt.
12 | 
13 | # Video Link:
14 | https://drive.google.com/file/d/1I3V8SlOgvMgg8hiMxO3Z2lrZl7v00VqM/view?usp=sharing
15 | 
```

--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------

```toml
 1 | [project]
 2 | name = "linkedln-mcp"
 3 | version = "0.1.0"
 4 | description = "Add your description here"
 5 | readme = "README.md"
 6 | requires-python = ">=3.12"
 7 | dependencies = [
 8 |     "httpx>=0.28.1",
 9 |     "mcp[cli]>=1.4.1",
10 | ]
11 | 
```

--------------------------------------------------------------------------------
/server.py:
--------------------------------------------------------------------------------

```python
 1 | from typing import Any
 2 | import httpx
 3 | import json
 4 | from mcp.server.fastmcp import FastMCP
 5 | import os
 6 | from dotenv import load_dotenv
 7 | 
 8 | load_dotenv()
 9 | 
10 | RAPIDAPI_KEY = os.getenv("RAPIDAPI_KEY")
11 | if not RAPIDAPI_KEY:
12 |     raise ValueError("RAPIDAPI_KEY is not set in the environment variables")
13 | 
14 | mcp = FastMCP("linkedin_profile_scrapper")
15 | 
16 | LINKEDIN_API_BASE = "https://fresh-linkedin-profile-data.p.rapidapi.com"
17 | RAPIDAPI_HOST = "fresh-linkedin-profile-data.p.rapidapi.com"
18 | 
19 | async def get_linkedin_data(linkedin_url: str) -> dict[str, Any] | None:
20 |     params = {
21 |         "linkedin_url": linkedin_url,
22 |         "include_skills": "true",
23 |         "include_certifications": "false",
24 |         "include_publications": "false",
25 |         "include_honors": "false",
26 |         "include_volunteers": "false",
27 |         "include_projects": "false",
28 |         "include_patents": "false",
29 |         "include_courses": "false",
30 |         "include_organizations": "false",
31 |         "include_profile_status": "false",
32 |         "include_company_public_url": "false"
33 |     }
34 |     headers = {
35 |         "x-rapidapi-key": RAPIDAPI_KEY,
36 |         "x-rapidapi-host": RAPIDAPI_HOST
37 |     }
38 |     async with httpx.AsyncClient() as client:
39 |         try:
40 |             response = await client.get(
41 |                 f"{LINKEDIN_API_BASE}/get-linkedin-profile",
42 |                 headers=headers,
43 |                 params=params,
44 |                 timeout=30.0
45 |             )
46 |             response.raise_for_status()
47 |             return response.json()
48 |         except Exception:
49 |             return None
50 | 
51 | @mcp.tool()
52 | async def get_profile(linkedin_url: str) -> str:
53 |     data = await get_linkedin_data(linkedin_url)
54 |     if not data:
55 |         return "Unable to fetch LinkedIn profile data."
56 |     return json.dumps(data, indent=2)
57 | 
58 | if __name__ == "__main__":
59 |     mcp.run(transport="stdio")
```