@zapier/connectors-sdk 0.1.0-experimental.6 → 0.1.0-experimental.8
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/README.internal.md +0 -26
- package/dist/index.cjs +2 -14
- package/dist/index.d.cts +19 -27
- package/dist/index.d.ts +19 -27
- package/dist/index.js +2 -14
- package/package.json +1 -1
package/README.internal.md
CHANGED
|
@@ -346,32 +346,6 @@ A multi-credential resolver `{ name: "hmac", keySuffixes: ["KEY", "SECRET"] }` w
|
|
|
346
346
|
|
|
347
347
|
The author never sees `process.env`, never threads a `Fetch` through their script body, never re-implements auth logic.
|
|
348
348
|
|
|
349
|
-
## `inputDependencies` — out-of-band dependent-field metadata
|
|
350
|
-
|
|
351
|
-
Some scripts have input fields whose accepted shape depends on another input field — e.g. Notion's `create_database_item` takes a `databaseId` and a `properties` map whose schema is determined by which database was chosen. JSON Schema can't express that conditional shape, but adapters that drive option-loading or schema-resolution chains need to know about it.
|
|
352
|
-
|
|
353
|
-
`defineTool` publishes the metadata in two places:
|
|
354
|
-
|
|
355
|
-
1. `definition.inputDependencies` — programmatic readers reach for it directly on the script's default export.
|
|
356
|
-
2. MCP registration shape — `_meta["zapier:inputDependencies"]` via either `toMcpTool` (wire-format) or `toMcpServerTool` (`McpServer.registerTool` config).
|
|
357
|
-
|
|
358
|
-
Shape constraints:
|
|
359
|
-
|
|
360
|
-
- Dependencies are keyed by the dependent input field's name (`databaseId`, `properties`).
|
|
361
|
-
- Each entry names another tool by **string** (`fromTool: "list-databases"`), not by function reference — so the chain stays serializable.
|
|
362
|
-
- Args passed to the resolver tool use `$<fieldName>` syntax to reference other input fields (`fromArgs: { databaseId: "$databaseId" }`). The adapter reads and evaluates these references; the script body does not.
|
|
363
|
-
|
|
364
|
-
```ts
|
|
365
|
-
inputDependencies: {
|
|
366
|
-
databaseId: { kind: "options", fromTool: "list-databases", fromArgs: {} },
|
|
367
|
-
properties: {
|
|
368
|
-
kind: "schema",
|
|
369
|
-
fromTool: "get-database-schema",
|
|
370
|
-
fromArgs: { databaseId: "$databaseId" },
|
|
371
|
-
},
|
|
372
|
-
} as const,
|
|
373
|
-
```
|
|
374
|
-
|
|
375
349
|
## `<bin> mcp` — local-MCP-server execution surface
|
|
376
350
|
|
|
377
351
|
Reached through the bundled CLI as `npx @zapier/<x>-connector mcp` — no per-app glue. The dispatcher reserves the primary command `mcp` and delegates to the internal `serveMcpStdio` helper:
|
package/dist/index.cjs
CHANGED
|
@@ -528,28 +528,18 @@ function toChatCompletionTool(definition) {
|
|
|
528
528
|
|
|
529
529
|
// src/surfaces/to-mcp-server-tool.ts
|
|
530
530
|
function toMcpServerTool(definition) {
|
|
531
|
-
|
|
531
|
+
return {
|
|
532
532
|
title: definition.title,
|
|
533
533
|
description: definition.description,
|
|
534
534
|
inputSchema: definition.inputSchema,
|
|
535
535
|
outputSchema: definition.outputSchema,
|
|
536
536
|
annotations: definition.annotations
|
|
537
537
|
};
|
|
538
|
-
if (definition.inputDependencies) {
|
|
539
|
-
config._meta = {
|
|
540
|
-
"zapier:inputDependencies": definition.inputDependencies
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
return config;
|
|
544
538
|
}
|
|
545
539
|
|
|
546
540
|
// src/surfaces/to-mcp-tool.ts
|
|
547
541
|
var import_zod2 = require("zod");
|
|
548
542
|
function toMcpTool(definition) {
|
|
549
|
-
const meta = {};
|
|
550
|
-
if (definition.inputDependencies) {
|
|
551
|
-
meta["zapier:inputDependencies"] = definition.inputDependencies;
|
|
552
|
-
}
|
|
553
543
|
return {
|
|
554
544
|
name: definition.name,
|
|
555
545
|
title: definition.title,
|
|
@@ -558,8 +548,7 @@ function toMcpTool(definition) {
|
|
|
558
548
|
outputSchema: import_zod2.z.toJSONSchema(
|
|
559
549
|
definition.outputSchema
|
|
560
550
|
),
|
|
561
|
-
annotations: definition.annotations
|
|
562
|
-
...Object.keys(meta).length > 0 ? { _meta: meta } : {}
|
|
551
|
+
annotations: definition.annotations
|
|
563
552
|
};
|
|
564
553
|
}
|
|
565
554
|
|
|
@@ -668,7 +657,6 @@ function defineTool(config) {
|
|
|
668
657
|
inputSchema: config.inputSchema,
|
|
669
658
|
outputSchema: config.outputSchema,
|
|
670
659
|
annotations: config.annotations,
|
|
671
|
-
inputDependencies: config.inputDependencies,
|
|
672
660
|
run: wrappedRun
|
|
673
661
|
};
|
|
674
662
|
if (hasSingular) base.connection = config.connection;
|
package/dist/index.d.cts
CHANGED
|
@@ -169,34 +169,30 @@ interface ContextMulti<TSlots extends string = string> {
|
|
|
169
169
|
fetch?: never;
|
|
170
170
|
connections: Record<TSlots, typeof globalThis.fetch>;
|
|
171
171
|
}
|
|
172
|
-
|
|
173
|
-
/** When authoring omits `inputDependencies`, the definition value is `undefined`. */
|
|
174
|
-
type InputDependenciesValue<T> = [T] extends [undefined] ? undefined : T;
|
|
175
|
-
interface DefineToolConfigBase<TIn extends z.ZodType, TOut extends z.ZodType, TInputDependencies extends AnyInputDependencies$1 | undefined, TName extends string> {
|
|
172
|
+
interface DefineToolConfigBase<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, TName extends string> {
|
|
176
173
|
name: TName;
|
|
177
174
|
title: string;
|
|
178
175
|
description: string;
|
|
179
176
|
inputSchema: TIn;
|
|
180
177
|
outputSchema: TOut;
|
|
181
178
|
annotations: _modelcontextprotocol_sdk_types_js.Tool["annotations"];
|
|
182
|
-
inputDependencies?: TInputDependencies;
|
|
183
179
|
}
|
|
184
|
-
interface DefineToolConfigNone<TIn extends z.
|
|
180
|
+
interface DefineToolConfigNone<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, TName extends string> extends DefineToolConfigBase<TIn, TOut, TName> {
|
|
185
181
|
connection?: never;
|
|
186
182
|
connections?: never;
|
|
187
183
|
run: (input: z.infer<TIn>, ctx?: ContextNone) => Promise<unknown>;
|
|
188
184
|
}
|
|
189
|
-
interface DefineToolConfigSingle<TIn extends z.
|
|
185
|
+
interface DefineToolConfigSingle<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, TName extends string, TKey extends string> extends DefineToolConfigBase<TIn, TOut, TName> {
|
|
190
186
|
connection: TKey;
|
|
191
187
|
connections?: never;
|
|
192
188
|
run: (input: z.infer<TIn>, ctx: ContextSingle) => Promise<unknown>;
|
|
193
189
|
}
|
|
194
|
-
interface DefineToolConfigMulti<TIn extends z.
|
|
190
|
+
interface DefineToolConfigMulti<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, TName extends string, TSlots extends string, TKey extends string> extends DefineToolConfigBase<TIn, TOut, TName> {
|
|
195
191
|
connection?: never;
|
|
196
192
|
connections: Record<TSlots, TKey>;
|
|
197
193
|
run: (input: z.infer<TIn>, ctx: ContextMulti<TSlots>) => Promise<unknown>;
|
|
198
194
|
}
|
|
199
|
-
interface ToolDefinitionBase<TIn extends z.
|
|
195
|
+
interface ToolDefinitionBase<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, TName extends string> {
|
|
200
196
|
readonly kind: "tool";
|
|
201
197
|
readonly name: TName;
|
|
202
198
|
readonly title: string;
|
|
@@ -204,28 +200,26 @@ interface ToolDefinitionBase<TIn extends z.ZodType, TOut extends z.ZodType, TInp
|
|
|
204
200
|
inputSchema: TIn;
|
|
205
201
|
outputSchema: TOut;
|
|
206
202
|
readonly annotations: _modelcontextprotocol_sdk_types_js.Tool["annotations"];
|
|
207
|
-
inputDependencies: InputDependenciesValue<TInputDependencies>;
|
|
208
203
|
}
|
|
209
|
-
interface ToolDefinitionNone<TIn extends z.
|
|
204
|
+
interface ToolDefinitionNone<TIn extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TName extends string = string> extends ToolDefinitionBase<TIn, TOut, TName> {
|
|
210
205
|
readonly connection?: undefined;
|
|
211
206
|
readonly connections?: undefined;
|
|
212
207
|
run: (input: z.infer<TIn>, ctx?: ContextNone) => Promise<z.infer<TOut>>;
|
|
213
208
|
}
|
|
214
|
-
interface ToolDefinitionSingle<TIn extends z.
|
|
209
|
+
interface ToolDefinitionSingle<TIn extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TName extends string = string, TKey extends string = string> extends ToolDefinitionBase<TIn, TOut, TName> {
|
|
215
210
|
readonly connection: TKey;
|
|
216
211
|
readonly connections?: undefined;
|
|
217
212
|
run: (input: z.infer<TIn>, ctx: ContextSingle) => Promise<z.infer<TOut>>;
|
|
218
213
|
}
|
|
219
|
-
interface ToolDefinitionMulti<TIn extends z.
|
|
214
|
+
interface ToolDefinitionMulti<TIn extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TName extends string = string, TSlots extends string = string, TKey extends string = string> extends ToolDefinitionBase<TIn, TOut, TName> {
|
|
220
215
|
readonly connection?: undefined;
|
|
221
216
|
readonly connections: Record<TSlots, TKey>;
|
|
222
217
|
run: (input: z.infer<TIn>, ctx: ContextMulti<TSlots>) => Promise<z.infer<TOut>>;
|
|
223
218
|
}
|
|
224
|
-
type ToolDefinition<TIn extends z.
|
|
219
|
+
type ToolDefinition<TIn extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TName extends string = string, TSlots extends string = string, TKey extends string = string> = ToolDefinitionNone<TIn, TOut, TName> | ToolDefinitionSingle<TIn, TOut, TName, TKey> | ToolDefinitionMulti<TIn, TOut, TName, TSlots, TKey>;
|
|
225
220
|
/** Wide author-side `run` signature for polymorphic walks. */
|
|
226
221
|
type AnyToolDefinitionRun = (input: any, ctx?: any) => Promise<any>;
|
|
227
|
-
type AnyToolDefinition = Omit<ToolDefinitionBase<z.
|
|
228
|
-
inputDependencies: AnyInputDependencies$1 | undefined;
|
|
222
|
+
type AnyToolDefinition = Omit<ToolDefinitionBase<z.ZodObject<z.ZodRawShape>, z.ZodObject<z.ZodRawShape>, string>, "run"> & {
|
|
229
223
|
run: AnyToolDefinitionRun;
|
|
230
224
|
readonly connection?: string | undefined;
|
|
231
225
|
readonly connections?: Record<string, string> | undefined;
|
|
@@ -328,10 +322,9 @@ declare function toChatCompletionTool(definition: AnyToolDefinition): ChatComple
|
|
|
328
322
|
interface McpRegisterToolConfig {
|
|
329
323
|
title?: string;
|
|
330
324
|
description?: string;
|
|
331
|
-
inputSchema?: z.
|
|
332
|
-
outputSchema?: z.
|
|
325
|
+
inputSchema?: z.ZodObject<z.ZodRawShape>;
|
|
326
|
+
outputSchema?: z.ZodObject<z.ZodRawShape>;
|
|
333
327
|
annotations?: ToolAnnotations;
|
|
334
|
-
_meta?: Record<string, unknown>;
|
|
335
328
|
}
|
|
336
329
|
/**
|
|
337
330
|
* Build the `McpServer.registerTool` config for a `ToolDefinition`.
|
|
@@ -387,7 +380,7 @@ declare function toResponsesTool(definition: AnyToolDefinition): ResponsesFuncti
|
|
|
387
380
|
* consume the wrapped scripts unchanged.
|
|
388
381
|
*/
|
|
389
382
|
|
|
390
|
-
type AnyDef = ToolDefinition<any, any,
|
|
383
|
+
type AnyDef = ToolDefinition<any, any, string, string, string>;
|
|
391
384
|
/**
|
|
392
385
|
* Map a script's `ToolDefinition` to its consumer-facing wrapped form,
|
|
393
386
|
* narrowed against the connector's `connectionResolvers` map. The wrapped
|
|
@@ -395,11 +388,11 @@ type AnyDef = ToolDefinition<any, any, any, string, string, string>;
|
|
|
395
388
|
* `RunOptions.connections.<slot>` is narrowed per the slot's resolver
|
|
396
389
|
* array via `ConnectionValueFor`.
|
|
397
390
|
*/
|
|
398
|
-
type WrappedScript<D extends AnyDef, TResolvers extends ConnectionResolversMap> = D extends ToolDefinitionNone<infer TIn, infer TOut, infer
|
|
391
|
+
type WrappedScript<D extends AnyDef, TResolvers extends ConnectionResolversMap> = D extends ToolDefinitionNone<infer TIn, infer TOut, infer _TName> ? Omit<D, "run"> & {
|
|
399
392
|
run: (input: z.infer<TIn>, opts?: RunOptionsNone) => Promise<z.infer<TOut>>;
|
|
400
|
-
} : D extends ToolDefinitionSingle<infer TIn, infer TOut, infer
|
|
393
|
+
} : D extends ToolDefinitionSingle<infer TIn, infer TOut, infer _TName, infer TKey> ? Omit<D, "run"> & {
|
|
401
394
|
run: (input: z.infer<TIn>, opts: RunOptionsSingle<ConnectionValueForKey<TResolvers, TKey>>) => Promise<z.infer<TOut>>;
|
|
402
|
-
} : D extends ToolDefinitionMulti<infer TIn, infer TOut, infer
|
|
395
|
+
} : D extends ToolDefinitionMulti<infer TIn, infer TOut, infer _TName, infer TSlots, infer TKey> ? Omit<D, "run"> & {
|
|
403
396
|
run: (input: z.infer<TIn>, opts: {
|
|
404
397
|
connection?: never;
|
|
405
398
|
connections: {
|
|
@@ -456,10 +449,9 @@ declare function defineConnector<TScripts extends Record<string, AnyDef>, const
|
|
|
456
449
|
* to `run`. The returned definition mirrors the input one-to-one.
|
|
457
450
|
*/
|
|
458
451
|
|
|
459
|
-
|
|
460
|
-
declare function defineTool<TIn extends z.
|
|
461
|
-
declare function defineTool<TIn extends z.
|
|
462
|
-
declare function defineTool<TIn extends z.ZodType, TOut extends z.ZodType, TInputDependencies extends AnyInputDependencies | undefined = undefined, const TName extends string = string, const TSlots extends string = string, const TKey extends string = string>(config: DefineToolConfigMulti<TIn, TOut, TInputDependencies, TName, TSlots, TKey>): ToolDefinitionMulti<TIn, TOut, TInputDependencies, TName, TSlots, TKey>;
|
|
452
|
+
declare function defineTool<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, const TName extends string = string>(config: DefineToolConfigNone<TIn, TOut, TName>): ToolDefinitionNone<TIn, TOut, TName>;
|
|
453
|
+
declare function defineTool<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, const TName extends string = string, const TKey extends string = string>(config: DefineToolConfigSingle<TIn, TOut, TName, TKey>): ToolDefinitionSingle<TIn, TOut, TName, TKey>;
|
|
454
|
+
declare function defineTool<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, const TName extends string = string, const TSlots extends string = string, const TKey extends string = string>(config: DefineToolConfigMulti<TIn, TOut, TName, TSlots, TKey>): ToolDefinitionMulti<TIn, TOut, TName, TSlots, TKey>;
|
|
463
455
|
|
|
464
456
|
/**
|
|
465
457
|
* `handleIfScriptMain(meta, definition, opts?)` — per-script CLI execution
|
package/dist/index.d.ts
CHANGED
|
@@ -169,34 +169,30 @@ interface ContextMulti<TSlots extends string = string> {
|
|
|
169
169
|
fetch?: never;
|
|
170
170
|
connections: Record<TSlots, typeof globalThis.fetch>;
|
|
171
171
|
}
|
|
172
|
-
|
|
173
|
-
/** When authoring omits `inputDependencies`, the definition value is `undefined`. */
|
|
174
|
-
type InputDependenciesValue<T> = [T] extends [undefined] ? undefined : T;
|
|
175
|
-
interface DefineToolConfigBase<TIn extends z.ZodType, TOut extends z.ZodType, TInputDependencies extends AnyInputDependencies$1 | undefined, TName extends string> {
|
|
172
|
+
interface DefineToolConfigBase<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, TName extends string> {
|
|
176
173
|
name: TName;
|
|
177
174
|
title: string;
|
|
178
175
|
description: string;
|
|
179
176
|
inputSchema: TIn;
|
|
180
177
|
outputSchema: TOut;
|
|
181
178
|
annotations: _modelcontextprotocol_sdk_types_js.Tool["annotations"];
|
|
182
|
-
inputDependencies?: TInputDependencies;
|
|
183
179
|
}
|
|
184
|
-
interface DefineToolConfigNone<TIn extends z.
|
|
180
|
+
interface DefineToolConfigNone<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, TName extends string> extends DefineToolConfigBase<TIn, TOut, TName> {
|
|
185
181
|
connection?: never;
|
|
186
182
|
connections?: never;
|
|
187
183
|
run: (input: z.infer<TIn>, ctx?: ContextNone) => Promise<unknown>;
|
|
188
184
|
}
|
|
189
|
-
interface DefineToolConfigSingle<TIn extends z.
|
|
185
|
+
interface DefineToolConfigSingle<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, TName extends string, TKey extends string> extends DefineToolConfigBase<TIn, TOut, TName> {
|
|
190
186
|
connection: TKey;
|
|
191
187
|
connections?: never;
|
|
192
188
|
run: (input: z.infer<TIn>, ctx: ContextSingle) => Promise<unknown>;
|
|
193
189
|
}
|
|
194
|
-
interface DefineToolConfigMulti<TIn extends z.
|
|
190
|
+
interface DefineToolConfigMulti<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, TName extends string, TSlots extends string, TKey extends string> extends DefineToolConfigBase<TIn, TOut, TName> {
|
|
195
191
|
connection?: never;
|
|
196
192
|
connections: Record<TSlots, TKey>;
|
|
197
193
|
run: (input: z.infer<TIn>, ctx: ContextMulti<TSlots>) => Promise<unknown>;
|
|
198
194
|
}
|
|
199
|
-
interface ToolDefinitionBase<TIn extends z.
|
|
195
|
+
interface ToolDefinitionBase<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, TName extends string> {
|
|
200
196
|
readonly kind: "tool";
|
|
201
197
|
readonly name: TName;
|
|
202
198
|
readonly title: string;
|
|
@@ -204,28 +200,26 @@ interface ToolDefinitionBase<TIn extends z.ZodType, TOut extends z.ZodType, TInp
|
|
|
204
200
|
inputSchema: TIn;
|
|
205
201
|
outputSchema: TOut;
|
|
206
202
|
readonly annotations: _modelcontextprotocol_sdk_types_js.Tool["annotations"];
|
|
207
|
-
inputDependencies: InputDependenciesValue<TInputDependencies>;
|
|
208
203
|
}
|
|
209
|
-
interface ToolDefinitionNone<TIn extends z.
|
|
204
|
+
interface ToolDefinitionNone<TIn extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TName extends string = string> extends ToolDefinitionBase<TIn, TOut, TName> {
|
|
210
205
|
readonly connection?: undefined;
|
|
211
206
|
readonly connections?: undefined;
|
|
212
207
|
run: (input: z.infer<TIn>, ctx?: ContextNone) => Promise<z.infer<TOut>>;
|
|
213
208
|
}
|
|
214
|
-
interface ToolDefinitionSingle<TIn extends z.
|
|
209
|
+
interface ToolDefinitionSingle<TIn extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TName extends string = string, TKey extends string = string> extends ToolDefinitionBase<TIn, TOut, TName> {
|
|
215
210
|
readonly connection: TKey;
|
|
216
211
|
readonly connections?: undefined;
|
|
217
212
|
run: (input: z.infer<TIn>, ctx: ContextSingle) => Promise<z.infer<TOut>>;
|
|
218
213
|
}
|
|
219
|
-
interface ToolDefinitionMulti<TIn extends z.
|
|
214
|
+
interface ToolDefinitionMulti<TIn extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TName extends string = string, TSlots extends string = string, TKey extends string = string> extends ToolDefinitionBase<TIn, TOut, TName> {
|
|
220
215
|
readonly connection?: undefined;
|
|
221
216
|
readonly connections: Record<TSlots, TKey>;
|
|
222
217
|
run: (input: z.infer<TIn>, ctx: ContextMulti<TSlots>) => Promise<z.infer<TOut>>;
|
|
223
218
|
}
|
|
224
|
-
type ToolDefinition<TIn extends z.
|
|
219
|
+
type ToolDefinition<TIn extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TName extends string = string, TSlots extends string = string, TKey extends string = string> = ToolDefinitionNone<TIn, TOut, TName> | ToolDefinitionSingle<TIn, TOut, TName, TKey> | ToolDefinitionMulti<TIn, TOut, TName, TSlots, TKey>;
|
|
225
220
|
/** Wide author-side `run` signature for polymorphic walks. */
|
|
226
221
|
type AnyToolDefinitionRun = (input: any, ctx?: any) => Promise<any>;
|
|
227
|
-
type AnyToolDefinition = Omit<ToolDefinitionBase<z.
|
|
228
|
-
inputDependencies: AnyInputDependencies$1 | undefined;
|
|
222
|
+
type AnyToolDefinition = Omit<ToolDefinitionBase<z.ZodObject<z.ZodRawShape>, z.ZodObject<z.ZodRawShape>, string>, "run"> & {
|
|
229
223
|
run: AnyToolDefinitionRun;
|
|
230
224
|
readonly connection?: string | undefined;
|
|
231
225
|
readonly connections?: Record<string, string> | undefined;
|
|
@@ -328,10 +322,9 @@ declare function toChatCompletionTool(definition: AnyToolDefinition): ChatComple
|
|
|
328
322
|
interface McpRegisterToolConfig {
|
|
329
323
|
title?: string;
|
|
330
324
|
description?: string;
|
|
331
|
-
inputSchema?: z.
|
|
332
|
-
outputSchema?: z.
|
|
325
|
+
inputSchema?: z.ZodObject<z.ZodRawShape>;
|
|
326
|
+
outputSchema?: z.ZodObject<z.ZodRawShape>;
|
|
333
327
|
annotations?: ToolAnnotations;
|
|
334
|
-
_meta?: Record<string, unknown>;
|
|
335
328
|
}
|
|
336
329
|
/**
|
|
337
330
|
* Build the `McpServer.registerTool` config for a `ToolDefinition`.
|
|
@@ -387,7 +380,7 @@ declare function toResponsesTool(definition: AnyToolDefinition): ResponsesFuncti
|
|
|
387
380
|
* consume the wrapped scripts unchanged.
|
|
388
381
|
*/
|
|
389
382
|
|
|
390
|
-
type AnyDef = ToolDefinition<any, any,
|
|
383
|
+
type AnyDef = ToolDefinition<any, any, string, string, string>;
|
|
391
384
|
/**
|
|
392
385
|
* Map a script's `ToolDefinition` to its consumer-facing wrapped form,
|
|
393
386
|
* narrowed against the connector's `connectionResolvers` map. The wrapped
|
|
@@ -395,11 +388,11 @@ type AnyDef = ToolDefinition<any, any, any, string, string, string>;
|
|
|
395
388
|
* `RunOptions.connections.<slot>` is narrowed per the slot's resolver
|
|
396
389
|
* array via `ConnectionValueFor`.
|
|
397
390
|
*/
|
|
398
|
-
type WrappedScript<D extends AnyDef, TResolvers extends ConnectionResolversMap> = D extends ToolDefinitionNone<infer TIn, infer TOut, infer
|
|
391
|
+
type WrappedScript<D extends AnyDef, TResolvers extends ConnectionResolversMap> = D extends ToolDefinitionNone<infer TIn, infer TOut, infer _TName> ? Omit<D, "run"> & {
|
|
399
392
|
run: (input: z.infer<TIn>, opts?: RunOptionsNone) => Promise<z.infer<TOut>>;
|
|
400
|
-
} : D extends ToolDefinitionSingle<infer TIn, infer TOut, infer
|
|
393
|
+
} : D extends ToolDefinitionSingle<infer TIn, infer TOut, infer _TName, infer TKey> ? Omit<D, "run"> & {
|
|
401
394
|
run: (input: z.infer<TIn>, opts: RunOptionsSingle<ConnectionValueForKey<TResolvers, TKey>>) => Promise<z.infer<TOut>>;
|
|
402
|
-
} : D extends ToolDefinitionMulti<infer TIn, infer TOut, infer
|
|
395
|
+
} : D extends ToolDefinitionMulti<infer TIn, infer TOut, infer _TName, infer TSlots, infer TKey> ? Omit<D, "run"> & {
|
|
403
396
|
run: (input: z.infer<TIn>, opts: {
|
|
404
397
|
connection?: never;
|
|
405
398
|
connections: {
|
|
@@ -456,10 +449,9 @@ declare function defineConnector<TScripts extends Record<string, AnyDef>, const
|
|
|
456
449
|
* to `run`. The returned definition mirrors the input one-to-one.
|
|
457
450
|
*/
|
|
458
451
|
|
|
459
|
-
|
|
460
|
-
declare function defineTool<TIn extends z.
|
|
461
|
-
declare function defineTool<TIn extends z.
|
|
462
|
-
declare function defineTool<TIn extends z.ZodType, TOut extends z.ZodType, TInputDependencies extends AnyInputDependencies | undefined = undefined, const TName extends string = string, const TSlots extends string = string, const TKey extends string = string>(config: DefineToolConfigMulti<TIn, TOut, TInputDependencies, TName, TSlots, TKey>): ToolDefinitionMulti<TIn, TOut, TInputDependencies, TName, TSlots, TKey>;
|
|
452
|
+
declare function defineTool<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, const TName extends string = string>(config: DefineToolConfigNone<TIn, TOut, TName>): ToolDefinitionNone<TIn, TOut, TName>;
|
|
453
|
+
declare function defineTool<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, const TName extends string = string, const TKey extends string = string>(config: DefineToolConfigSingle<TIn, TOut, TName, TKey>): ToolDefinitionSingle<TIn, TOut, TName, TKey>;
|
|
454
|
+
declare function defineTool<TIn extends z.ZodObject<z.ZodRawShape>, TOut extends z.ZodObject<z.ZodRawShape>, const TName extends string = string, const TSlots extends string = string, const TKey extends string = string>(config: DefineToolConfigMulti<TIn, TOut, TName, TSlots, TKey>): ToolDefinitionMulti<TIn, TOut, TName, TSlots, TKey>;
|
|
463
455
|
|
|
464
456
|
/**
|
|
465
457
|
* `handleIfScriptMain(meta, definition, opts?)` — per-script CLI execution
|
package/dist/index.js
CHANGED
|
@@ -422,28 +422,18 @@ function toChatCompletionTool(definition) {
|
|
|
422
422
|
|
|
423
423
|
// src/surfaces/to-mcp-server-tool.ts
|
|
424
424
|
function toMcpServerTool(definition) {
|
|
425
|
-
|
|
425
|
+
return {
|
|
426
426
|
title: definition.title,
|
|
427
427
|
description: definition.description,
|
|
428
428
|
inputSchema: definition.inputSchema,
|
|
429
429
|
outputSchema: definition.outputSchema,
|
|
430
430
|
annotations: definition.annotations
|
|
431
431
|
};
|
|
432
|
-
if (definition.inputDependencies) {
|
|
433
|
-
config._meta = {
|
|
434
|
-
"zapier:inputDependencies": definition.inputDependencies
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
return config;
|
|
438
432
|
}
|
|
439
433
|
|
|
440
434
|
// src/surfaces/to-mcp-tool.ts
|
|
441
435
|
import { z as z2 } from "zod";
|
|
442
436
|
function toMcpTool(definition) {
|
|
443
|
-
const meta = {};
|
|
444
|
-
if (definition.inputDependencies) {
|
|
445
|
-
meta["zapier:inputDependencies"] = definition.inputDependencies;
|
|
446
|
-
}
|
|
447
437
|
return {
|
|
448
438
|
name: definition.name,
|
|
449
439
|
title: definition.title,
|
|
@@ -452,8 +442,7 @@ function toMcpTool(definition) {
|
|
|
452
442
|
outputSchema: z2.toJSONSchema(
|
|
453
443
|
definition.outputSchema
|
|
454
444
|
),
|
|
455
|
-
annotations: definition.annotations
|
|
456
|
-
...Object.keys(meta).length > 0 ? { _meta: meta } : {}
|
|
445
|
+
annotations: definition.annotations
|
|
457
446
|
};
|
|
458
447
|
}
|
|
459
448
|
|
|
@@ -562,7 +551,6 @@ function defineTool(config) {
|
|
|
562
551
|
inputSchema: config.inputSchema,
|
|
563
552
|
outputSchema: config.outputSchema,
|
|
564
553
|
annotations: config.annotations,
|
|
565
|
-
inputDependencies: config.inputDependencies,
|
|
566
554
|
run: wrappedRun
|
|
567
555
|
};
|
|
568
556
|
if (hasSingular) base.connection = config.connection;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/connectors-sdk",
|
|
3
|
-
"version": "0.1.0-experimental.
|
|
3
|
+
"version": "0.1.0-experimental.8",
|
|
4
4
|
"description": "SDK for building Zapier connectors. Provides the authoring primitives and execution surfaces for connector scripts.",
|
|
5
5
|
"license": "Elastic-2.0",
|
|
6
6
|
"type": "module",
|