Spaces:
Runtime error
Runtime error
File size: 2,270 Bytes
4db8ed6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | from mcp.server.fastmcp import FastMCP
from processing import CVProcessor, JobProcessor, ApplicantEvaluator
mcp = FastMCP("AI Recruiter Agent")
cv_processor = CVProcessor(api_key=None)
job_processor = JobProcessor(api_key=None)
applicant_evaluator = ApplicantEvaluator(api_key=None)
# Tool implementation
@mcp.tool()
def evaluate_applicant(
applicant_cv_path: str,
job_description: str
) -> dict:
"""
Evaluate the applicant's CV against the job description.
Parameters
----------
applicant_cv_path: str
The path to the applicant's CV file.
job_description: str
The job description text.
Returns
-------
dict: Parsed CV and job description annotation with match score and reasoning.
"""
if not applicant_cv_path:
return {
"error": "Applicant CV path is empty."
}
if not job_description:
return {
"error": "Job description is empty."
}
response = {}
# Get CV annotation
cv_annotation = cv_processor.get_cv_content(applicant_cv_path)
response |= cv_annotation
# Get job annotation
job_annotation = job_processor.get_job_content(job_description)
response |= job_annotation
# Evaluate the applicant against the job description
evaluation = applicant_evaluator.evaluate_applicant(
cv_annotation["cv"]["annotation"],
job_annotation["job"]["annotation"]
)
response["evaluation"] = evaluation
return response
@mcp.tool()
def get_cv_annotation(cv_path: str) -> dict:
"""
"""
if not cv_path:
raise ValueError("CV path is empty.")
response = cv_processor.get_cv_content(cv_path)
return response
@mcp.tool()
def get_job_annotation(job_description: str) -> dict:
"""
Get job annotation from a text.
Parameters
----------
job_description: str
The job description text.
Returns
-------
dict: Parsed job description annotation.
"""
if not job_description:
raise ValueError("Job description is empty.")
response = job_processor.get_job_content(job_description)
return response
# Run the server
if __name__ == "__main__":
mcp.run() |