@szdatatalk/sqlward-mcp 0.3.5 → 0.4.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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/server.mjs +31 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@szdatatalk/sqlward-mcp",
3
- "version": "0.3.5",
3
+ "version": "0.4.0",
4
4
  "mcpName": "io.github.shygoly/sqlward",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -41,7 +41,7 @@
41
41
  "access": "public"
42
42
  },
43
43
  "dependencies": {
44
- "@szdatatalk/sqlward": "0.3.3"
44
+ "@szdatatalk/sqlward": "0.4.0"
45
45
  },
46
46
  "scripts": {
47
47
  "test": "node --test test/mcp.test.mjs"
package/src/server.mjs CHANGED
@@ -10,7 +10,7 @@ import readline from "node:readline";
10
10
  import { pathToFileURL } from "node:url";
11
11
 
12
12
  const SERVER_NAME = "@szdatatalk/sqlward-mcp";
13
- const SERVER_VERSION = "0.3.5";
13
+ const SERVER_VERSION = "0.4.0";
14
14
  const SUPPORTED_PROTOCOL_VERSION = "2024-11-05";
15
15
 
16
16
  const READ_ONLY_ANNOTATIONS = {
@@ -21,6 +21,25 @@ const READ_ONLY_ANNOTATIONS = {
21
21
  };
22
22
 
23
23
  export const TOOL_SCHEMAS = [
24
+ {
25
+ name: "sqlward_review_query",
26
+ description: "Review AI-generated metric SQL offline, compare a repair, or omit SQL to get metric and join context. Use only caller-authorized catalog metadata.",
27
+ annotations: READ_ONLY_ANNOTATIONS,
28
+ inputSchema: { type: "object", required: ["catalog"], properties: {
29
+ catalog: { type: "object", description: "Versioned relations, relationship keys/cardinalities and approved metrics." },
30
+ metricId: { type: "string" }, dialect: { type: "string" }, sql: { type: "string" },
31
+ targetDialect: { type: "string" }, relatedTables: { type: "array", items: { type: "string" } },
32
+ previousSql: { type: "string" }
33
+ } },
34
+ },
35
+ {
36
+ name: "sqlward_extract_query_candidate",
37
+ description: "Extract projections, filters, grouping and join keys from a reviewed report or compiled dbt SELECT for catalog-owner approval.",
38
+ annotations: READ_ONLY_ANNOTATIONS,
39
+ inputSchema: { type: "object", required: ["sql", "sourceId", "revision"], properties: {
40
+ sql: { type: "string" }, dialect: { type: "string" }, sourceId: { type: "string" }, revision: { type: "string" }
41
+ } },
42
+ },
24
43
  {
25
44
  name: "sqlward_parse_column",
26
45
  description:
@@ -176,6 +195,12 @@ export async function createMcpHandler({ sqlwardModule, wasmPath } = {}) {
176
195
  const resolvedWasmPath = wasmPath || process.env.SQLWARD_WASM_PATH || sw.defaultWasmPath();
177
196
  const wasm = await sw.instantiateWasm(resolvedWasmPath);
178
197
 
198
+ const toolsAvailable = TOOL_SCHEMAS.filter(tool => {
199
+ if (tool.name === "sqlward_review_query") return typeof wasm.reviewQuery === "function";
200
+ if (tool.name === "sqlward_extract_query_candidate") return typeof wasm.extractQueryCandidate === "function";
201
+ return true;
202
+ });
203
+
179
204
  async function callTool(name, args = {}) {
180
205
  switch (name) {
181
206
  case "sqlward_version_info":
@@ -216,6 +241,10 @@ export async function createMcpHandler({ sqlwardModule, wasmPath } = {}) {
216
241
  });
217
242
  }
218
243
 
244
+ case "sqlward_review_query":
245
+ return wasm.reviewQuery(args);
246
+ case "sqlward_extract_query_candidate":
247
+ return wasm.extractQueryCandidate(args);
219
248
  case "sqlward_column_impact": {
220
249
  if (typeof args.sql !== "string" || !args.sql.trim()) {
221
250
  throw new Error("`sql` must be a non-empty string");
@@ -341,7 +370,7 @@ export async function createMcpHandler({ sqlwardModule, wasmPath } = {}) {
341
370
  return {
342
371
  jsonrpc: "2.0",
343
372
  id,
344
- result: { tools: TOOL_SCHEMAS },
373
+ result: { tools: toolsAvailable },
345
374
  };
346
375
  }
347
376