@zapier/zapier-sdk-mcp 0.12.1 โ†’ 0.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @zapier/zapier-sdk-mcp
2
2
 
3
+ ## 0.13.1
4
+
5
+ ### Patch Changes
6
+
7
+ - cd8f37b: Collapse the approval-flow surface into a single tri-state `approvalMode` option.
8
+
9
+ What changed:
10
+ - `approvalMode` is now `"disabled" | "poll" | "throw"` (was `"poll" | "fail"`).
11
+ - `"disabled"` is the default. While the approval flow is alpha, callers must opt in explicitly via `approvalMode: "poll"` or `approvalMode: "throw"` (or the `ZAPIER_APPROVAL_MODE` env var). On an approval-required response, `"disabled"` throws a `ZapierApprovalError` with `status: "approval_required"` without creating an approval.
12
+ - The `isInteractive` SDK option and the `ZAPIER_IS_INTERACTIVE` env var have been removed. Their role is subsumed by `approvalMode`: choosing `"poll"` / `"throw"` is the explicit opt-in that previously required `isInteractive: true`.
13
+ - `"fail"` has been renamed to `"throw"` (both the option value and the `ZAPIER_APPROVAL_MODE` env var value). The behavior is unchanged: throw a `ZapierApprovalError` carrying the approval URL so the caller can surface it.
14
+ - `approvalMode`, `approvalTimeoutMs`, and `maxApprovalRetries` are now part of the public API (no longer marked `internal: true`).
15
+
16
+ There is no back-compat shim. `approvalMode: "fail"` and `isInteractive: <anything>` will fail Zod validation up front.
17
+
18
+ - Updated dependencies [cd8f37b]
19
+ - @zapier/zapier-sdk@0.50.0
20
+
21
+ ## 0.13.0
22
+
23
+ ### Minor Changes
24
+
25
+ - 529663c: Add experimental support for triggers.
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [529663c]
30
+ - @zapier/zapier-sdk@0.49.0
31
+
3
32
  ## 0.12.1
4
33
 
5
34
  ### Patch Changes
package/README.md CHANGED
@@ -123,10 +123,10 @@ pnpm test
123
123
  - [`get-profile`](#get-profile)
124
124
  - [Actions](#actions)
125
125
  - [`get-action`](#get-action)
126
- - [`get-input-fields-schema`](#get-input-fields-schema)
126
+ - [`get-action-input-fields-schema`](#get-action-input-fields-schema)
127
+ - [`list-action-input-field-choices`](#list-action-input-field-choices)
128
+ - [`list-action-input-fields`](#list-action-input-fields)
127
129
  - [`list-actions`](#list-actions)
128
- - [`list-input-field-choices`](#list-input-field-choices)
129
- - [`list-input-fields`](#list-input-fields)
130
130
  - [`run-action`](#run-action)
131
131
  - [Apps](#apps)
132
132
  - [`get-app`](#get-app)
@@ -155,6 +155,22 @@ pnpm test
155
155
  - [`list-table-records`](#list-table-records)
156
156
  - [`list-tables`](#list-tables)
157
157
  - [`update-table-records`](#update-table-records)
158
+ - [Triggers (Experimental)](#triggers-experimental)
159
+ - [`ack-trigger-inbox-messages`](#ack-trigger-inbox-messages--experimental)
160
+ - [`create-trigger-inbox`](#create-trigger-inbox--experimental)
161
+ - [`delete-trigger-inbox`](#delete-trigger-inbox--experimental)
162
+ - [`ensure-trigger-inbox`](#ensure-trigger-inbox--experimental)
163
+ - [`get-trigger-inbox`](#get-trigger-inbox--experimental)
164
+ - [`get-trigger-input-fields-schema`](#get-trigger-input-fields-schema--experimental)
165
+ - [`lease-trigger-inbox-messages`](#lease-trigger-inbox-messages--experimental)
166
+ - [`list-trigger-inbox-messages`](#list-trigger-inbox-messages--experimental)
167
+ - [`list-trigger-inboxes`](#list-trigger-inboxes--experimental)
168
+ - [`list-trigger-input-field-choices`](#list-trigger-input-field-choices--experimental)
169
+ - [`list-trigger-input-fields`](#list-trigger-input-fields--experimental)
170
+ - [`pause-trigger-inbox`](#pause-trigger-inbox--experimental)
171
+ - [`release-trigger-inbox-messages`](#release-trigger-inbox-messages--experimental)
172
+ - [`resume-trigger-inbox`](#resume-trigger-inbox--experimental)
173
+ - [`update-trigger-inbox`](#update-trigger-inbox--experimental)
158
174
 
159
175
  ## Available Tools
160
176
 
@@ -172,22 +188,22 @@ Get current user's profile information
172
188
 
173
189
  Get detailed information about a specific action
174
190
 
175
- #### `get-input-fields-schema`
191
+ #### `get-action-input-fields-schema`
176
192
 
177
193
  Get the JSON Schema representation of input fields for an action. Returns a JSON Schema object describing the structure, types, and validation rules for the action's input parameters.
178
194
 
179
- #### `list-actions`
180
-
181
- List all actions for a specific app
182
-
183
- #### `list-input-field-choices`
195
+ #### `list-action-input-field-choices`
184
196
 
185
197
  Get the available choices for a dynamic dropdown input field
186
198
 
187
- #### `list-input-fields`
199
+ #### `list-action-input-fields`
188
200
 
189
201
  Get the input fields required for a specific action
190
202
 
203
+ #### `list-actions`
204
+
205
+ List all actions for a specific app
206
+
191
207
  #### `run-action`
192
208
 
193
209
  Execute an action with the given inputs
@@ -289,3 +305,67 @@ List tables available to the authenticated user
289
305
  #### `update-table-records`
290
306
 
291
307
  Update one or more records in a table
308
+
309
+ ### Triggers (Experimental)
310
+
311
+ > Experimental. Start the MCP server via `zapier-sdk-experimental mcp` (or pass `--experimental` to `zapier-sdk mcp`). Tools and behavior may change, and availability may be limited to some users.
312
+
313
+ #### `ack-trigger-inbox-messages` ๐Ÿงช _experimental_
314
+
315
+ Acknowledge messages from a lease. Acked messages are removed from the inbox; unacked ones return to the available pool when the lease expires.
316
+
317
+ #### `create-trigger-inbox` ๐Ÿงช _experimental_
318
+
319
+ Create a new trigger inbox subscription with an auto-generated name. Always creates; use ensureTriggerInbox for get-or-create on a stable name.
320
+
321
+ #### `delete-trigger-inbox` ๐Ÿงช _experimental_
322
+
323
+ Mark a trigger inbox for deletion
324
+
325
+ #### `ensure-trigger-inbox` ๐Ÿงช _experimental_
326
+
327
+ Get-or-create a trigger inbox by name. Idempotent on (user, account, name): returns the existing inbox if a matching subscription is registered, creates a new one otherwise. Throws ZapierConflictError if the name exists with a different subscription.
328
+
329
+ #### `get-trigger-inbox` ๐Ÿงช _experimental_
330
+
331
+ Get details of a trigger inbox by ID
332
+
333
+ #### `get-trigger-input-fields-schema` ๐Ÿงช _experimental_
334
+
335
+ Get the JSON Schema representation of input fields for a trigger. Returns a JSON Schema object describing the structure, types, and validation rules for the trigger's input parameters.
336
+
337
+ #### `lease-trigger-inbox-messages` ๐Ÿงช _experimental_
338
+
339
+ Lease up to N messages from a trigger inbox. Returns messages plus a lease ID; ack within the lease window to remove from the inbox.
340
+
341
+ #### `list-trigger-inbox-messages` ๐Ÿงช _experimental_
342
+
343
+ List messages in a trigger inbox (no payload, status-only)
344
+
345
+ #### `list-trigger-inboxes` ๐Ÿงช _experimental_
346
+
347
+ List all trigger inboxes for the authenticated user
348
+
349
+ #### `list-trigger-input-field-choices` ๐Ÿงช _experimental_
350
+
351
+ Get the available choices for a dynamic dropdown input field on a trigger
352
+
353
+ #### `list-trigger-input-fields` ๐Ÿงช _experimental_
354
+
355
+ Get the input fields required for a specific trigger
356
+
357
+ #### `pause-trigger-inbox` ๐Ÿงช _experimental_
358
+
359
+ Pause a trigger inbox; events stop being collected
360
+
361
+ #### `release-trigger-inbox-messages` ๐Ÿงช _experimental_
362
+
363
+ Release messages from a lease back to the inbox without acknowledging them. Released messages become immediately available for re-leasing. The lease attempt still counts against the per-message lease limit; releasing does not refund the attempt.
364
+
365
+ #### `resume-trigger-inbox` ๐Ÿงช _experimental_
366
+
367
+ Resume a paused trigger inbox; events resume being collected
368
+
369
+ #### `update-trigger-inbox` ๐Ÿงช _experimental_
370
+
371
+ Update settings on an existing trigger inbox
package/dist/index.d.mts CHANGED
@@ -10,6 +10,13 @@ interface ZapierMcpServerOptions {
10
10
  * the server then uses a vanilla public SDK.
11
11
  */
12
12
  extensions?: Plugin<unknown, PluginProvides>[];
13
+ /**
14
+ * Build the server against `@zapier/zapier-sdk/experimental` instead of
15
+ * the stable surface, so experimental plugins (e.g. trigger inboxes)
16
+ * appear as MCP tools. Mirrors the CLI's `--experimental` opt-in: a
17
+ * default invocation only ever sees stable plugins.
18
+ */
19
+ experimental?: boolean;
13
20
  }
14
21
  /**
15
22
  * Creates an MCP server that exposes Zapier SDK functions as MCP tools.
@@ -29,7 +36,7 @@ interface ZapierMcpServerOptions {
29
36
  * await server.connect(transport);
30
37
  * ```
31
38
  */
32
- declare function createZapierMcpServer({ debug, extensions, }?: ZapierMcpServerOptions): Server<{
39
+ declare function createZapierMcpServer({ debug, extensions, experimental, }?: ZapierMcpServerOptions): Server<{
33
40
  method: string;
34
41
  params?: {
35
42
  [x: string]: unknown;
package/dist/index.mjs CHANGED
@@ -6,9 +6,10 @@ import {
6
6
  ListToolsRequestSchema
7
7
  } from "@modelcontextprotocol/sdk/types.js";
8
8
  import {
9
- createZapierSdk,
9
+ createZapierSdk as createStableSdk,
10
10
  ZapierApprovalError
11
11
  } from "@zapier/zapier-sdk";
12
+ import { createZapierSdk as createExperimentalSdk } from "@zapier/zapier-sdk/experimental";
12
13
 
13
14
  // src/utils/schema-converter.ts
14
15
  function getZodDef(schema) {
@@ -224,7 +225,7 @@ function convertZodType(def, schema) {
224
225
  // package.json
225
226
  var package_default = {
226
227
  name: "@zapier/zapier-sdk-mcp",
227
- version: "0.12.1",
228
+ version: "0.13.1",
228
229
  description: "MCP server for Zapier SDK",
229
230
  main: "dist/index.mjs",
230
231
  types: "dist/index.d.mts",
@@ -356,14 +357,15 @@ function reconstructMcpPositionalArgs(inputParameters, flatArgs) {
356
357
  }
357
358
  function createZapierMcpServer({
358
359
  debug = false,
359
- extensions = []
360
+ extensions = [],
361
+ experimental = false
360
362
  } = {}) {
363
+ const createZapierSdk = experimental ? createExperimentalSdk : createStableSdk;
361
364
  let zapierSdk = createZapierSdk({
362
365
  debug,
363
366
  eventEmission: { callContext: "mcp" },
364
367
  callerPackage: { name: package_default.name, version: package_default.version },
365
- isInteractive: true,
366
- approvalMode: "fail"
368
+ approvalMode: "throw"
367
369
  });
368
370
  for (const ext of extensions) {
369
371
  try {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils/schema-converter.ts","../package.json"],"sourcesContent":["import { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n createZapierSdk,\n ZapierApprovalError,\n type ZapierSdk,\n type FunctionRegistryEntry,\n type Plugin,\n type PluginProvides,\n} from \"@zapier/zapier-sdk\";\nimport { convertZodToMcpSchema } from \"./utils/schema-converter.js\";\nimport packageJson from \"../package.json\" with { type: \"json\" };\n\nimport type { z } from \"zod\";\n\ninterface ZapierMcpServerOptions {\n debug?: boolean;\n /**\n * Extra plugins to layer onto the SDK before exposing it as MCP tools.\n * Used by the CLI's `mcp` command to forward extensions discovered via\n * the `ZAPIER_SDK_EXTENSIONS` env var. Standalone callers can omit this;\n * the server then uses a vanilla public SDK.\n */\n extensions?: Plugin<unknown, PluginProvides>[];\n}\n\ninterface ZodSchemaWithShape extends z.ZodSchema {\n shape?: Record<string, z.ZodSchema>;\n}\n\n/**\n * Build a flat MCP-compatible JSON schema from inputParameters.\n * Simple-type params become required top-level properties; object-type params\n * have their properties flattened into the top level.\n */\nfunction convertInputParametersToMcpSchema(\n inputParameters: Array<{ name: string; schema: z.ZodSchema }>,\n): Record<string, unknown> {\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const param of inputParameters) {\n let schema = param.schema;\n let isOptional = false;\n\n const optionalDef = (\n schema as unknown as {\n _zod?: { def?: { type?: string; innerType?: z.ZodSchema } };\n }\n )._zod?.def;\n\n if (optionalDef?.type === \"optional\" && optionalDef.innerType) {\n isOptional = true;\n schema = optionalDef.innerType;\n }\n\n const objectDef = (\n schema as unknown as { _zod?: { def?: { type?: string } } }\n )._zod?.def;\n\n if (objectDef?.type === \"object\") {\n const schemaWithShape = schema as ZodSchemaWithShape;\n if (schemaWithShape.shape) {\n for (const [key, fieldSchema] of Object.entries(\n schemaWithShape.shape,\n )) {\n properties[key] = convertZodToMcpSchema(fieldSchema);\n const fieldDef = (\n fieldSchema as unknown as {\n _zod?: { def?: { type?: string } };\n }\n )._zod?.def;\n if (\n !isOptional &&\n fieldDef?.type !== \"optional\" &&\n fieldDef?.type !== \"nullable\"\n ) {\n required.push(key);\n }\n }\n }\n } else {\n properties[param.name] = convertZodToMcpSchema(param.schema);\n if (!isOptional) {\n required.push(param.name);\n }\n }\n }\n\n const result: Record<string, unknown> = {\n type: \"object\",\n properties,\n };\n if (required.length > 0) {\n result.required = required;\n }\n return result;\n}\n\n/**\n * Reconstruct positional arguments for SDK invocation from a flat args object.\n * Mirrors the CLI's reconstructPositionalArgs for MCP tool calls.\n */\nfunction reconstructMcpPositionalArgs(\n inputParameters: Array<{ name: string; schema: z.ZodSchema }>,\n flatArgs: Record<string, unknown>,\n): unknown[] {\n const args: unknown[] = [];\n\n for (const param of inputParameters) {\n let schema = param.schema;\n\n const optionalDef = (\n schema as unknown as {\n _zod?: { def?: { type?: string; innerType?: z.ZodSchema } };\n }\n )._zod?.def;\n\n if (optionalDef?.type === \"optional\" && optionalDef.innerType) {\n schema = optionalDef.innerType;\n }\n\n const objectDef = (\n schema as unknown as { _zod?: { def?: { type?: string } } }\n )._zod?.def;\n\n if (objectDef?.type === \"object\") {\n const schemaWithShape = schema as ZodSchemaWithShape;\n if (schemaWithShape.shape) {\n const obj: Record<string, unknown> = {};\n let hasValues = false;\n for (const key of Object.keys(schemaWithShape.shape)) {\n if (key in flatArgs && flatArgs[key] !== undefined) {\n obj[key] = flatArgs[key];\n hasValues = true;\n }\n }\n args.push(hasValues ? obj : undefined);\n } else {\n args.push(undefined);\n }\n } else {\n args.push(flatArgs[param.name]);\n }\n }\n\n return args;\n}\n\n/**\n * Creates an MCP server that exposes Zapier SDK functions as MCP tools.\n *\n * The server automatically discovers all available SDK functions and converts\n * their Zod schemas to MCP-compatible JSON schemas. It handles tool execution\n * by validating inputs and calling the appropriate SDK functions.\n *\n * @param options - Configuration options for the MCP server\n * @param options.debug - Enable debug logging for detailed error information\n * @returns An MCP server instance configured to expose Zapier SDK tools\n *\n * @example\n * ```typescript\n * const server = createZapierMcpServer({ debug: true });\n * const transport = new StdioServerTransport();\n * await server.connect(transport);\n * ```\n */\nfunction createZapierMcpServer({\n debug = false,\n extensions = [],\n}: ZapierMcpServerOptions = {}) {\n // Create Zapier SDK instance\n let zapierSdk: ZapierSdk = createZapierSdk({\n debug,\n eventEmission: { callContext: \"mcp\" },\n callerPackage: { name: packageJson.name, version: packageJson.version },\n isInteractive: true,\n approvalMode: \"fail\",\n });\n\n // Layer extension plugins on top of the vanilla SDK so their methods show\n // up in `getRegistry({ package: \"mcp\" })` alongside the public surface.\n // Same robustness contract as the CLI: a broken extension warns and\n // skips rather than killing the MCP server.\n for (const ext of extensions) {\n try {\n zapierSdk = zapierSdk.addPlugin(ext) as typeof zapierSdk;\n } catch (err) {\n console.warn(\n `Extension plugin failed to construct: ${(err as Error).message}; skipping.`,\n );\n }\n }\n\n // Create MCP server\n const server = new Server(\n {\n name: \"zapier-sdk\",\n version: \"1.0.0\",\n },\n {\n capabilities: {\n tools: {},\n },\n },\n );\n\n // Register list_tools handler - dynamically list all SDK functions as tools\n server.setRequestHandler(ListToolsRequestSchema, async () => {\n const tools = zapierSdk\n .getRegistry({ package: \"mcp\" })\n .functions.map((functionInfo: FunctionRegistryEntry) => {\n const toolName = functionInfo.name\n .replace(/([A-Z])/g, \"-$1\")\n .toLowerCase();\n\n const description =\n functionInfo.description ||\n functionInfo.inputSchema?.description ||\n `Execute ${functionInfo.name}`;\n\n if (functionInfo.inputSchema) {\n return {\n name: toolName,\n description,\n inputSchema: convertZodToMcpSchema(functionInfo.inputSchema),\n };\n }\n\n // Build a synthetic MCP schema from inputParameters\n return {\n name: toolName,\n description,\n inputSchema: convertInputParametersToMcpSchema(\n functionInfo.inputParameters!,\n ),\n };\n });\n\n return { tools };\n });\n\n // Register call_tool handler - execute SDK functions\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n // Convert kebab-case tool name back to camelCase function name\n const functionName = name.replace(/-([a-z])/g, (_, letter) =>\n letter.toUpperCase(),\n );\n\n // Find the function info\n const functionInfo: FunctionRegistryEntry | undefined = zapierSdk\n .getRegistry({ package: \"mcp\" })\n .functions.find(\n (info: FunctionRegistryEntry) => info.name === functionName,\n );\n\n if (!functionInfo) {\n const availableTools = zapierSdk\n .getRegistry({ package: \"mcp\" })\n .functions.map((info) =>\n info.name.replace(/([A-Z])/g, \"-$1\").toLowerCase(),\n )\n .join(\", \");\n throw new Error(\n `Unknown tool: ${name}. Available tools: ${availableTools}`,\n );\n }\n\n try {\n let result: unknown;\n\n if (functionInfo.inputSchema) {\n // Standard single-object-parameter function\n const validatedArgs = functionInfo.inputSchema.parse(args || {});\n const sdkFn = (\n zapierSdk as unknown as Record<\n string,\n (...args: unknown[]) => Promise<unknown>\n >\n )[functionInfo.name];\n result = await sdkFn(validatedArgs);\n } else if (functionInfo.inputParameters) {\n // Multi-parameter function (e.g. fetch) โ€” reconstruct positional args from flat object\n const flatArgs = (args || {}) as Record<string, unknown>;\n const positionalArgs = reconstructMcpPositionalArgs(\n functionInfo.inputParameters,\n flatArgs,\n );\n const sdkFn = (\n zapierSdk as unknown as Record<\n string,\n (...args: unknown[]) => Promise<unknown>\n >\n )[functionInfo.name];\n result = await sdkFn(...positionalArgs);\n } else {\n const sdkFn = (\n zapierSdk as unknown as Record<\n string,\n (...args: unknown[]) => Promise<unknown>\n >\n )[functionInfo.name];\n result = await sdkFn();\n }\n\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n } catch (error) {\n if (debug) {\n console.error(\n `Error executing function '${functionInfo.name}' (tool: ${name}):`,\n error,\n );\n }\n\n if (error instanceof ZapierApprovalError) {\n switch (error.approvalStatus) {\n // Pending approval: return the URL so the LLM can instruct the user\n case \"pending\":\n return {\n content: [\n {\n type: \"text\",\n text: `This action requires approval. The end user must open this link in their browser to approve this action, then retry this tool call:\\n\\n${error.approvalUrl}`,\n },\n ],\n isError: false,\n };\n // Policy denied: hard deny, cannot be approved\n case \"policy_denied\":\n return {\n content: [\n {\n type: \"text\",\n text: `This action was denied by policy and cannot be approved:\\n\\n${error.message}`,\n },\n ],\n isError: true,\n };\n }\n }\n\n let errorMessage: string;\n let isValidationError = false;\n\n if (error instanceof Error) {\n // Check if it's a Zod validation error\n if (error.name === \"ZodError\") {\n isValidationError = true;\n errorMessage = `Validation error for ${functionInfo.name}: ${error.message}`;\n } else {\n errorMessage = `Error in ${functionInfo.name}: ${error.message}`;\n }\n } else {\n errorMessage = `Unexpected error in ${functionInfo.name}: ${String(error)}`;\n }\n\n const errorSchema = functionInfo.inputSchema\n ? convertZodToMcpSchema(functionInfo.inputSchema)\n : functionInfo.inputParameters\n ? convertInputParametersToMcpSchema(functionInfo.inputParameters)\n : {};\n\n return {\n content: [\n {\n type: \"text\",\n text: isValidationError\n ? `${errorMessage}\\n\\nExpected input format:\\n${JSON.stringify(errorSchema, null, 2)}`\n : errorMessage,\n },\n ],\n isError: true,\n };\n }\n });\n\n return server;\n}\n\n/**\n * Starts an MCP server with stdio transport for CLI usage.\n *\n * This is the main entry point when running the MCP server from the command line.\n * It creates the server and connects it using stdio transport for communication\n * with MCP clients like Claude Code.\n *\n * @param options - Configuration options for the MCP server\n * @param options.debug - Enable debug logging for detailed error information\n *\n * @example\n * ```typescript\n * // Start server with debug logging\n * await startMcpServer({ debug: true });\n * ```\n */\nasync function startMcpServer(\n options: ZapierMcpServerOptions = {},\n): Promise<void> {\n const server = createZapierMcpServer(options);\n const transport = new StdioServerTransport();\n\n return new Promise<void>((resolve) => {\n let isShuttingDown = false;\n\n const cleanup = async () => {\n if (isShuttingDown) return;\n isShuttingDown = true;\n\n try {\n await server.close();\n } finally {\n resolve();\n }\n };\n\n // Handle clean shutdown when client closes connection\n server.onclose = () => {\n cleanup();\n };\n\n // Handle termination signals (Ctrl+C, kill, etc.)\n // Using process.once() to prevent handler accumulation\n process.once(\"SIGINT\", cleanup);\n process.once(\"SIGTERM\", cleanup);\n\n server.connect(transport).catch((error) => {\n console.error(\"Failed to start MCP server:\", error);\n process.exit(1);\n });\n });\n}\n\nexport { createZapierMcpServer, startMcpServer };\n","/**\n * A robust schema converter that handles conversion from Zod schemas to JSON Schema format:\n *\n * **Core Types:**\n * - โœ… Objects, arrays, strings, numbers, booleans\n * - โœ… Enums, unions, intersections, literals\n * - โœ… Optional and nullable fields\n * - โœ… Records and dates\n * - โœ… Nested schemas and complex types\n *\n * **Additional Types:**\n * - โœ… Any, unknown, bigint, null, undefined, void, NaN\n * - โœ… Default values and catch handlers (unwrapped to inner type)\n * - โœ… Graceful fallback for unsupported types\n */\n\nimport type { z } from \"zod\";\n\ninterface McpSchema {\n type?: string | string[];\n properties?: Record<string, McpSchema>;\n required?: string[];\n description?: string;\n items?: McpSchema;\n enum?: unknown[];\n anyOf?: McpSchema[];\n oneOf?: McpSchema[];\n allOf?: McpSchema[];\n additionalProperties?: McpSchema | boolean;\n format?: string;\n}\n\n// Zod internal definition structure\ninterface ZodDef {\n type: string; // e.g., \"string\", \"number\", \"object\", \"optional\", etc.\n element?: z.ZodSchema; // For arrays\n innerType?: z.ZodSchema; // For optional, nullable, default, catch\n entries?: Record<string, string>; // For enums\n values?: unknown[]; // For literals\n options?: z.ZodSchema[]; // For unions\n left?: z.ZodSchema; // For intersections\n right?: z.ZodSchema; // For intersections\n keyType?: z.ZodSchema; // For records (key type)\n valueType?: z.ZodSchema; // For records (value type)\n shape?: Record<string, z.ZodSchema>; // For objects (function in some cases)\n}\n\n// Zod schema with description (description is on the schema, not the def)\ninterface ZodSchemaWithDescription extends z.ZodSchema {\n description?: string;\n}\n\ninterface ZodSchemaWithShape extends z.ZodSchema {\n shape?: Record<string, z.ZodSchema>;\n}\n\n/**\n * Gets the Zod def from a schema, with fallback for edge cases\n */\nfunction getZodDef(schema: z.ZodSchema): ZodDef | undefined {\n const schemaAny = schema as unknown as { _zod?: { def?: ZodDef } };\n return schemaAny._zod?.def;\n}\n\n/**\n * Gets the description from a Zod schema (description is on the schema object, not the def)\n */\nfunction getDescription(schema?: z.ZodSchema): string | undefined {\n if (!schema) return undefined;\n return (schema as ZodSchemaWithDescription).description;\n}\n\n/**\n * Converts a Zod schema to MCP-compatible JSON Schema format.\n *\n * This function handles the conversion of Zod validation schemas (used internally\n * by the Zapier SDK) to JSON Schema format required by the MCP protocol. It supports\n * most common Zod types including objects, arrays, primitives, enums, unions, and more.\n *\n * @param zodSchema - The Zod schema to convert\n * @returns An MCP-compatible JSON Schema object\n *\n * @example\n * ```typescript\n * import { z } from \"zod\";\n *\n * const userSchema = z.object({\n * name: z.string(),\n * age: z.number().optional(),\n * email: z.string().email()\n * });\n *\n * const mcpSchema = convertZodToMcpSchema(userSchema);\n * // Result: { type: \"object\", properties: { ... }, required: [\"name\", \"email\"] }\n * ```\n */\nfunction convertZodToMcpSchema(zodSchema: z.ZodSchema): McpSchema {\n const def = getZodDef(zodSchema);\n if (!def) {\n // Fallback for schemas without _zod.def (e.g., custom or invalid schemas)\n return {\n type: \"string\",\n description: \"Unsupported schema type\",\n };\n }\n return convertZodType(def, zodSchema);\n}\n\n/**\n * Internal function that recursively converts Zod type definitions to MCP schema format.\n *\n * This function handles the actual conversion logic for different Zod types by examining\n * the internal type definition and converting it to the appropriate JSON Schema structure.\n *\n * @param def - The Zod internal definition object\n * @param schema - The original Zod schema (used for accessing shape in objects)\n * @returns An MCP-compatible JSON Schema object\n * @internal\n */\nfunction convertZodType(def: ZodDef, schema?: z.ZodSchema): McpSchema {\n const description = getDescription(schema);\n\n // Handle object\n if (def.type === \"object\" && schema) {\n const schemaWithShape = schema as ZodSchemaWithShape;\n const properties: Record<string, McpSchema> = {};\n const required: string[] = [];\n\n if (schemaWithShape.shape) {\n for (const [key, value] of Object.entries(schemaWithShape.shape)) {\n const fieldDef = getZodDef(value);\n if (fieldDef) {\n properties[key] = convertZodType(fieldDef, value);\n\n // Check if field is required (not optional or nullable)\n if (fieldDef.type !== \"optional\" && fieldDef.type !== \"nullable\") {\n required.push(key);\n }\n }\n }\n }\n\n const result: McpSchema = {\n type: \"object\",\n properties,\n };\n\n if (description) result.description = description;\n if (required.length > 0) result.required = required;\n\n return result;\n }\n\n // Handle string\n if (def.type === \"string\") {\n const result: McpSchema = { type: \"string\" };\n if (description) result.description = description;\n return result;\n }\n\n // Handle number\n if (def.type === \"number\") {\n const result: McpSchema = { type: \"number\" };\n if (description) result.description = description;\n return result;\n }\n\n // Handle boolean\n if (def.type === \"boolean\") {\n const result: McpSchema = { type: \"boolean\" };\n if (description) result.description = description;\n return result;\n }\n\n // Handle array\n if (def.type === \"array\" && def.element) {\n const elementDef = getZodDef(def.element);\n const result: McpSchema = {\n type: \"array\",\n items: elementDef\n ? convertZodType(elementDef, def.element)\n : { type: \"string\" },\n };\n if (description) result.description = description;\n return result;\n }\n\n // Handle optional\n if (def.type === \"optional\" && def.innerType) {\n const innerDef = getZodDef(def.innerType);\n if (innerDef) {\n return convertZodType(innerDef, def.innerType);\n }\n }\n\n // Handle nullable\n if (def.type === \"nullable\" && def.innerType) {\n const innerDef = getZodDef(def.innerType);\n if (innerDef) {\n const innerSchema = convertZodType(innerDef, def.innerType);\n if (innerSchema.type !== undefined) {\n return {\n ...innerSchema,\n type: Array.isArray(innerSchema.type)\n ? [...innerSchema.type, \"null\"]\n : [innerSchema.type, \"null\"],\n };\n }\n return {\n anyOf: [innerSchema, { type: \"null\" }],\n };\n }\n }\n\n // Handle enum\n if (def.type === \"enum\" && def.entries) {\n const result: McpSchema = {\n type: \"string\",\n enum: Object.keys(def.entries),\n };\n if (description) result.description = description;\n return result;\n }\n\n // Handle union\n if (def.type === \"union\" && def.options) {\n const result: McpSchema = {\n oneOf: def.options\n .map((option) => {\n const optionDef = getZodDef(option);\n return optionDef ? convertZodType(optionDef, option) : null;\n })\n .filter((s): s is McpSchema => s !== null),\n };\n if (description) result.description = description;\n return result;\n }\n\n // Handle intersection\n if (def.type === \"intersection\" && def.left && def.right) {\n const leftDef = getZodDef(def.left);\n const rightDef = getZodDef(def.right);\n const result: McpSchema = {\n allOf: [\n leftDef ? convertZodType(leftDef, def.left) : { type: \"string\" },\n rightDef ? convertZodType(rightDef, def.right) : { type: \"string\" },\n ],\n };\n if (description) result.description = description;\n return result;\n }\n\n // Handle literal\n if (def.type === \"literal\" && def.values && def.values.length > 0) {\n const value = def.values[0];\n const result: McpSchema = {\n type: typeof value as \"string\" | \"number\" | \"boolean\",\n enum: [value],\n };\n if (description) result.description = description;\n return result;\n }\n\n // Handle record\n if (def.type === \"record\") {\n let additionalProperties: McpSchema | boolean = true;\n if (def.valueType) {\n const valueDef = getZodDef(def.valueType);\n if (valueDef) {\n additionalProperties = convertZodType(valueDef, def.valueType);\n }\n }\n const result: McpSchema = {\n type: \"object\",\n additionalProperties,\n };\n if (description) result.description = description;\n return result;\n }\n\n // Handle any\n if (def.type === \"any\") {\n const result: McpSchema = {};\n if (description) result.description = description;\n return result;\n }\n\n // Handle unknown\n if (def.type === \"unknown\") {\n const result: McpSchema = {};\n if (description) result.description = description;\n return result;\n }\n\n // Handle date\n if (def.type === \"date\") {\n return {\n type: \"string\",\n format: \"date-time\",\n description: description || \"ISO 8601 date-time string\",\n };\n }\n\n // Handle bigint\n if (def.type === \"bigint\") {\n return {\n type: \"string\",\n description: description || \"BigInt as string\",\n };\n }\n\n // Handle undefined\n if (def.type === \"undefined\") {\n return {\n type: \"null\",\n description: description || \"Undefined value\",\n };\n }\n\n // Handle null\n if (def.type === \"null\") {\n return {\n type: \"null\",\n description: description || \"Null value\",\n };\n }\n\n // Handle void\n if (def.type === \"void\") {\n return {\n type: \"null\",\n description: description || \"Void (null) value\",\n };\n }\n\n // Handle nan\n if (def.type === \"nan\") {\n return {\n type: \"number\",\n description: description || \"Not-a-Number value\",\n };\n }\n\n // Handle default\n if (def.type === \"default\" && def.innerType) {\n const innerDef = getZodDef(def.innerType);\n if (innerDef) {\n return convertZodType(innerDef, def.innerType);\n }\n }\n\n // Handle catch (with fallback value)\n if (def.type === \"catch\" && def.innerType) {\n const innerDef = getZodDef(def.innerType);\n if (innerDef) {\n return convertZodType(innerDef, def.innerType);\n }\n }\n\n // Fallback for unhandled types\n console.warn(\n `Unhandled Zod type: ${def.type}. Please consider adding support for this type.`,\n );\n return {\n type: \"string\",\n description: description || `Unsupported type: ${def.type}`,\n };\n}\n\nexport { convertZodToMcpSchema };\n","{\n \"name\": \"@zapier/zapier-sdk-mcp\",\n \"version\": \"0.12.1\",\n \"description\": \"MCP server for Zapier SDK\",\n \"main\": \"dist/index.mjs\",\n \"types\": \"dist/index.d.mts\",\n \"exports\": {\n \".\": {\n \"source\": \"./src/index.ts\",\n \"import\": {\n \"types\": \"./dist/index.d.mts\",\n \"default\": \"./dist/index.mjs\"\n },\n \"default\": \"./dist/index.mjs\"\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rm -rf dist\",\n \"rebuild\": \"pnpm clean && pnpm build\",\n \"dev\": \"tsup --watch\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest\",\n \"test:run\": \"vitest run\",\n \"prepublishOnly\": \"node ../../scripts/check-version.js\"\n },\n \"keywords\": [\n \"zapier\",\n \"sdk\",\n \"mcp\",\n \"model-context-protocol\"\n ],\n \"author\": \"\",\n \"license\": \"SEE LICENSE IN LICENSE\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://gitlab.com/zapier/zapier-sdk/zapier-sdk.git\",\n \"directory\": \"packages/zapier-sdk-mcp\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/sdk\": \"^1.17.3\",\n \"@zapier/zapier-sdk\": \"workspace:*\",\n \"zod\": \"4.3.6\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^20.0.0\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.0.0\",\n \"vitest\": \"^4.1.4\"\n },\n \"files\": [\n \"dist\",\n \"README.md\",\n \"CHANGELOG.md\"\n ]\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,4BAA4B;A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,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAkBA,eAAe,eACb,UAAkC,CAAC,GACpB;AACf,QAAM,SAAS,sBAAsB,OAAO;AAC5C,QAAM,YAAY,IAAI,qBAAqB;AAE3C,SAAO,IAAI,QAAc,CAAC,YAAY;AACpC,QAAI,iBAAiB;AAErB,UAAM,UAAU,YAAY;AAC1B,UAAI,eAAgB;AACpB,uBAAiB;AAEjB,UAAI;AACF,cAAM,OAAO,MAAM;AAAA,MACrB,UAAE;AACA,gBAAQ;AAAA,MACV;AAAA,IACF;AAGA,WAAO,UAAU,MAAM;AACrB,cAAQ;AAAA,IACV;AAIA,YAAQ,KAAK,UAAU,OAAO;AAC9B,YAAQ,KAAK,WAAW,OAAO;AAE/B,WAAO,QAAQ,SAAS,EAAE,MAAM,CAAC,UAAU;AACzC,cAAQ,MAAM,+BAA+B,KAAK;AAClD,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/utils/schema-converter.ts","../package.json"],"sourcesContent":["import { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n createZapierSdk as createStableSdk,\n ZapierApprovalError,\n type ZapierSdk,\n type FunctionRegistryEntry,\n type Plugin,\n type PluginProvides,\n} from \"@zapier/zapier-sdk\";\nimport { createZapierSdk as createExperimentalSdk } from \"@zapier/zapier-sdk/experimental\";\nimport { convertZodToMcpSchema } from \"./utils/schema-converter.js\";\nimport packageJson from \"../package.json\" with { type: \"json\" };\n\nimport type { z } from \"zod\";\n\ninterface ZapierMcpServerOptions {\n debug?: boolean;\n /**\n * Extra plugins to layer onto the SDK before exposing it as MCP tools.\n * Used by the CLI's `mcp` command to forward extensions discovered via\n * the `ZAPIER_SDK_EXTENSIONS` env var. Standalone callers can omit this;\n * the server then uses a vanilla public SDK.\n */\n extensions?: Plugin<unknown, PluginProvides>[];\n /**\n * Build the server against `@zapier/zapier-sdk/experimental` instead of\n * the stable surface, so experimental plugins (e.g. trigger inboxes)\n * appear as MCP tools. Mirrors the CLI's `--experimental` opt-in: a\n * default invocation only ever sees stable plugins.\n */\n experimental?: boolean;\n}\n\ninterface ZodSchemaWithShape extends z.ZodSchema {\n shape?: Record<string, z.ZodSchema>;\n}\n\n/**\n * Build a flat MCP-compatible JSON schema from inputParameters.\n * Simple-type params become required top-level properties; object-type params\n * have their properties flattened into the top level.\n */\nfunction convertInputParametersToMcpSchema(\n inputParameters: Array<{ name: string; schema: z.ZodSchema }>,\n): Record<string, unknown> {\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n\n for (const param of inputParameters) {\n let schema = param.schema;\n let isOptional = false;\n\n const optionalDef = (\n schema as unknown as {\n _zod?: { def?: { type?: string; innerType?: z.ZodSchema } };\n }\n )._zod?.def;\n\n if (optionalDef?.type === \"optional\" && optionalDef.innerType) {\n isOptional = true;\n schema = optionalDef.innerType;\n }\n\n const objectDef = (\n schema as unknown as { _zod?: { def?: { type?: string } } }\n )._zod?.def;\n\n if (objectDef?.type === \"object\") {\n const schemaWithShape = schema as ZodSchemaWithShape;\n if (schemaWithShape.shape) {\n for (const [key, fieldSchema] of Object.entries(\n schemaWithShape.shape,\n )) {\n properties[key] = convertZodToMcpSchema(fieldSchema);\n const fieldDef = (\n fieldSchema as unknown as {\n _zod?: { def?: { type?: string } };\n }\n )._zod?.def;\n if (\n !isOptional &&\n fieldDef?.type !== \"optional\" &&\n fieldDef?.type !== \"nullable\"\n ) {\n required.push(key);\n }\n }\n }\n } else {\n properties[param.name] = convertZodToMcpSchema(param.schema);\n if (!isOptional) {\n required.push(param.name);\n }\n }\n }\n\n const result: Record<string, unknown> = {\n type: \"object\",\n properties,\n };\n if (required.length > 0) {\n result.required = required;\n }\n return result;\n}\n\n/**\n * Reconstruct positional arguments for SDK invocation from a flat args object.\n * Mirrors the CLI's reconstructPositionalArgs for MCP tool calls.\n */\nfunction reconstructMcpPositionalArgs(\n inputParameters: Array<{ name: string; schema: z.ZodSchema }>,\n flatArgs: Record<string, unknown>,\n): unknown[] {\n const args: unknown[] = [];\n\n for (const param of inputParameters) {\n let schema = param.schema;\n\n const optionalDef = (\n schema as unknown as {\n _zod?: { def?: { type?: string; innerType?: z.ZodSchema } };\n }\n )._zod?.def;\n\n if (optionalDef?.type === \"optional\" && optionalDef.innerType) {\n schema = optionalDef.innerType;\n }\n\n const objectDef = (\n schema as unknown as { _zod?: { def?: { type?: string } } }\n )._zod?.def;\n\n if (objectDef?.type === \"object\") {\n const schemaWithShape = schema as ZodSchemaWithShape;\n if (schemaWithShape.shape) {\n const obj: Record<string, unknown> = {};\n let hasValues = false;\n for (const key of Object.keys(schemaWithShape.shape)) {\n if (key in flatArgs && flatArgs[key] !== undefined) {\n obj[key] = flatArgs[key];\n hasValues = true;\n }\n }\n args.push(hasValues ? obj : undefined);\n } else {\n args.push(undefined);\n }\n } else {\n args.push(flatArgs[param.name]);\n }\n }\n\n return args;\n}\n\n/**\n * Creates an MCP server that exposes Zapier SDK functions as MCP tools.\n *\n * The server automatically discovers all available SDK functions and converts\n * their Zod schemas to MCP-compatible JSON schemas. It handles tool execution\n * by validating inputs and calling the appropriate SDK functions.\n *\n * @param options - Configuration options for the MCP server\n * @param options.debug - Enable debug logging for detailed error information\n * @returns An MCP server instance configured to expose Zapier SDK tools\n *\n * @example\n * ```typescript\n * const server = createZapierMcpServer({ debug: true });\n * const transport = new StdioServerTransport();\n * await server.connect(transport);\n * ```\n */\nfunction createZapierMcpServer({\n debug = false,\n extensions = [],\n experimental = false,\n}: ZapierMcpServerOptions = {}) {\n // Pick the SDK factory by opt-in. The experimental factory is a strict\n // superset (same plugins plus those marked `meta.experimental: true`),\n // so the registry path used below works the same; the cast preserves a\n // single zapierSdk variable across both branches.\n const createZapierSdk = experimental\n ? createExperimentalSdk\n : createStableSdk;\n let zapierSdk: ZapierSdk = createZapierSdk({\n debug,\n eventEmission: { callContext: \"mcp\" },\n callerPackage: { name: packageJson.name, version: packageJson.version },\n approvalMode: \"throw\",\n }) as ZapierSdk;\n\n // Layer extension plugins on top of the vanilla SDK so their methods show\n // up in `getRegistry({ package: \"mcp\" })` alongside the public surface.\n // Same robustness contract as the CLI: a broken extension warns and\n // skips rather than killing the MCP server.\n for (const ext of extensions) {\n try {\n zapierSdk = zapierSdk.addPlugin(ext) as typeof zapierSdk;\n } catch (err) {\n console.warn(\n `Extension plugin failed to construct: ${(err as Error).message}; skipping.`,\n );\n }\n }\n\n // Create MCP server\n const server = new Server(\n {\n name: \"zapier-sdk\",\n version: \"1.0.0\",\n },\n {\n capabilities: {\n tools: {},\n },\n },\n );\n\n // Register list_tools handler - dynamically list all SDK functions as tools\n server.setRequestHandler(ListToolsRequestSchema, async () => {\n const tools = zapierSdk\n .getRegistry({ package: \"mcp\" })\n .functions.map((functionInfo: FunctionRegistryEntry) => {\n const toolName = functionInfo.name\n .replace(/([A-Z])/g, \"-$1\")\n .toLowerCase();\n\n const description =\n functionInfo.description ||\n functionInfo.inputSchema?.description ||\n `Execute ${functionInfo.name}`;\n\n if (functionInfo.inputSchema) {\n return {\n name: toolName,\n description,\n inputSchema: convertZodToMcpSchema(functionInfo.inputSchema),\n };\n }\n\n // Build a synthetic MCP schema from inputParameters\n return {\n name: toolName,\n description,\n inputSchema: convertInputParametersToMcpSchema(\n functionInfo.inputParameters!,\n ),\n };\n });\n\n return { tools };\n });\n\n // Register call_tool handler - execute SDK functions\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n // Convert kebab-case tool name back to camelCase function name\n const functionName = name.replace(/-([a-z])/g, (_, letter) =>\n letter.toUpperCase(),\n );\n\n // Find the function info\n const functionInfo: FunctionRegistryEntry | undefined = zapierSdk\n .getRegistry({ package: \"mcp\" })\n .functions.find(\n (info: FunctionRegistryEntry) => info.name === functionName,\n );\n\n if (!functionInfo) {\n const availableTools = zapierSdk\n .getRegistry({ package: \"mcp\" })\n .functions.map((info) =>\n info.name.replace(/([A-Z])/g, \"-$1\").toLowerCase(),\n )\n .join(\", \");\n throw new Error(\n `Unknown tool: ${name}. Available tools: ${availableTools}`,\n );\n }\n\n try {\n let result: unknown;\n\n if (functionInfo.inputSchema) {\n // Standard single-object-parameter function\n const validatedArgs = functionInfo.inputSchema.parse(args || {});\n const sdkFn = (\n zapierSdk as unknown as Record<\n string,\n (...args: unknown[]) => Promise<unknown>\n >\n )[functionInfo.name];\n result = await sdkFn(validatedArgs);\n } else if (functionInfo.inputParameters) {\n // Multi-parameter function (e.g. fetch) โ€” reconstruct positional args from flat object\n const flatArgs = (args || {}) as Record<string, unknown>;\n const positionalArgs = reconstructMcpPositionalArgs(\n functionInfo.inputParameters,\n flatArgs,\n );\n const sdkFn = (\n zapierSdk as unknown as Record<\n string,\n (...args: unknown[]) => Promise<unknown>\n >\n )[functionInfo.name];\n result = await sdkFn(...positionalArgs);\n } else {\n const sdkFn = (\n zapierSdk as unknown as Record<\n string,\n (...args: unknown[]) => Promise<unknown>\n >\n )[functionInfo.name];\n result = await sdkFn();\n }\n\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n } catch (error) {\n if (debug) {\n console.error(\n `Error executing function '${functionInfo.name}' (tool: ${name}):`,\n error,\n );\n }\n\n if (error instanceof ZapierApprovalError) {\n switch (error.approvalStatus) {\n // Pending approval: return the URL so the LLM can instruct the user\n case \"pending\":\n return {\n content: [\n {\n type: \"text\",\n text: `This action requires approval. The end user must open this link in their browser to approve this action, then retry this tool call:\\n\\n${error.approvalUrl}`,\n },\n ],\n isError: false,\n };\n // Policy denied: hard deny, cannot be approved\n case \"policy_denied\":\n return {\n content: [\n {\n type: \"text\",\n text: `This action was denied by policy and cannot be approved:\\n\\n${error.message}`,\n },\n ],\n isError: true,\n };\n }\n }\n\n let errorMessage: string;\n let isValidationError = false;\n\n if (error instanceof Error) {\n // Check if it's a Zod validation error\n if (error.name === \"ZodError\") {\n isValidationError = true;\n errorMessage = `Validation error for ${functionInfo.name}: ${error.message}`;\n } else {\n errorMessage = `Error in ${functionInfo.name}: ${error.message}`;\n }\n } else {\n errorMessage = `Unexpected error in ${functionInfo.name}: ${String(error)}`;\n }\n\n const errorSchema = functionInfo.inputSchema\n ? convertZodToMcpSchema(functionInfo.inputSchema)\n : functionInfo.inputParameters\n ? convertInputParametersToMcpSchema(functionInfo.inputParameters)\n : {};\n\n return {\n content: [\n {\n type: \"text\",\n text: isValidationError\n ? `${errorMessage}\\n\\nExpected input format:\\n${JSON.stringify(errorSchema, null, 2)}`\n : errorMessage,\n },\n ],\n isError: true,\n };\n }\n });\n\n return server;\n}\n\n/**\n * Starts an MCP server with stdio transport for CLI usage.\n *\n * This is the main entry point when running the MCP server from the command line.\n * It creates the server and connects it using stdio transport for communication\n * with MCP clients like Claude Code.\n *\n * @param options - Configuration options for the MCP server\n * @param options.debug - Enable debug logging for detailed error information\n *\n * @example\n * ```typescript\n * // Start server with debug logging\n * await startMcpServer({ debug: true });\n * ```\n */\nasync function startMcpServer(\n options: ZapierMcpServerOptions = {},\n): Promise<void> {\n const server = createZapierMcpServer(options);\n const transport = new StdioServerTransport();\n\n return new Promise<void>((resolve) => {\n let isShuttingDown = false;\n\n const cleanup = async () => {\n if (isShuttingDown) return;\n isShuttingDown = true;\n\n try {\n await server.close();\n } finally {\n resolve();\n }\n };\n\n // Handle clean shutdown when client closes connection\n server.onclose = () => {\n cleanup();\n };\n\n // Handle termination signals (Ctrl+C, kill, etc.)\n // Using process.once() to prevent handler accumulation\n process.once(\"SIGINT\", cleanup);\n process.once(\"SIGTERM\", cleanup);\n\n server.connect(transport).catch((error) => {\n console.error(\"Failed to start MCP server:\", error);\n process.exit(1);\n });\n });\n}\n\nexport { createZapierMcpServer, startMcpServer };\n","/**\n * A robust schema converter that handles conversion from Zod schemas to JSON Schema format:\n *\n * **Core Types:**\n * - โœ… Objects, arrays, strings, numbers, booleans\n * - โœ… Enums, unions, intersections, literals\n * - โœ… Optional and nullable fields\n * - โœ… Records and dates\n * - โœ… Nested schemas and complex types\n *\n * **Additional Types:**\n * - โœ… Any, unknown, bigint, null, undefined, void, NaN\n * - โœ… Default values and catch handlers (unwrapped to inner type)\n * - โœ… Graceful fallback for unsupported types\n */\n\nimport type { z } from \"zod\";\n\ninterface McpSchema {\n type?: string | string[];\n properties?: Record<string, McpSchema>;\n required?: string[];\n description?: string;\n items?: McpSchema;\n enum?: unknown[];\n anyOf?: McpSchema[];\n oneOf?: McpSchema[];\n allOf?: McpSchema[];\n additionalProperties?: McpSchema | boolean;\n format?: string;\n}\n\n// Zod internal definition structure\ninterface ZodDef {\n type: string; // e.g., \"string\", \"number\", \"object\", \"optional\", etc.\n element?: z.ZodSchema; // For arrays\n innerType?: z.ZodSchema; // For optional, nullable, default, catch\n entries?: Record<string, string>; // For enums\n values?: unknown[]; // For literals\n options?: z.ZodSchema[]; // For unions\n left?: z.ZodSchema; // For intersections\n right?: z.ZodSchema; // For intersections\n keyType?: z.ZodSchema; // For records (key type)\n valueType?: z.ZodSchema; // For records (value type)\n shape?: Record<string, z.ZodSchema>; // For objects (function in some cases)\n}\n\n// Zod schema with description (description is on the schema, not the def)\ninterface ZodSchemaWithDescription extends z.ZodSchema {\n description?: string;\n}\n\ninterface ZodSchemaWithShape extends z.ZodSchema {\n shape?: Record<string, z.ZodSchema>;\n}\n\n/**\n * Gets the Zod def from a schema, with fallback for edge cases\n */\nfunction getZodDef(schema: z.ZodSchema): ZodDef | undefined {\n const schemaAny = schema as unknown as { _zod?: { def?: ZodDef } };\n return schemaAny._zod?.def;\n}\n\n/**\n * Gets the description from a Zod schema (description is on the schema object, not the def)\n */\nfunction getDescription(schema?: z.ZodSchema): string | undefined {\n if (!schema) return undefined;\n return (schema as ZodSchemaWithDescription).description;\n}\n\n/**\n * Converts a Zod schema to MCP-compatible JSON Schema format.\n *\n * This function handles the conversion of Zod validation schemas (used internally\n * by the Zapier SDK) to JSON Schema format required by the MCP protocol. It supports\n * most common Zod types including objects, arrays, primitives, enums, unions, and more.\n *\n * @param zodSchema - The Zod schema to convert\n * @returns An MCP-compatible JSON Schema object\n *\n * @example\n * ```typescript\n * import { z } from \"zod\";\n *\n * const userSchema = z.object({\n * name: z.string(),\n * age: z.number().optional(),\n * email: z.string().email()\n * });\n *\n * const mcpSchema = convertZodToMcpSchema(userSchema);\n * // Result: { type: \"object\", properties: { ... }, required: [\"name\", \"email\"] }\n * ```\n */\nfunction convertZodToMcpSchema(zodSchema: z.ZodSchema): McpSchema {\n const def = getZodDef(zodSchema);\n if (!def) {\n // Fallback for schemas without _zod.def (e.g., custom or invalid schemas)\n return {\n type: \"string\",\n description: \"Unsupported schema type\",\n };\n }\n return convertZodType(def, zodSchema);\n}\n\n/**\n * Internal function that recursively converts Zod type definitions to MCP schema format.\n *\n * This function handles the actual conversion logic for different Zod types by examining\n * the internal type definition and converting it to the appropriate JSON Schema structure.\n *\n * @param def - The Zod internal definition object\n * @param schema - The original Zod schema (used for accessing shape in objects)\n * @returns An MCP-compatible JSON Schema object\n * @internal\n */\nfunction convertZodType(def: ZodDef, schema?: z.ZodSchema): McpSchema {\n const description = getDescription(schema);\n\n // Handle object\n if (def.type === \"object\" && schema) {\n const schemaWithShape = schema as ZodSchemaWithShape;\n const properties: Record<string, McpSchema> = {};\n const required: string[] = [];\n\n if (schemaWithShape.shape) {\n for (const [key, value] of Object.entries(schemaWithShape.shape)) {\n const fieldDef = getZodDef(value);\n if (fieldDef) {\n properties[key] = convertZodType(fieldDef, value);\n\n // Check if field is required (not optional or nullable)\n if (fieldDef.type !== \"optional\" && fieldDef.type !== \"nullable\") {\n required.push(key);\n }\n }\n }\n }\n\n const result: McpSchema = {\n type: \"object\",\n properties,\n };\n\n if (description) result.description = description;\n if (required.length > 0) result.required = required;\n\n return result;\n }\n\n // Handle string\n if (def.type === \"string\") {\n const result: McpSchema = { type: \"string\" };\n if (description) result.description = description;\n return result;\n }\n\n // Handle number\n if (def.type === \"number\") {\n const result: McpSchema = { type: \"number\" };\n if (description) result.description = description;\n return result;\n }\n\n // Handle boolean\n if (def.type === \"boolean\") {\n const result: McpSchema = { type: \"boolean\" };\n if (description) result.description = description;\n return result;\n }\n\n // Handle array\n if (def.type === \"array\" && def.element) {\n const elementDef = getZodDef(def.element);\n const result: McpSchema = {\n type: \"array\",\n items: elementDef\n ? convertZodType(elementDef, def.element)\n : { type: \"string\" },\n };\n if (description) result.description = description;\n return result;\n }\n\n // Handle optional\n if (def.type === \"optional\" && def.innerType) {\n const innerDef = getZodDef(def.innerType);\n if (innerDef) {\n return convertZodType(innerDef, def.innerType);\n }\n }\n\n // Handle nullable\n if (def.type === \"nullable\" && def.innerType) {\n const innerDef = getZodDef(def.innerType);\n if (innerDef) {\n const innerSchema = convertZodType(innerDef, def.innerType);\n if (innerSchema.type !== undefined) {\n return {\n ...innerSchema,\n type: Array.isArray(innerSchema.type)\n ? [...innerSchema.type, \"null\"]\n : [innerSchema.type, \"null\"],\n };\n }\n return {\n anyOf: [innerSchema, { type: \"null\" }],\n };\n }\n }\n\n // Handle enum\n if (def.type === \"enum\" && def.entries) {\n const result: McpSchema = {\n type: \"string\",\n enum: Object.keys(def.entries),\n };\n if (description) result.description = description;\n return result;\n }\n\n // Handle union\n if (def.type === \"union\" && def.options) {\n const result: McpSchema = {\n oneOf: def.options\n .map((option) => {\n const optionDef = getZodDef(option);\n return optionDef ? convertZodType(optionDef, option) : null;\n })\n .filter((s): s is McpSchema => s !== null),\n };\n if (description) result.description = description;\n return result;\n }\n\n // Handle intersection\n if (def.type === \"intersection\" && def.left && def.right) {\n const leftDef = getZodDef(def.left);\n const rightDef = getZodDef(def.right);\n const result: McpSchema = {\n allOf: [\n leftDef ? convertZodType(leftDef, def.left) : { type: \"string\" },\n rightDef ? convertZodType(rightDef, def.right) : { type: \"string\" },\n ],\n };\n if (description) result.description = description;\n return result;\n }\n\n // Handle literal\n if (def.type === \"literal\" && def.values && def.values.length > 0) {\n const value = def.values[0];\n const result: McpSchema = {\n type: typeof value as \"string\" | \"number\" | \"boolean\",\n enum: [value],\n };\n if (description) result.description = description;\n return result;\n }\n\n // Handle record\n if (def.type === \"record\") {\n let additionalProperties: McpSchema | boolean = true;\n if (def.valueType) {\n const valueDef = getZodDef(def.valueType);\n if (valueDef) {\n additionalProperties = convertZodType(valueDef, def.valueType);\n }\n }\n const result: McpSchema = {\n type: \"object\",\n additionalProperties,\n };\n if (description) result.description = description;\n return result;\n }\n\n // Handle any\n if (def.type === \"any\") {\n const result: McpSchema = {};\n if (description) result.description = description;\n return result;\n }\n\n // Handle unknown\n if (def.type === \"unknown\") {\n const result: McpSchema = {};\n if (description) result.description = description;\n return result;\n }\n\n // Handle date\n if (def.type === \"date\") {\n return {\n type: \"string\",\n format: \"date-time\",\n description: description || \"ISO 8601 date-time string\",\n };\n }\n\n // Handle bigint\n if (def.type === \"bigint\") {\n return {\n type: \"string\",\n description: description || \"BigInt as string\",\n };\n }\n\n // Handle undefined\n if (def.type === \"undefined\") {\n return {\n type: \"null\",\n description: description || \"Undefined value\",\n };\n }\n\n // Handle null\n if (def.type === \"null\") {\n return {\n type: \"null\",\n description: description || \"Null value\",\n };\n }\n\n // Handle void\n if (def.type === \"void\") {\n return {\n type: \"null\",\n description: description || \"Void (null) value\",\n };\n }\n\n // Handle nan\n if (def.type === \"nan\") {\n return {\n type: \"number\",\n description: description || \"Not-a-Number value\",\n };\n }\n\n // Handle default\n if (def.type === \"default\" && def.innerType) {\n const innerDef = getZodDef(def.innerType);\n if (innerDef) {\n return convertZodType(innerDef, def.innerType);\n }\n }\n\n // Handle catch (with fallback value)\n if (def.type === \"catch\" && def.innerType) {\n const innerDef = getZodDef(def.innerType);\n if (innerDef) {\n return convertZodType(innerDef, def.innerType);\n }\n }\n\n // Fallback for unhandled types\n console.warn(\n `Unhandled Zod type: ${def.type}. Please consider adding support for this type.`,\n );\n return {\n type: \"string\",\n description: description || `Unsupported type: ${def.type}`,\n };\n}\n\nexport { convertZodToMcpSchema };\n","{\n \"name\": \"@zapier/zapier-sdk-mcp\",\n \"version\": \"0.13.1\",\n \"description\": \"MCP server for Zapier SDK\",\n \"main\": \"dist/index.mjs\",\n \"types\": \"dist/index.d.mts\",\n \"exports\": {\n \".\": {\n \"source\": \"./src/index.ts\",\n \"import\": {\n \"types\": \"./dist/index.d.mts\",\n \"default\": \"./dist/index.mjs\"\n },\n \"default\": \"./dist/index.mjs\"\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"rm -rf dist\",\n \"rebuild\": \"pnpm clean && pnpm build\",\n \"dev\": \"tsup --watch\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest\",\n \"test:run\": \"vitest run\",\n \"prepublishOnly\": \"node ../../scripts/check-version.js\"\n },\n \"keywords\": [\n \"zapier\",\n \"sdk\",\n \"mcp\",\n \"model-context-protocol\"\n ],\n \"author\": \"\",\n \"license\": \"SEE LICENSE IN LICENSE\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://gitlab.com/zapier/zapier-sdk/zapier-sdk.git\",\n \"directory\": \"packages/zapier-sdk-mcp\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/sdk\": \"^1.17.3\",\n \"@zapier/zapier-sdk\": \"workspace:*\",\n \"zod\": \"4.3.6\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^20.0.0\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.0.0\",\n \"vitest\": \"^4.1.4\"\n },\n \"files\": [\n \"dist\",\n \"README.md\",\n \"CHANGELOG.md\"\n ]\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE,mBAAmB;AAAA,EACnB;AAAA,OAKK;AACP,SAAS,mBAAmB,6BAA6B;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A,eAAe,eACb,UAAkC,CAAC,GACpB;AACf,QAAM,SAAS,sBAAsB,OAAO;AAC5C,QAAM,YAAY,IAAI,qBAAqB;AAE3C,SAAO,IAAI,QAAc,CAAC,YAAY;AACpC,QAAI,iBAAiB;AAErB,UAAM,UAAU,YAAY;AAC1B,UAAI,eAAgB;AACpB,uBAAiB;AAEjB,UAAI;AACF,cAAM,OAAO,MAAM;AAAA,MACrB,UAAE;AACA,gBAAQ;AAAA,MACV;AAAA,IACF;AAGA,WAAO,UAAU,MAAM;AACrB,cAAQ;AAAA,IACV;AAIA,YAAQ,KAAK,UAAU,OAAO;AAC9B,YAAQ,KAAK,WAAW,OAAO;AAE/B,WAAO,QAAQ,SAAS,EAAE,MAAM,CAAC,UAAU;AACzC,cAAQ,MAAM,+BAA+B,KAAK;AAClD,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk-mcp",
3
- "version": "0.12.1",
3
+ "version": "0.13.1",
4
4
  "description": "MCP server for Zapier SDK",
5
5
  "main": "dist/index.mjs",
6
6
  "types": "dist/index.d.mts",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@modelcontextprotocol/sdk": "^1.17.3",
35
35
  "zod": "4.3.6",
36
- "@zapier/zapier-sdk": "0.48.1"
36
+ "@zapier/zapier-sdk": "0.50.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^20.0.0",