# Clone & install
git clone <repo-url>
cd HaravanMCP
npm install
# Chạy development mode
npm run dev -- mcp -t <your_haravan_token>
# Build production
npm run build
# Chạy production
node dist/cli.js mcp -t <your_haravan_token>docker/
├── Dockerfile # Multi-stage build (builder + production)
├── docker-compose.yml # Services: haravan-mcp + ngrok (optional)
└── .dockerignore # Exclude node_modules, tests, docs
# Build và chạy
docker compose -f docker/docker-compose.yml up -d
# Xem logs
docker logs haravan-mcp -f
# Rebuild sau khi sửa code
docker compose -f docker/docker-compose.yml up -d --build
# Dừng
docker compose -f docker/docker-compose.yml down# Copy file env mẫu, điền token thật
cp docker/.env.example docker/.envSửa docker/.env:
HARAVAN_ACCESS_TOKEN=your_haravan_token_here
NGROK_AUTHTOKEN=your_ngrok_authtoken_here # optional, chỉ cần nếu dùng ngrokLưu ý: docker/.env đã nằm trong .gitignore — không bao giờ bị push lên GitHub. Chỉ docker/.env.example (template không chứa key) được commit.
# Local
curl http://localhost:4567/health
# → {"status":"ok"}
# MCP endpoint
curl -X POST http://localhost:4567/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'# Cài đặt
brew install cloudflared # macOS
# hoặc: apt install cloudflared # Linux
# Chạy tunnel
cloudflared tunnel --url http://localhost:4567
# Output: https://xxx-xxx-xxx.trycloudflare.com
# MCP endpoint: https://xxx-xxx-xxx.trycloudflare.com/mcpLưu ý: URL thay đổi mỗi lần restart (free plan). Dùng named tunnel cho URL cố định.
# Thêm ngrok service vào docker-compose.yml
ngrok:
image: ngrok/ngrok:latest
environment:
- NGROK_AUTHTOKEN=<your_authtoken>
command: http haravan-mcp:3000
ports:
- "4040:4040"
depends_on:
haravan-mcp:
condition: service_healthyCảnh báo: ngrok free tier hiển thị interstitial page → Claude.ai / MCP clients có thể không connect được. Dùng Cloudflare Tunnel thay thế.
Claude Skill là lớp tri thức giúp Claude dùng Haravan MCP đúng cách — chọn đúng tool, tránh lãng phí token, viết insight có giá trị. Cần cài riêng ngoài MCP Server.
- Tải file
haravan-mcp-skill.ziptừ release hoặc build từclaudeskill/haravan-mcp/ - Truy cập Claude.ai → Settings → Claude Code → Skills → Upload Skill
- Upload file zip → Confirm activation
- Kiểm tra: hỏi Claude "tình hình cửa hàng tuần này" → Claude nên tự chọn tools và trình bày dashboard đúng format
Lưu ý: Skill chỉ cần upload 1 lần. Tự động áp dụng cho mọi conversation có kết nối Haravan MCP.
# Copy skill vào thư mục skills của Claude Code
cp -r claudeskill/haravan-mcp/ ~/.claude/skills/haravan-mcp/
# Hoặc tạo symlink (tiện cho development)
ln -s /path/to/HaravanMCP/claudeskill/haravan-mcp/ ~/.claude/skills/haravan-mcpCấu trúc sau khi cài:
~/.claude/skills/haravan-mcp/
├── SKILL.md
└── references/
├── mcp-tools.md
├── insights-formulas.md
└── examples.md
Sau khi cài, mở conversation mới với Claude (đã kết nối MCP Server) và hỏi:
"tình hình cửa hàng tuần này"
Claude nên tự động:
- Gọi
hrv_orders_summaryvới date range tuần hiện tại - Gọi
hrv_inventory_healthsong song - Trả về dashboard với bảng KPI, trend indicators (↑↓), alerts (
⚠️ 🔴) - Viết insight có con số và hành động cụ thể
Nếu Claude hỏi lại "bạn muốn xem gì?" thay vì tự chạy → Skill chưa được load đúng.
# Pull bản mới và copy lại
git pull origin main
cp -r claudeskill/haravan-mcp/ ~/.claude/skills/haravan-mcp/{
"mcpServers": {
"haravan-mcp": {
"command": "npx",
"args": ["-y", "haravan-mcp", "mcp", "-t", "<token>"]
}
}
}- Chạy Docker container:
docker compose -f docker/docker-compose.yml up -d - Expose qua Cloudflare:
cloudflared tunnel --url http://localhost:4567 - Thêm connector trên Claude.ai: URL =
https://xxx.trycloudflare.com/mcp
{
"mcpServers": {
"haravan-mcp": {
"command": "npx",
"args": ["-y", "haravan-mcp", "mcp", "-t", "<token>", "--tools", "preset.smart,preset.orders"]
}
}
}| Vấn đề | Nguyên nhân | Giải pháp |
|---|---|---|
| "Couldn't reach the MCP server" | ngrok interstitial / URL sai | Dùng Cloudflare Tunnel |
| "Parse error: Invalid JSON" | express.json() consume body | Đảm bảo handleRequest(req, res, req.body) |
| Tools không hiển thị | Session ID không lưu | Check sse.ts session flow |
| Chỉ 50 orders bất kể date range | Pagination break condition sai | Verify PAGE_SIZE=50 trong helpers.ts |
| 429 Rate Limited | Quá nhiều API calls | Smart tools tự throttle; giảm tần suất gọi |
| Container restart loop | Port conflict / token sai | Check docker logs haravan-mcp |
| Variable | Bắt buộc | Mô tả |
|---|---|---|
HARAVAN_ACCESS_TOKEN |
✅ | Private app token hoặc OAuth token |
HARAVAN_APP_ID |
OAuth only | App ID cho OAuth flow |
HARAVAN_APP_SECRET |
OAuth only | App Secret cho OAuth flow |
NODE_ENV |
❌ | production để disable debug logs |
English: This guide covers local development, Docker deployment, internet exposure via Cloudflare Tunnel, and connecting to AI assistants (Claude Desktop, Cursor, Claude.ai web).