@mesheshq/mcp-server 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +167 -0
- package/dist/client.d.ts +114 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +185 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +19 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/connections.d.ts +4 -0
- package/dist/tools/connections.d.ts.map +1 -0
- package/dist/tools/connections.js +235 -0
- package/dist/tools/connections.js.map +1 -0
- package/dist/tools/deliveries.d.ts +4 -0
- package/dist/tools/deliveries.d.ts.map +1 -0
- package/dist/tools/deliveries.js +153 -0
- package/dist/tools/deliveries.js.map +1 -0
- package/dist/tools/events.d.ts +4 -0
- package/dist/tools/events.d.ts.map +1 -0
- package/dist/tools/events.js +89 -0
- package/dist/tools/events.js.map +1 -0
- package/dist/tools/rules.d.ts +4 -0
- package/dist/tools/rules.d.ts.map +1 -0
- package/dist/tools/rules.js +134 -0
- package/dist/tools/rules.js.map +1 -0
- package/dist/tools/workspaces.d.ts +4 -0
- package/dist/tools/workspaces.d.ts.map +1 -0
- package/dist/tools/workspaces.js +145 -0
- package/dist/tools/workspaces.js.map +1 -0
- package/dist/types.d.ts +101 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +14 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +10 -0
- package/dist/utils.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { toolError, toolOk } from '../utils.js';
|
|
3
|
+
const INTEGRATION_TYPES = [
|
|
4
|
+
'activecampaign',
|
|
5
|
+
'aweber',
|
|
6
|
+
'hubspot',
|
|
7
|
+
'intercom',
|
|
8
|
+
'mailchimp',
|
|
9
|
+
'mailerlite',
|
|
10
|
+
'resend',
|
|
11
|
+
'salesforce',
|
|
12
|
+
'webhook',
|
|
13
|
+
'zoom',
|
|
14
|
+
];
|
|
15
|
+
export function registerConnectionTools(server, client) {
|
|
16
|
+
server.registerTool('meshes_list_connections', {
|
|
17
|
+
title: 'List Connections',
|
|
18
|
+
description: 'List all connections across the organization. Connections are configured destinations (HubSpot, Salesforce, Resend, webhooks, etc.) holding credentials and config.',
|
|
19
|
+
inputSchema: {},
|
|
20
|
+
annotations: {
|
|
21
|
+
readOnlyHint: true,
|
|
22
|
+
destructiveHint: false,
|
|
23
|
+
idempotentHint: true,
|
|
24
|
+
openWorldHint: true,
|
|
25
|
+
},
|
|
26
|
+
}, async () => {
|
|
27
|
+
try {
|
|
28
|
+
return toolOk(await client.listConnections());
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
return toolError(e);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
server.registerTool('meshes_get_connection', {
|
|
35
|
+
title: 'Get Connection',
|
|
36
|
+
description: 'Get details of a specific connection. Does not expose raw credentials.',
|
|
37
|
+
inputSchema: {
|
|
38
|
+
connection_id: z.string().uuid().describe('The connection UUID'),
|
|
39
|
+
},
|
|
40
|
+
annotations: {
|
|
41
|
+
readOnlyHint: true,
|
|
42
|
+
destructiveHint: false,
|
|
43
|
+
idempotentHint: true,
|
|
44
|
+
openWorldHint: true,
|
|
45
|
+
},
|
|
46
|
+
}, async ({ connection_id }) => {
|
|
47
|
+
try {
|
|
48
|
+
return toolOk(await client.getConnection(connection_id));
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
return toolError(e);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
server.registerTool('meshes_create_connection', {
|
|
55
|
+
title: 'Create Connection',
|
|
56
|
+
description: 'Create a new connection (destination) in a workspace. The metadata object contains connector-specific configuration (API keys, OAuth tokens, webhook URLs, etc.).',
|
|
57
|
+
inputSchema: {
|
|
58
|
+
workspace: z
|
|
59
|
+
.string()
|
|
60
|
+
.uuid()
|
|
61
|
+
.describe('The workspace UUID this connection belongs to'),
|
|
62
|
+
type: z.enum(INTEGRATION_TYPES).describe('Integration type'),
|
|
63
|
+
name: z
|
|
64
|
+
.string()
|
|
65
|
+
.min(1)
|
|
66
|
+
.max(128)
|
|
67
|
+
.describe('Connection name (alphanumeric/space/underscore/dash)'),
|
|
68
|
+
metadata: z
|
|
69
|
+
.record(z.string(), z.unknown())
|
|
70
|
+
.describe('Connector-specific configuration'),
|
|
71
|
+
hidden: z
|
|
72
|
+
.boolean()
|
|
73
|
+
.default(false)
|
|
74
|
+
.optional()
|
|
75
|
+
.describe('Hide from UI (default false)'),
|
|
76
|
+
},
|
|
77
|
+
annotations: {
|
|
78
|
+
readOnlyHint: false,
|
|
79
|
+
destructiveHint: false,
|
|
80
|
+
idempotentHint: false,
|
|
81
|
+
openWorldHint: true,
|
|
82
|
+
},
|
|
83
|
+
}, async ({ workspace, type, name, metadata, hidden }) => {
|
|
84
|
+
try {
|
|
85
|
+
return toolOk(await client.createConnection({
|
|
86
|
+
workspace,
|
|
87
|
+
type: type,
|
|
88
|
+
name,
|
|
89
|
+
metadata,
|
|
90
|
+
hidden,
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
return toolError(e);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
server.registerTool('meshes_update_connection', {
|
|
98
|
+
title: 'Update Connection',
|
|
99
|
+
description: "Update a connection's name, metadata, or visibility.",
|
|
100
|
+
inputSchema: {
|
|
101
|
+
connection_id: z.string().uuid().describe('The connection UUID'),
|
|
102
|
+
name: z.string().min(1).max(128).describe('Updated name'),
|
|
103
|
+
metadata: z
|
|
104
|
+
.record(z.string(), z.unknown())
|
|
105
|
+
.describe('Updated connector-specific configuration'),
|
|
106
|
+
hidden: z.boolean().optional().describe('Hide from UI'),
|
|
107
|
+
},
|
|
108
|
+
annotations: {
|
|
109
|
+
readOnlyHint: false,
|
|
110
|
+
destructiveHint: false,
|
|
111
|
+
idempotentHint: true,
|
|
112
|
+
openWorldHint: true,
|
|
113
|
+
},
|
|
114
|
+
}, async ({ connection_id, name, metadata, hidden }) => {
|
|
115
|
+
try {
|
|
116
|
+
return toolOk(await client.updateConnection(connection_id, {
|
|
117
|
+
name,
|
|
118
|
+
metadata,
|
|
119
|
+
hidden,
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
return toolError(e);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
server.registerTool('meshes_delete_connection', {
|
|
127
|
+
title: 'Delete Connection',
|
|
128
|
+
description: 'Delete a connection. Returns 409 if it has active rules unless force_delete is true.',
|
|
129
|
+
inputSchema: {
|
|
130
|
+
connection_id: z.string().uuid().describe('The connection UUID'),
|
|
131
|
+
force_delete: z
|
|
132
|
+
.boolean()
|
|
133
|
+
.default(false)
|
|
134
|
+
.optional()
|
|
135
|
+
.describe('Force delete even if rules exist'),
|
|
136
|
+
},
|
|
137
|
+
annotations: {
|
|
138
|
+
readOnlyHint: false,
|
|
139
|
+
destructiveHint: true,
|
|
140
|
+
idempotentHint: false,
|
|
141
|
+
openWorldHint: true,
|
|
142
|
+
},
|
|
143
|
+
}, async ({ connection_id, force_delete }) => {
|
|
144
|
+
try {
|
|
145
|
+
return toolOk(await client.deleteConnection(connection_id, force_delete));
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
return toolError(e);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
server.registerTool('meshes_get_connection_actions', {
|
|
152
|
+
title: 'Get Connection Actions',
|
|
153
|
+
description: 'Get available actions for a connection (e.g., create_or_update_contact, add_to_list). Use this to discover what actions to put in rule metadata.',
|
|
154
|
+
inputSchema: {
|
|
155
|
+
connection_id: z.string().uuid().describe('The connection UUID'),
|
|
156
|
+
},
|
|
157
|
+
annotations: {
|
|
158
|
+
readOnlyHint: true,
|
|
159
|
+
destructiveHint: false,
|
|
160
|
+
idempotentHint: true,
|
|
161
|
+
openWorldHint: true,
|
|
162
|
+
},
|
|
163
|
+
}, async ({ connection_id }) => {
|
|
164
|
+
try {
|
|
165
|
+
return toolOk(await client.getConnectionActions(connection_id));
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
return toolError(e);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
server.registerTool('meshes_get_connection_fields', {
|
|
172
|
+
title: 'Get Connection Fields',
|
|
173
|
+
description: 'Get the destination field catalog for a connection. Returns field keys, types, constraints, and allowed values. Useful for building field mappings.',
|
|
174
|
+
inputSchema: {
|
|
175
|
+
connection_id: z.string().uuid().describe('The connection UUID'),
|
|
176
|
+
refresh: z
|
|
177
|
+
.boolean()
|
|
178
|
+
.default(false)
|
|
179
|
+
.optional()
|
|
180
|
+
.describe('Force refresh the field catalog from the provider'),
|
|
181
|
+
},
|
|
182
|
+
annotations: {
|
|
183
|
+
readOnlyHint: true,
|
|
184
|
+
destructiveHint: false,
|
|
185
|
+
idempotentHint: true,
|
|
186
|
+
openWorldHint: true,
|
|
187
|
+
},
|
|
188
|
+
}, async ({ connection_id, refresh }) => {
|
|
189
|
+
try {
|
|
190
|
+
return toolOk(await client.getConnectionFields(connection_id, refresh));
|
|
191
|
+
}
|
|
192
|
+
catch (e) {
|
|
193
|
+
return toolError(e);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
server.registerTool('meshes_get_connection_default_mappings', {
|
|
197
|
+
title: 'Get Connection Default Mappings',
|
|
198
|
+
description: 'Get the default field mapping for a connection. Mappings define how event payload fields map to destination fields with optional transforms (trim, lower, upper, to_string, etc.).',
|
|
199
|
+
inputSchema: {
|
|
200
|
+
connection_id: z.string().uuid().describe('The connection UUID'),
|
|
201
|
+
},
|
|
202
|
+
annotations: {
|
|
203
|
+
readOnlyHint: true,
|
|
204
|
+
destructiveHint: false,
|
|
205
|
+
idempotentHint: true,
|
|
206
|
+
openWorldHint: true,
|
|
207
|
+
},
|
|
208
|
+
}, async ({ connection_id }) => {
|
|
209
|
+
try {
|
|
210
|
+
return toolOk(await client.getConnectionDefaultMappings(connection_id));
|
|
211
|
+
}
|
|
212
|
+
catch (e) {
|
|
213
|
+
return toolError(e);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
server.registerTool('meshes_list_integrations', {
|
|
217
|
+
title: 'List Integrations',
|
|
218
|
+
description: "Get metadata about all supported integration types. Returns each type's authentication method (oauth, api_key, basic, none), available actions, and field definitions. Useful for discovering what integrations are possible and what actions they support.",
|
|
219
|
+
inputSchema: {},
|
|
220
|
+
annotations: {
|
|
221
|
+
readOnlyHint: true,
|
|
222
|
+
destructiveHint: false,
|
|
223
|
+
idempotentHint: true,
|
|
224
|
+
openWorldHint: true,
|
|
225
|
+
},
|
|
226
|
+
}, async () => {
|
|
227
|
+
try {
|
|
228
|
+
return toolOk(await client.listIntegrations());
|
|
229
|
+
}
|
|
230
|
+
catch (e) {
|
|
231
|
+
return toolError(e);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../src/tools/connections.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,iBAAiB,GAAG;IACxB,gBAAgB;IAChB,QAAQ;IACR,SAAS;IACT,UAAU;IACV,WAAW;IACX,YAAY;IACZ,QAAQ;IACR,YAAY;IACZ,SAAS;IACT,MAAM;CACE,CAAC;AAEX,MAAM,UAAU,uBAAuB,CACrC,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AW,EAAE,EAAE;QACf,WAAW,EAAE;YACX,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,IAAI;SACpB;KACF,EACD,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,OAAO,MAAM,CAAC,MAAM,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC;QACjD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deliveries.d.ts","sourceRoot":"","sources":["../../src/tools/deliveries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAWpD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,eAAe,QAiLxB"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { toolError, toolOk } from '../utils.js';
|
|
3
|
+
const EVENT_STATUSES = [
|
|
4
|
+
'pending',
|
|
5
|
+
'processing',
|
|
6
|
+
'completed',
|
|
7
|
+
'failed',
|
|
8
|
+
];
|
|
9
|
+
export function registerDeliveryTools(server, client) {
|
|
10
|
+
server.registerTool('meshes_get_workspace_events', {
|
|
11
|
+
title: 'Get Workspace Events',
|
|
12
|
+
description: 'List events for a workspace with optional filters. Useful for checking delivery status, debugging, or monitoring event flow.',
|
|
13
|
+
inputSchema: {
|
|
14
|
+
workspace_id: z.string().uuid().describe('The workspace UUID'),
|
|
15
|
+
limit: z
|
|
16
|
+
.number()
|
|
17
|
+
.min(1)
|
|
18
|
+
.max(200)
|
|
19
|
+
.default(50)
|
|
20
|
+
.optional()
|
|
21
|
+
.describe('Results per page (1-200, default 50)'),
|
|
22
|
+
cursor: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Pagination cursor from previous response's next_cursor"),
|
|
26
|
+
event: z
|
|
27
|
+
.string()
|
|
28
|
+
.optional()
|
|
29
|
+
.describe("Filter by event type (e.g., 'user.signup')"),
|
|
30
|
+
status: z
|
|
31
|
+
.enum(EVENT_STATUSES)
|
|
32
|
+
.optional()
|
|
33
|
+
.describe('Filter by delivery status'),
|
|
34
|
+
resource: z.string().optional().describe('Filter by resource type'),
|
|
35
|
+
resource_id: z.string().optional().describe('Filter by resource ID'),
|
|
36
|
+
},
|
|
37
|
+
annotations: {
|
|
38
|
+
readOnlyHint: true,
|
|
39
|
+
destructiveHint: false,
|
|
40
|
+
idempotentHint: true,
|
|
41
|
+
openWorldHint: true,
|
|
42
|
+
},
|
|
43
|
+
}, async ({ workspace_id, limit, cursor, event, status, resource, resource_id, }) => {
|
|
44
|
+
try {
|
|
45
|
+
return toolOk(await client.getWorkspaceEvents(workspace_id, {
|
|
46
|
+
limit,
|
|
47
|
+
cursor,
|
|
48
|
+
event,
|
|
49
|
+
status: status,
|
|
50
|
+
resource,
|
|
51
|
+
resource_id,
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
return toolError(e);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
server.registerTool('meshes_list_events', {
|
|
59
|
+
title: 'List Events',
|
|
60
|
+
description: 'List events across the organization with pagination.',
|
|
61
|
+
inputSchema: {
|
|
62
|
+
limit: z
|
|
63
|
+
.number()
|
|
64
|
+
.min(1)
|
|
65
|
+
.max(200)
|
|
66
|
+
.default(50)
|
|
67
|
+
.optional()
|
|
68
|
+
.describe('Results per page (1-200, default 50)'),
|
|
69
|
+
cursor: z
|
|
70
|
+
.string()
|
|
71
|
+
.optional()
|
|
72
|
+
.describe('Pagination cursor from previous response'),
|
|
73
|
+
},
|
|
74
|
+
annotations: {
|
|
75
|
+
readOnlyHint: true,
|
|
76
|
+
destructiveHint: false,
|
|
77
|
+
idempotentHint: true,
|
|
78
|
+
openWorldHint: true,
|
|
79
|
+
},
|
|
80
|
+
}, async ({ limit, cursor }) => {
|
|
81
|
+
try {
|
|
82
|
+
return toolOk(await client.listEvents({ limit, cursor }));
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
return toolError(e);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
server.registerTool('meshes_get_event', {
|
|
89
|
+
title: 'Get Event',
|
|
90
|
+
description: 'Get event details including delivery status and per-rule results (rule_events). Each rule_event shows connection, integration_type, status, attempt_count, and last_error.',
|
|
91
|
+
inputSchema: {
|
|
92
|
+
event_id: z.string().uuid().describe('The event UUID'),
|
|
93
|
+
},
|
|
94
|
+
annotations: {
|
|
95
|
+
readOnlyHint: true,
|
|
96
|
+
destructiveHint: false,
|
|
97
|
+
idempotentHint: true,
|
|
98
|
+
openWorldHint: true,
|
|
99
|
+
},
|
|
100
|
+
}, async ({ event_id }) => {
|
|
101
|
+
try {
|
|
102
|
+
return toolOk(await client.getEvent(event_id));
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
return toolError(e);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
server.registerTool('meshes_get_event_payload', {
|
|
109
|
+
title: 'Get Event with Payload',
|
|
110
|
+
description: 'Get event details including the full event payload. Useful for debugging what data was sent.',
|
|
111
|
+
inputSchema: {
|
|
112
|
+
event_id: z.string().uuid().describe('The event UUID'),
|
|
113
|
+
},
|
|
114
|
+
annotations: {
|
|
115
|
+
readOnlyHint: true,
|
|
116
|
+
destructiveHint: false,
|
|
117
|
+
idempotentHint: true,
|
|
118
|
+
openWorldHint: true,
|
|
119
|
+
},
|
|
120
|
+
}, async ({ event_id }) => {
|
|
121
|
+
try {
|
|
122
|
+
return toolOk(await client.getEventPayload(event_id));
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
return toolError(e);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
server.registerTool('meshes_retry_event_rule', {
|
|
129
|
+
title: 'Retry Event Rule',
|
|
130
|
+
description: 'Manually retry a failed rule delivery for a specific event. Use after investigating and fixing the underlying issue (e.g., expired credentials, misconfigured mapping).',
|
|
131
|
+
inputSchema: {
|
|
132
|
+
event_id: z.string().uuid().describe('The event UUID'),
|
|
133
|
+
rule_id: z
|
|
134
|
+
.string()
|
|
135
|
+
.uuid()
|
|
136
|
+
.describe('The rule UUID (from rule_events in the event detail)'),
|
|
137
|
+
},
|
|
138
|
+
annotations: {
|
|
139
|
+
readOnlyHint: false,
|
|
140
|
+
destructiveHint: false,
|
|
141
|
+
idempotentHint: false,
|
|
142
|
+
openWorldHint: true,
|
|
143
|
+
},
|
|
144
|
+
}, async ({ event_id, rule_id }) => {
|
|
145
|
+
try {
|
|
146
|
+
return toolOk(await client.retryEventRule(event_id, rule_id));
|
|
147
|
+
}
|
|
148
|
+
catch (e) {
|
|
149
|
+
return toolError(e);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=deliveries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deliveries.js","sourceRoot":"","sources":["../../src/tools/deliveries.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,cAAc,GAAG;IACrB,SAAS;IACT,YAAY;IACZ,WAAW;IACX,QAAQ;CACA,CAAC;AAEX,MAAM,UAAU,qBAAqB,CACnC,MAAiB,EACjB,MAAuB;IAEvB,MAAM,CAAC,YAAY,CACjB,6BAA6B,EAC7B;QACE,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EACT,8HAA8H;QAChI,WAAW,EAAE;YACX,YAAY,EAAE,CAA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Ac,EAAE,KAAK;YACrB,aAAa,EAAE,IAAI;SACpB;KACF,EACD,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QAC9B,IAAI,CAAC;YACH,OAAO,MAAM,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;QAChE,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/tools/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,QAqG5E"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { toolError, toolOk } from '../utils.js';
|
|
3
|
+
export function registerEventTools(server, client) {
|
|
4
|
+
server.registerTool('meshes_emit_event', {
|
|
5
|
+
title: 'Emit Event',
|
|
6
|
+
description: "Emit a product event to Meshes for routing and delivery. The event is matched against rules in the specified workspace and delivered to all matching connections. Always include 'email' in the payload for person-related events.",
|
|
7
|
+
inputSchema: {
|
|
8
|
+
workspace: z
|
|
9
|
+
.string()
|
|
10
|
+
.uuid()
|
|
11
|
+
.describe('The workspace UUID to emit the event into'),
|
|
12
|
+
event: z
|
|
13
|
+
.string()
|
|
14
|
+
.min(1)
|
|
15
|
+
.describe("Event type (e.g., 'user.signup', 'payment.failed', 'form.submitted')"),
|
|
16
|
+
payload: z
|
|
17
|
+
.record(z.string(), z.unknown())
|
|
18
|
+
.describe("Event payload. Include 'email' for person-related events. Supports: email, id, ip_address, name, first_name, last_name, phone, resource_url, plus custom fields."),
|
|
19
|
+
resource: z
|
|
20
|
+
.string()
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("Optional resource type (e.g., 'user', 'order')"),
|
|
23
|
+
resource_id: z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe('Optional resource ID for deduplication'),
|
|
27
|
+
},
|
|
28
|
+
annotations: {
|
|
29
|
+
readOnlyHint: false,
|
|
30
|
+
destructiveHint: false,
|
|
31
|
+
idempotentHint: false,
|
|
32
|
+
openWorldHint: true,
|
|
33
|
+
},
|
|
34
|
+
}, async ({ workspace, event, payload, resource, resource_id }) => {
|
|
35
|
+
try {
|
|
36
|
+
const result = await client.emitEvent({
|
|
37
|
+
workspace,
|
|
38
|
+
event,
|
|
39
|
+
payload,
|
|
40
|
+
resource,
|
|
41
|
+
resource_id,
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
content: [
|
|
45
|
+
{
|
|
46
|
+
type: 'text',
|
|
47
|
+
text: `Event emitted successfully. ID: ${result.event.id}\n` +
|
|
48
|
+
`Event "${event}" will be routed to all matching rules in workspace ${workspace}.\n\n` +
|
|
49
|
+
JSON.stringify(result, null, 2),
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
return toolError(e);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
server.registerTool('meshes_emit_bulk_events', {
|
|
59
|
+
title: 'Emit Bulk Events',
|
|
60
|
+
description: 'Emit up to 100 events in a single request. Returns 201 on full success, 207 on partial success with per-event error details.',
|
|
61
|
+
inputSchema: {
|
|
62
|
+
events: z
|
|
63
|
+
.array(z.object({
|
|
64
|
+
workspace: z.string().uuid(),
|
|
65
|
+
event: z.string().min(1),
|
|
66
|
+
payload: z.record(z.string(), z.unknown()),
|
|
67
|
+
resource: z.string().optional(),
|
|
68
|
+
resource_id: z.string().optional(),
|
|
69
|
+
}))
|
|
70
|
+
.min(1)
|
|
71
|
+
.max(100)
|
|
72
|
+
.describe('Array of 1-100 event objects'),
|
|
73
|
+
},
|
|
74
|
+
annotations: {
|
|
75
|
+
readOnlyHint: false,
|
|
76
|
+
destructiveHint: false,
|
|
77
|
+
idempotentHint: false,
|
|
78
|
+
openWorldHint: true,
|
|
79
|
+
},
|
|
80
|
+
}, async ({ events }) => {
|
|
81
|
+
try {
|
|
82
|
+
return toolOk(await client.emitBulkEvents(events));
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
return toolError(e);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/tools/events.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,UAAU,kBAAkB,CAAC,MAAiB,EAAE,MAAuB;IAC3E,MAAM,CAAC,YAAY,CACjB,mBAAmB,EACnB;QACE,KAAK,EAAE,YAAY;QACnB,WAAW,EACT,oOAAoO;QACtO,WAAW,EAAE;YACX,SAAS,EAAE,CAAC;iBACT,MAAM,EAAE;iBACR,IAAI,EAAE;iBACN,QAAQ,CAAC,2CAA2C,CAAC;YACxD,KAAK,EAAE,CAAC;iBACL,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,CACP,sEAAsE,CACvE;YACH,OAAO,EAAE,CAAC;iBACP,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;iBAC/B,QAAQ,CACP,kKAAkK,CACnK;YACH,QAAQ,EAAE,CAAC;iBACR,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,gDA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E,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;gBAC1C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;gBAC/B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;aACnC,CAAC,CACH;iBACA,GAAG,CAAC,CAAC,CAAC;iBACN,GAAG,CAAC,GAAG,CAAC;iBACR,QAAQ,CAAC,8BAA8B,CAAC;SAC5C;QACD,WAAW,EAAE;YACX,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,KAAK;YACrB,aAAa,EAAE,IAAI;SACpB;KACF,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QACnB,IAAI,CAAC;YACH,OAAO,MAAM,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;QACrD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/tools/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,QAwK3E"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { toolError, toolOk } from '../utils.js';
|
|
3
|
+
export function registerRuleTools(server, client) {
|
|
4
|
+
server.registerTool('meshes_list_rules', {
|
|
5
|
+
title: 'List Rules',
|
|
6
|
+
description: 'List all routing rules across the organization. Rules bind event types to connections with action metadata. Supports filtering by event, resource, and resource_id.',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
event: z
|
|
9
|
+
.string()
|
|
10
|
+
.optional()
|
|
11
|
+
.describe("Filter by event type (e.g., 'user.signup')"),
|
|
12
|
+
resource: z.string().optional().describe('Filter by resource type'),
|
|
13
|
+
resource_id: z.string().optional().describe('Filter by resource ID'),
|
|
14
|
+
},
|
|
15
|
+
annotations: {
|
|
16
|
+
readOnlyHint: true,
|
|
17
|
+
destructiveHint: false,
|
|
18
|
+
idempotentHint: true,
|
|
19
|
+
openWorldHint: true,
|
|
20
|
+
},
|
|
21
|
+
}, async ({ event, resource, resource_id }) => {
|
|
22
|
+
try {
|
|
23
|
+
return toolOk(await client.listRules({ event, resource, resource_id }));
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
return toolError(e);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
server.registerTool('meshes_get_rule', {
|
|
30
|
+
title: 'Get Rule',
|
|
31
|
+
description: 'Get details of a specific routing rule by UUID.',
|
|
32
|
+
inputSchema: {
|
|
33
|
+
rule_id: z.string().uuid().describe('The rule UUID'),
|
|
34
|
+
},
|
|
35
|
+
annotations: {
|
|
36
|
+
readOnlyHint: true,
|
|
37
|
+
destructiveHint: false,
|
|
38
|
+
idempotentHint: true,
|
|
39
|
+
openWorldHint: true,
|
|
40
|
+
},
|
|
41
|
+
}, async ({ rule_id }) => {
|
|
42
|
+
try {
|
|
43
|
+
return toolOk(await client.getRule(rule_id));
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
return toolError(e);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
server.registerTool('meshes_create_rule', {
|
|
50
|
+
title: 'Create Rule',
|
|
51
|
+
description: "Create a routing rule that binds an event type to a connection. The metadata.action field is required and determines what the destination does (e.g., 'create_or_update_contact'). Use meshes_get_connection_actions to discover available actions.",
|
|
52
|
+
inputSchema: {
|
|
53
|
+
workspace: z.string().uuid().describe('The workspace UUID'),
|
|
54
|
+
connection: z
|
|
55
|
+
.string()
|
|
56
|
+
.uuid()
|
|
57
|
+
.describe('The connection UUID this rule routes to'),
|
|
58
|
+
event: z
|
|
59
|
+
.string()
|
|
60
|
+
.min(1)
|
|
61
|
+
.describe("Event type to match (e.g., 'user.signup', 'payment.failed')"),
|
|
62
|
+
action: z
|
|
63
|
+
.string()
|
|
64
|
+
.min(1)
|
|
65
|
+
.describe('The action the destination performs (goes into metadata.action)'),
|
|
66
|
+
resource: z
|
|
67
|
+
.string()
|
|
68
|
+
.optional()
|
|
69
|
+
.describe('Optional resource type filter'),
|
|
70
|
+
resource_id: z
|
|
71
|
+
.string()
|
|
72
|
+
.optional()
|
|
73
|
+
.describe('Optional resource ID filter (pattern: ^[A-Za-z0-9._:-]{1,64}$)'),
|
|
74
|
+
active: z
|
|
75
|
+
.boolean()
|
|
76
|
+
.default(true)
|
|
77
|
+
.optional()
|
|
78
|
+
.describe('Whether the rule is active (default true)'),
|
|
79
|
+
hidden: z
|
|
80
|
+
.boolean()
|
|
81
|
+
.default(false)
|
|
82
|
+
.optional()
|
|
83
|
+
.describe('Hide from UI (default false)'),
|
|
84
|
+
metadata_extra: z
|
|
85
|
+
.record(z.string(), z.string())
|
|
86
|
+
.optional()
|
|
87
|
+
.describe('Additional metadata fields (id, name, value, key, data, option, option_value)'),
|
|
88
|
+
},
|
|
89
|
+
annotations: {
|
|
90
|
+
readOnlyHint: false,
|
|
91
|
+
destructiveHint: false,
|
|
92
|
+
idempotentHint: false,
|
|
93
|
+
openWorldHint: true,
|
|
94
|
+
},
|
|
95
|
+
}, async ({ workspace, connection, event, action, resource, resource_id, active, hidden, metadata_extra, }) => {
|
|
96
|
+
try {
|
|
97
|
+
const metadata = { action, ...metadata_extra };
|
|
98
|
+
return toolOk(await client.createRule({
|
|
99
|
+
workspace,
|
|
100
|
+
connection,
|
|
101
|
+
event,
|
|
102
|
+
metadata,
|
|
103
|
+
resource,
|
|
104
|
+
resource_id,
|
|
105
|
+
active,
|
|
106
|
+
hidden,
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
return toolError(e);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
server.registerTool('meshes_delete_rule', {
|
|
114
|
+
title: 'Delete Rule',
|
|
115
|
+
description: 'Delete a routing rule. Events matching this rule will no longer be routed to its connection.',
|
|
116
|
+
inputSchema: {
|
|
117
|
+
rule_id: z.string().uuid().describe('The rule UUID'),
|
|
118
|
+
},
|
|
119
|
+
annotations: {
|
|
120
|
+
readOnlyHint: false,
|
|
121
|
+
destructiveHint: true,
|
|
122
|
+
idempotentHint: false,
|
|
123
|
+
openWorldHint: true,
|
|
124
|
+
},
|
|
125
|
+
}, async ({ rule_id }) => {
|
|
126
|
+
try {
|
|
127
|
+
return toolOk(await client.deleteRule(rule_id));
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
return toolError(e);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=rules.js.map
|