jobsearch-mcp-server / src /tools /profile_tool.py
daniielyan's picture
🔨 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
"""Profile tool for managing user profiles - profile.upsert endpoint."""
from typing import Dict, Any
from ..services import ProfileService
class ProfileTool:
"""Tool for managing user profiles."""
def __init__(self):
self.profile_service = ProfileService()
def upsert(self, user_id: str, profile_data: str) -> Dict[str, Any]:
"""
Store or update user profile.
This is the main profile.upsert endpoint that stores the user résumé,
skills, salary expectations, and career goals.
Args:
user_id: Unique identifier for the user
profile_data: JSON string containing user profile information
Expected format:
{
"resume": "Full resume text...",
"skills": ["Python", "JavaScript", "React", ...],
"salary_wish": "$80,000 - $120,000 annually",
"career_goals": "Looking to transition into senior developer role...",
"experience_level": "Mid-level", # Optional
"location": "Remote", # Optional
"education": "BS Computer Science", # Optional
"certifications": ["AWS Certified"] # Optional
}
Returns:
Dict with success status, message, and profile metadata
"""
return self.profile_service.upsert_profile(user_id, profile_data)
def get(self, user_id: str) -> Dict[str, Any]:
"""
Get user profile by ID.
Args:
user_id: Unique user identifier
Returns:
Dict with profile data or error message
"""
try:
profile = self.profile_service.get_profile(user_id)
if profile:
return {"success": True, "profile": profile.dict()}
else:
return {"success": False, "message": "Profile not found"}
except Exception as e:
return {"success": False, "message": f"Error retrieving profile: {str(e)}"}
def delete(self, user_id: str) -> Dict[str, Any]:
"""
Delete user profile.
Args:
user_id: Unique user identifier
Returns:
Dict with operation result
"""
try:
deleted = self.profile_service.delete_profile(user_id)
if deleted:
return {"success": True, "message": "Profile deleted successfully"}
else:
return {"success": False, "message": "Profile not found"}
except Exception as e:
return {"success": False, "message": f"Error deleting profile: {str(e)}"}
def list_all(self) -> Dict[str, Any]:
"""
List all user IDs with profiles.
Returns:
Dict with list of user IDs
"""
try:
user_ids = self.profile_service.list_profiles()
return {"success": True, "user_ids": user_ids, "count": len(user_ids)}
except Exception as e:
return {"success": False, "message": f"Error listing profiles: {str(e)}"}