@daydream-technologies/3d-db-mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +113 -0
  2. package/dist/http.js +144 -0
  3. package/dist/index.js +44 -0
  4. package/dist/mcp.js +112 -0
  5. package/dist/setup.js +89 -0
  6. package/dist/token.js +9 -0
  7. package/package.json +39 -0
  8. package/static/assets/index-B0dnwIo5.css +1 -0
  9. package/static/assets/index-MBzCJJWx.js +5054 -0
  10. package/static/docs/IMPORT_MONGODB.md +63 -0
  11. package/static/docs/IMPORT_MYSQL.md +52 -0
  12. package/static/docs/IMPORT_POSTGRES.md +15 -0
  13. package/static/docs/IMPORT_SUPABASE.md +82 -0
  14. package/static/docs/SCHEMA_FORMAT.md +63 -0
  15. package/static/index.html +14 -0
  16. package/static/learn/lessons.md +242 -0
  17. package/static/samples/blog.json +83 -0
  18. package/static/samples/ecommerce.json +103 -0
  19. package/static/samples/library.json +79 -0
  20. package/static/samples/restaurant/13_cte_repeat_customers.sql +20 -0
  21. package/static/samples/restaurant/14_union_active_contacts.sql +25 -0
  22. package/static/samples/restaurant/15_distinct_customer_methods.sql +10 -0
  23. package/static/samples/restaurant/16_full_join_staff_shifts.sql +12 -0
  24. package/static/samples/restaurant/17_like_menu_search.sql +12 -0
  25. package/static/samples/restaurant/18_is_null_missing_data.sql +13 -0
  26. package/static/samples/restaurant/19_offset_pagination.sql +13 -0
  27. package/static/samples/restaurant/20_from_subquery_top_items.sql +20 -0
  28. package/static/samples/restaurant/21_between_date_range.sql +13 -0
  29. package/static/samples/restaurant/22_right_join_unused_promos.sql +14 -0
  30. package/static/samples/restaurant/proposal-add-loyalty.json +131 -0
  31. package/static/samples/restaurant/proposal-baseline.json +66 -0
  32. package/static/samples/restaurant/schema_postgres.sql +221 -0
  33. package/static/samples/restaurant-antipatterns.json +111 -0
  34. package/static/samples/restaurant.json +425 -0
  35. package/static/vite.svg +5 -0
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "E-commerce (sample)",
3
+ "tables": [
4
+ {
5
+ "name": "users",
6
+ "rowCount": 12500,
7
+ "columns": [
8
+ { "name": "id", "type": "uuid", "primaryKey": true },
9
+ { "name": "email", "type": "text", "nullable": false, "indexed": true },
10
+ { "name": "created_at", "type": "timestamptz", "nullable": false }
11
+ ]
12
+ },
13
+ {
14
+ "name": "products",
15
+ "rowCount": 820,
16
+ "columns": [
17
+ { "name": "id", "type": "uuid", "primaryKey": true },
18
+ { "name": "sku", "type": "text", "nullable": false, "indexed": true },
19
+ { "name": "title", "type": "text", "nullable": false },
20
+ { "name": "price_cents", "type": "int", "nullable": false }
21
+ ]
22
+ },
23
+ {
24
+ "name": "inventory",
25
+ "rowCount": 950000,
26
+ "columns": [
27
+ { "name": "id", "type": "bigserial", "primaryKey": true },
28
+ {
29
+ "name": "product_id",
30
+ "type": "uuid",
31
+ "nullable": false,
32
+ "foreignKey": { "table": "products", "column": "id" },
33
+ "indexed": false
34
+ },
35
+ { "name": "warehouse", "type": "text", "nullable": false },
36
+ { "name": "qty", "type": "int", "nullable": false },
37
+ { "name": "snapshot_at", "type": "timestamptz", "nullable": true }
38
+ ]
39
+ },
40
+ {
41
+ "name": "orders",
42
+ "rowCount": 210000,
43
+ "columns": [
44
+ { "name": "id", "type": "uuid", "primaryKey": true },
45
+ {
46
+ "name": "user_id",
47
+ "type": "uuid",
48
+ "nullable": false,
49
+ "foreignKey": { "table": "users", "column": "id" },
50
+ "indexed": true
51
+ },
52
+ { "name": "status", "type": "text", "nullable": false, "indexed": true },
53
+ { "name": "placed_at", "type": "timestamptz", "nullable": false }
54
+ ]
55
+ },
56
+ {
57
+ "name": "order_items",
58
+ "rowCount": 480000,
59
+ "columns": [
60
+ { "name": "id", "type": "bigserial", "primaryKey": true },
61
+ {
62
+ "name": "order_id",
63
+ "type": "uuid",
64
+ "nullable": false,
65
+ "foreignKey": { "table": "orders", "column": "id" },
66
+ "indexed": true
67
+ },
68
+ {
69
+ "name": "product_id",
70
+ "type": "uuid",
71
+ "nullable": false,
72
+ "foreignKey": { "table": "products", "column": "id" },
73
+ "indexed": true
74
+ },
75
+ { "name": "qty", "type": "int", "nullable": false },
76
+ { "name": "unit_price_cents", "type": "int", "nullable": false }
77
+ ]
78
+ },
79
+ {
80
+ "name": "reviews",
81
+ "rowCount": 89000,
82
+ "columns": [
83
+ { "name": "id", "type": "bigserial", "primaryKey": true },
84
+ {
85
+ "name": "product_id",
86
+ "type": "uuid",
87
+ "nullable": false,
88
+ "foreignKey": { "table": "products", "column": "id" },
89
+ "indexed": true
90
+ },
91
+ {
92
+ "name": "user_id",
93
+ "type": "uuid",
94
+ "nullable": true,
95
+ "foreignKey": { "table": "users", "column": "id" },
96
+ "indexed": false
97
+ },
98
+ { "name": "rating", "type": "smallint", "nullable": false },
99
+ { "name": "body", "type": "text", "nullable": true }
100
+ ]
101
+ }
102
+ ]
103
+ }
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "Library (sample)",
3
+ "tables": [
4
+ {
5
+ "name": "authors",
6
+ "rowCount": 1200,
7
+ "columns": [
8
+ { "name": "id", "type": "serial", "primaryKey": true },
9
+ { "name": "name", "type": "text", "nullable": false, "indexed": true }
10
+ ]
11
+ },
12
+ {
13
+ "name": "books",
14
+ "rowCount": 28000,
15
+ "columns": [
16
+ { "name": "id", "type": "serial", "primaryKey": true },
17
+ {
18
+ "name": "author_id",
19
+ "type": "int",
20
+ "nullable": false,
21
+ "foreignKey": { "table": "authors", "column": "id" },
22
+ "indexed": true
23
+ },
24
+ { "name": "isbn", "type": "varchar(20)", "nullable": false, "indexed": true },
25
+ { "name": "title", "type": "text", "nullable": false },
26
+ { "name": "published_year", "type": "int", "nullable": true }
27
+ ]
28
+ },
29
+ {
30
+ "name": "members",
31
+ "rowCount": 4500,
32
+ "columns": [
33
+ { "name": "id", "type": "serial", "primaryKey": true },
34
+ { "name": "card_number", "type": "varchar(32)", "nullable": false, "indexed": true },
35
+ { "name": "name", "type": "text", "nullable": false }
36
+ ]
37
+ },
38
+ {
39
+ "name": "loans",
40
+ "rowCount": 120000,
41
+ "columns": [
42
+ { "name": "id", "type": "bigserial", "primaryKey": true },
43
+ {
44
+ "name": "book_id",
45
+ "type": "int",
46
+ "nullable": false,
47
+ "foreignKey": { "table": "books", "column": "id" },
48
+ "indexed": true
49
+ },
50
+ {
51
+ "name": "member_id",
52
+ "type": "int",
53
+ "nullable": false,
54
+ "foreignKey": { "table": "members", "column": "id" },
55
+ "indexed": true
56
+ },
57
+ { "name": "borrowed_at", "type": "date", "nullable": false },
58
+ { "name": "due_at", "type": "date", "nullable": false },
59
+ { "name": "returned_at", "type": "date", "nullable": true }
60
+ ]
61
+ },
62
+ {
63
+ "name": "fines",
64
+ "rowCount": 8900,
65
+ "columns": [
66
+ { "name": "id", "type": "serial", "primaryKey": true },
67
+ {
68
+ "name": "loan_id",
69
+ "type": "bigint",
70
+ "nullable": false,
71
+ "foreignKey": { "table": "loans", "column": "id" },
72
+ "indexed": true
73
+ },
74
+ { "name": "amount_cents", "type": "int", "nullable": false },
75
+ { "name": "paid", "type": "boolean", "nullable": false, "indexed": true }
76
+ ]
77
+ }
78
+ ]
79
+ }
@@ -0,0 +1,20 @@
1
+ -- CTE: customers who ordered more than once, with their total spend.
2
+
3
+ WITH repeat_buyers AS (
4
+ SELECT
5
+ c.id,
6
+ c.name,
7
+ COUNT(o.id) AS order_count,
8
+ SUM(ol.qty * ol.unit_price_cents) AS lifetime_cents
9
+ FROM customers c
10
+ JOIN orders o ON o.customer_id = c.id
11
+ JOIN order_lines ol ON ol.order_id = o.id
12
+ GROUP BY c.id, c.name
13
+ HAVING COUNT(o.id) > 1
14
+ )
15
+ SELECT
16
+ rb.name,
17
+ rb.order_count,
18
+ rb.lifetime_cents
19
+ FROM repeat_buyers rb
20
+ ORDER BY rb.lifetime_cents DESC;
@@ -0,0 +1,25 @@
1
+ -- UNION: combine customers with upcoming reservations and those on the waitlist.
2
+
3
+ SELECT
4
+ c.name,
5
+ c.phone,
6
+ 'reservation' AS contact_reason,
7
+ r.start_at AS scheduled_at
8
+ FROM customers c
9
+ JOIN reservations r ON r.customer_id = c.id
10
+ JOIN reservation_statuses rs ON rs.id = r.reservation_status_id
11
+ WHERE rs.code IN ('requested', 'confirmed')
12
+
13
+ UNION ALL
14
+
15
+ SELECT
16
+ c.name,
17
+ c.phone,
18
+ 'waitlist' AS contact_reason,
19
+ w.requested_at AS scheduled_at
20
+ FROM customers c
21
+ JOIN waitlist w ON w.customer_id = c.id
22
+ JOIN waitlist_statuses ws ON ws.id = w.waitlist_status_id
23
+ WHERE ws.code = 'waiting'
24
+
25
+ ORDER BY scheduled_at;
@@ -0,0 +1,10 @@
1
+ -- DISTINCT: unique payment methods used by each customer.
2
+
3
+ SELECT DISTINCT
4
+ c.name AS customer_name,
5
+ p.method
6
+ FROM customers c
7
+ JOIN orders o ON o.customer_id = c.id
8
+ JOIN payments p ON p.order_id = o.id
9
+ WHERE p.method <> 'pending'
10
+ ORDER BY c.name, p.method;
@@ -0,0 +1,12 @@
1
+ -- FULL OUTER JOIN: all staff paired with all shifts to find unscheduled staff
2
+ -- and shifts with no assigned person (useful for coverage gaps).
3
+
4
+ SELECT
5
+ st.name AS staff_name,
6
+ r.name AS role_name,
7
+ sh.starts_at,
8
+ sh.ends_at
9
+ FROM staff st
10
+ FULL OUTER JOIN shifts sh ON sh.staff_id = st.id
11
+ LEFT JOIN roles r ON r.id = st.role_id
12
+ ORDER BY sh.starts_at NULLS LAST, st.name;
@@ -0,0 +1,12 @@
1
+ -- LIKE / NOT LIKE: search menu items by keyword, excluding beverages.
2
+
3
+ SELECT
4
+ mi.id,
5
+ mi.name,
6
+ mc.name AS category,
7
+ mi.price_cents
8
+ FROM menu_items mi
9
+ JOIN menu_categories mc ON mc.id = mi.category_id
10
+ WHERE mi.name LIKE '%sal%'
11
+ AND mc.name NOT LIKE '%Beverage%'
12
+ ORDER BY mi.name;
@@ -0,0 +1,13 @@
1
+ -- IS NULL / IS NOT NULL: find orders without a dining table (takeout)
2
+ -- and customers who never provided an email.
3
+
4
+ SELECT
5
+ o.id AS order_id,
6
+ o.placed_at,
7
+ c.name AS customer_name,
8
+ c.email
9
+ FROM orders o
10
+ JOIN customers c ON c.id = o.customer_id
11
+ WHERE o.dining_table_id IS NULL
12
+ AND c.email IS NOT NULL
13
+ ORDER BY o.placed_at DESC;
@@ -0,0 +1,13 @@
1
+ -- OFFSET: paginated list of orders (page 3, 10 per page).
2
+
3
+ SELECT
4
+ o.id AS order_id,
5
+ o.placed_at,
6
+ os.name AS status,
7
+ c.name AS customer_name
8
+ FROM orders o
9
+ JOIN order_statuses os ON os.id = o.order_status_id
10
+ JOIN customers c ON c.id = o.customer_id
11
+ ORDER BY o.placed_at DESC
12
+ LIMIT 10
13
+ OFFSET 20;
@@ -0,0 +1,20 @@
1
+ -- FROM subquery (derived table): find which kitchen stations prepare
2
+ -- the top-selling items.
3
+
4
+ SELECT
5
+ ks.name AS station,
6
+ top_items.item_name,
7
+ top_items.total_qty
8
+ FROM (
9
+ SELECT
10
+ mi.kitchen_station_id,
11
+ mi.name AS item_name,
12
+ SUM(ol.qty) AS total_qty
13
+ FROM order_lines ol
14
+ JOIN menu_items mi ON mi.id = ol.menu_item_id
15
+ GROUP BY mi.kitchen_station_id, mi.name
16
+ ORDER BY total_qty DESC
17
+ LIMIT 5
18
+ ) AS top_items
19
+ JOIN kitchen_stations ks ON ks.id = top_items.kitchen_station_id
20
+ ORDER BY top_items.total_qty DESC;
@@ -0,0 +1,13 @@
1
+ -- BETWEEN: orders placed in a specific date range with total line amounts.
2
+
3
+ SELECT
4
+ o.id AS order_id,
5
+ o.placed_at,
6
+ c.name AS customer_name,
7
+ SUM(ol.qty * ol.unit_price_cents) AS total_cents
8
+ FROM orders o
9
+ JOIN customers c ON c.id = o.customer_id
10
+ JOIN order_lines ol ON ol.order_id = o.id
11
+ WHERE o.placed_at BETWEEN '2026-04-01' AND '2026-04-30'
12
+ GROUP BY o.id, o.placed_at, c.name
13
+ ORDER BY o.placed_at;
@@ -0,0 +1,14 @@
1
+ -- RIGHT JOIN: find promotions that have never been used on any order.
2
+
3
+ SELECT
4
+ p.id AS promo_id,
5
+ p.code,
6
+ p.discount_pct,
7
+ p.valid_from,
8
+ p.valid_to,
9
+ COUNT(op.order_id) AS times_used
10
+ FROM order_promotions op
11
+ RIGHT JOIN promotions p ON p.id = op.promotion_id
12
+ GROUP BY p.id, p.code, p.discount_pct, p.valid_from, p.valid_to
13
+ HAVING COUNT(op.order_id) = 0
14
+ ORDER BY p.valid_from;
@@ -0,0 +1,131 @@
1
+ {
2
+ "name": "Restaurant (with loyalty program)",
3
+ "tables": [
4
+ {
5
+ "name": "customers",
6
+ "rowCount": 8500,
7
+ "columns": [
8
+ { "name": "id", "type": "integer", "primaryKey": true },
9
+ { "name": "name", "type": "text", "nullable": false, "indexed": true },
10
+ { "name": "email", "type": "text", "nullable": true },
11
+ { "name": "phone", "type": "text", "nullable": true, "indexed": true },
12
+ { "name": "created_at", "type": "text", "nullable": false },
13
+ { "name": "loyalty_tier", "type": "text", "nullable": true }
14
+ ]
15
+ },
16
+ {
17
+ "name": "orders",
18
+ "rowCount": 52000,
19
+ "columns": [
20
+ { "name": "id", "type": "integer", "primaryKey": true },
21
+ {
22
+ "name": "customer_id",
23
+ "type": "integer",
24
+ "nullable": false,
25
+ "foreignKey": { "table": "customers", "column": "id" },
26
+ "indexed": true
27
+ },
28
+ { "name": "placed_at", "type": "text", "nullable": false, "indexed": true },
29
+ { "name": "notes", "type": "text", "nullable": true }
30
+ ]
31
+ },
32
+ {
33
+ "name": "order_lines",
34
+ "rowCount": 145000,
35
+ "columns": [
36
+ { "name": "id", "type": "integer", "primaryKey": true },
37
+ {
38
+ "name": "order_id",
39
+ "type": "integer",
40
+ "nullable": false,
41
+ "foreignKey": { "table": "orders", "column": "id" },
42
+ "indexed": true
43
+ },
44
+ { "name": "menu_item_id", "type": "integer", "nullable": false },
45
+ { "name": "qty", "type": "integer", "nullable": false },
46
+ { "name": "unit_price_cents", "type": "integer", "nullable": false }
47
+ ]
48
+ },
49
+ {
50
+ "name": "payments",
51
+ "rowCount": 52000,
52
+ "columns": [
53
+ { "name": "id", "type": "integer", "primaryKey": true },
54
+ {
55
+ "name": "order_id",
56
+ "type": "integer",
57
+ "nullable": false,
58
+ "foreignKey": { "table": "orders", "column": "id" },
59
+ "indexed": true
60
+ },
61
+ { "name": "method", "type": "text", "nullable": false },
62
+ { "name": "amount_cents", "type": "integer", "nullable": false },
63
+ { "name": "processed_at", "type": "text", "nullable": false, "indexed": true }
64
+ ]
65
+ },
66
+ {
67
+ "name": "loyalty_points",
68
+ "rowCount": 0,
69
+ "columns": [
70
+ { "name": "id", "type": "integer", "primaryKey": true },
71
+ {
72
+ "name": "customer_id",
73
+ "type": "integer",
74
+ "nullable": false,
75
+ "foreignKey": { "table": "customers", "column": "id" },
76
+ "indexed": true
77
+ },
78
+ {
79
+ "name": "order_id",
80
+ "type": "integer",
81
+ "nullable": true,
82
+ "foreignKey": { "table": "orders", "column": "id" },
83
+ "indexed": true
84
+ },
85
+ { "name": "points", "type": "integer", "nullable": false },
86
+ { "name": "reason", "type": "text", "nullable": false },
87
+ { "name": "created_at", "type": "text", "nullable": false }
88
+ ]
89
+ },
90
+ {
91
+ "name": "loyalty_rewards",
92
+ "rowCount": 0,
93
+ "columns": [
94
+ { "name": "id", "type": "integer", "primaryKey": true },
95
+ { "name": "name", "type": "text", "nullable": false },
96
+ { "name": "points_required", "type": "integer", "nullable": false },
97
+ { "name": "reward_type", "type": "text", "nullable": false },
98
+ { "name": "discount_pct", "type": "integer", "nullable": true },
99
+ { "name": "is_active", "type": "integer", "nullable": false }
100
+ ]
101
+ },
102
+ {
103
+ "name": "loyalty_redemptions",
104
+ "rowCount": 0,
105
+ "columns": [
106
+ { "name": "id", "type": "integer", "primaryKey": true },
107
+ {
108
+ "name": "customer_id",
109
+ "type": "integer",
110
+ "nullable": false,
111
+ "foreignKey": { "table": "customers", "column": "id" },
112
+ "indexed": true
113
+ },
114
+ {
115
+ "name": "reward_id",
116
+ "type": "integer",
117
+ "nullable": false,
118
+ "foreignKey": { "table": "loyalty_rewards", "column": "id" }
119
+ },
120
+ {
121
+ "name": "order_id",
122
+ "type": "integer",
123
+ "nullable": true,
124
+ "foreignKey": { "table": "orders", "column": "id" }
125
+ },
126
+ { "name": "points_spent", "type": "integer", "nullable": false },
127
+ { "name": "redeemed_at", "type": "text", "nullable": false }
128
+ ]
129
+ }
130
+ ]
131
+ }
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "Restaurant (baseline for proposal test)",
3
+ "tables": [
4
+ {
5
+ "name": "customers",
6
+ "rowCount": 8500,
7
+ "columns": [
8
+ { "name": "id", "type": "integer", "primaryKey": true },
9
+ { "name": "name", "type": "text", "nullable": false, "indexed": true },
10
+ { "name": "email", "type": "text", "nullable": true },
11
+ { "name": "phone", "type": "text", "nullable": true, "indexed": true },
12
+ { "name": "created_at", "type": "text", "nullable": false }
13
+ ]
14
+ },
15
+ {
16
+ "name": "orders",
17
+ "rowCount": 52000,
18
+ "columns": [
19
+ { "name": "id", "type": "integer", "primaryKey": true },
20
+ {
21
+ "name": "customer_id",
22
+ "type": "integer",
23
+ "nullable": false,
24
+ "foreignKey": { "table": "customers", "column": "id" },
25
+ "indexed": true
26
+ },
27
+ { "name": "placed_at", "type": "text", "nullable": false, "indexed": true },
28
+ { "name": "notes", "type": "text", "nullable": true }
29
+ ]
30
+ },
31
+ {
32
+ "name": "order_lines",
33
+ "rowCount": 145000,
34
+ "columns": [
35
+ { "name": "id", "type": "integer", "primaryKey": true },
36
+ {
37
+ "name": "order_id",
38
+ "type": "integer",
39
+ "nullable": false,
40
+ "foreignKey": { "table": "orders", "column": "id" },
41
+ "indexed": true
42
+ },
43
+ { "name": "menu_item_id", "type": "integer", "nullable": false },
44
+ { "name": "qty", "type": "integer", "nullable": false },
45
+ { "name": "unit_price_cents", "type": "integer", "nullable": false }
46
+ ]
47
+ },
48
+ {
49
+ "name": "payments",
50
+ "rowCount": 52000,
51
+ "columns": [
52
+ { "name": "id", "type": "integer", "primaryKey": true },
53
+ {
54
+ "name": "order_id",
55
+ "type": "integer",
56
+ "nullable": false,
57
+ "foreignKey": { "table": "orders", "column": "id" },
58
+ "indexed": true
59
+ },
60
+ { "name": "method", "type": "text", "nullable": false },
61
+ { "name": "amount_cents", "type": "integer", "nullable": false },
62
+ { "name": "processed_at", "type": "text", "nullable": false, "indexed": true }
63
+ ]
64
+ }
65
+ ]
66
+ }