@tiangong-lca/mcp-server 0.0.24 → 0.0.25

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.
@@ -1,4 +1,3 @@
1
- import { randomUUID } from 'node:crypto';
2
1
  import { createClient, FunctionRegion } from '@supabase/supabase-js';
3
2
  import { createContact, createFlow, createLifeCycleModel, createProcess, createSource, } from '@tiangong-lca/tidas-sdk/core';
4
3
  import { z } from 'zod';
@@ -35,7 +34,7 @@ const filtersSchema = z.record(filterValueSchema);
35
34
  const toolParamsSchema = {
36
35
  operation: z
37
36
  .enum(['select', 'insert', 'update', 'delete'])
38
- .describe('CRUD operation to perform: select optionally accepts limit/id/version/filters, insert requires jsonOrdered (id auto-generated), update requires id/version/jsonOrdered, delete requires id/version.'),
37
+ .describe('CRUD operation to perform: select optionally accepts limit/id/version/filters, insert requires id/jsonOrdered, update requires id/version/jsonOrdered, delete requires id/version.'),
39
38
  table: tableSchema.describe('Target table for the operation; must be one of contacts, flows, lifecyclemodels, processes, or sources.'),
40
39
  limit: z
41
40
  .number()
@@ -47,7 +46,7 @@ const toolParamsSchema = {
47
46
  .string()
48
47
  .uuid()
49
48
  .optional()
50
- .describe('UUID string stored in the `id` column (required for update/delete, optional filter for select).'),
49
+ .describe('UUID string stored in the `id` column (required for insert/update/delete, optional filter for select).'),
51
50
  version: z
52
51
  .string()
53
52
  .min(1)
@@ -73,6 +72,13 @@ const refinedInputSchema = z
73
72
  path: ['jsonOrdered'],
74
73
  });
75
74
  }
75
+ if (data.id === undefined) {
76
+ ctx.addIssue({
77
+ code: z.ZodIssueCode.custom,
78
+ message: 'id is required for insert operations.',
79
+ path: ['id'],
80
+ });
81
+ }
76
82
  break;
77
83
  case 'update':
78
84
  if (data.id === undefined) {
@@ -233,22 +239,24 @@ async function handleSelect(supabase, input) {
233
239
  return JSON.stringify({ data: data ?? [], count: data?.length ?? 0 });
234
240
  }
235
241
  async function handleInsert(supabase, input) {
236
- const { table, jsonOrdered } = input;
242
+ const { table, jsonOrdered, id } = input;
237
243
  if (jsonOrdered === undefined) {
238
244
  throw new Error('jsonOrdered is required for insert operations.');
239
245
  }
246
+ if (id === undefined) {
247
+ throw new Error('id is required for insert operations.');
248
+ }
240
249
  validateJsonOrdered(table, jsonOrdered);
241
- const newId = randomUUID();
242
250
  const keyColumn = getPrimaryKeyColumn(table);
243
251
  const { data, error } = await supabase
244
252
  .from(table)
245
- .insert([{ [keyColumn]: newId, json_ordered: jsonOrdered }])
253
+ .insert([{ [keyColumn]: id, json_ordered: jsonOrdered }])
246
254
  .select();
247
255
  if (error) {
248
256
  console.error('Error inserting into the database:', error);
249
257
  throw error;
250
258
  }
251
- return JSON.stringify({ id: newId, data: data ?? [] });
259
+ return JSON.stringify({ id, data: data ?? [] });
252
260
  }
253
261
  async function handleUpdate(supabase, accessToken, input) {
254
262
  const { table, id, version, jsonOrdered } = input;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiangong-lca/mcp-server",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "description": "TianGong LCA MCP Server",
5
5
  "license": "MIT",
6
6
  "author": "Nan LI",
@@ -28,23 +28,23 @@
28
28
  "ncu:update": "npx npm-check-updates -u"
29
29
  },
30
30
  "dependencies": {
31
- "@modelcontextprotocol/sdk": "^1.20.2",
32
- "@supabase/supabase-js": "^2.78.0",
33
- "@tiangong-lca/tidas-sdk": "^0.1.19",
34
- "@types/express": "^5.0.5",
35
- "@upstash/redis": "^1.35.6",
31
+ "@modelcontextprotocol/sdk": "^1.24.3",
32
+ "@supabase/supabase-js": "^2.86.2",
33
+ "@tiangong-lca/tidas-sdk": "^0.1.21",
34
+ "@types/express": "^5.0.6",
35
+ "@upstash/redis": "^1.35.7",
36
36
  "aws-jwt-verify": "^5.1.1",
37
37
  "olca-ipc": "^2.2.1",
38
38
  "zod": "^3.25.76"
39
39
  },
40
40
  "devDependencies": {
41
- "@modelcontextprotocol/inspector": "^0.17.2",
41
+ "@modelcontextprotocol/inspector": "^0.17.5",
42
42
  "dotenv-cli": "^11.0.0",
43
43
  "npm-check-updates": "^19.1.2",
44
- "prettier": "^3.6.2",
44
+ "prettier": "^3.7.4",
45
45
  "prettier-plugin-organize-imports": "^4.3.0",
46
46
  "shx": "^0.4.0",
47
- "tsx": "^4.20.6",
47
+ "tsx": "^4.21.0",
48
48
  "typescript": "^5.9.3"
49
49
  }
50
50
  }