@swatbloc/mcp-server 0.1.0 → 0.1.1
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.
- package/dist/common/supabase.js +16 -0
- package/dist/tools/index.js +5 -1
- package/package.json +2 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createClient } from "@supabase/supabase-js";
|
|
2
|
+
let supabaseClient = null;
|
|
3
|
+
export function getSupabaseClient() {
|
|
4
|
+
if (supabaseClient)
|
|
5
|
+
return supabaseClient;
|
|
6
|
+
const supabaseUrl = process.env.SUPABASE_URL ||
|
|
7
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL;
|
|
8
|
+
const supabaseKey = process.env.SUPABASE_SERVICE_ROLE_KEY ||
|
|
9
|
+
process.env.SUPABASE_ANON_KEY ||
|
|
10
|
+
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
|
11
|
+
if (!supabaseUrl || !supabaseKey) {
|
|
12
|
+
throw new Error("Missing Supabase configuration. Set SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY (recommended), or NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY.");
|
|
13
|
+
}
|
|
14
|
+
supabaseClient = createClient(supabaseUrl, supabaseKey);
|
|
15
|
+
return supabaseClient;
|
|
16
|
+
}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { getSupabaseClient } from "../common/supabase.js";
|
|
3
3
|
/**
|
|
4
4
|
* Generate Cartesian product from options
|
|
5
5
|
*/
|
|
@@ -39,6 +39,7 @@ export const tools = [
|
|
|
39
39
|
})
|
|
40
40
|
},
|
|
41
41
|
execute: async (args) => {
|
|
42
|
+
const supabase = getSupabaseClient();
|
|
42
43
|
const { store_id, name, slug, fields } = args;
|
|
43
44
|
// Check if exists (Idempotency)
|
|
44
45
|
const { data: existing } = await supabase
|
|
@@ -94,6 +95,7 @@ export const tools = [
|
|
|
94
95
|
})
|
|
95
96
|
},
|
|
96
97
|
execute: async (args) => {
|
|
98
|
+
const supabase = getSupabaseClient();
|
|
97
99
|
const { store_id, limit = 50, published_only = false } = args;
|
|
98
100
|
let query = supabase
|
|
99
101
|
.from('products')
|
|
@@ -138,6 +140,7 @@ export const tools = [
|
|
|
138
140
|
})
|
|
139
141
|
},
|
|
140
142
|
execute: async (args) => {
|
|
143
|
+
const supabase = getSupabaseClient();
|
|
141
144
|
const { store_id, action, product_id, data } = args;
|
|
142
145
|
if (action === 'create') {
|
|
143
146
|
if (!data?.title) {
|
|
@@ -243,6 +246,7 @@ export const tools = [
|
|
|
243
246
|
})
|
|
244
247
|
},
|
|
245
248
|
execute: async (args) => {
|
|
249
|
+
const supabase = getSupabaseClient();
|
|
246
250
|
const { product_id, action, variant_id, data, replace_existing = true } = args;
|
|
247
251
|
// Verify product exists
|
|
248
252
|
const { data: product, error: productError } = await supabase
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swatbloc/mcp-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"prepublishOnly": "npm run build"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@supabase/supabase-js": "^2.86.2",
|
|
23
24
|
"@modelcontextprotocol/sdk": "^0.6.0",
|
|
24
25
|
"zod": "^4.3.5",
|
|
25
26
|
"zod-to-json-schema": "^3.25.1"
|