คู่มือการเชื่อมต่อและใช้งาน — ตั้งแต่การขอ API Key, วิธีเชื่อมต่อผ่าน MCP SSE Protocol, ตัวอย่างโค้ดสำหรับเรียกใช้จาก Python, และรายชื่อเครื่องมือที่มีให้เรียกใช้ — เพื่อให้ผู้เรียนนำไปต่อยอดสร้างแอปพลิเคชันของตัวเองได้ทันที
| Endpoint | https://db.panupong.net/mcp |
| Transport | SSE (Server-Sent Events) + JSON-RPC |
| Auth | API Key in Header X-API-Key |
| SSL | Let's Encrypt (auto-renew) |
| Infra | Docker · PostgreSQL · Oracle ARM64 4c/24GB |
| Tool | Description | Example Prompt |
|---|---|---|
| query | Run SQL (SELECT / INSERT / UPDATE / DELETE) | "top 10 energy customers" |
| list_tables | Show 25 tables + row counts | "what tables exist" |
| describe_table | Table schema (column name, type, nullable) | "describe pharma_customers table" |
| reset_data | Reset to seed (requires confirm: true) | "reset data please" |
| generate_insight ✨ | Generate strategic insights from data via AI (DeepSeek) | "analyze revenue data" |
| ask_data | Ask in natural language → AI generates SQL + chart | "Power Pharma Industrial revenue over 5 years" |
After adding config, try asking AI:
what tables exist in the database?
If it returns 25 tables → Connection successful
opencode.json ในโฟลเดอร์โปรเจกต์สร้างไฟล์ opencode.json ในโฟลเดอร์โปรเจกต์:
{
"mcp": {
"bgrimm-db": {
"type": "remote",
"enabled": true,
"transport": "sse",
"url": "https://db.panupong.net/mcp",
"headers": {
"X-API-Key": "bg-t1-chun-xxxxxxxxxxxxxxxx"
}
}
}
}
.vscode/mcp.json ในโปรเจกต์{
"servers": {
"bgrimm-db": {
"type": "sse",
"url": "https://db.panupong.net/mcp",
"headers": {
"X-API-Key": "bg-t1-chun-xxxxxxxxxxxxxxxx"
}
}
}
}
Cmd+Shift+P → "MCP: Add Server"bgrimm-db → Type: sse → URL → Headersหรือแก้ .cursor/mcp.json โดยตรง:
{
"mcpServers": {
"bgrimm-db": {
"url": "https://db.panupong.net/mcp",
"headers": {
"X-API-Key": "bg-t1-chun-xxxxxxxxxxxxxxxx"
}
}
}
}
mcpServers{
"mcpServers": {
"bgrimm-db": {
"url": "https://db.panupong.net/mcp",
"headers": {
"X-API-Key": "bg-t1-chun-xxxxxxxxxxxxxxxx"
}
}
}
}
claude_desktop_config.json — เพิ่ม bgrimm-db server{
"mcpServers": {
"bgrimm-db": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-client"],
"env": {
"MCP_URL": "https://db.panupong.net/mcp",
"MCP_API_KEY": "bg-t1-chun-xxxxxxxxxxxxxxxx"
}
}
}
}
คลิกที่ชื่อตารางเพื่อคัดลอก
| กลุ่มธุรกิจ | ชื่อตาราง | รายละเอียด |
|---|---|---|
| B.Grimm Power | power_plants_detailed | 18 โรงไฟฟ้า (CCGT, Cogen, Solar, Wind, Hydro) — efficiency, PPA, co2 |
power_plants | 24 โรงไฟฟ้าไทย+ต่างประเทศ (Vietnam, Laos, Cambodia, Philippines, Malaysia, Indonesia, Korea) | |
energy_customers | 44 ลูกค้า — EGAT, PEA, EVN, EDL, PLN, NGCP, TNB, KEPCO, EDC + industrial estates + commercial | |
energy_contracts | 41 PPA contracts — cost, margin, fuel/OM per MWh | |
power_generation | 17,399 records 2016-2025 (daily, 16 plants, CO₂ emissions) | |
power_sensors | 47,196 records IoT (12 sensor types, 9 plants, temp/vibration/pressure) | |
power_maintenance | 812 records 2016-2025 (preventive/corrective/overhaul) | |
transmission_lines | 10 เส้น 115kV/230kV · 142 km | |
| B.Grimm Pharma | pharma_customers | 50 ลูกค้า (รพ.รัฐ-เอกชน, pharmacy chains, distributors) |
pharma_products | 414 ผลิตภัณฑ์ 12 กลุ่มยา (unit_cost, margin, GMP, registration) | |
pharma_orders | 15,456 คำสั่งซื้อ 2016-2025 | |
pharma_batches | 7,332 แบตช์ (89.7% released, 10.3% quarantine) | |
pharma_quality_tests | 20,000 ผลตรวจ (10 test types, 94.8% pass rate) | |
| B.Grimm Industrial | industrial_customers | 26 ลูกค้า |
industrial_products | 68 ผลิตภัณฑ์ (BG Aircon 25, BG Tech 23, Carrier 20) — cost, margin, stock | |
industrial_orders | 10,186 คำสั่งซื้อ 2016-2025 | |
industrial_production | 8,750 records — 68/68 products covered, defect tracking | |
industrial_service | 2,820 records (repair, maintenance, installation, warranty) | |
industrial_estates | 32 นิคมอุตสาหกรรม 7,255 MW | |
industrial_production | 8,750 records — all 68 products | |
| Cross-Business | revenue_fact | 3,360 records — revenue per group/month 2016-2025 |
cross_business_kpi | VIEW — Revenue, Margin, Profit, Customers per group per year | |
| ทั่วไป | employees | 10,170 คน 57 แผนก |
departments | 57 แผนก — Power, Pharma, Industrial, Corporate |
SELECT ec2.name as off_taker, pp.name as plant, ec.amount_mw,
ec.price_per_mwh, ec.margin_pct
FROM energy_contracts ec
JOIN energy_customers ec2 ON ec.customer_id=ec2.id
JOIN power_plants pp ON ec.plant_id=pp.id
ORDER BY ec.amount_mw DESC;
SELECT * FROM cross_business_kpi WHERE yr=2025;
-- Returns: Revenue, Margin%, Profit, Customers, Portfolio
-- for all 3 business groups in one query!
SELECT product_name, category, unit_price, unit_cost,
ROUND((unit_price-unit_cost)/unit_price*100,1) as margin_pct
FROM pharma_products
WHERE unit_cost IS NOT NULL
ORDER BY margin_pct DESC LIMIT 10;
SELECT ip.product_name, ip.sku, COUNT(*) as orders,
SUM(io.qty) as total_qty,
ROUND(SUM(io.total_amount)/1000000,1) as rev_mb
FROM industrial_orders io
JOIN industrial_products ip ON io.product_id=ip.id
WHERE ip.sub_business='bgaircon'
GROUP BY ip.product_name, ip.sku ORDER BY rev_mb DESC;
https:// (ไม่ใช่ http)X-API-Key — ตัวพิมพ์ใหญ่-เล็กตามนี้B.Grimm MCP SSE — OKwhat tables exist? — ถ้าตอบไม่ได้ แสดงว่ายังเชื่อมไม่สำเร็จ