This project implements two Model Context Protocol (MCP) servers using the FastMCP framework:
- Sequential Thinking: A tool for structured problem-solving, ideal for tasks like supply chain management planning.
- Leave Manager: An AI tool for HR to manage employee leave tasks, interacting with a mock leave database.
The servers are launched concurrently using a main.py script and can be queried via Claude Desktop, which integrates with the MCP servers for sending API requests using the Model Context Protocol.
directory/
├── main.py # Launches both MCP servers
├── leave_manager.py # Leave Manager MCP server
├── sequential.py # Sequential Thinking MCP server
- Purpose: Facilitates structured, step-by-step problem-solving using the Model Context Protocol, ideal for planning complex tasks like supply chain management.
- Tool:
sequential_thinking- Breaks down problems into sequential thoughts.
- Supports revising thoughts, branching for alternative strategies, and dynamically adjusting the number of steps.
- Maintains context via a
sessionId.
- Use Case: Plan supply chains, projects, or any task requiring iterative reasoning.
- Port: Runs on
http://localhost:8001.
- Purpose: Assists HR with employee leave management using the Model Context Protocol.
- Tools:
get_leave_balance: Check an employee’s remaining leave days.apply_leave: Apply for leave on specific dates.get_leave_history: View an employee’s leave history.
- Resource:
greeting://{name}for personalized greetings. - Port: Runs on
http://localhost:8000.
- main.py: Uses
multiprocessingto run both servers concurrently on their respective ports.
- Python: Version 3.8 or higher.
- Claude Desktop: For sending MCP queries to the servers.
- uv: Package manager for installing dependencies.
- Operating System: Tested on Linux (e.g., Ubuntu).
Follow these steps to set up the project:
-
Install Claude Desktop:
- Download and install Claude Desktop from the official source.
- Ensure it’s configured to send API queries (e.g., via a query input field).
-
Install uv:
pip install uv
-
Create Project Directory:
uv init my-first-mcp-server cd my-first-mcp-server -
Add MCP CLI:
uv add "mcp[cli]" -
Add Server Code:
- Place the following files in
my-first-mcp-server/:main.py: Launcher for both servers.leave_manager.py: Leave Manager server code.sequential.py: Sequential Thinking server code.
- Ensure the code matches the provided implementations (see project repository or documentation).
- Place the following files in
-
Run the Servers:
- Instead of
uv run mcp install main.py(which may fail due to multiple servers), run:uv run python main.py
- Instead of
-
Restart Claude Desktop (if needed):
- Kill any running Claude Desktop instances via Task Manager (Windows) or
killall(Linux). - Restart Claude Desktop to ensure it recognizes the running servers.
- Kill any running Claude Desktop instances via Task Manager (Windows) or
Start both servers using:
cd ~/my-first-mcp-server
uv run python main.pyThis launches:
- Leave Manager on
http://localhost:8000. - Sequential Thinking on
http://localhost:8001.
Note: Keep the terminal open to maintain server uptime.
Use Claude Desktop’s query input field to send JSON queries to the servers via the Model Context Protocol. Below are examples for both servers, with a focus on supply chain management using the Sequential Thinking server.
- Endpoint:
http://localhost:8001/tool/sequential_thinking - Purpose: Plan a supply chain by breaking it into steps, revising plans, or exploring alternatives using MCP.
- Input: Paste JSON queries into Claude Desktop’s query field and submit.
Example: Plan a Supply Chain for a Smartwatch
-
Define Objective:
{ "thought": "Define objective: Plan a cost-efficient supply chain for a new smartwatch, ensuring global delivery within 5 months.", "nextThoughtNeeded": true, "thoughtNumber": 1, "totalThoughts": 8 }- Submit in Claude Desktop (e.g., paste into the query field and click “Send”).
- Copy the
sessionId(e.g.,123e4567-...) from the response.
-
Select Suppliers:
{ "sessionId": "<sessionId>", "thought": "Select suppliers: Source microchips from Supplier X (Taiwan), displays from Supplier Y (South Korea), batteries from Supplier Z (China).", "nextThoughtNeeded": true, "thoughtNumber": 2, "totalThoughts": 8 }- Replace
<sessionId>with the ID from Step 1.
- Replace
-
Plan Manufacturing:
{ "sessionId": "<sessionId>", "thought": "Plan manufacturing: Assemble smartwatches in Factory A (Vietnam) for low labor costs and supplier proximity.", "nextThoughtNeeded": true, "thoughtNumber": 3, "totalThoughts": 8 } -
Revise Supplier:
{ "sessionId": "<sessionId>", "thought": "Revised: Switch battery supplier to Supplier W (Japan) for better quality, despite 10% higher cost.", "nextThoughtNeeded": true, "thoughtNumber": 2, "totalThoughts": 8, "isRevision": true, "revisesThought": 2 } -
Explore Alternative Logistics (Branch):
{ "sessionId": "<sessionId>", "thought": "Alternative: Use air freight for distribution to Europe to ensure 7-day delivery.", "nextThoughtNeeded": true, "thoughtNumber": 4, "totalThoughts": 8, "branchFromThought": 3, "branchId": "air_freight" } -
Plan Inventory:
{ "sessionId": "<sessionId>", "thought": "Plan inventory: Maintain 20,000 units in regional warehouses (USA, Europe, Asia) with just-in-time delivery.", "nextThoughtNeeded": true, "thoughtNumber": 5, "totalThoughts": 8 } -
Mitigate Risks:
{ "sessionId": "<sessionId>", "thought": "Mitigate risks: Dual-source microchips and maintain 15% buffer inventory for supply disruptions.", "nextThoughtNeeded": true, "thoughtNumber": 6, "totalThoughts": 10, "needsMoreThoughts": true } -
Set Timeline:
{ "sessionId": "<sessionId>", "thought": "Set timeline: Supplier contracts by Month 1, manufacturing by Month 3, distribution by Month 4.", "nextThoughtNeeded": false, "thoughtNumber": 7, "totalThoughts": 10 }
Tips:
- Session ID: Save the
sessionIdafter the first query for use in subsequent queries. - Claude Desktop Format: If required, prepend the JSON with:
Example:
POST http://localhost:8001/tool/sequential_thinkingPOST http://localhost:8001/tool/sequential_thinking { "thought": "Define objective: Plan a cost-efficient supply chain for a new smartwatch, ensuring global delivery within 5 months.", "nextThoughtNeeded": true, "thoughtNumber": 1, "totalThoughts": 8 } - Customization: Modify
thoughtcontent for other supply chains (e.g., food, pharmaceuticals). Example for food:{ "thought": "Define objective: Plan a cold-chain supply chain for fresh produce, ensuring delivery within 48 hours.", "nextThoughtNeeded": true, "thoughtNumber": 1, "totalThoughts": 8 }
- Endpoint:
http://localhost:8000 - Purpose: Manage employee leaves via a mock database (
employee_leaves.json) using MCP. - Example Queries:
- Check leave balance:
Send to
{ "employee_id": "E001" }http://localhost:8000/tool/get_leave_balance. - Apply for leave:
Send to
{ "employee_id": "E001", "leave_dates": ["2025-06-01", "2025-06-02"] }http://localhost:8000/tool/apply_leave. - Get leave history:
Send to
{ "employee_id": "E001" }http://localhost:8000/tool/get_leave_history.
- Check leave balance:
- Persistence for Sequential Thinking: Add JSON or database storage to save supply chain plans, similar to
employee_leaves.json. - Claude Desktop Automation: Create a script to manage
sessionIdand streamline query input. - Visualization: Generate supply chain flowcharts or timelines from Sequential Thinking data.
- Metrics: Enhance
sequential_thinkingto calculate costs or lead times from thoughts.