@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,221 @@
1
+ -- Restaurant schema — PostgreSQL dialect
2
+ -- Compatible with 3d-db's SQL DDL parser (node-sql-parser, postgresql mode)
3
+
4
+ CREATE TABLE roles (
5
+ id SERIAL PRIMARY KEY,
6
+ code TEXT NOT NULL UNIQUE,
7
+ name TEXT NOT NULL
8
+ );
9
+
10
+ CREATE TABLE order_statuses (
11
+ id SERIAL PRIMARY KEY,
12
+ code TEXT NOT NULL UNIQUE,
13
+ name TEXT NOT NULL
14
+ );
15
+
16
+ CREATE TABLE reservation_statuses (
17
+ id SERIAL PRIMARY KEY,
18
+ code TEXT NOT NULL UNIQUE,
19
+ name TEXT NOT NULL
20
+ );
21
+
22
+ CREATE TABLE waitlist_statuses (
23
+ id SERIAL PRIMARY KEY,
24
+ code TEXT NOT NULL UNIQUE,
25
+ name TEXT NOT NULL
26
+ );
27
+
28
+ CREATE TABLE allergens (
29
+ id SERIAL PRIMARY KEY,
30
+ name TEXT NOT NULL UNIQUE
31
+ );
32
+
33
+ CREATE TABLE kitchen_stations (
34
+ id SERIAL PRIMARY KEY,
35
+ code TEXT NOT NULL UNIQUE,
36
+ name TEXT NOT NULL
37
+ );
38
+
39
+ CREATE TABLE locations (
40
+ id SERIAL PRIMARY KEY,
41
+ name TEXT NOT NULL,
42
+ address TEXT NOT NULL,
43
+ phone TEXT
44
+ );
45
+
46
+ CREATE TABLE dining_tables (
47
+ id SERIAL PRIMARY KEY,
48
+ location_id INTEGER NOT NULL REFERENCES locations (id),
49
+ name TEXT NOT NULL,
50
+ capacity INTEGER NOT NULL CHECK (capacity > 0),
51
+ is_active BOOLEAN NOT NULL DEFAULT TRUE,
52
+ UNIQUE (location_id, name)
53
+ );
54
+ CREATE INDEX idx_dining_tables_location ON dining_tables (location_id);
55
+
56
+ CREATE TABLE staff (
57
+ id SERIAL PRIMARY KEY,
58
+ role_id INTEGER NOT NULL REFERENCES roles (id),
59
+ name TEXT NOT NULL,
60
+ email TEXT,
61
+ hired_at DATE NOT NULL,
62
+ is_active BOOLEAN NOT NULL DEFAULT TRUE
63
+ );
64
+ CREATE INDEX idx_staff_role ON staff (role_id);
65
+
66
+ CREATE TABLE customers (
67
+ id SERIAL PRIMARY KEY,
68
+ name TEXT NOT NULL,
69
+ email TEXT,
70
+ phone TEXT,
71
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
72
+ );
73
+ CREATE INDEX idx_customers_phone ON customers (phone);
74
+ CREATE INDEX idx_customers_name ON customers (name);
75
+
76
+ CREATE TABLE menu_categories (
77
+ id SERIAL PRIMARY KEY,
78
+ name TEXT NOT NULL,
79
+ sort_order INTEGER NOT NULL DEFAULT 0
80
+ );
81
+
82
+ CREATE TABLE menu_items (
83
+ id SERIAL PRIMARY KEY,
84
+ category_id INTEGER NOT NULL REFERENCES menu_categories (id),
85
+ name TEXT NOT NULL,
86
+ description TEXT,
87
+ price_cents INTEGER NOT NULL CHECK (price_cents >= 0),
88
+ kitchen_station_id INTEGER REFERENCES kitchen_stations (id),
89
+ is_available BOOLEAN NOT NULL DEFAULT TRUE
90
+ );
91
+ CREATE INDEX idx_menu_items_category ON menu_items (category_id);
92
+ CREATE INDEX idx_menu_items_available ON menu_items (is_available);
93
+
94
+ CREATE TABLE suppliers (
95
+ id SERIAL PRIMARY KEY,
96
+ name TEXT NOT NULL,
97
+ contact_phone TEXT
98
+ );
99
+
100
+ CREATE TABLE inventory_items (
101
+ id SERIAL PRIMARY KEY,
102
+ sku TEXT NOT NULL UNIQUE,
103
+ name TEXT NOT NULL,
104
+ unit TEXT NOT NULL,
105
+ quantity_on_hand NUMERIC NOT NULL DEFAULT 0 CHECK (quantity_on_hand >= 0),
106
+ reorder_point NUMERIC NOT NULL DEFAULT 0 CHECK (reorder_point >= 0)
107
+ );
108
+
109
+ CREATE TABLE promotions (
110
+ id SERIAL PRIMARY KEY,
111
+ code TEXT NOT NULL UNIQUE,
112
+ discount_pct INTEGER NOT NULL CHECK (discount_pct >= 0 AND discount_pct <= 100),
113
+ valid_from DATE NOT NULL,
114
+ valid_to DATE NOT NULL
115
+ );
116
+
117
+ CREATE TABLE menu_item_allergens (
118
+ menu_item_id INTEGER NOT NULL REFERENCES menu_items (id) ON DELETE CASCADE,
119
+ allergen_id INTEGER NOT NULL REFERENCES allergens (id),
120
+ PRIMARY KEY (menu_item_id, allergen_id)
121
+ );
122
+
123
+ CREATE TABLE supplier_items (
124
+ supplier_id INTEGER NOT NULL REFERENCES suppliers (id),
125
+ inventory_item_id INTEGER NOT NULL REFERENCES inventory_items (id),
126
+ unit_cost_cents INTEGER NOT NULL CHECK (unit_cost_cents >= 0),
127
+ PRIMARY KEY (supplier_id, inventory_item_id)
128
+ );
129
+
130
+ CREATE TABLE menu_item_recipe (
131
+ menu_item_id INTEGER NOT NULL REFERENCES menu_items (id) ON DELETE CASCADE,
132
+ inventory_item_id INTEGER NOT NULL REFERENCES inventory_items (id),
133
+ qty_per_portion NUMERIC NOT NULL CHECK (qty_per_portion > 0),
134
+ PRIMARY KEY (menu_item_id, inventory_item_id)
135
+ );
136
+
137
+ CREATE TABLE shifts (
138
+ id SERIAL PRIMARY KEY,
139
+ staff_id INTEGER NOT NULL REFERENCES staff (id),
140
+ starts_at TIMESTAMPTZ NOT NULL,
141
+ ends_at TIMESTAMPTZ NOT NULL
142
+ );
143
+ CREATE INDEX idx_shifts_staff ON shifts (staff_id);
144
+ CREATE INDEX idx_shifts_starts ON shifts (starts_at);
145
+
146
+ CREATE TABLE orders (
147
+ id SERIAL PRIMARY KEY,
148
+ customer_id INTEGER NOT NULL REFERENCES customers (id),
149
+ dining_table_id INTEGER REFERENCES dining_tables (id),
150
+ order_status_id INTEGER NOT NULL REFERENCES order_statuses (id),
151
+ placed_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
152
+ notes TEXT
153
+ );
154
+ CREATE INDEX idx_orders_customer ON orders (customer_id);
155
+ CREATE INDEX idx_orders_table ON orders (dining_table_id);
156
+ CREATE INDEX idx_orders_status ON orders (order_status_id);
157
+ CREATE INDEX idx_orders_placed ON orders (placed_at);
158
+
159
+ CREATE TABLE order_lines (
160
+ id SERIAL PRIMARY KEY,
161
+ order_id INTEGER NOT NULL REFERENCES orders (id) ON DELETE CASCADE,
162
+ menu_item_id INTEGER NOT NULL REFERENCES menu_items (id),
163
+ qty INTEGER NOT NULL CHECK (qty > 0),
164
+ unit_price_cents INTEGER NOT NULL CHECK (unit_price_cents >= 0)
165
+ );
166
+ CREATE INDEX idx_order_lines_order ON order_lines (order_id);
167
+ CREATE INDEX idx_order_lines_menu_item ON order_lines (menu_item_id);
168
+
169
+ CREATE TABLE order_promotions (
170
+ order_id INTEGER NOT NULL REFERENCES orders (id) ON DELETE CASCADE,
171
+ promotion_id INTEGER NOT NULL REFERENCES promotions (id),
172
+ discount_cents INTEGER NOT NULL DEFAULT 0 CHECK (discount_cents >= 0),
173
+ PRIMARY KEY (order_id, promotion_id)
174
+ );
175
+
176
+ CREATE TABLE payments (
177
+ id SERIAL PRIMARY KEY,
178
+ order_id INTEGER NOT NULL REFERENCES orders (id) ON DELETE CASCADE,
179
+ method TEXT NOT NULL,
180
+ amount_cents INTEGER NOT NULL CHECK (amount_cents >= 0),
181
+ processed_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
182
+ );
183
+ CREATE INDEX idx_payments_order ON payments (order_id);
184
+ CREATE INDEX idx_payments_processed ON payments (processed_at);
185
+
186
+ CREATE TABLE reservations (
187
+ id SERIAL PRIMARY KEY,
188
+ customer_id INTEGER NOT NULL REFERENCES customers (id),
189
+ dining_table_id INTEGER NOT NULL REFERENCES dining_tables (id),
190
+ party_size INTEGER NOT NULL CHECK (party_size > 0),
191
+ start_at TIMESTAMPTZ NOT NULL,
192
+ end_at TIMESTAMPTZ NOT NULL,
193
+ reservation_status_id INTEGER NOT NULL REFERENCES reservation_statuses (id),
194
+ notes TEXT,
195
+ CHECK (end_at > start_at)
196
+ );
197
+ CREATE INDEX idx_reservations_table ON reservations (dining_table_id);
198
+ CREATE INDEX idx_reservations_start ON reservations (start_at);
199
+ CREATE INDEX idx_reservations_status ON reservations (reservation_status_id);
200
+
201
+ CREATE TABLE waitlist (
202
+ id SERIAL PRIMARY KEY,
203
+ customer_id INTEGER NOT NULL REFERENCES customers (id),
204
+ party_size INTEGER NOT NULL CHECK (party_size > 0),
205
+ requested_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
206
+ waitlist_status_id INTEGER NOT NULL REFERENCES waitlist_statuses (id),
207
+ notes TEXT
208
+ );
209
+ CREATE INDEX idx_waitlist_status ON waitlist (waitlist_status_id);
210
+ CREATE INDEX idx_waitlist_requested ON waitlist (requested_at);
211
+
212
+ CREATE TABLE reviews (
213
+ id SERIAL PRIMARY KEY,
214
+ customer_id INTEGER NOT NULL REFERENCES customers (id),
215
+ order_id INTEGER NOT NULL REFERENCES orders (id),
216
+ rating INTEGER NOT NULL CHECK (rating BETWEEN 1 AND 5),
217
+ comment TEXT,
218
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
219
+ UNIQUE (customer_id, order_id)
220
+ );
221
+ CREATE INDEX idx_reviews_order ON reviews (order_id);
@@ -0,0 +1,111 @@
1
+ {
2
+ "name": "Restaurant (anti-patterns)",
3
+ "tables": [
4
+ {
5
+ "name": "audit_log",
6
+ "rowCount": 980000,
7
+ "columns": [
8
+ { "name": "row_num", "type": "integer" },
9
+ { "name": "action", "type": "text", "nullable": true },
10
+ { "name": "entity_type", "type": "text", "nullable": true },
11
+ { "name": "entity_id", "type": "integer", "nullable": true },
12
+ { "name": "old_value", "type": "text", "nullable": true },
13
+ { "name": "new_value", "type": "text", "nullable": true },
14
+ { "name": "performed_by", "type": "text", "nullable": true },
15
+ { "name": "performed_at", "type": "text", "nullable": true },
16
+ { "name": "ip_address", "type": "text", "nullable": true },
17
+ { "name": "user_agent", "type": "text", "nullable": true },
18
+ { "name": "session_id", "type": "text", "nullable": true },
19
+ { "name": "notes", "type": "text", "nullable": true }
20
+ ]
21
+ },
22
+ {
23
+ "name": "customer_analytics",
24
+ "rowCount": 250000,
25
+ "columns": [
26
+ { "name": "id", "type": "integer", "primaryKey": true },
27
+ { "name": "customer_id", "type": "integer", "nullable": false, "foreignKey": { "table": "customers", "column": "id" }, "indexed": false },
28
+ { "name": "first_visit", "type": "text", "nullable": true },
29
+ { "name": "last_visit", "type": "text", "nullable": true },
30
+ { "name": "total_spend_cents", "type": "integer", "nullable": true },
31
+ { "name": "avg_rating_given", "type": "real", "nullable": true },
32
+ { "name": "preferred_table_id", "type": "integer", "nullable": true },
33
+ { "name": "referral_source", "type": "text", "nullable": true },
34
+ { "name": "marketing_consent", "type": "integer", "nullable": true },
35
+ { "name": "loyalty_tier", "type": "text", "nullable": true },
36
+ { "name": "notes_1", "type": "text", "nullable": true },
37
+ { "name": "notes_2", "type": "text", "nullable": true },
38
+ { "name": "notes_3", "type": "text", "nullable": true },
39
+ { "name": "flag_a", "type": "integer", "nullable": true },
40
+ { "name": "flag_b", "type": "integer", "nullable": true },
41
+ { "name": "flag_c", "type": "integer", "nullable": true },
42
+ { "name": "meta_json", "type": "text", "nullable": true },
43
+ { "name": "segment_1", "type": "text", "nullable": true },
44
+ { "name": "segment_2", "type": "text", "nullable": true },
45
+ { "name": "segment_3", "type": "text", "nullable": true },
46
+ { "name": "campaign_id", "type": "text", "nullable": true },
47
+ { "name": "utm_source", "type": "text", "nullable": true },
48
+ { "name": "utm_medium", "type": "text", "nullable": true },
49
+ { "name": "utm_campaign", "type": "text", "nullable": true },
50
+ { "name": "utm_term", "type": "text", "nullable": true },
51
+ { "name": "utm_content", "type": "text", "nullable": true },
52
+ { "name": "custom_field_1", "type": "text", "nullable": true },
53
+ { "name": "custom_field_2", "type": "text", "nullable": true }
54
+ ]
55
+ },
56
+ {
57
+ "name": "orphan_config",
58
+ "rowCount": 12,
59
+ "columns": [
60
+ { "name": "id", "type": "integer", "primaryKey": true },
61
+ { "name": "key", "type": "text", "nullable": false },
62
+ { "name": "value", "type": "text", "nullable": true },
63
+ { "name": "updated_at", "type": "text", "nullable": true }
64
+ ]
65
+ },
66
+ {
67
+ "name": "customers",
68
+ "rowCount": 8500,
69
+ "columns": [
70
+ { "name": "id", "type": "integer", "primaryKey": true, "indexed": false },
71
+ { "name": "name", "type": "text", "nullable": false, "indexed": true },
72
+ { "name": "email", "type": "text", "nullable": true },
73
+ { "name": "phone", "type": "text", "nullable": true, "indexed": true },
74
+ { "name": "created_at", "type": "text", "nullable": false }
75
+ ]
76
+ },
77
+ {
78
+ "name": "orders",
79
+ "rowCount": 52000,
80
+ "columns": [
81
+ { "name": "id", "type": "integer", "primaryKey": true },
82
+ {
83
+ "name": "customer_id",
84
+ "type": "integer",
85
+ "nullable": false,
86
+ "foreignKey": { "table": "customers", "column": "id" },
87
+ "indexed": true
88
+ },
89
+ { "name": "placed_at", "type": "text", "nullable": false, "indexed": true },
90
+ { "name": "notes", "type": "text", "nullable": true }
91
+ ]
92
+ },
93
+ {
94
+ "name": "order_lines",
95
+ "rowCount": 145000,
96
+ "columns": [
97
+ { "name": "id", "type": "integer", "primaryKey": true },
98
+ {
99
+ "name": "order_id",
100
+ "type": "integer",
101
+ "nullable": false,
102
+ "foreignKey": { "table": "orders", "column": "id" },
103
+ "indexed": false
104
+ },
105
+ { "name": "menu_item_id", "type": "integer", "nullable": false },
106
+ { "name": "qty", "type": "integer", "nullable": false },
107
+ { "name": "unit_price_cents", "type": "integer", "nullable": false }
108
+ ]
109
+ }
110
+ ]
111
+ }