StockPilot
Provides inventory management capabilities for products, stock levels, transactions, and inbound/outbound operations, using PostgreSQL as the underlying data store.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@StockPilotCheck stock levels for SKU-1001 and alert if low"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
📦 StockPilot — AI-Powered Inventory Assistant with MCP
🎯 Mục đích dự án
StockPilot là dự án cá nhân thực hành và đào sâu chuẩn giao thức Model Context Protocol (MCP) của Anthropic thông qua bài toán thực tế: Quản lý kho hàng thông minh (Inventory Management).
🔑 Điểm nhấn kỹ thuật:
Chuẩn MCP: Tách biệt rõ ràng giữa Chat Host, Client, và FastMCP Server.
Human-in-the-loop (HITL): Tự động phát hiện và yêu cầu người dùng xác nhận (
PENDING$\rightarrow$CONFIRMED) trước khi thực thi các thao tác nhạy cảm (nhập, xuất kho, tạo sản phẩm).ACID & Idempotency: Thao tác Database an toàn qua
asyncpgconnection pool và chống trùng lặp giao dịch.Docker Compose: Khởi chạy đồng bộ FastAPI, PostgreSQL 17 và pgAdmin chỉ với 1 lệnh.
Related MCP server: MCP Inventory Manager
🏗️ Kiến trúc hệ thống
flowchart TD
User([👤 Người dùng]) <-->|REST API / Chat| Host[🌐 Chat Host / FastAPI]
subgraph ChatHostApp ["Chat Host (Orchestrator)"]
Host <--> Agent["🤖 ReAct Agent Loop"]
Agent <--> LLM["🧠 LLM (Groq / OpenAI)"]
Agent <--> HITL["🛡️ Human-in-the-loop Gate"]
Agent <--> MCPClient["🔌 MCP Client"]
end
subgraph MCPServerApp ["MCP Server (StockPilot)"]
MCPClient <==>|MCP Protocol| MCPServer["⚙️ FastMCP Server"]
MCPServer --> ReadTools["📖 Read Tools (find, get_stock, alert)"]
MCPServer --> WriteTools["✍️ Write Tools (receive, issue, add)"]
ReadTools & WriteTools --> DBModule["💾 DB Layer (asyncpg)"]
end
DBModule <==>|Connection Pool| Postgres[(🐘 PostgreSQL)]🛠️ Danh mục MCP Tools
Tool | Loại | Tham số chính | Mô tả |
| 📖 Read |
| Tìm kiếm sản phẩm theo tên hoặc SKU (mờ |
| 📖 Read |
| Lấy chi tiết tồn kho theo ID sản phẩm. |
| 📖 Read |
| Cảnh báo danh sách sản phẩm sắp hết hàng. |
| 📖 Read |
| Lấy lịch sử biến động kho gần nhất. |
| ✍️ Write |
| ⚠️ Thêm mặt hàng mới vào danh mục (cần xác nhận). |
| ✍️ Write |
| ⚠️ Nhập kho và lưu log giao dịch (cần xác nhận). |
| ✍️ Write |
| ⚠️ Xuất kho sau khi kiểm tra số lượng tồn (cần xác nhận). |
📁 Cấu trúc thư mục
stockpilot/
├── 📄 compose.yaml # Docker Compose cho PostgreSQL & pgAdmin
├── 📄 Dockerfile # Dockerfile cho Chat Host
├── 📄 requirements.txt # Dependencies
├── 📄 .env.example # Mẫu cấu hình biến môi trường
├── 📁 db/init.sql # Schema Database & Index
├── 📁 scripts/seed_products.py # Nạp dữ liệu mẫu
├── 📁 src/
│ ├── 📁 mcp_server/ # FastMCP Server, Database & Tools
│ └── 📁 chat_host/ # FastAPI Host, ReAct Agent & HITL Confirmation
└── 📁 tests/ # Test suite (Unit, Integration)🚦 Hướng dẫn cài đặt & Chạy nhanh
1. Chuẩn bị môi trường & Database
# Clone repo & cấu hình .env
git clone https://github.com/tutran27/stockpilot-mcp.git
cd stockpilot-mcp
cp .env.example .env # Điền GROQ_API_KEY hoặc OPENAI_API_KEY
# Khởi động PostgreSQL qua Docker
docker compose up -d(pgAdmin xem DB tại http://localhost:5050 — admin@admin.com / admin).
2. Cài đặt thư viện & Nạp dữ liệu mẫu
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
# Nạp dữ liệu sản phẩm mẫu vào DB
python scripts/seed_products.py3. Khởi chạy & Truy cập hệ thống
docker compose up -d🌐 Giao diện Web Chat (Streamlit): http://localhost:8501
⚡ API Swagger Docs (FastAPI): http://localhost:8000/docs
🐘 pgAdmin Web UI: http://localhost:5050 (Email:
admin@admin.com| Pass:admin)
🧪 Luồng trải nghiệm Human-in-the-loop
Bước 1: Gửi yêu cầu nhập hàng qua POST /api/chat
{
"message": "Tôi muốn nhập 10 cái Laptop Dell XPS 13 từ NCC FPT, số HĐ: FPT-1234."
}👉 Agent phản hồi và sinh mã xác nhận:
⚠️ Thao tác `receive_stock` cần bạn xác nhận trước khi thực hiện.
Mã hành động: `e70ce90c-575f-4462-81ae-672a29b26fdc`
Chi tiết: {'product_id': '...', 'quantity': 10, 'partner': 'FPT'}Bước 2: Xác nhận thực thi qua POST /api/chat/confirm
{
"action_id": "e70ce90c-575f-4462-81ae-672a29b26fdc"
}✅ Thao tác được chuyển trạng thái CONFIRMED và ghi nhận thành công vào Database!
📄 License
Phân phối dưới giấy phép MIT License.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Hosted MCP for e-commerce: live product catalog, stock, and pricing for AI agents.
Let AI agents query data and act across all your business apps via MCP.
Pay-per-use tool marketplace for AI agents. Search, price-check, and call APIs via MCP.
Search & install 6,500+ AI agent skills from skills-hub.ai inside any MCP tool.
Related MCP Servers
FlicenseNot gradedqualityCmaintenanceEnables interaction with ScanPower's inventory and shipment management system through a secure MCP interface. Supports retrieving inventory data, creating shipment plans, and managing logistics operations through natural language.2- FlicenseNot gradedqualityDmaintenanceAn AI-powered inventory management system with a natural language interface, enabling CRUD operations on items and suppliers, stock transfers, and supplier management via MCP tools.
- AlicenseNot gradedqualityBmaintenanceUnifies inventory data from four sources (Jikeyun, Supor factory, WeChat Excel, RPA) with timestamps, and exposes MCP tools for AI agents to query stock levels.18ISC
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to view SAP production orders, answer questions, and post goods receipts by integrating with SAP backend through MCP tools.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/tutran27/stockpilot-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server