@mixio-pro/kalaasetu-mcp 2.0.10-beta → 2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mixio-pro/kalaasetu-mcp",
3
- "version": "2.0.10-beta",
3
+ "version": "2.1.0",
4
4
  "description": "A powerful Model Context Protocol server providing AI tools for content generation and analysis",
5
5
  "type": "module",
6
6
  "module": "src/index.ts",
@@ -55,6 +55,7 @@
55
55
  "fastmcp": "3.26.8",
56
56
  "form-data": "^4.0.5",
57
57
  "google-auth-library": "^10.5.0",
58
+ "jsonata": "^2.1.0",
58
59
  "wav": "^1.0.2",
59
60
  "zod": "^4.1.12"
60
61
  }
@@ -50,6 +50,11 @@ export interface FalPresetConfig {
50
50
  promptEnhancer?: string | PromptEnhancerConfig;
51
51
  /** Optional JSON schema for the model's input parameters */
52
52
  input_schema?: Record<string, any>;
53
+ /** Optional transformers for input parameters (e.g., convert string to number or JSONata) */
54
+ transformers?: {
55
+ jsonata?: string;
56
+ types?: Record<string, string>;
57
+ };
53
58
  }
54
59
 
55
60
  /**
@@ -95,16 +100,21 @@ export const DEFAULT_PRESETS: FalPresetConfig[] = [
95
100
  default: "time",
96
101
  },
97
102
  duration: {
98
- type: "integer",
99
- enum: [5, 10],
100
- default: 5,
103
+ type: "string",
104
+ enum: ["5", "10"],
105
+ default: "5",
101
106
  description: "Duration in seconds.",
102
107
  },
103
108
  seed: {
104
- type: "integer",
109
+ type: "number",
105
110
  description: "Random seed for reproducibility.",
106
111
  },
107
112
  },
113
+ transformers: {
114
+ types: {
115
+ duration: "number"
116
+ }
117
+ }
108
118
  },
109
119
  {
110
120
  presetName: "ltx_retake_video",
@@ -123,9 +133,13 @@ export const DEFAULT_PRESETS: FalPresetConfig[] = [
123
133
  start_time: {
124
134
  type: "number",
125
135
  description: "Start timestamp for the edit.",
136
+ default: 0
126
137
  },
127
- end_time: { type: "number", description: "End timestamp for the edit." },
128
- },
138
+ end_time: {
139
+ type: "number",
140
+ description: "End timestamp for the edit."
141
+ },
142
+ }
129
143
  },
130
144
  ];
131
145
 
@@ -5,13 +5,14 @@
5
5
  * Each preset becomes a first-class MCP tool with its own Zod schema.
6
6
  */
7
7
 
8
- import { z, type ZodTypeAny } from "zod";
9
- import { safeToolExecute } from "../../utils/tool-wrapper";
8
+ import jsonata from "jsonata";
9
+ import { z } from "zod";
10
10
  import { resolveEnhancer } from "../../utils/prompt-enhancer-presets";
11
11
  import { sanitizeResponse } from "../../utils/sanitize";
12
+ import { safeToolExecute } from "../../utils/tool-wrapper";
12
13
  import {
13
- FAL_QUEUE_URL,
14
14
  AUTHENTICATED_TIMEOUT,
15
+ FAL_QUEUE_URL,
15
16
  getApiKey,
16
17
  loadFalConfig,
17
18
  type FalPresetConfig,
@@ -222,12 +223,43 @@ export function createToolFromPreset(preset: FalPresetConfig) {
222
223
  }
223
224
 
224
225
  // Merge: schema defaults → preset defaultParams → user params
225
- const mergedParams = {
226
+ const mergedParams: Record<string, any> = {
226
227
  ...schemaDefaults,
227
228
  ...(preset.defaultParams || {}),
228
229
  ...userParams,
229
230
  };
230
231
 
232
+ // Apply transformations if defined
233
+ if (preset.transformers) {
234
+ // 1. JSONata transformation
235
+ if (preset.transformers.jsonata) {
236
+ try {
237
+ const expression = jsonata(preset.transformers.jsonata);
238
+ const transformed = await expression.evaluate(mergedParams);
239
+ if (transformed && typeof transformed === "object") {
240
+ Object.assign(mergedParams, transformed);
241
+ }
242
+ } catch (err) {
243
+ context?.log?.info(`JSONata transformation failed: ${err}`);
244
+ }
245
+ }
246
+
247
+ // 2. Type-based coercion
248
+ if (preset.transformers.types) {
249
+ for (const [key, type] of Object.entries(preset.transformers.types)) {
250
+ if (mergedParams[key] !== undefined && mergedParams[key] !== null) {
251
+ if (type === "number") {
252
+ mergedParams[key] = Number(mergedParams[key]);
253
+ } else if (type === "string") {
254
+ mergedParams[key] = String(mergedParams[key]);
255
+ } else if (type === "boolean") {
256
+ mergedParams[key] = String(mergedParams[key]).toLowerCase() === "true";
257
+ }
258
+ }
259
+ }
260
+ }
261
+ }
262
+
231
263
  // Apply prompt enhancement if enabled
232
264
  const shouldEnhance = auto_enhance !== false;
233
265
  if (shouldEnhance && preset.promptEnhancer && mergedParams.prompt) {
@@ -2,7 +2,7 @@ import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
3
  import { mkdir, readFile, writeFile } from "node:fs/promises";
4
4
 
5
- const CACHE_DIR = path.join(process.cwd(), ".cache");
5
+ const CACHE_DIR = path.resolve(__dirname, "..", "..", ".cache");
6
6
 
7
7
  /**
8
8
  * Options for remote configuration syncing.