Integrating-MCP-with-Claude-Desktop-on-Windows

Model Context Protocol (MCP) Integration Guide - Use this guide to connect your MCP-based Python service to Claude Desktop on Windows to handle leave management operations.

GitHub Stars

4

User Rating

Not Rated

Forks

0

Issues

0

Views

1

Favorites

0

README
Integrating MCP with Claude Desktop on Windows

Model Context Protocol (MCP) Integration Guide
Use this guide to connect your MCP-based Python service to Claude Desktop on Windows to handle leave management operations.


📚 Table of Contents

🚀 Features
  • ✅ Check employee leave balance
  • 📆 Apply for leave on specific dates
  • 📜 View leave history
  • 🙋 Personalized greeting functionality
  • 🔁 Cancel approved leaves
  • 👥 Add/Remove employee records
  • 🧮 Calculate total leaves taken

📁 Project Structure
mcp-server/
├── main.py                # MCP server logic for leave management
├── pyproject.toml         # Python dependencies for the MCP server
└── README.md              # Project documentation

📋 Prerequisites
  • Operating System: Windows 10 or later
  • Software:
    • Claude Desktop
    • Python 3.13+
    • uv (package manager)
    • mcp Python SDK

🛠️ Workflow
  1. Install Claude Desktop on Windows
  2. Start Claude Desktop in Developer Mode
  3. Install Python, uv, and mcp
  4. Initialize a project using uv init
  5. Add main.py to the project
  6. Run uv run mcp install main.py
  7. Verify and test integrated tools in Claude

🖥️ Install Claude Desktop
➤ Windows
  1. Download Installer:
  2. Install Claude Desktop:
    • Execute Claude-Setup-x64.exe and follow the installation prompts. Claude Desktop Setup Claude Desktop Setup Claude Desktop Setup
    • After installation, restart computer if required.
    • After restarting computer, Claude Desktop runs in the system tray. Claude In System Tray
  3. Enable Developer Mode:
    • Click the ☰ menu → HelpEnable Developer Mode
    • Developer tools will now be availablemenue and click on Enable Developer Mode Enable Developer Mode Enable Developer Mode Enable Developer Mode

🐍 Install Python
  1. Download Installer:
    • Visit Python Download and click Download for Windows to get python-3.13.4-amd64.exe. Python Download
  2. Run the Installer:
    • Execute Claude-Setup-x64.exe and follow the installation prompts. Python Setup Python Setup Python Setup
  3. Verify Installation:
    • Open PowerShell and run the command

      python --version
      

      Python Setup

    • Check pip installation

      pip --version
      

      Python Setup

    • Upgrade pip if required

      python -m pip install --upgrade pip
      

📦 Install uv Python package manager
  1. uv documentation:

  2. Install uv:

    pip install uv
    

    uv command uv command

  3. Verify Installation:

    • Open PowerShell and run the command
      uv --version
      
      uv command

🔧 Install MCP Python SDK
  1. mcp documentation:
  2. Install SDK and CLI
    pip install mcp
    pip install mcp[cli]
    
    mcp command mcp command mcp command
  3. Verify Installation:
    • Open PowerShell and run the command
    pip show mcp
    

    mcp command


📁 Create Project Using uv
  1. uv documentation
  2. Initialize uv project
    uv init mcp-server
    cd mcp-server
    
    uv project
  3. Copy main.py with leave management tools into project directory Sample MCP Server: main.py
    from mcp.server.fastmcp import FastMCP
    from typing import List
    from datetime import datetime
    
    # In-memory mock database
    # In-memory mock database with 5 sample employees
    employee_leaves = {
       "E1": {"balance": 18, "history": ["2024-12-25", "2025-01-01"]},
       "E2": {"balance": 20, "history": []},
       "E3": {"balance": 15, "history": ["2025-03-15", "2025-03-18"]},
       "E4": {"balance": 10, "history": ["2025-02-14", "2025-04-10", "2025-05-05"]},
       "E5": {"balance": 5, "history": ["2025-01-15", "2025-03-01", "2025-04-01", "2025-05-01", "2025-05-15"]}
    }
    
    # Create MCP server
    mcp = FastMCP("LeaveManager")
    
    # 1. Check Leave Balance
    @mcp.tool()
    def get_leave_balance(employee_id: str) -> str:
       """Check how many leave days are left for the employee"""
       data = employee_leaves.get(employee_id)
       if data:
          return f"{employee_id} has {data['balance']} leave days remaining."
       return "Employee ID not found."
    
    # 2. Apply for Leave
    @mcp.tool()
    def apply_leave(employee_id: str, leave_dates: List[str]) -> str:
       """Apply for leave on specified dates"""
       if employee_id not in employee_leaves:
          return "Employee ID not found."
    
       requested_days = len(leave_dates)
       available_balance = employee_leaves[employee_id]["balance"]
    
       if available_balance < requested_days:
          return f"Insufficient leave balance. Requested {requested_days}, but only {available_balance} available."
    
       employee_leaves[employee_id]["balance"] -= requested_days
       employee_leaves[employee_id]["history"].extend(leave_dates)
    
       return f"Leave applied for {requested_days} day(s). Remaining balance: {employee_leaves[employee_id]['balance']}."
    
    # 3. Get Leave History
    @mcp.tool()
    def get_leave_history(employee_id: str) -> str:
       """Retrieve leave history of an employee"""
       data = employee_leaves.get(employee_id)
       if data:
          history = ', '.join(data['history']) if data['history'] else "No leaves taken."
          return f"Leave history for {employee_id}: {history}"
       return "Employee ID not found."
    
    # 4. Cancel Leave
    @mcp.tool()
    def cancel_leave(employee_id: str, cancel_dates: List[str]) -> str:
       """Cancel previously applied leave dates"""
       if employee_id not in employee_leaves:
          return "Employee ID not found."
    
       history = employee_leaves[employee_id]["history"]
       cancelled = [date for date in cancel_dates if date in history]
    
       if not cancelled:
          return "None of the specified dates were found in leave history."
    
       for date in cancelled:
          history.remove(date)
          employee_leaves[employee_id]["balance"] += 1
    
       return f"Cancelled {len(cancelled)} day(s). New balance: {employee_leaves[employee_id]['balance']}."
    
    # 5. Check if a Date is on Leave
    @mcp.tool()
    def is_on_leave(employee_id: str, date: str) -> str:
       """Check if an employee is on leave for a specific date"""
       if employee_id not in employee_leaves:
          return "Employee ID not found."
       return "Yes" if date in employee_leaves[employee_id]["history"] else "No"
    
    # 6. Total Leaves Taken
    @mcp.tool()
    def total_leaves_taken(employee_id: str) -> str:
       """Get the total number of leave days taken by the employee"""
       if employee_id not in employee_leaves:
          return "Employee ID not found."
       return f"{employee_id} has taken {len(employee_leaves[employee_id]['history'])} leave day(s)."
    
    # 7. Set Leave Balance
    @mcp.tool()
    def set_leave_balance(employee_id: str, new_balance: int) -> str:
       """Set a new leave balance for an employee (admin use)"""
       if employee_id not in employee_leaves:
          return "Employee ID not found."
       employee_leaves[employee_id]["balance"] = new_balance
       return f"{employee_id}'s leave balance updated to {new_balance} day(s)."
    
    # 8. Add New Employee
    @mcp.tool()
    def add_employee(employee_id: str, initial_balance: int = 20) -> str:
       """Add a new employee to the leave management system"""
       if employee_id in employee_leaves:
          return "Employee ID already exists."
       employee_leaves[employee_id] = {"balance": initial_balance, "history": []}
       return f"Employee {employee_id} added with {initial_balance} leave day(s)."
    
    # 9. Remove Employee
    @mcp.tool()
    def remove_employee(employee_id: str) -> str:
       """Remove an employee from the system"""
       if employee_id not in employee_leaves:
          return "Employee ID not found."
       del employee_leaves[employee_id]
       return f"Employee {employee_id} removed from system."
    
    # 10. List All Employees
    @mcp.tool()
    def list_all_employees() -> str:
       """List all employee IDs currently in the system"""
       return "Employees: " + ", ".join(employee_leaves.keys())
    
    # Greeting Resource
    @mcp.resource("greeting://{name}")
    def get_greeting(name: str) -> str:
       """Get a personalized greeting"""
       return f"Hello, {name}! How can I assist you with leave management today?"
    
    if __name__ == "__main__":
       mcp.run()
    

▶️ Run the MCP service
  1. Run mcp server using main.py file:
    uv run mcp install main.py
    
    run mcp
  2. Verify the MCP tools:
    • This will configure and register tools with Claude
    • Restart Claude Desktop (Quit & Open) and verify in Tools Panel
    • You should see LeaveManager and all listed tools run mcp run mcp run mcp
  3. Verify the MCP server configuration: run mcp run mcp

🧪 Sample Questions to Ask the Leave Management System
  1. How many leave days are left for employee E1?
  2. What are the exact dates when E1 took leaves?
  3. Please apply for leave on July 4th for employee E2.
  4. How many leave days are remaining for E2 after that?
  5. List all the days E2 has taken off.
  6. Cancel E5’s leave on May 1st.
  7. Is E4 on leave on April 10th?"
  8. Add a new employee with ID E6 and 25 leave days.
  9. Update E3’s leave balance to 12 days.
  10. Show me the list of all employees in the system.

Sample answers

Author Information
Ahmad Awsaf uz zaman

Full Stack Developer (.NET/React)🔹Providing AI solutions🔹Developing Scalable Web & Desktop Applications🔹Expert in Business Applications

Finland

2

Followers

54

Repositories

0

Gists

2

Total Contributions

Top Contributors

Threads