休假管理系统

一个基于FastMCP(模型上下文协议)构建的最小化、支持AI的休假管理系统,可直接为AI客户端(如Claude Desktop)提供后端业务逻辑,无需REST API或提示技巧。

  • by git-akki
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 git-akki/leave-manager-mcp

使用说明

使用MCP(模型上下文协议)的休假管理系统

A. 最小的、支持人工智能的休假管理系统 使用 FastMCP(模型上下文协议).
此项目演示了如何公开后端业务逻辑 直接面向AI客户端 (如Claude Desktop),没有REST API或提示黑客。


✨ 为什么这个项目存在

我们大多数人:

  • 手表卷轴
  • 保存YouTube教程
  • 为博客添加书签

…但永远不要执行。

这个项目是在我搜索时开始的:

“员工管理系统的快速api后端”

并找到了这篇Medium文章:
👉 用FastAPI和FastMCP构建休假管理系统 由Madhuri撰写

我没有读它,而是问:

“为什么不自己建造呢?”

这种好奇心变成了执行力,而这个回购就是结果。


🧠 这个项目展示了什么

  • 什么 MCP(模型上下文协议) 实际上看起来像是在实践中
  • AI模型如何 发现并调用后端函数
  • 如何构建一个 AI第一后端,不仅仅是API
  • Claude Desktop如何与实际应用程序逻辑交互

⚙️ 特性

MCP工具

  • get_leave_balance(employee_id)
  • apply_leave(employee_id, leave_dates)
  • get_leave_history(employee_id)

MCP资源

  • greeting://{name}

系统详情

  • 内存模拟数据库
  • 兼容Claude Desktop(基于stdio的MCP服务器)
  • 没有REST API,没有前端——纯MCP

🏗️ 项目结构

离职经理mcp/ ├── main.py#MCP服务器(兼容克劳德) ├── requirements.txt#依赖关系 └── README.md

YAML 复制代码


▶️ 工作原理(大图)

克劳德桌面版 ↓ 模型上下文协议(MCP) ↓ FastMCP服务器(Python) ↓ 业务逻辑(休假管理)

YAML 复制代码

克劳德 发现工具,理解它们的模式,并直接调用它们。


🚀 入门指南

1.️⃣ 创建并激活虚拟环境

python -m venv .venv
source .venv/bin/activate     # Windows: .venv\Scripts\activate
2️⃣ Install dependencies
bash
Copy code
pip install -r requirements.txt
3️⃣ Run MCP server (manual testing)
bash
Copy code
python main.py
⚠️ For Claude Desktop, Claude itself starts this process via MCP configuration.

🤖 Claude Desktop Configuration (Windows Example)
json
Copy code
{
  "mcpServers": {
    "LeaveManagerPython": {
      "command": "C:\\Users\\<USERNAME>\\path\\to\\.venv\\Scripts\\python.exe",
      "args": [
        "C:\\Users\\<USERNAME>\\path\\to\\main.py"
      ],
      "cwd": "C:\\Users\\<USERNAME>\\path\\to\\leave-manager-mcp"
    }
  }
}
🔁 Restart Claude Desktop after updating the config.

🧪 Example Prompts (Claude)
rust
Copy code
Check leave balance for employee E001
Apply leave for employee E002 on 2025-04-17 and 2025-04-18
Show leave history of E001
Use greeting://Akash
Claude will automatically call the correct MCP tools.

⚠️ Key Learnings
MCP requires a pure stdio process

FastAPI & MCP must be separated

Claude Desktop caches MCP configs aggressively

Execution teaches more than tutorials

🔮 Future Improvements
Add FastAPI (dual-mode: REST + MCP)

Persist data using PostgreSQL

Add authentication & roles

Build AI agents on top of MCP tools

Production deployment

📌 Final Thought
Reading tutorials gives comfort.
Watching reels gives motivation.

But execution gives clarity.

This repo exists because of curiosity — not perfection.

yaml
Copy code

---

## ✅ Why This README Works

✔ Clean headings  
✔ Clear story hook  
✔ Explains MCP simply  
✔ Recruiter / dev friendly  
✔ Medium-article ready  
✔ No fluff, no noise  

---

### 🚀 Next (Recommended)
Now that GitHub is ready, next we should:
1. **Write the Medium article using this repo**
2. **Add FastAPI back cleanly (dual-mode)**
3. **Create an AI agent on top of this**

Just say **which one** and we continue 🔥```