MCP (Model Context Protocol) is a custom implementation in this codebase. The system does not use the official MCP Python SDK but instead implements a custom MCP-compatible system tailored specifically for the Warehouse Operational Assistant.
-
No Official Package in Dependencies
requirements.txtdoes not includemcpormodel-context-protocol- All MCP code is in
src/api/services/mcp/(custom implementation)
-
Custom Implementation Files
src/api/services/mcp/server.py- Custom MCP serversrc/api/services/mcp/client.py- Custom MCP clientsrc/api/services/mcp/base.py- Custom base classessrc/api/services/mcp/tool_discovery.py- Custom tool discoverysrc/api/services/mcp/tool_binding.py- Custom tool bindingsrc/api/services/mcp/tool_routing.py- Custom tool routingsrc/api/services/mcp/tool_validation.py- Custom validationsrc/api/services/mcp/adapters/- Custom adapter implementations
-
Protocol Compliance
- Implements MCP protocol specification (tools/list, tools/call, resources/list, etc.)
- Follows MCP message format (JSON-RPC 2.0)
- Compatible with MCP specification but custom-built
Custom Features:
- Domain-Specific Tool Categories: Equipment, Operations, Safety, Forecasting, Document processing
- Warehouse-Specific Adapters: ERP, WMS, IoT, RFID, Time Attendance adapters built for warehouse operations
- Optimized Tool Discovery: Fast discovery for warehouse-specific tools (equipment status, inventory queries, safety procedures)
- Custom Routing Logic: Intelligent routing based on warehouse query patterns
Example:
# Custom warehouse-specific tool categories
class ToolCategory(Enum):
DATA_ACCESS = "data_access"
DATA_MODIFICATION = "data_modification"
ANALYSIS = "analysis"
REPORTING = "reporting"
INTEGRATION = "integration"
UTILITY = "utility"
SAFETY = "safety" # Warehouse-specific
EQUIPMENT = "equipment" # Warehouse-specific
OPERATIONS = "operations" # Warehouse-specific
FORECASTING = "forecasting" # Warehouse-specificCustom Integration:
- Direct integration with LangGraph workflow orchestration
- Custom state management (
MCPWarehouseState) for warehouse workflows - Seamless agent-to-agent communication via MCP
- Optimized for multi-agent warehouse operations
Example:
# Custom state for warehouse operations
class MCPWarehouseState(TypedDict):
messages: Annotated[List[BaseMessage], "Chat messages"]
user_intent: Optional[str]
routing_decision: Optional[str]
agent_responses: Dict[str, str]
mcp_results: Optional[Any] # MCP execution results
tool_execution_plan: Optional[List[Dict[str, Any]]]
available_tools: Optional[List[Dict[str, Any]]]Custom Capabilities:
- Intelligent Tool Routing: Query-based tool selection with confidence scoring
- Tool Binding: Dynamic binding of tools to agents based on context
- Parameter Validation: Warehouse-specific parameter validation (SKU formats, equipment IDs, etc.)
- Error Handling: Custom error handling for warehouse operations (equipment unavailable, inventory errors, etc.)
Example:
# Custom tool routing with warehouse context
class ToolRoutingService:
async def route_tool(
self,
query: str,
context: RoutingContext
) -> RoutingDecision:
# Warehouse-specific routing logic
if "equipment" in query.lower():
return self._route_to_equipment_tools(query, context)
elif "inventory" in query.lower():
return self._route_to_inventory_tools(query, context)
# ... warehouse-specific routingCustom Optimizations:
- In-Memory Tool Registry: Fast tool lookup without external dependencies
- Caching: Tool discovery results cached for warehouse query patterns
- Async/Await: Fully async implementation optimized for FastAPI
- Connection Pooling: Custom connection management for warehouse adapters
Example:
# Custom in-memory tool registry
class ToolDiscoveryService:
def __init__(self):
self.tool_cache: Dict[str, List[DiscoveredTool]] = {}
self.discovery_sources: Dict[str, Any] = {}
async def discover_tools(self, query: str) -> List[DiscoveredTool]:
# Fast in-memory lookup
if query in self.tool_cache:
return self.tool_cache[query]
# ... custom discovery logicCustom Adapters:
- Equipment Adapter: Equipment status, assignments, maintenance, telemetry
- Operations Adapter: Task management, workforce coordination
- Safety Adapter: Incident logging, safety procedures, compliance
- Forecasting Adapter: Demand forecasting, reorder recommendations
- ERP/WMS/IoT Adapters: Warehouse system integrations
Example:
# Custom warehouse adapter
class EquipmentMCPAdapter(MCPAdapter):
async def initialize(self) -> bool:
# Warehouse-specific initialization
self.register_tool("get_equipment_status", ...)
self.register_tool("assign_equipment", ...)
self.register_tool("get_maintenance_schedule", ...)
# ... warehouse-specific toolsBenefits:
- Rapid Development: Add warehouse-specific features without waiting for upstream updates
- Custom Error Handling: Warehouse-specific error messages and recovery
- Integration Control: Direct control over how MCP integrates with warehouse systems
- Testing: Custom test suites for warehouse-specific scenarios
Benefits:
- Smaller Footprint: No external MCP SDK dependency
- Version Control: No dependency on external package updates
- Security: Full control over security implementation
- Compatibility: No compatibility issues with other dependencies
| Aspect | Custom Implementation | Official MCP SDK |
|---|---|---|
| Warehouse-Specific Features | ✅ Built-in | ❌ Generic |
| LangGraph Integration | ✅ Tight integration | |
| Performance | ✅ Optimized for warehouse queries | |
| Tool Routing | ✅ Warehouse-specific logic | |
| Adapters | ✅ Warehouse adapters included | ❌ Need to build |
| Dependencies | ✅ Minimal | |
| Control | ✅ Full control | |
| Maintenance | ✅ Community maintained | |
| Documentation | ✅ Official docs | |
| Standards Compliance | ✅ MCP-compliant | ✅ MCP-compliant |
- ✅ You need domain-specific optimizations (warehouse operations)
- ✅ You require tight integration with existing systems (LangGraph, FastAPI)
- ✅ You need custom tool routing and discovery logic
- ✅ You want full control over the implementation
- ✅ You have specific performance requirements
- ✅ You need warehouse-specific adapters and tools
- ✅ You want a standardized, community-maintained solution
- ✅ You need compatibility with other MCP implementations
- ✅ You prefer less maintenance overhead
- ✅ You're building a generic MCP server/client
- ✅ You want official documentation and support
- MCP Server (tool registration, discovery, execution)
- MCP Client (tool discovery, execution, resource access)
- Tool Discovery Service (automatic tool discovery from adapters)
- Tool Binding Service (dynamic tool binding to agents)
- Tool Routing Service (intelligent tool selection)
- Tool Validation Service (parameter validation, error handling)
- Warehouse-Specific Adapters (Equipment, Operations, Safety, Forecasting, Document)
- Integration with LangGraph workflow orchestration
- Total MCP Files: 15+ files
- Adapters: 9 warehouse-specific adapters
- Tools Registered: 30+ warehouse-specific tools
- Lines of Code: ~3,000+ lines of custom MCP code
The custom MCP implementation provides significant benefits for the Warehouse Operational Assistant:
- Warehouse-Specific Optimizations: Built for warehouse operations, not generic use
- Tight Integration: Seamless integration with LangGraph and FastAPI
- Performance: Optimized for warehouse query patterns and tool discovery
- Flexibility: Full control over features and behavior
- Reduced Dependencies: No external SDK dependency
While the official MCP Python SDK is a great solution for generic MCP implementations, the custom implementation is better suited for the specific needs of the Warehouse Operational Assistant, providing warehouse-specific features, optimizations, and integrations that would be difficult to achieve with a generic SDK.
If needed in the future, the custom implementation could be:
- Wrapped: Custom implementation could wrap the official SDK
- Hybrid: Use official SDK for core protocol, custom for warehouse features
- Maintained: Continue custom implementation with MCP specification updates
Continue with custom implementation because:
- It's already fully functional and optimized
- Provides warehouse-specific features not in generic SDK
- Tight integration with existing systems
- Full control over future enhancements