MCP-Server-for-HR-Leave-Management-Assistant

Subitha-Murugesan/MCP-Server-for-HR-Leave-Management-Assistant

3.2

If you are the rightful owner of MCP-Server-for-HR-Leave-Management-Assistant 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 document provides a structured summary of an MCP server designed for an HR leave management assistant.

Tools
  1. get_leave_balance

    Retrieves the leave balance for a specified employee.

  2. apply_leave

    Applies leave for a specified employee on given dates.

  3. get_leave_history

    Fetches the leave history for a specified employee.

First MCP server for a real-life use caseβ€”an HR leave management assistant.

Overview:

  • Objective: Build an MCP server that powers an HR assistant chatbot to manage employee leave (check balance, apply, view history).

Architecture

  1. Database: leave database
  2. MCP Server: Python-based server using the mcp SDK.
  3. Client: Uses Claude Desktop (a generic MCP client) instead of a custom chatbot UI for simplicity.

Setup Instructions

Install Tools:
  • pip install mcp – MCP SDK.
  • pip install uv – UV is a Python project manager (like Poetry).
  • Claude Desktop – Download from official site based on OS.
Initialize MCP Project:
uv init my-first-mcp-server
cd my-first-mcp-server
Project Structure:
  • main.py: Your core MCP server code.
  • pyproject.toml: Metadata/config for UV.

Mock Database Example

mock_db = {
    "E001": {"balance": 18, "leaves_taken": ["2024-12-25", "2025-01-01"]},
    "E002": {"balance": 20, "leaves_taken": []}
}

MCP Server Code Design

  • Import FastMCP class.

  • Create tools:

    • get_leave_balance(employee_id)
    • apply_leave(employee_id, leave_dates)
    • get_leave_history(employee_id)
  • Add a resource tool for greetings.

Key Tip: Write detailed docstrings β€” they're essential for LLM-based tool selection.


Running the Server

uv mcp install main.py
  • Registers the server (e.g., leave-manager) in Claude's config.

Claude Desktop Integration

  • Open Claude Desktop.
  • Enable Developer Mode (important for seeing custom tools).
  • Go to File β†’ Settings β†’ Developer.
  • Edit config to verify the MCP server (leave-manager) is correctly registered.

Using the Assistant (Claude Desktop)

  • Ask: β€œHow many leaves does E001 have?”

    • Calls: get_leave_balance("E001")
  • Ask: β€œShow me leave dates for the same person.”

    • Maintains context (E001) β†’ calls: get_leave_history("E001")
  • Ask: β€œApply leave for E002 on 4th July.”

    • Calls: apply_leave("E002", ["2025-07-04"])

Claude interprets natural language, maps to the right tool, and fills parameters intelligently.


Troubleshooting Tip

If errors like type str occur:

pip install --upgrade typer

image

image