@zapier/zapier-sdk-mcp 0.1.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/README.md +115 -0
- package/dist/index.d.mts +81 -0
- package/dist/index.mjs +361 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Zapier SDK MCP Server
|
|
2
|
+
|
|
3
|
+
A MCP (Model Context Protocol) server implementation for the Zapier SDK, allowing AI assistants to interact with Zapier's APIs through a standardized protocol.
|
|
4
|
+
|
|
5
|
+
## What is MCP?
|
|
6
|
+
|
|
7
|
+
The [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) is a protocol developed by Anthropic that enables AI assistants like Claude and Cursor to interact with external tools and data sources through a standardized interface. This package creates an MCP server that exposes all Zapier SDK functions as MCP tools.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
This package is part of the Zapier SDK monorepo and is automatically installed when you install the CLI:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -D @zapier/zapier-sdk-cli
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### Starting the MCP Server
|
|
20
|
+
|
|
21
|
+
You can start the MCP server using the CLI:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Start the MCP server
|
|
25
|
+
npx zapier-sdk mcp
|
|
26
|
+
|
|
27
|
+
# Enable debug logging
|
|
28
|
+
npx zapier-sdk mcp --debug
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Using with Claude Code
|
|
32
|
+
|
|
33
|
+
To use this MCP server with Claude Code, add it to your MCP configuration:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"mcpServers": {
|
|
38
|
+
"zapier-sdk": {
|
|
39
|
+
"command": "npx",
|
|
40
|
+
"args": ["zapier-sdk", "mcp"]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Programmatic Usage
|
|
47
|
+
|
|
48
|
+
You can also use the server programmatically:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { createZapierMcpServer, startMcpServer } from "@zapier/zapier-sdk-mcp";
|
|
52
|
+
|
|
53
|
+
// Create and configure the server
|
|
54
|
+
const server = createZapierMcpServer({ debug: true });
|
|
55
|
+
|
|
56
|
+
// Or start it directly
|
|
57
|
+
await startMcpServer({ debug: true });
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## How It Works
|
|
61
|
+
|
|
62
|
+
The MCP server:
|
|
63
|
+
|
|
64
|
+
1. **Dynamically discovers** all available Zapier SDK functions from the SDK's internal registry
|
|
65
|
+
2. **Converts function schemas** from Zod format (used internally by the SDK) to JSON Schema format (required by MCP)
|
|
66
|
+
3. **Exposes functions as MCP tools** with kebab-case naming (e.g., `listApps` becomes `list-apps`)
|
|
67
|
+
4. **Handles tool execution** by validating inputs, calling the appropriate SDK function, and returning results
|
|
68
|
+
|
|
69
|
+
## Available Tools
|
|
70
|
+
|
|
71
|
+
All Zapier SDK functions are automatically exposed as MCP tools:
|
|
72
|
+
|
|
73
|
+
- `list-apps` - List available Zapier apps
|
|
74
|
+
- `list-actions` - List actions for a specific app
|
|
75
|
+
- `get-action` - Get details about a specific action
|
|
76
|
+
- `run-action` - Execute a Zapier action
|
|
77
|
+
- `list-authentications` - List your authentications
|
|
78
|
+
- And many more...
|
|
79
|
+
|
|
80
|
+
## Error Handling
|
|
81
|
+
|
|
82
|
+
The server provides comprehensive error handling:
|
|
83
|
+
|
|
84
|
+
- **Validation errors** include the expected input schema
|
|
85
|
+
- **Unknown tools** list all available alternatives
|
|
86
|
+
- **Execution errors** provide context about which function failed
|
|
87
|
+
- **Debug mode** provides detailed error logging
|
|
88
|
+
|
|
89
|
+
## Architecture
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
AI Assistant (Claude)
|
|
93
|
+
↓ MCP Protocol
|
|
94
|
+
MCP Server (@zapier/zapier-sdk-mcp)
|
|
95
|
+
↓ Function Calls
|
|
96
|
+
Zapier SDK (@zapier/zapier-sdk)
|
|
97
|
+
↓ HTTP Requests
|
|
98
|
+
Zapier APIs
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The MCP server acts as an adapter, translating between the MCP protocol and the Zapier SDK's function-based interface.
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
### Building
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pnpm build
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Testing
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
pnpm test
|
|
115
|
+
```
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
|
|
4
|
+
interface ZapierMcpServerOptions {
|
|
5
|
+
debug?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Creates an MCP server that exposes Zapier SDK functions as MCP tools.
|
|
9
|
+
*
|
|
10
|
+
* The server automatically discovers all available SDK functions and converts
|
|
11
|
+
* their Zod schemas to MCP-compatible JSON schemas. It handles tool execution
|
|
12
|
+
* by validating inputs and calling the appropriate SDK functions.
|
|
13
|
+
*
|
|
14
|
+
* @param options - Configuration options for the MCP server
|
|
15
|
+
* @param options.debug - Enable debug logging for detailed error information
|
|
16
|
+
* @returns An MCP server instance configured to expose Zapier SDK tools
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const server = createZapierMcpServer({ debug: true });
|
|
21
|
+
* const transport = new StdioServerTransport();
|
|
22
|
+
* await server.connect(transport);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function createZapierMcpServer({ debug }?: ZapierMcpServerOptions): Server<{
|
|
26
|
+
method: string;
|
|
27
|
+
params?: {
|
|
28
|
+
[x: string]: unknown;
|
|
29
|
+
_meta?: {
|
|
30
|
+
[x: string]: unknown;
|
|
31
|
+
progressToken?: string | number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}, {
|
|
35
|
+
method: string;
|
|
36
|
+
params?: {
|
|
37
|
+
[x: string]: unknown;
|
|
38
|
+
_meta?: {
|
|
39
|
+
[x: string]: unknown;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}, {
|
|
43
|
+
[x: string]: unknown;
|
|
44
|
+
_meta?: {
|
|
45
|
+
[x: string]: unknown;
|
|
46
|
+
};
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Starts an MCP server with stdio transport for CLI usage.
|
|
50
|
+
*
|
|
51
|
+
* This is the main entry point when running the MCP server from the command line.
|
|
52
|
+
* It creates the server and connects it using stdio transport for communication
|
|
53
|
+
* with MCP clients like Claude Code.
|
|
54
|
+
*
|
|
55
|
+
* @param options - Configuration options for the MCP server
|
|
56
|
+
* @param options.debug - Enable debug logging for detailed error information
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* // Start server with debug logging
|
|
61
|
+
* await startMcpServer({ debug: true });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare function startMcpServer(options?: ZapierMcpServerOptions): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Starts the MCP server as a child process with process lifecycle management.
|
|
67
|
+
*
|
|
68
|
+
* This function handles spawning the MCP server as a separate Node.js process,
|
|
69
|
+
* managing its lifecycle, and providing graceful shutdown handling. It's designed
|
|
70
|
+
* to be called from CLI tools that need to start the MCP server.
|
|
71
|
+
*
|
|
72
|
+
* @param options - Configuration options for the MCP server process
|
|
73
|
+
* @param options.debug - Enable debug logging
|
|
74
|
+
* @param options.port - Port to listen on (for future HTTP transport)
|
|
75
|
+
*/
|
|
76
|
+
declare function startMcpServerAsProcess(options?: {
|
|
77
|
+
debug?: boolean;
|
|
78
|
+
port?: string;
|
|
79
|
+
}): Promise<void>;
|
|
80
|
+
|
|
81
|
+
export { createZapierMcpServer, startMcpServer, startMcpServerAsProcess };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
+
import {
|
|
7
|
+
CallToolRequestSchema,
|
|
8
|
+
ListToolsRequestSchema
|
|
9
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
10
|
+
import {
|
|
11
|
+
createZapierSdk
|
|
12
|
+
} from "@zapier/zapier-sdk";
|
|
13
|
+
|
|
14
|
+
// src/utils/schema-converter.ts
|
|
15
|
+
function convertZodToMcpSchema(zodSchema) {
|
|
16
|
+
return convertZodType(
|
|
17
|
+
zodSchema._def,
|
|
18
|
+
zodSchema
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
function convertZodType(def, schema) {
|
|
22
|
+
if (def.typeName === "ZodObject" && schema) {
|
|
23
|
+
const schemaWithShape = schema;
|
|
24
|
+
const properties = {};
|
|
25
|
+
const required = [];
|
|
26
|
+
if (schemaWithShape.shape) {
|
|
27
|
+
for (const [key, value] of Object.entries(schemaWithShape.shape)) {
|
|
28
|
+
const fieldDef = value._def;
|
|
29
|
+
properties[key] = convertZodType(fieldDef, value);
|
|
30
|
+
if (fieldDef.typeName !== "ZodOptional" && fieldDef.typeName !== "ZodNullable") {
|
|
31
|
+
required.push(key);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const result = {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties,
|
|
38
|
+
description: def.description
|
|
39
|
+
};
|
|
40
|
+
if (required.length > 0) {
|
|
41
|
+
result.required = required;
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
if (def.typeName === "ZodString") {
|
|
46
|
+
const schema2 = { type: "string" };
|
|
47
|
+
if (def.description) schema2.description = def.description;
|
|
48
|
+
return schema2;
|
|
49
|
+
}
|
|
50
|
+
if (def.typeName === "ZodNumber") {
|
|
51
|
+
const schema2 = { type: "number" };
|
|
52
|
+
if (def.description) schema2.description = def.description;
|
|
53
|
+
return schema2;
|
|
54
|
+
}
|
|
55
|
+
if (def.typeName === "ZodBoolean") {
|
|
56
|
+
const schema2 = { type: "boolean" };
|
|
57
|
+
if (def.description) schema2.description = def.description;
|
|
58
|
+
return schema2;
|
|
59
|
+
}
|
|
60
|
+
if (def.typeName === "ZodArray" && def.type) {
|
|
61
|
+
return {
|
|
62
|
+
type: "array",
|
|
63
|
+
items: convertZodType(
|
|
64
|
+
def.type._def,
|
|
65
|
+
def.type
|
|
66
|
+
),
|
|
67
|
+
description: def.description
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (def.typeName === "ZodOptional" && def.innerType) {
|
|
71
|
+
return convertZodType(
|
|
72
|
+
def.innerType._def,
|
|
73
|
+
def.innerType
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if (def.typeName === "ZodNullable" && def.innerType) {
|
|
77
|
+
const innerSchema = convertZodType(
|
|
78
|
+
def.innerType._def,
|
|
79
|
+
def.innerType
|
|
80
|
+
);
|
|
81
|
+
return {
|
|
82
|
+
...innerSchema,
|
|
83
|
+
type: Array.isArray(innerSchema.type) ? [...innerSchema.type, "null"] : [innerSchema.type, "null"]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (def.typeName === "ZodEnum" && def.values) {
|
|
87
|
+
return {
|
|
88
|
+
type: "string",
|
|
89
|
+
enum: Array.from(def.values),
|
|
90
|
+
description: def.description
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (def.typeName === "ZodUnion" && def.options) {
|
|
94
|
+
return {
|
|
95
|
+
oneOf: def.options.map(
|
|
96
|
+
(option) => convertZodType(option._def, option)
|
|
97
|
+
),
|
|
98
|
+
description: def.description
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (def.typeName === "ZodIntersection" && def.left && def.right) {
|
|
102
|
+
return {
|
|
103
|
+
allOf: [
|
|
104
|
+
convertZodType(
|
|
105
|
+
def.left._def,
|
|
106
|
+
def.left
|
|
107
|
+
),
|
|
108
|
+
convertZodType(
|
|
109
|
+
def.right._def,
|
|
110
|
+
def.right
|
|
111
|
+
)
|
|
112
|
+
],
|
|
113
|
+
description: def.description
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (def.typeName === "ZodLiteral" && def.value !== void 0) {
|
|
117
|
+
const value = def.value;
|
|
118
|
+
return {
|
|
119
|
+
type: typeof value,
|
|
120
|
+
enum: [value],
|
|
121
|
+
description: def.description
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (def.typeName === "ZodRecord") {
|
|
125
|
+
return {
|
|
126
|
+
type: "object",
|
|
127
|
+
additionalProperties: def.valueType ? convertZodType(
|
|
128
|
+
def.valueType._def,
|
|
129
|
+
def.valueType
|
|
130
|
+
) : true,
|
|
131
|
+
description: def.description
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if (def.typeName === "ZodAny") {
|
|
135
|
+
return {
|
|
136
|
+
description: def.description || "Any value"
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
if (def.typeName === "ZodUnknown") {
|
|
140
|
+
return {
|
|
141
|
+
description: def.description || "Unknown value"
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (def.typeName === "ZodDate") {
|
|
145
|
+
return {
|
|
146
|
+
type: "string",
|
|
147
|
+
format: "date-time",
|
|
148
|
+
description: def.description || "ISO 8601 date-time string"
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (def.typeName === "ZodBigInt") {
|
|
152
|
+
return {
|
|
153
|
+
type: "string",
|
|
154
|
+
description: def.description || "BigInt as string"
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
if (def.typeName === "ZodUndefined") {
|
|
158
|
+
return {
|
|
159
|
+
type: "null",
|
|
160
|
+
description: def.description || "Undefined value"
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (def.typeName === "ZodNull") {
|
|
164
|
+
return {
|
|
165
|
+
type: "null",
|
|
166
|
+
description: def.description || "Null value"
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
if (def.typeName === "ZodVoid") {
|
|
170
|
+
return {
|
|
171
|
+
type: "null",
|
|
172
|
+
description: def.description || "Void (null) value"
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
if (def.typeName === "ZodNaN") {
|
|
176
|
+
return {
|
|
177
|
+
type: "number",
|
|
178
|
+
description: def.description || "Not-a-Number value"
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
if (def.typeName === "ZodDefault" && def.innerType) {
|
|
182
|
+
return convertZodType(
|
|
183
|
+
def.innerType._def,
|
|
184
|
+
def.innerType
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
if (def.typeName === "ZodCatch" && def.innerType) {
|
|
188
|
+
return convertZodType(
|
|
189
|
+
def.innerType._def,
|
|
190
|
+
def.innerType
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
console.warn(
|
|
194
|
+
`Unhandled Zod type: ${def.typeName}. Please consider adding support for this type.`
|
|
195
|
+
);
|
|
196
|
+
return {
|
|
197
|
+
type: "string",
|
|
198
|
+
description: def.description || `Unsupported type: ${def.typeName}`
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// src/index.ts
|
|
203
|
+
import { spawn } from "child_process";
|
|
204
|
+
import { existsSync } from "fs";
|
|
205
|
+
import { createRequire } from "module";
|
|
206
|
+
function createZapierMcpServer({ debug = false } = {}) {
|
|
207
|
+
const zapierSdk = createZapierSdk({ debug });
|
|
208
|
+
const server = new Server(
|
|
209
|
+
{
|
|
210
|
+
name: "zapier-sdk",
|
|
211
|
+
version: "1.0.0"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
capabilities: {
|
|
215
|
+
tools: {}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
220
|
+
const tools = zapierSdk.__registry.map(
|
|
221
|
+
(functionInfo) => {
|
|
222
|
+
const toolName = functionInfo.name.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
223
|
+
return {
|
|
224
|
+
name: toolName,
|
|
225
|
+
description: functionInfo.inputSchema.description || `Execute ${functionInfo.name}`,
|
|
226
|
+
inputSchema: convertZodToMcpSchema(functionInfo.inputSchema)
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
return { tools };
|
|
231
|
+
});
|
|
232
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
233
|
+
const { name, arguments: args } = request.params;
|
|
234
|
+
const functionName = name.replace(
|
|
235
|
+
/-([a-z])/g,
|
|
236
|
+
(_, letter) => letter.toUpperCase()
|
|
237
|
+
);
|
|
238
|
+
const functionInfo = zapierSdk.__registry.find(
|
|
239
|
+
(info) => info.name === functionName
|
|
240
|
+
);
|
|
241
|
+
if (!functionInfo) {
|
|
242
|
+
const availableTools = zapierSdk.__registry.map((info) => info.name.replace(/([A-Z])/g, "-$1").toLowerCase()).join(", ");
|
|
243
|
+
throw new Error(
|
|
244
|
+
`Unknown tool: ${name}. Available tools: ${availableTools}`
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
try {
|
|
248
|
+
const validatedArgs = functionInfo.inputSchema.parse(args || {});
|
|
249
|
+
const result = await functionInfo.implementation(validatedArgs);
|
|
250
|
+
return {
|
|
251
|
+
content: [
|
|
252
|
+
{
|
|
253
|
+
type: "text",
|
|
254
|
+
text: JSON.stringify(result, null, 2)
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
};
|
|
258
|
+
} catch (error) {
|
|
259
|
+
if (debug) {
|
|
260
|
+
console.error(
|
|
261
|
+
`Error executing function '${functionInfo.name}' (tool: ${name}):`,
|
|
262
|
+
error
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
let errorMessage;
|
|
266
|
+
let isValidationError = false;
|
|
267
|
+
if (error instanceof Error) {
|
|
268
|
+
if (error.name === "ZodError") {
|
|
269
|
+
isValidationError = true;
|
|
270
|
+
errorMessage = `Validation error for ${functionInfo.name}: ${error.message}`;
|
|
271
|
+
} else {
|
|
272
|
+
errorMessage = `Error in ${functionInfo.name}: ${error.message}`;
|
|
273
|
+
}
|
|
274
|
+
} else {
|
|
275
|
+
errorMessage = `Unexpected error in ${functionInfo.name}: ${String(error)}`;
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
content: [
|
|
279
|
+
{
|
|
280
|
+
type: "text",
|
|
281
|
+
text: isValidationError ? `${errorMessage}
|
|
282
|
+
|
|
283
|
+
Expected input format:
|
|
284
|
+
${JSON.stringify(convertZodToMcpSchema(functionInfo.inputSchema), null, 2)}` : errorMessage
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
isError: true
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
return server;
|
|
292
|
+
}
|
|
293
|
+
async function startMcpServer(options = {}) {
|
|
294
|
+
const server = createZapierMcpServer(options);
|
|
295
|
+
const transport = new StdioServerTransport();
|
|
296
|
+
await server.connect(transport);
|
|
297
|
+
}
|
|
298
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
299
|
+
const debug = process.argv.includes("--debug");
|
|
300
|
+
startMcpServer({ debug }).catch((error) => {
|
|
301
|
+
console.error("Failed to start MCP server:", error);
|
|
302
|
+
process.exit(1);
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
async function startMcpServerAsProcess(options = {}) {
|
|
306
|
+
try {
|
|
307
|
+
const require2 = createRequire(import.meta.url);
|
|
308
|
+
let mcpServerPath;
|
|
309
|
+
try {
|
|
310
|
+
mcpServerPath = require2.resolve("@zapier/zapier-sdk-mcp/dist/index.mjs");
|
|
311
|
+
} catch {
|
|
312
|
+
mcpServerPath = require2.resolve("@zapier/zapier-sdk-mcp");
|
|
313
|
+
}
|
|
314
|
+
if (!existsSync(mcpServerPath)) {
|
|
315
|
+
console.error(`MCP server executable not found at: ${mcpServerPath}`);
|
|
316
|
+
console.error("Please run 'pnpm build' to build the MCP server package.");
|
|
317
|
+
process.exit(1);
|
|
318
|
+
}
|
|
319
|
+
const args = [];
|
|
320
|
+
if (options.debug) {
|
|
321
|
+
args.push("--debug");
|
|
322
|
+
}
|
|
323
|
+
if (options.port) {
|
|
324
|
+
args.push("--port", options.port);
|
|
325
|
+
}
|
|
326
|
+
const mcpProcess = spawn("node", [mcpServerPath, ...args], {
|
|
327
|
+
stdio: "inherit",
|
|
328
|
+
cwd: process.cwd()
|
|
329
|
+
});
|
|
330
|
+
mcpProcess.on("error", (error) => {
|
|
331
|
+
console.error("Failed to start MCP server:", error.message);
|
|
332
|
+
process.exit(1);
|
|
333
|
+
});
|
|
334
|
+
mcpProcess.on("exit", (code, signal) => {
|
|
335
|
+
if (signal) {
|
|
336
|
+
console.log(`MCP server terminated by signal: ${signal}`);
|
|
337
|
+
} else if (code !== 0) {
|
|
338
|
+
console.error(`MCP server exited with code: ${code}`);
|
|
339
|
+
process.exit(code);
|
|
340
|
+
} else {
|
|
341
|
+
console.log("MCP server stopped gracefully");
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
const shutdown = (signal) => {
|
|
345
|
+
console.log(`
|
|
346
|
+
Received ${signal}, shutting down MCP server...`);
|
|
347
|
+
mcpProcess.kill(signal);
|
|
348
|
+
};
|
|
349
|
+
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
350
|
+
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
|
351
|
+
} catch (error) {
|
|
352
|
+
console.error("Error starting MCP server:", error);
|
|
353
|
+
process.exit(1);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
export {
|
|
357
|
+
createZapierMcpServer,
|
|
358
|
+
startMcpServer,
|
|
359
|
+
startMcpServerAsProcess
|
|
360
|
+
};
|
|
361
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/schema-converter.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { 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 type ZapierSdk,\n type FunctionRegistryEntry,\n} from \"@zapier/zapier-sdk\";\nimport { convertZodToMcpSchema } from \"./utils/schema-converter.js\";\nimport { spawn } from \"child_process\";\nimport { existsSync } from \"fs\";\nimport { createRequire } from \"module\";\n\ninterface ZapierMcpServerOptions {\n debug?: boolean;\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({ debug = false }: ZapierMcpServerOptions = {}) {\n // Create Zapier SDK instance\n const zapierSdk: ZapierSdk = createZapierSdk({ debug });\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.__registry.map(\n (functionInfo: FunctionRegistryEntry) => {\n const toolName = functionInfo.name\n .replace(/([A-Z])/g, \"-$1\")\n .toLowerCase();\n\n return {\n name: toolName,\n description:\n functionInfo.inputSchema.description ||\n `Execute ${functionInfo.name}`,\n inputSchema: convertZodToMcpSchema(functionInfo.inputSchema),\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 =\n zapierSdk.__registry.find(\n (info: FunctionRegistryEntry) => info.name === functionName,\n );\n\n if (!functionInfo) {\n const availableTools = zapierSdk.__registry\n .map((info) => info.name.replace(/([A-Z])/g, \"-$1\").toLowerCase())\n .join(\", \");\n throw new Error(\n `Unknown tool: ${name}. Available tools: ${availableTools}`,\n );\n }\n\n try {\n // Validate arguments against schema\n const validatedArgs = functionInfo.inputSchema.parse(args || {});\n\n // Execute the function\n const result = await functionInfo.implementation(validatedArgs);\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 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 return {\n content: [\n {\n type: \"text\",\n text: isValidationError\n ? `${errorMessage}\\n\\nExpected input format:\\n${JSON.stringify(convertZodToMcpSchema(functionInfo.inputSchema), 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(options: ZapierMcpServerOptions = {}) {\n const server = createZapierMcpServer(options);\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n\n// Auto-start if this file is run directly\nif (import.meta.url === `file://${process.argv[1]}`) {\n const debug = process.argv.includes(\"--debug\");\n startMcpServer({ debug }).catch((error) => {\n console.error(\"Failed to start MCP server:\", error);\n process.exit(1);\n });\n}\n\n/**\n * Starts the MCP server as a child process with process lifecycle management.\n *\n * This function handles spawning the MCP server as a separate Node.js process,\n * managing its lifecycle, and providing graceful shutdown handling. It's designed\n * to be called from CLI tools that need to start the MCP server.\n *\n * @param options - Configuration options for the MCP server process\n * @param options.debug - Enable debug logging\n * @param options.port - Port to listen on (for future HTTP transport)\n */\nasync function startMcpServerAsProcess(\n options: {\n debug?: boolean;\n port?: string;\n } = {},\n) {\n try {\n // Resolve our own executable path using Node.js module resolution\n const require = createRequire(import.meta.url);\n let mcpServerPath: string;\n\n try {\n // Try to resolve the built executable first\n mcpServerPath = require.resolve(\"@zapier/zapier-sdk-mcp/dist/index.mjs\");\n } catch {\n // Fallback to package main entry\n mcpServerPath = require.resolve(\"@zapier/zapier-sdk-mcp\");\n }\n\n // Validate that the executable exists\n if (!existsSync(mcpServerPath)) {\n console.error(`MCP server executable not found at: ${mcpServerPath}`);\n console.error(\"Please run 'pnpm build' to build the MCP server package.\");\n process.exit(1);\n }\n\n // Prepare arguments\n const args: string[] = [];\n if (options.debug) {\n args.push(\"--debug\");\n }\n if (options.port) {\n args.push(\"--port\", options.port);\n }\n\n // Start the MCP server as a child process\n const mcpProcess = spawn(\"node\", [mcpServerPath, ...args], {\n stdio: \"inherit\",\n cwd: process.cwd(),\n });\n\n // Handle process events\n mcpProcess.on(\"error\", (error) => {\n console.error(\"Failed to start MCP server:\", error.message);\n process.exit(1);\n });\n\n mcpProcess.on(\"exit\", (code, signal) => {\n if (signal) {\n console.log(`MCP server terminated by signal: ${signal}`);\n } else if (code !== 0) {\n console.error(`MCP server exited with code: ${code}`);\n process.exit(code);\n } else {\n console.log(\"MCP server stopped gracefully\");\n }\n });\n\n // Handle graceful shutdown\n const shutdown = (signal: NodeJS.Signals) => {\n console.log(`\\nReceived ${signal}, shutting down MCP server...`);\n mcpProcess.kill(signal);\n };\n\n process.on(\"SIGINT\", () => shutdown(\"SIGINT\"));\n process.on(\"SIGTERM\", () => shutdown(\"SIGTERM\"));\n } catch (error) {\n console.error(\"Error starting MCP server:\", error);\n process.exit(1);\n }\n}\n\nexport { createZapierMcpServer, startMcpServer, startMcpServerAsProcess };\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 { 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// Types for Zod internals to improve type safety\ninterface ZodDef {\n typeName: string;\n description?: string;\n type?: z.ZodSchema;\n innerType?: z.ZodSchema;\n values?: readonly string[];\n options?: z.ZodSchema[];\n left?: z.ZodSchema;\n right?: z.ZodSchema;\n value?: unknown;\n valueType?: z.ZodSchema;\n}\n\ninterface ZodSchemaWithShape extends z.ZodSchema {\n shape?: Record<string, z.ZodSchema>;\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 return convertZodType(\n (zodSchema as unknown as { _def: ZodDef })._def,\n zodSchema,\n );\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 // Handle ZodObject\n if (def.typeName === \"ZodObject\" && 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 = (value as unknown as { _def: ZodDef })._def;\n properties[key] = convertZodType(fieldDef, value);\n\n // Check if field is required (not optional)\n if (\n fieldDef.typeName !== \"ZodOptional\" &&\n fieldDef.typeName !== \"ZodNullable\"\n ) {\n required.push(key);\n }\n }\n }\n\n const result: McpSchema = {\n type: \"object\",\n properties,\n description: def.description,\n };\n\n if (required.length > 0) {\n result.required = required;\n }\n\n return result;\n }\n\n // Handle ZodString\n if (def.typeName === \"ZodString\") {\n const schema: McpSchema = { type: \"string\" };\n if (def.description) schema.description = def.description;\n return schema;\n }\n\n // Handle ZodNumber\n if (def.typeName === \"ZodNumber\") {\n const schema: McpSchema = { type: \"number\" };\n if (def.description) schema.description = def.description;\n return schema;\n }\n\n // Handle ZodBoolean\n if (def.typeName === \"ZodBoolean\") {\n const schema: McpSchema = { type: \"boolean\" };\n if (def.description) schema.description = def.description;\n return schema;\n }\n\n // Handle ZodArray\n if (def.typeName === \"ZodArray\" && def.type) {\n return {\n type: \"array\",\n items: convertZodType(\n (def.type as unknown as { _def: ZodDef })._def,\n def.type,\n ),\n description: def.description,\n };\n }\n\n // Handle ZodOptional\n if (def.typeName === \"ZodOptional\" && def.innerType) {\n return convertZodType(\n (def.innerType as unknown as { _def: ZodDef })._def,\n def.innerType,\n );\n }\n\n // Handle ZodNullable\n if (def.typeName === \"ZodNullable\" && def.innerType) {\n const innerSchema = convertZodType(\n (def.innerType as unknown as { _def: ZodDef })._def,\n def.innerType,\n );\n return {\n ...innerSchema,\n type: Array.isArray(innerSchema.type)\n ? [...innerSchema.type, \"null\"]\n : [innerSchema.type, \"null\"],\n };\n }\n\n // Handle ZodEnum\n if (def.typeName === \"ZodEnum\" && def.values) {\n return {\n type: \"string\",\n enum: Array.from(def.values),\n description: def.description,\n };\n }\n\n // Handle ZodUnion\n if (def.typeName === \"ZodUnion\" && def.options) {\n return {\n oneOf: def.options.map((option) =>\n convertZodType((option as unknown as { _def: ZodDef })._def, option),\n ),\n description: def.description,\n };\n }\n\n // Handle ZodIntersection\n if (def.typeName === \"ZodIntersection\" && def.left && def.right) {\n return {\n allOf: [\n convertZodType(\n (def.left as unknown as { _def: ZodDef })._def,\n def.left,\n ),\n convertZodType(\n (def.right as unknown as { _def: ZodDef })._def,\n def.right,\n ),\n ],\n description: def.description,\n };\n }\n\n // Handle ZodLiteral\n if (def.typeName === \"ZodLiteral\" && def.value !== undefined) {\n const value = def.value;\n return {\n type: typeof value as \"string\" | \"number\" | \"boolean\",\n enum: [value],\n description: def.description,\n };\n }\n\n // Handle ZodRecord (for object with string keys)\n if (def.typeName === \"ZodRecord\") {\n return {\n type: \"object\",\n additionalProperties: def.valueType\n ? convertZodType(\n (def.valueType as unknown as { _def: ZodDef })._def,\n def.valueType,\n )\n : true,\n description: def.description,\n };\n }\n\n // Handle ZodAny\n if (def.typeName === \"ZodAny\") {\n return {\n description: def.description || \"Any value\",\n };\n }\n\n // Handle ZodUnknown\n if (def.typeName === \"ZodUnknown\") {\n return {\n description: def.description || \"Unknown value\",\n };\n }\n\n // Handle ZodDate\n if (def.typeName === \"ZodDate\") {\n return {\n type: \"string\",\n format: \"date-time\",\n description: def.description || \"ISO 8601 date-time string\",\n };\n }\n\n // Handle ZodBigInt\n if (def.typeName === \"ZodBigInt\") {\n return {\n type: \"string\",\n description: def.description || \"BigInt as string\",\n };\n }\n\n // Handle ZodUndefined\n if (def.typeName === \"ZodUndefined\") {\n return {\n type: \"null\",\n description: def.description || \"Undefined value\",\n };\n }\n\n // Handle ZodNull\n if (def.typeName === \"ZodNull\") {\n return {\n type: \"null\",\n description: def.description || \"Null value\",\n };\n }\n\n // Handle ZodVoid\n if (def.typeName === \"ZodVoid\") {\n return {\n type: \"null\",\n description: def.description || \"Void (null) value\",\n };\n }\n\n // Handle ZodNaN\n if (def.typeName === \"ZodNaN\") {\n return {\n type: \"number\",\n description: def.description || \"Not-a-Number value\",\n };\n }\n\n // Handle ZodDefault\n if (def.typeName === \"ZodDefault\" && def.innerType) {\n return convertZodType(\n (def.innerType as unknown as { _def: ZodDef })._def,\n def.innerType,\n );\n }\n\n // Handle ZodCatch (with fallback value)\n if (def.typeName === \"ZodCatch\" && def.innerType) {\n return convertZodType(\n (def.innerType as unknown as { _def: ZodDef })._def,\n def.innerType,\n );\n }\n\n // Fallback for unhandled types\n console.warn(\n `Unhandled Zod type: ${def.typeName}. Please consider adding support for this type.`,\n );\n return {\n type: \"string\",\n description: def.description || `Unsupported type: ${def.typeName}`,\n };\n}\n\nexport { convertZodToMcpSchema };\n"],"mappings":";;;AAEA,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,OAGK;;;AC8DP,SAAS,sBAAsB,WAAmC;AAChE,SAAO;AAAA,IACJ,UAA0C;AAAA,IAC3C;AAAA,EACF;AACF;AAaA,SAAS,eAAe,KAAa,QAAiC;AAEpE,MAAI,IAAI,aAAa,eAAe,QAAQ;AAC1C,UAAM,kBAAkB;AACxB,UAAM,aAAwC,CAAC;AAC/C,UAAM,WAAqB,CAAC;AAE5B,QAAI,gBAAgB,OAAO;AACzB,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,gBAAgB,KAAK,GAAG;AAChE,cAAM,WAAY,MAAsC;AACxD,mBAAW,GAAG,IAAI,eAAe,UAAU,KAAK;AAGhD,YACE,SAAS,aAAa,iBACtB,SAAS,aAAa,eACtB;AACA,mBAAS,KAAK,GAAG;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAEA,UAAM,SAAoB;AAAA,MACxB,MAAM;AAAA,MACN;AAAA,MACA,aAAa,IAAI;AAAA,IACnB;AAEA,QAAI,SAAS,SAAS,GAAG;AACvB,aAAO,WAAW;AAAA,IACpB;AAEA,WAAO;AAAA,EACT;AAGA,MAAI,IAAI,aAAa,aAAa;AAChC,UAAMA,UAAoB,EAAE,MAAM,SAAS;AAC3C,QAAI,IAAI,YAAa,CAAAA,QAAO,cAAc,IAAI;AAC9C,WAAOA;AAAA,EACT;AAGA,MAAI,IAAI,aAAa,aAAa;AAChC,UAAMA,UAAoB,EAAE,MAAM,SAAS;AAC3C,QAAI,IAAI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M,aAAa,MAAM,QAAQ,CAAC,eAAe,GAAG,IAAI,GAAG;AAAA,MACzD,OAAO;AAAA,MACP,KAAK,QAAQ,IAAI;AAAA,IACnB,CAAC;AAGD,eAAW,GAAG,SAAS,CAAC,UAAU;AAChC,cAAQ,MAAM,+BAA+B,MAAM,OAAO;AAC1D,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAED,eAAW,GAAG,QAAQ,CAAC,MAAM,WAAW;AACtC,UAAI,QAAQ;AACV,gBAAQ,IAAI,oCAAoC,MAAM,EAAE;AAAA,MAC1D,WAAW,SAAS,GAAG;AACrB,gBAAQ,MAAM,gCAAgC,IAAI,EAAE;AACpD,gBAAQ,KAAK,IAAI;AAAA,MACnB,OAAO;AACL,gBAAQ,IAAI,+BAA+B;AAAA,MAC7C;AAAA,IACF,CAAC;AAGD,UAAM,WAAW,CAAC,WAA2B;AAC3C,cAAQ,IAAI;AAAA,WAAc,MAAM,+BAA+B;AAC/D,iBAAW,KAAK,MAAM;AAAA,IACxB;AAEA,YAAQ,GAAG,UAAU,MAAM,SAAS,QAAQ,CAAC;AAC7C,YAAQ,GAAG,WAAW,MAAM,SAAS,SAAS,CAAC;AAAA,EACjD,SAAS,OAAO;AACd,YAAQ,MAAM,8BAA8B,KAAK;AACjD,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":["schema","require"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zapier/zapier-sdk-mcp",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "MCP server for Zapier SDK",
|
|
5
|
+
"main": "dist/index.mjs",
|
|
6
|
+
"types": "dist/index.d.mts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"zapier-sdk-mcp": "./dist/index.mjs"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"zapier",
|
|
12
|
+
"sdk",
|
|
13
|
+
"mcp",
|
|
14
|
+
"model-context-protocol"
|
|
15
|
+
],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "restricted"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@modelcontextprotocol/sdk": "^1.17.3",
|
|
23
|
+
"zod": "^3.22.4",
|
|
24
|
+
"@zapier/zapier-sdk": "0.4.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^20.0.0",
|
|
28
|
+
"tsup": "^8.0.0",
|
|
29
|
+
"typescript": "^5.0.0",
|
|
30
|
+
"vitest": "^3.2.4"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsup",
|
|
37
|
+
"clean": "rm -rf dist",
|
|
38
|
+
"rebuild": "pnpm clean && pnpm build",
|
|
39
|
+
"dev": "tsup --watch",
|
|
40
|
+
"start": "node dist/index.mjs",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"test": "vitest",
|
|
43
|
+
"test:run": "vitest run"
|
|
44
|
+
}
|
|
45
|
+
}
|