Provides a web interface for monitoring and controlling the FastMCP server with real-time updates and visualization of supply chain events and AI recommendations.
Supports generating markdown explanations for price changes in the e-commerce pricing agent extension scenario.
Used for data analysis in the supply chain tools, particularly for processing inventory and event data, with potential extensions for correlation calculations and statistical analysis.
FastMCP Supply Chain Optimizer
A custom implementation of FastMCP (Model Context Protocol) for real-time supply chain optimization using Gemini AI. This project demonstrates low-latency, multi-tool orchestration inspired by Anthropic's internal FastMCP system.
🎯 What This Demonstrates
- Custom FastMCP Implementation: Multi-tool calling at every LLM processing step (not sequential)
- Real-time Event Processing: Stream of supply chain events with live AI responses
- Intelligent Recommendations: AI-powered inventory optimization with actionable insights
- Live Web Interface: Real-time monitoring and control with beautiful UI
- Modular Tool Architecture: Easy to extend and modify for different use cases
🔧 About FastMCP vs MCP
FastMCP is not open source - it's Anthropic's internal implementation. This project is a minimal simulation of FastMCP's key innovation:
Core Difference: Parallel Tool Calling
- Standard MCP: Sequential alternating between 1 LLM call → 1 tool call → 1 LLM call
- FastMCP: Multiple tools called at every step of LLM processing
- This Implementation: Simulates FastMCP's approach with multiple tool execution per event
FastMCP isn't open source, so I built a minimal simulation of a low-latency multi-tool orchestration stack inspired by it — showcasing how an LLM agent can respond to real-time supply chain updates with actionable suggestions via routed tools.
🚀 Quick Start
1. Install Dependencies
2. Run the Application
3. Open Browser
Navigate to http://localhost:5000
4. Alternative: Use Local LLM
For data privacy and internal tool usage, you can replace Gemini API with your own local LLM using local-llm-api:
🎮 How to Use
- Start FastMCP Server: Click "Start FastMCP Server" to initialize the AI agent
- Start Event Stream: Click "Start Event Stream" to begin processing supply chain events
- Monitor Results: Watch the terminal output and action recommendations in real-time
- Stop When Done: Use the stop buttons to gracefully shut down
🛠️ Tools Implemented
Core Supply Chain Tools
1. get_inventory_status
- Purpose: Check current inventory levels across all warehouses
- Parameters:
product_id
(optional) - Returns: Complete inventory data for product or all products
- Example:
{"product_id": "P001"}
→ Returns warehouse A/B/C stock levels
2. update_inventory
- Purpose: Modify warehouse stock levels (add/subtract)
- Parameters:
product_id
,warehouse
,quantity
- Returns: Success status and inventory change details
- Example:
{"product_id": "P001", "warehouse": "warehouse_A", "quantity": -10}
3. calculate_transfer
- Purpose: Move inventory between warehouses
- Parameters:
product_id
,from_warehouse
,to_warehouse
,quantity
- Returns: Transfer execution details and new inventory levels
- Example:
{"product_id": "P001", "from_warehouse": "warehouse_B", "to_warehouse": "warehouse_A", "quantity": 20}
4. predict_stockout
- Purpose: Forecast when products will run out of stock
- Parameters:
product_id
,warehouse
- Returns: Risk level and predicted stockout timeline
- Example:
{"product_id": "P001", "warehouse": "warehouse_A"}
→ "HIGH risk, 1-2 days"
5. recommend_reorder
- Purpose: Suggest reorder quantities and suppliers
- Parameters:
product_id
,quantity
- Returns: Order details with cost calculations
- Example:
{"product_id": "P001", "quantity": 50}
→ "ORDER: 50 units from Supplier X at $5.50/unit"
How to Modify Tools
Adding New Tools
- Add function to
supply_chain_tools.py
:
- Register tool in
fastmcp_server.py
:
- Add handler in
handle_call_tool
:
📊 What Happens
Event Types Processed:
- DEMAND_SPIKE: Sudden increase in product demand
- DELAY: Supplier delivery delays
- COST_INCREASE: Price changes from suppliers
AI Actions:
- Inventory Transfers: Move stock between warehouses
- Reorder Recommendations: Suggest new orders with quantities
- Stockout Predictions: Forecast when products will run out
- Cost Optimization: Analyze supplier alternatives
🏗️ Architecture
📁 Project Structure
🎯 Example Workflow
- Event:
DEMAND_SPIKE for P001 - 40 units
- Analysis: AI checks current inventory across warehouses
- Prediction: Identifies potential stockout risk
- Action: Recommends transfer from warehouse B to A
- Execution: Updates inventory and logs the action
Sample Conversation Flow:
🔍 Monitoring
- Terminal Output: Real-time server logs and processing status
- Action Log: All AI recommendations and executed actions
- Status Indicators: Server and event stream status
- Event Progress: Current event being processed
🚀 Key Features
- Real-time Processing: Events processed as they arrive
- Intelligent Recommendations: AI-powered decision making
- Live Updates: Web interface updates in real-time
- Simple Setup: Minimal dependencies and configuration
- Extensible: Easy to add new tools and event types
- Privacy Options: Can use local LLM instead of cloud APIs
🎯 Use Cases
- Supply Chain Optimization: Real-time inventory management
- Demand Forecasting: AI-powered stock predictions
- Cost Optimization: Supplier and pricing analysis
- Risk Management: Stockout prevention and mitigation
🔄 Scenario Modifications
1. Real-Time Supply Chain Optimizer (Streaming Input + Live Agent Correction)
Current Implementation: ✅ Partially Implemented
- ✅ Streaming CSV events
- ✅ Real-time AI responses
- ✅ Basic inventory tools
- ❌ Fast correlation calculator
- ❌ Forecasting tool (ARIMA/exponential smoothing)
- ❌ Live agent correction
What Can Be Added Soon:
Example Conversation:
2. Interactive Survey Analyzer (Multi-Agent & Multi-Tool)
Modification Required:
Example Conversation:
3. Clinical Triage Assistant (Tool Selection with Tight Latency Loop)
Modification Required:
Example Conversation:
4. E-Commerce Pricing Agent (Fast Feedback Loop)
Modification Required:
Example Conversation:
🔧 Development
Adding New Tools
- Add function to
supply_chain_tools.py
- Register tool in
fastmcp_server.py
- Update system prompts as needed
Adding New Event Types
- Add event to
data/events.csv
- Update event processing logic in
fastmcp_server.py
- Test with the web interface
Switching to Local LLM
- Set up local-llm-api
- Modify
fastmcp_server.py
to use local API endpoint - Update prompts for local model compatibility
📝 Notes
- This is a demonstration using simulated data
- Inventory changes are saved back to CSV on server stop
- Uses Gemini API free tier (rate limits apply)
- Designed for simplicity and educational purposes
- FastMCP is not open source - this is a custom implementation
- Can be extended with local LLM for data privacy
🤝 Contributing
Feel free to extend this with:
- More sophisticated AI models
- Real database integration
- Additional supply chain tools
- Enhanced web interface features
- Parallel tool execution optimization
- Real-time data streaming
🔗 Related Projects
- local-llm-api: Local LLM API for data privacy
- MCP-RAG: Reference MCP implementation
Ready to optimize your supply chain with AI? Start the server and watch the magic happen! 🚀
This project demonstrates how to build a custom FastMCP-like system for real-time, multi-tool AI orchestration.
This server cannot be installed
A custom implementation for real-time supply chain optimization that enables parallel tool calling to provide intelligent inventory management recommendations and actionable insights in response to live supply chain events.
Related MCP Servers
- -securityFlicense-qualityEnables users to upload retail data, analyze trends, optimize inventory, and forecast sales using AI-powered insights, acting as a senior supply chain expert.Last updated -JavaScript
- AsecurityFlicenseAqualityProvides Material Requirements Planning (MRP) tools for calculating delivery schedules, determining order needs, and performing MRP period calculations based on inventory levels, forecasts, and order constraints.Last updated -1JavaScript
- AsecurityAlicenseAqualityA tool that enables users to interact with blockchain data to retrieve token total supply, chain IDs, and filtered RPC endpoints across different blockchain networks.Last updated -62JavaScriptMIT License
- -security-license-qualityAn MCP server that provides real-time access to Chainlink's decentralized on-chain price feeds, optimized for seamless integration into AI agents and autonomous systems.Last updated -JavaScriptMIT License