π¨ Implement core functionality for Job Search MCP Server, including user profile management, job search, cover letter generation, and Q&A response tools. Add configuration and service layers, and establish dependency management with uv. Introduce .gitignore and .python-version files for environment setup.
4fd18a2
"""Job search tool for finding and ranking relevant jobs - jobs.search endpoint.""" | |
from typing import Dict, Any | |
from ..services import JobSearchService | |
class JobSearchTool: | |
"""Tool for searching and ranking job opportunities.""" | |
def __init__(self): | |
self.job_search_service = JobSearchService() | |
def search( | |
self, user_id: str, query: str = "", location: str = "", job_type: str = "" | |
) -> Dict[str, Any]: | |
""" | |
Search for jobs and rank them by relevance to user profile. | |
This is the main jobs.search endpoint that pulls fresh job posts, | |
ranks them with GPU embeddings, and returns fit scores. | |
Args: | |
user_id: User identifier to get personalized results based on profile | |
query: Job search query/keywords (e.g., "Python developer", "Data scientist") | |
location: Preferred job location (e.g., "Remote", "New York", "San Francisco") | |
job_type: Type of job (e.g., "full-time", "part-time", "contract", "remote", "freelance") | |
Returns: | |
Dict with ranked job listings and fit scores: | |
{ | |
"success": True, | |
"jobs": [ | |
{ | |
"id": "job_123", | |
"title": "Senior Python Developer", | |
"company": "TechCorp", | |
"location": "Remote", | |
"description": "Job description...", | |
"requirements": "Skills required...", | |
"salary": "$80,000 - $120,000", | |
"url": "https://company.com/jobs/123", | |
"posted_date": "2024-01-15T10:30:00", | |
"job_type": "full-time", | |
"fit_score": 85, # Percentage match (0-100) | |
"match_reasons": ["Skills match: Python, Django", "Location preference match"] | |
} | |
], | |
"total_found": 10, | |
"search_params": { | |
"query": "Python developer", | |
"location": "Remote", | |
"job_type": "full-time" | |
}, | |
"user_profile": { | |
"skills_count": 15, | |
"location": "Remote" | |
} | |
} | |
""" | |
return self.job_search_service.search_jobs(user_id, query, location, job_type) | |
def get_job_details(self, job_id: str) -> Dict[str, Any]: | |
""" | |
Get detailed information about a specific job. | |
Args: | |
job_id: Unique job identifier | |
Returns: | |
Dict with detailed job information or error message | |
""" | |
# This would typically fetch from job cache or re-scrape | |
# For now, return a placeholder implementation | |
return { | |
"success": False, | |
"message": "Job details retrieval not implemented yet", | |
} | |
def get_search_suggestions(self, user_id: str) -> Dict[str, Any]: | |
""" | |
Get personalized job search suggestions based on user profile. | |
Args: | |
user_id: User identifier | |
Returns: | |
Dict with suggested search queries and parameters | |
""" | |
try: | |
from ..services import ProfileService | |
profile_service = ProfileService() | |
profile = profile_service.get_profile(user_id) | |
if not profile: | |
return {"success": False, "message": "User profile not found"} | |
# Generate suggestions based on skills and career goals | |
suggestions = [] | |
# Skill-based suggestions | |
top_skills = profile.skills[:5] # Top 5 skills | |
for skill in top_skills: | |
suggestions.append( | |
{ | |
"query": f"{skill} developer", | |
"reason": f"Based on your {skill} skills", | |
} | |
) | |
# Career goal-based suggestions | |
if "senior" in profile.career_goals.lower(): | |
suggestions.append( | |
{ | |
"query": "senior developer", | |
"reason": "Based on your career goals", | |
} | |
) | |
if "remote" in profile.career_goals.lower(): | |
suggestions.append( | |
{ | |
"location": "Remote", | |
"reason": "Based on your location preferences", | |
} | |
) | |
return { | |
"success": True, | |
"suggestions": suggestions[:10], # Limit to 10 suggestions | |
"profile_skills": profile.skills[:10], | |
} | |
except Exception as e: | |
return {"success": False, "message": f"Error getting suggestions: {str(e)}"} | |
def clear_job_cache(self) -> Dict[str, Any]: | |
""" | |
Clear the job search cache to force fresh results. | |
Returns: | |
Dict with operation result | |
""" | |
try: | |
self.job_search_service.jobs_cache = {} | |
self.job_search_service._save_cache() | |
# Also clear embedding index | |
self.job_search_service.embedding_service.clear_index() | |
return { | |
"success": True, | |
"message": "Job cache and embeddings cleared successfully", | |
} | |
except Exception as e: | |
return {"success": False, "message": f"Error clearing cache: {str(e)}"} | |