Leave Management MCP Server
README.md
# Leave Management MCP Server
An AI-powered Leave Management System built using the **Model Context Protocol (MCP)**.
This project demonstrates how a Large Language Model (LLM) can discover and invoke MCP tools to perform business operations such as checking leave balances, applying for leave, and retrieving leave history through natural language.
---
## Features
- Built using the FastMCP framework
- Streamlit-based AI client
- Gemini API for intelligent tool selection
- SQLite database for persistent data storage
- Dynamic MCP tool discovery using `list_tools()`
- Natural language interface
---
## Project Structure
```text
.
├── app.py # Streamlit AI Client
├── main.py # MCP Server
├── llm.py # Gemini Integration
├── database.py # SQLite Helper Functions
├── init_db.py # Database Initialization
├── pyproject.toml
├── uv.lock
├── .python-version
├── .env.example
├── README.md
└── .gitignore
```
---
## Available MCP Tools
- `get_leave_balance`
- `apply_leave`
- `get_leave_history`
---
## Tech Stack
- Python
- Model Context Protocol (MCP)
- FastMCP
- Streamlit
- Gemini API
- SQLite
- uv
---
## Installation
### 1. Clone the repository
```bash
git clone https://github.com/ratankumarthakur/leave-management-mcp
cd leave-management-mcp
```
### 2. Install dependencies
```bash
uv sync
```
### 3. Configure the environment
Create a `.env` file in the project root.
```text
GEMINI_API_KEY=YOUR_API_KEY
```
### 4. Initialize the database
```bash
python init_db.py
```
### 5. Run the application
```bash
streamlit run app.py
```
---
## Example Queries
Try asking:
- Show leave balance for E001
- Apply leave for E002 on 2026-08-10
- Show leave history for E001
- Apply leave for E001 on 15 September 2026
---
## Architecture
```text
User
│
▼
Streamlit Client
│
▼
Gemini LLM
│
▼
MCP Client
│
▼
MCP Server
│
▼
SQLite Database
```
---
## How It Works
1. The user enters a natural language query.
2. The Gemini model selects the appropriate MCP tool.
3. The Streamlit client invokes the selected MCP tool.
4. The MCP server executes the requested operation.
5. Data is read from or written to the SQLite database.
6. The result is returned to the client and displayed to the user.
---
## Learning Objective
This project was built to understand the fundamentals of the Model Context Protocol (MCP), including:
- Building an MCP server
- Creating an MCP client
- Dynamic tool discovery
- LLM-driven tool invocation
- Database-backed tool execution
- Developing an AI-powered application using Streamlit
---
## Screenshot
<img width="1919" height="868" alt="Screenshot 2026-08-03 232719" src="https://github.com/user-attachments/assets/12b8c9b2-6d64-415a-8618-64396af69d61" />
TDQS
C2.1/5.0
Scored across 3 tools
Disambiguation5/5
Each tool covers a distinct aspect: balance inquiry, leave application, and history lookup. There is no overlap or ambiguity between them.
Naming Consistency5/5
All tool names follow the consistent verb_noun pattern: get_leave_balance, apply_leave, get_leave_history. The naming is clear and predictable.
Tool Count5/5
Three tools are well-scoped for a simple leave management server, covering the core employee-facing actions without unnecessary bloat.
Completeness4/5
Core leave lifecycle is covered (check balance, apply, view history), but missing operations like cancel or update leave applications are notable gaps.
Maintenance
ActivitySlowing
ResponsivenessNo issues