|
|
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) |
|
|
|
|
|
|
|
|
@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 = {} |
|
|
|
|
|
cv_annotation = cv_processor.get_cv_content(applicant_cv_path) |
|
|
response |= cv_annotation |
|
|
|
|
|
job_annotation = job_processor.get_job_content(job_description) |
|
|
response |= job_annotation |
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
mcp.run() |