Managing Your Warehouse with AI Agents: A Practical Guide to MCP in Flash Warehouse WMS
Flash Warehouse WMS is the first WMS in China to support the Model Context Protocol (MCP). Through the fwh CLI tool, AI Agents like Claude Code, Cursor, and Windsurf can query inventory, create bills, and manage workflows using natural language -- secured by a login-first, tenant-locked, write-opt-in safety model.
When AI Agents Meet Warehouse Management
The traditional workflow for warehouse management is rigid: open a browser, log into the backend, click through menus, fill out forms, submit. For high-frequency daily operations -- checking stock, creating purchase orders, approving receipts -- this process is repetitive and time-consuming.
What if a warehouse manager could simply tell an AI "check the stock for Coca-Cola" and get precise inventory data back in seconds? Flash Warehouse WMS makes this possible through its implementation of the Model Context Protocol (MCP). To our knowledge, Flash Warehouse is the first WMS in China to support MCP.
What Is MCP
MCP (Model Context Protocol) is an open protocol published by Anthropic in 2024 that defines a standardized communication layer between AI models and external tools. In practical terms, MCP lets an AI Agent call functions on external systems -- reading data, executing writes, and triggering workflows -- through a structured JSON-RPC interface over stdio.
The protocol works through three key mechanisms:
- Tool registration: The server declares its capabilities (tools) to the AI, each with a name, parameter schema, and description
- Standardized invocation: The AI calls these tools via JSON-RPC messages and receives structured return values
- stdio transport: Communication happens over standard input/output, making it a natural fit for CLI tool integration
AI clients with MCP support include Claude Code (Anthropic's official CLI), Cursor, and Windsurf.
fwh: Flash Warehouse's CLI and MCP Server
Flash Warehouse's MCP capability is provided by fwh (Flash Warehouse CLI), a static binary written in Go with zero runtime dependencies. It runs on macOS, Linux, and Windows.
fwh serves two roles simultaneously:
- Traditional CLI tool: 23 top-level commands for direct terminal-based warehouse operations
- MCP server: Started via
fwh mcp, exposing 44 read-only tools and 106 total tools (with writes enabled)
Configuring Claude Code
Add the following to ~/.claude/mcp.json:
{
"mcpServers": {
"flash-warehouse": {
"command": "/absolute/path/to/fwh",
"args": ["mcp"]
}
}
}
To enable write operations (creating bills, approvals, etc.), change args to:
"args": ["mcp", "--enable-writes"]
The configuration format is identical for Cursor and Windsurf.
Real Usage Scenarios
Once configured, you can operate your warehouse using natural language in an AI conversation:
- "Check stock for Coca-Cola" -- The AI calls
goods_listwith a fuzzy name search and returns matching products with quantities and warehouse locations - "What are today's sales?" -- The AI calls
bi_today_sales_revenueand returns revenue and order count - "Create a purchase receipt for 500 units of item 6954767410388" -- The AI calls
purchase_input_createwith the specified goods data - "Approve bill INQ-20260411-001" -- The AI calls
bill_auditto complete the approval workflow - "Which products are below their alert thresholds?" -- The AI calls
alert_overviewand returns an inventory alert summary
Every tool returns structured JSON data that the AI parses and presents in natural language.
The Three-Layer Safety Model
Letting an AI Agent operate on production data demands rigorous safety guarantees. fwh is built around three hard rules:
Layer 1: Login-First
The MCP server refuses to start without an active login session. You must run fwh login in your terminal first. This means an AI Agent can never log in on its own -- login credentials never appear in conversation history.
fwh login --user 13800138000
# Password: ********
# logged in as 13800138000 (user_id=1)
Layer 2: Tenant-Locked
binding_user_id is the core field that isolates multi-tenant data in Flash Warehouse WMS. In fwh, this value is captured once at login time from the server response and stored in an unexported Go struct field with a getter and no setter. No CLI flag, environment variable, or MCP tool argument can override it.
A source-level audit test (TestTenantLock_UserIDChokepoints) verifies on every build that session.UserID() is read in exactly 3 fixed locations within api/client.go. Any new read site outside these chokepoints fails the test.
Layer 3: Write Opt-In
fwh mcp registers only read-only tools (44) by default. Write tools (create, modify, delete, approve) are registered only when --enable-writes is explicitly passed. An unregistered tool does not exist at the MCP protocol level -- the AI cannot call a tool that is not in the server's registry.
Additionally, every write tool's description begins with WARNING: to ensure the AI's reasoning surfaces the destructive nature of the operation before execution. For example:
WARNING: APPROVE a bill. Commits inventory changes, cannot be undone.
Tool Coverage
The MCP tools in fwh cover the full functionality of Flash Warehouse's PC management frontend:
| Domain | Read Tools | Write Tools |
|---|---|---|
| Goods | goods_list, goods_get, goods_search_barcode, goods_amount | goods_create, goods_modify, goods_delete |
| Warehouse | warehouse_list | warehouse_create, warehouse_modify, warehouse_delete |
| Bills (16 types) | bill_list, bill_search, bill_info_by_type | Purchase/sales/transfer creation, audit, reject, conversions (23 tools) |
| BI Dashboard | bi_total_value, bi_today_sales_revenue, and 6 more | -- |
| Stock Alerts | alert_overview, alert_list, alert_count | alert_set_config, alert_refresh |
| Stocktake | check_task_list, check_task_items, and 3 more | check_task_create, check_task_finish, and 2 more |
| POS | -- | pos_sell |
| Staff and RBAC | staff_list, role_list, power_list, and 5 more | staff_create, role_bind, and 10 more |
Comparison with Traditional Workflows
Consider a common daily task: "check alerts and restock."
Traditional approach: Open browser -> Log in -> Navigate to inventory alerts -> Identify low-stock items -> Switch to purchase module -> Fill out purchase form -> Submit. Approximately 5-10 minutes.
MCP approach: In Claude Code, say "Check inventory alerts and create a purchase receipt for items below threshold." The AI sequentially calls alert_overview -> alert_list -> purchase_input_create. Approximately 30 seconds.
Getting Started
# 1. Build fwh (requires Go 1.22+)
cd flash_warehouse_cli
go build -o ./bin/fwh ./cmd/fwh
# 2. Log in
./bin/fwh login --user your-phone-number
# 3. Verify identity
./bin/fwh whoami
# 4. Configure Claude Code (edit ~/.claude/mcp.json)
# 5. Restart Claude Code and start managing your warehouse with natural language
Conclusion
The MCP protocol introduces a fundamentally new interaction paradigm for warehouse management. Flash Warehouse WMS, through fwh's 44 read-only and 106 total MCP tools, achieves complete feature parity with the PC frontend while maintaining production safety through its login-first, tenant-locked, write-opt-in security model.
Flash Warehouse WMS is completely free. Visit flashwarehouse.cn to learn more.