π BookStore MCP - Complete Setup Guide
π― Project Overview
Full-featured bookstore MCP server vα»i 6 tools vΓ 4 interactive widgets, sα» dα»₯ng Fractal MCP SDK chΓnh thα»ng.
Features:
β 6 MCP Tools: search, detail, cart, checkout, history
β 4 React Widgets: vα»i useWidgetProps, useWidgetState, useLayout, useGlobalContext
β Zod Validation: Type-safe input schemas
β Structured Content: Proper widget props
β Dark/Light Theme: Responsive design
β In-Memory Database: 8 sample books
π¦ Step 1: Create Project
π Step 2: Create File Structure
Sao chΓ©p nα»i dung tα»« cΓ‘c artifacts vΓ o files tΖ°Ζ‘ng α»©ng:
package.json- tα»« artifact "package.json"tsconfig.json- tα»« artifact "tsconfig.json"src/server/types.ts- tα»« artifact "src/server/types.ts"src/server/database.ts- tα»« artifact "src/server/database.ts"src/server/index.ts- tα»« artifact "src/server/index.ts - BookStore MCP Server"src/ui/BookListWidget.tsx- tα»« artifact "src/ui/BookListWidget.tsx"src/ui/BookDetailWidget.tsx- tα»« artifact "src/ui/BookDetailWidget.tsx"src/ui/CartWidget.tsx- tα»« artifact "src/ui/CartWidget.tsx"src/ui/OrderHistoryWidget.tsx- tα»« artifact "src/ui/OrderHistoryWidget.tsx"
π₯ Step 3: Install Dependencies
ποΈ Step 4: Build Project
Or if error run
Expected output:
π Step 5: Start Server Locally
Expected console output:
π§ͺ Step 6: Test Local Server
Terminal 1 (Server):
Terminal 2 (Test):
BαΊ‘n sαΊ½ thαΊ₯y UI vα»i thΓ΄ng tin server!
π Step 7: Deploy to Render
7.1 Push to GitHub
7.2 Deploy on Render
Truy cαΊp https://render.com
Click "New +" β "Web Service"
Connect GitHub repository
Settings:
Name:
bookstore-mcpEnvironment:
NodeBuild Command:
npm install && npm run buildStart Command:
npm startInstance Type: Free
Click "Create Web Service"
7.3 Get URL
Sau khi deploy xong (3-5 phΓΊt):
Test: Mα» URL trong browser, bαΊ‘n sαΊ½ thαΊ₯y server info page!
π Step 8: Connect to ChatGPT
Method 1: Direct URL (Recommended)
Mα» ChatGPT β Settings (βοΈ)
Click "Apps SDK" (hoαΊ·c "Integrations")
Click "Add App"
NhαΊp URL:
https://bookstore-mcp-xxxx.onrender.comChatGPT sαΊ½ auto-discover MCP endpoint
Click "Connect"
Method 2: MCP Endpoint
NαΊΏu method 1 khΓ΄ng work:
URL:
https://bookstore-mcp-xxxx.onrender.com/mcpTransport: SSE (Server-Sent Events)
No authentication required
π¬ Step 9: Test in ChatGPT
Sau khi connect thΓ nh cΓ΄ng, thα» cΓ‘c lα»nh:
ChatGPT sαΊ½:
β Show text response
β Render interactive widget UI
β Widget cΓ³ dark/light theme
β Data update real-time
π Troubleshooting
Issue 1: Build fails
Issue 2: Widget khΓ΄ng hiα»n thα»
Check:
Fix:
Issue 3: ChatGPT connection failed
Verify endpoints:
Common fixes:
ΔαΊ£m bαΊ£o Render service Δang running (khΓ΄ng sleep)
Check Render logs for errors
Verify PORT env variable (Render auto-sets this)
Issue 4: Module not found errors
π Architecture
π¨ Customization
Add new book:
Edit src/server/database.ts:
Add new tool:
Edit src/server/index.ts:
Modify widget UI:
Edit src/ui/*.tsx files, then:
π Resources
Fractal MCP SDK: https://github.com/fractal-mcp/sdk
OpenAI Apps SDK: https://developers.openai.com/apps-sdk/
Model Context Protocol: https://modelcontextprotocol.io
Render Docs: https://render.com/docs
β Success Checklist
Project created vα»i ΔΓΊng structure
Dependencies installed
Build successful (cΓ³ dist/ui/*/index.html)
Server chαΊ‘y local (port 8000)
Deployed to Render
ChatGPT connected
All 6 tools hoαΊ‘t Δα»ng
Widgets hiα»n thα» ΔΓΊng
Theme switching works
π Done!
BαΊ‘n ΔΓ£ cΓ³ mα»t BookStore MCP Server hoΓ n chα»nh vα»i:
β 6 powerful tools
β 4 beautiful widgets
β Full Fractal MCP SDK features
β ChatGPT integration
β Production-ready code
Next steps:
Add more books to database
Implement user authentication
Add payment processing
Deploy to production domain
Share with community!
Happy coding! ππ
This server cannot be installed