FastAPI-MCP-Server

saiprasaad2002/FastAPI-MCP-Server

3.2

If you are the rightful owner of FastAPI-MCP-Server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This project is a sophisticated, agentic workflow orchestration system built using the Model Context Protocol (MCP) on top of FastAPI.

Tools
  1. extract_text

    Extracts content from resumes.

  2. generate_summary

    Summarizes job descriptions using an LLM.

  3. calculate_score

    Computes semantic similarity between resumes and job summaries.

  4. extract_email

    Identifies email addresses via regex.

  5. send_email

    Manages email notifications.

  6. send_interview_invitation

    Sends interview invitations.

  7. check_existing_application

    Detects duplicates in the database.

  8. validate_resume

    Ensures uploaded files are valid resumes.

Custom FastAPI MCP Server - Job Application Processing Agent

Python FastAPI

Overview

This project is a sophisticated, agentic workflow orchestration system built using the Model Context Protocol (MCP) on top of FastAPI. This application automates the processing of job applications by integrating Mistral:7b from Ollama, all-MiniLM-L6-v2 for vector embeddings, calculates cosine similarity, and email notification workflows (using Resend). It leverages multiple specialized agents (tools) to extract resume content, generate job summaries, calculate semantic similarity scores, and dispatch interview invitations—all orchestrated through a single custom MCP server and utilises SQLite for persistent storage handled with Object-Relational Mapping. This application is designed for scalability, extensibility, and robustness, making it suitable for HR automation, talent acquisition pipelines, and intelligent document processing use cases.


Features

  • Resume Extraction: Extracts text from PDF and DOCX files using PyMuPDF and python-docx.
  • Job Description Summarization: Generates concise job requirement summaries using the mistral:7b model from ollama.
  • Semantic Scoring: Computes a cosine similarity score (0-100) between resumes and job summaries using sentence-transformers (all-MiniLM-L6-v2).
  • Email Automation: Sends interview invitations via the resend API for candidates scoring 70% or higher.
  • Duplicate Detection: Identifies existing applications by email, resume content, and job description to prevent redundant processing.
  • Resume Validation: Validates uploaded documents as resumes using LLM-based analysis.
  • Error Logging: Persists detailed error logs in a SQLite database for debugging and auditing.
  • Custom MCP Server: Orchestrates the agent workflows via a custom MCP server, exposing tools as reusable GET endpoints.

Architecture

The application follows a modular, agent-based architecture orchestrated through the MCP framework:

  1. FastAPI: Serves as the HTTP server, handling requests and responses with asynchronous endpoints.
  2. MCP Server: Extends FastAPI with a /mcp mount path, providing a unified interface for agentic tools:
    • extract_text: Extracts content from resumes.
    • generate_summary: Summarizes job descriptions using an LLM.
    • calculate_score: Computes semantic similarity between resumes and job summaries.
    • extract_email: Identifies email addresses via regex.
    • send_email & send_interview_invitation: Manages email notifications.
    • check_existing_application: Detects duplicates in the database.
    • validate_resume: Ensures uploaded files are valid resumes.
  3. Database Layer: Uses SQLAlchemy with SQLite to store application data (applications) and error logs (error_logs).
  4. File Handling: Persists uploaded resumes in an uploads/ directory.

Workflow

  1. A job application is submitted via the /job-application endpoint with a resume file and job description.
  2. The MCP server orchestrates the following steps:
    • Validates and extracts resume content.
    • Checks for existing applications.
    • Summarizes the job description.
    • Scores the resume against the summary.
    • Sends an interview invitation if the score exceeds 70%.
  3. Results are saved to the database, and errors are logged as needed.

Technical Stack

ComponentTechnologyPurpose
FrameworkFastAPIAsynchronous API server
MCPfastapi-mcpStandardized Multi-agent workflow orchestration
DatabaseSQLAlchemy, SQLitePersistent storage
NLPsentence-transformersSemantic similarity scoring
LLMollama (mistral:7b)Job description summarization
EmailresendNotification delivery
File ProcessingPyMuPDF, python-docxResume text extraction
Dependency Mgmtuv, pyproject.tomlPackage management
RuntimePython 3.10+Core language runtime

API Endpoints

POST /job-application

Processes a job application by analyzing a resume and job description.

  • Request:
    • file: Resume file (PDF or DOCX)
    • job_description: Text of the job description
  • Response:
    {
      "email": "candidate@example.com",
      "score": 85.5,
      "email_status": true,
      "message": "Candidate has passed the eligibility for interview and invitation sent successfully",
      "job_description": "Full-stack developer with Python and AWS experience..."
    }
    

Errors

The API may return the following HTTP error codes:

  • 400: Invalid file format or missing email
  • 422: Text extraction or processing errors
  • 500: Database or server errors

MCP Tools

Accessible under the /mcp path, these tools are orchestrated internally by the MCP server but can be invoked individually for testing or extension:

  • /mcp/extract_text
  • /mcp/generate_summary
  • /mcp/calculate_score
  • /mcp/extract_email
  • /mcp/send_email
  • /mcp/send_interview_invitation
  • /mcp/check_existing_application
  • /mcp/validate_resume

Database Schema

applications

ColumnTypeDescription
idIntegerPrimary key
emailStringCandidate email
resume_contentTextExtracted resume text
job_descriptionTextJob description text
scoreFloatSimilarity score (0-100)
email_statusBooleanEmail sent status
created_atDateTimeTimestamp of creation

error_logs

ColumnTypeDescription
idIntegerPrimary key
error_messageTextDetailed error description
created_atDateTimeTimestamp of error occurrence

Dependencies

  • fastapi: API framework
  • fastapi-mcp: MCP orchestration
  • sentence-transformers: Semantic embeddings
  • ollama: LLM integration
  • resend: Email API
  • sqlalchemy: ORM for database
  • PyMuPDF, python-docx: File parsing

Usage Notes

  • Ensure the RESEND_API_KEY environment variable is set for email functionality.
  • The uploads/ directory must exist and be writable for resume storage.
  • The SQLite database (applications.db) is initialized automatically via init_db() on startup.

Resend API Note

This application currently uses a trial version of the Resend API without verifying or adding a domain. In this mode, email functionality is limited to specific test scenarios (e.g., sending to verified test emails). To extend this application for sending emails to all candidates, you must add and verify a domain in the Resend dashboard. Refer to the Resend documentation for instructions on domain verification.