Subitha-Murugesan/MCP-Server-for-HR-Leave-Management-Assistant
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.
get_leave_balance
Retrieves the leave balance for a specified employee.
apply_leave
Applies leave for a specified employee on given dates.
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
- Database: leave database
- MCP Server: Python-based server using the
mcp
SDK. - 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")
- Calls:
-
Ask: βShow me leave dates for the same person.β
- Maintains context (
E001
) β calls:get_leave_history("E001")
- Maintains context (
-
Ask: βApply leave for E002 on 4th July.β
- Calls:
apply_leave("E002", ["2025-07-04"])
- Calls:
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