A comprehensive LLM and MCP (Model Context Protocol) chatbot system for Hyundai accessories that provides both guided flow and direct search capabilities.
The system consists of three main components:
- MCP Server (
mcp-server.js) - Handles API calls and tool definitions - MCP Client (
mcp-client.js) - Web-based chat interface - LLM Integration (
llm-integration-example.js) - Demonstrates LLM interaction patterns
- Step-by-step navigation through:
- Model selection (Creta, i20, Venue, etc.)
- Accessory type selection (Interior, Exterior, etc.)
- Subtype selection (Seat Covers, Floor Mats, etc.)
- Product selection and details
- Direct product search with natural language
- Example: "Show me seat covers for Creta"
- Returns matching products with full details
- Node.js (v16 or higher)
- npm or yarn
npm install# Start the MCP server
npm start
# Or for development with auto-restart
npm run devOpen index.html in your browser or serve it with a local server.
- Endpoint:
https://api.hyundaimobisin.com/service/accessories/getByModelIdYear - Parameters:
modelId: Mapped from model namesyear: Always set to 2018
{
'creta': 35,
'alcazar': 34,
'creta n line': 31,
'i20': 27,
'exter': 26,
'verna': 23,
'i10 nios': 25,
'nios': 25,
'aura': 24,
'venue n line': 22,
'venue nline': 22,
'new venue': 20,
'venue': 20,
'kona': 33
}Purpose: Guided step-by-step accessories selection
Parameters:
step: Current step in flow ('start', 'select_model', 'select_type', 'select_subtype', 'select_product')model_name: Selected Hyundai modeltype_name: Selected accessory typesubtype_name: Selected accessory subtypeproduct_name: Selected product name
Flow Steps:
- start β Shows available models
- select_model β Shows accessory types for selected model
- select_type β Shows subtypes for selected type
- select_subtype β Shows products for selected subtype
- select_product β Shows product details
Purpose: Direct product search without guided flow
Parameters:
model_name: Hyundai model nameproduct_query: Product or accessory to search for
The llm-integration-example.js demonstrates how an LLM would interact with the MCP server:
The LLM analyzes user input to determine whether to use:
- Flow Mode: For browsing and exploration
- Universal Mode: For specific product searches
User: "Show me what accessories you have"
LLM: Calls flow_accessories tool with step='start'
Response: Lists available Hyundai models
User: "Show me seat covers for Creta"
LLM: Calls universal_accessories tool
Response: Returns matching seat cover products
- Modern, responsive design
- Real-time message updates
- Interactive menu buttons
- Product detail cards
- Loading indicators
- Message Container: Displays conversation history
- Input Bar: Text input for direct queries
- Menu Bars: Interactive buttons for flow navigation
- Product Cards: Detailed product information display
chatbotmcppoc/
βββ mcp-server.js # MCP server implementation
βββ mcp-client.js # Web client interface
βββ llm-integration-example.js # LLM integration patterns
βββ index.html # Main web page
βββ styles.css # UI styling
βββ package.json # Dependencies and scripts
βββ README.md # This file
- User clicks "π Accessories Flow"
- System shows available Hyundai models
- User selects a model (e.g., "Creta")
- System shows accessory types
- User selects type (e.g., "Interior Accessories")
- System shows subtypes
- User selects subtype (e.g., "Seat Covers")
- System shows available products
- User selects product to see details
- User types: "Show me LED lights for i20"
- LLM calls
universal_accessoriestool - System searches for LED lights in i20
- Returns matching products with details
Update the MODEL_MAPPINGS object in mcp-server.js:
this.MODEL_MAPPINGS = {
// ... existing mappings
'new_model': modelId
};The system expects API responses in this format:
{
types: [
{
typeName: "Category Name",
subtypes: [
{
subtypeName: "Subcategory Name",
products: [
{
productName: "Product Name",
price: "βΉPrice",
description: "Product description",
partNumber: "Part Number"
}
]
}
]
}
]
}- Modify
styles.cssfor visual changes - Update
mcp-client.jsfor behavior changes - Edit
index.htmlfor structure changes
- Start the MCP server
- Open
index.htmlin browser - Test both flow and direct search modes
- Verify API responses are handled correctly
# Run tests (if implemented)
npm testThe system includes comprehensive error handling for:
- Invalid model names
- API connection failures
- Missing product data
- Invalid user inputs
- API calls are cached where possible
- Mock data is used for development
- Responsive UI for mobile devices
- Efficient search algorithms
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.
For issues and questions:
- Check the documentation
- Review existing issues
- Create a new issue with detailed information
Note: This system is designed for demonstration purposes. In production, ensure proper error handling, security measures, and API rate limiting.