Job Copilot MCP
# job-copilot-mcp



Local-first **Model Context Protocol (MCP) Server** and **Human-in-the-Loop (HITL) Job Application Copilot** for automating job discovery, semantic ranking, and tailored application drafting across Indonesian job portals (JobStreet & Glints).
Designed with a **zero-API-cost, hardware-aware architecture** that combines CPU semantic filtering with a rate-limit-resilient LLM cascade router (Cloud Free-Tier APIs with automatic fallback to quantized local models on 4GB VRAM GPUs).
---
## System Architecture
```mermaid
flowchart TD
A[Playwright Persistent Session] -->|Scrape & Regex Filter| B[(SQLite + SHA-256 Dedup)]
B -->|Filter NEW Jobs| C[CPU Semantic Ranker<br/>multilingual-e5-small]
C -->|Top-K Relevant Jobs| D[Pydantic AI Cascade Router]
D -->|Primary| E[Gemini / Groq Free Tier]
D -->|Fallback on 429 / Offline| F[Local Ollama qwen2.5:3b<br/>4GB VRAM]
E & F -->|Structured ApplicationKit| B
B -->|Expose 6 MCP Tools| G[FastMCP Server]
B -->|Visual Pipeline Tracker| H[Streamlit Dashboard]
G -->|HITL Form Prefill| A
```
---
## Key Engineering Highlights
* **Zero-Token Funnel & Role Filtering:** Eliminates duplicate postings via deterministic `SHA-256` content hashing (`company | title | description[:500]`), filters out senior/managerial roles via regex rules in `selectors.py`, and scores entry/mid-level listings locally on CPU using `intfloat/multilingual-e5-small` before invoking any LLM.
* **Anti-Hallucination Grounding:** Enforces strict structured outputs (`ApplicationKit` via **Pydantic AI**) anchored exclusively to verified candidate facts in `data/profile_facts.json`—preventing fabricated metrics, degrees, or work experience.
* **Rate-Limit Resilient Cascade Router:** Prioritizes fast cloud free-tier models (Gemini / Groq) and seamlessly falls back to a quantized local `qwen2.5:3b` model via **Ollama** (`http://localhost:11434/v1`) when encountering `429 Too Many Requests` or offline conditions.
* **Decoupled DOM Selectors:** Centralizes portal CSS/XPath locators in `src/browser/selectors.py` for rapid maintenance against portal UI changes.
* **Human-in-the-Loop (HITL) Browser Safety:** Uses Chromium persistent browser profiles (`launch_persistent_context`) to preserve authenticated sessions without repeated login/CAPTCHA friction, auto-fills cover letters, and intentionally pauses before employer knockout questions and final submission.
---
## Dashboard Preview

---
## Project Structure
```text
job-copilot-mcp/
├── .github/
│ └── workflows/
│ └── ci.yml # Matrix CI testing across Python 3.11–3.13
├── pyproject.toml # Dependencies (uv) and pytest configuration
├── README.md # Architecture and setup documentation
├── LICENSE # MIT License
├── assets/
│ └── dashboard.png # Streamlit application tracker preview
├── data/
│ └── profile_facts.example.json # Ground-truth candidate profile template
├── src/
│ ├── server.py # FastMCP Server exposing 6 pipeline tools
│ ├── dashboard.py # Streamlit pipeline tracker & draft inspector
│ ├── browser/
│ │ ├── session.py # Persistent Playwright browser context
│ │ ├── selectors.py # Centralized DOM locators & negative title filters
│ │ ├── scraper.py # JobStreet & Glints job extractor
│ │ └── prefill.py # HITL cover letter auto-filler
│ ├── intelligence/
│ │ ├── ranker.py # Local CPU cosine-similarity ranker
│ │ └── agent.py # Pydantic AI structured drafting & fallback router
│ └── storage/
│ └── db.py # SQLite schema and SHA-256 deduplication
└── tests/
├── test_pipeline.py # Unit tests for hashing, DB deduplication, and schemas
└── test_mcp_and_security.py # MCP stdio handshake & gitignore privacy guard tests
```
---
## Setup & Installation
### 1. Clone & Install Dependencies
Requires Python 3.11+ and [`uv`](https://docs.astral.sh/uv/):
```bash
git clone https://github.com/MLwithDyy/job-copilot-mcp.git
cd job-copilot-mcp
uv venv
# Windows PowerShell:
.\.venv\Scripts\Activate.ps1
uv sync --locked
uv run playwright install chromium
```
### 2. Configure Profile Ground Truth & Environment
1. Copy the profile template and fill in your verified CV facts (including `target_roles` used automatically by the scraper):
```bash
cp data/profile_facts.example.json data/profile_facts.json
```
2. *(Optional)* Create a `.env` file if you want to prioritize cloud free-tier LLMs before falling back to local Ollama:
```env
GEMINI_API_KEY=your_gemini_api_key
GROQ_API_KEY=your_groq_api_key
```
3. *(Optional)* Pull the local fallback model via [Ollama](https://ollama.com/):
```bash
ollama pull qwen2.5:3b
```
---
## Usage
### Step 1: Authenticate Portal Sessions Once
Launch the persistent browser context and manually log in to your JobStreet and Glints accounts (cookies are saved locally in `data/browser_profile/`):
```bash
uv run python -m src.browser.session login
```
### Step 2: Run the Discovery & Drafting Pipeline
```bash
# 1. Scrape latest postings based on target_roles in profile_facts.json
uv run python -m src.browser.scraper
# 2. Score all NEW jobs locally on CPU
uv run python -m src.intelligence.ranker
# 3. Generate tailored cover letters & screening Q&A for Top-K matches
uv run python -m src.intelligence.agent
```
### Step 3: Review & Apply (HITL) or Open Dashboard
* **Launch the Streamlit Pipeline Tracker:**
```bash
uv run streamlit run src/dashboard.py
```
* **Open a prepared job (`job_id=24`) in browser with cover letter prefilled:**
```bash
uv run python -m src.browser.prefill 24
```
### Step 4: Connect as an MCP Server
Add the following entry to your MCP client configuration (VS Code GitHub Copilot / Claude Desktop):
```json
{
"mcpServers": {
"job-copilot": {
"command": "uv",
"args": [
"--directory",
"/path/to/job-copilot-mcp",
"run",
"python",
"-m",
"src.server"
]
}
}
}
```
#### Exposed MCP Tools
| Tool | Description |
| :--- | :--- |
| `scrape_jobs` | Scrapes JobStreet & Glints postings by keyword into local SQLite. |
| `rank_jobs` | Computes CPU semantic similarity scores for all `NEW` listings. |
| `generate_application_kits` | Runs the Pydantic AI cascade router to draft cover letters & screening answers. |
| `list_jobs` | Lists stored jobs filtered by pipeline status (`NEW`, `RANKED`, `PREPARED`, `APPLIED`). |
| `get_job_kit` | Retrieves full job details, match reasoning, cover letter, and screening Q&A. |
| `update_job_status` | Updates the tracking status of a job posting. |
---
## Testing
```bash
uv run pytest -v
```
---
## Responsible Automation & Privacy
* **Human-in-the-Loop Enforcement:** Never performs unattended mass submissions; every application requires explicit human review of employer screening questions and final submission.
* **Conservative Rate Limiting:** Uses randomized human-like navigation delays and local deduplication to minimize portal requests.
* **Local-First Data Isolation:** Browser sessions (`data/browser_profile/`), SQLite records (`data/jobs.db`), API keys (`.env`), and personal CV facts (`data/profile_facts.json`) remain strictly local and excluded from version control.
---
## License
MIT License — Copyright (c) 2026 Mahdy Firmansyah.TDQS
Scored across 6 tools
Each tool maps to a clearly distinct stage or operation in the job-application workflow: scraping, ranking, generating kits, listing, reading details, and updating status. There is no meaningful overlap between tools, and an agent can confidently select the right one.
All tool names use a consistent snake_case verb_noun pattern, such as scrape_jobs, rank_jobs, list_jobs, get_job_kit, and update_job_status. The convention is predictable throughout.
Six tools are well-scoped for a job-copilot pipeline. Each tool corresponds to a necessary workflow step without redundant operations or excessive surface area.
The surface covers the core lifecycle from scraping through ranking, kit generation, inspection, and status updates. Minor gaps exist, such as no explicit delete/archive operation, search/filtering, or way to re-rank or regenerate a single job kit, but these are workaroundable.