@elastic.io/mcp 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.
Files changed (155) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +171 -0
  3. package/dist/api/client.d.ts +12 -0
  4. package/dist/api/client.d.ts.map +1 -0
  5. package/dist/api/client.js +124 -0
  6. package/dist/api/client.js.map +1 -0
  7. package/dist/api/jsonapi.d.ts +28 -0
  8. package/dist/api/jsonapi.d.ts.map +1 -0
  9. package/dist/api/jsonapi.js +45 -0
  10. package/dist/api/jsonapi.js.map +1 -0
  11. package/dist/api/logger.d.ts +9 -0
  12. package/dist/api/logger.d.ts.map +1 -0
  13. package/dist/api/logger.js +46 -0
  14. package/dist/api/logger.js.map +1 -0
  15. package/dist/api/samples.d.ts +21 -0
  16. package/dist/api/samples.d.ts.map +1 -0
  17. package/dist/api/samples.js +465 -0
  18. package/dist/api/samples.js.map +1 -0
  19. package/dist/config.d.ts +16 -0
  20. package/dist/config.d.ts.map +1 -0
  21. package/dist/config.js +49 -0
  22. package/dist/config.js.map +1 -0
  23. package/dist/embeddings/factory.d.ts +7 -0
  24. package/dist/embeddings/factory.d.ts.map +1 -0
  25. package/dist/embeddings/factory.js +25 -0
  26. package/dist/embeddings/factory.js.map +1 -0
  27. package/dist/embeddings/google.d.ts +19 -0
  28. package/dist/embeddings/google.d.ts.map +1 -0
  29. package/dist/embeddings/google.js +132 -0
  30. package/dist/embeddings/google.js.map +1 -0
  31. package/dist/embeddings/types.d.ts +27 -0
  32. package/dist/embeddings/types.d.ts.map +1 -0
  33. package/dist/embeddings/types.js +2 -0
  34. package/dist/embeddings/types.js.map +1 -0
  35. package/dist/index.d.ts +3 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +226 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/paths.d.ts +3 -0
  40. package/dist/paths.d.ts.map +1 -0
  41. package/dist/paths.js +10 -0
  42. package/dist/paths.js.map +1 -0
  43. package/dist/server.d.ts +29 -0
  44. package/dist/server.d.ts.map +1 -0
  45. package/dist/server.js +361 -0
  46. package/dist/server.js.map +1 -0
  47. package/dist/tools/confirmation.d.ts +41 -0
  48. package/dist/tools/confirmation.d.ts.map +1 -0
  49. package/dist/tools/confirmation.js +120 -0
  50. package/dist/tools/confirmation.js.map +1 -0
  51. package/dist/tools/constants.d.ts +31 -0
  52. package/dist/tools/constants.d.ts.map +1 -0
  53. package/dist/tools/constants.js +85 -0
  54. package/dist/tools/constants.js.map +1 -0
  55. package/dist/tools/definitions.d.ts +3 -0
  56. package/dist/tools/definitions.d.ts.map +1 -0
  57. package/dist/tools/definitions.js +883 -0
  58. package/dist/tools/definitions.js.map +1 -0
  59. package/dist/tools/handlers/auth.d.ts +3 -0
  60. package/dist/tools/handlers/auth.d.ts.map +1 -0
  61. package/dist/tools/handlers/auth.js +540 -0
  62. package/dist/tools/handlers/auth.js.map +1 -0
  63. package/dist/tools/handlers/component.d.ts +3 -0
  64. package/dist/tools/handlers/component.d.ts.map +1 -0
  65. package/dist/tools/handlers/component.js +145 -0
  66. package/dist/tools/handlers/component.js.map +1 -0
  67. package/dist/tools/handlers/data-sample.d.ts +3 -0
  68. package/dist/tools/handlers/data-sample.d.ts.map +1 -0
  69. package/dist/tools/handlers/data-sample.js +51 -0
  70. package/dist/tools/handlers/data-sample.js.map +1 -0
  71. package/dist/tools/handlers/dynamic.d.ts +3 -0
  72. package/dist/tools/handlers/dynamic.d.ts.map +1 -0
  73. package/dist/tools/handlers/dynamic.js +110 -0
  74. package/dist/tools/handlers/dynamic.js.map +1 -0
  75. package/dist/tools/handlers/flow.d.ts +9 -0
  76. package/dist/tools/handlers/flow.d.ts.map +1 -0
  77. package/dist/tools/handlers/flow.js +899 -0
  78. package/dist/tools/handlers/flow.js.map +1 -0
  79. package/dist/tools/handlers/log.d.ts +3 -0
  80. package/dist/tools/handlers/log.d.ts.map +1 -0
  81. package/dist/tools/handlers/log.js +61 -0
  82. package/dist/tools/handlers/log.js.map +1 -0
  83. package/dist/tools/handlers/organization.d.ts +3 -0
  84. package/dist/tools/handlers/organization.d.ts.map +1 -0
  85. package/dist/tools/handlers/organization.js +39 -0
  86. package/dist/tools/handlers/organization.js.map +1 -0
  87. package/dist/tools/handlers/raw.d.ts +3 -0
  88. package/dist/tools/handlers/raw.d.ts.map +1 -0
  89. package/dist/tools/handlers/raw.js +77 -0
  90. package/dist/tools/handlers/raw.js.map +1 -0
  91. package/dist/tools/handlers/search.d.ts +3 -0
  92. package/dist/tools/handlers/search.d.ts.map +1 -0
  93. package/dist/tools/handlers/search.js +82 -0
  94. package/dist/tools/handlers/search.js.map +1 -0
  95. package/dist/tools/handlers/session.d.ts +3 -0
  96. package/dist/tools/handlers/session.d.ts.map +1 -0
  97. package/dist/tools/handlers/session.js +15 -0
  98. package/dist/tools/handlers/session.js.map +1 -0
  99. package/dist/tools/handlers.d.ts +12 -0
  100. package/dist/tools/handlers.d.ts.map +1 -0
  101. package/dist/tools/handlers.js +197 -0
  102. package/dist/tools/handlers.js.map +1 -0
  103. package/dist/tools/helpers.d.ts +45 -0
  104. package/dist/tools/helpers.d.ts.map +1 -0
  105. package/dist/tools/helpers.js +195 -0
  106. package/dist/tools/helpers.js.map +1 -0
  107. package/dist/tools/types.d.ts +32 -0
  108. package/dist/tools/types.d.ts.map +1 -0
  109. package/dist/tools/types.js +2 -0
  110. package/dist/tools/types.js.map +1 -0
  111. package/dist/tools/validation.d.ts +24 -0
  112. package/dist/tools/validation.d.ts.map +1 -0
  113. package/dist/tools/validation.js +748 -0
  114. package/dist/tools/validation.js.map +1 -0
  115. package/dist/types/index.d.ts +47 -0
  116. package/dist/types/index.d.ts.map +1 -0
  117. package/dist/types/index.js +2 -0
  118. package/dist/types/index.js.map +1 -0
  119. package/dist/vectorstore/factory.d.ts +7 -0
  120. package/dist/vectorstore/factory.d.ts.map +1 -0
  121. package/dist/vectorstore/factory.js +25 -0
  122. package/dist/vectorstore/factory.js.map +1 -0
  123. package/dist/vectorstore/qdrant.d.ts +11 -0
  124. package/dist/vectorstore/qdrant.d.ts.map +1 -0
  125. package/dist/vectorstore/qdrant.js +107 -0
  126. package/dist/vectorstore/qdrant.js.map +1 -0
  127. package/dist/vectorstore/types.d.ts +28 -0
  128. package/dist/vectorstore/types.d.ts.map +1 -0
  129. package/dist/vectorstore/types.js +2 -0
  130. package/dist/vectorstore/types.js.map +1 -0
  131. package/package.json +51 -0
  132. package/resources/docs/component-test-scenarios.md +2468 -0
  133. package/resources/docs/credential-validation-gaps.md +35 -0
  134. package/resources/docs/debug-issues.md +71 -0
  135. package/resources/docs/deployment-and-scaling.md +136 -0
  136. package/resources/docs/flow-building-guide.md +565 -0
  137. package/resources/docs/packaging-plan.md +84 -0
  138. package/resources/docs/standardized-components-guide.md +66 -0
  139. package/resources/docs/system-instructions.md +177 -0
  140. package/resources/docs/unique-components.md +60 -0
  141. package/resources/docs/verified-creds-flow-ids.md +193 -0
  142. package/resources/flow-examples/batch-flow-1-collect.json +51 -0
  143. package/resources/flow-examples/batch-flow-2-process.json +70 -0
  144. package/resources/flow-examples/code-component-transform.json +65 -0
  145. package/resources/flow-examples/code-component-trigger.json +52 -0
  146. package/resources/flow-examples/code-component-with-credentials-trigger.json +53 -0
  147. package/resources/flow-examples/code-component-with-credentials.json +67 -0
  148. package/resources/flow-examples/filter-step.json +63 -0
  149. package/resources/flow-examples/polling-sync-trigger.json +50 -0
  150. package/resources/flow-examples/router-branching.json +94 -0
  151. package/resources/flow-examples/splitter-re-assemble.json +72 -0
  152. package/resources/flow-examples/splitter-split.json +68 -0
  153. package/resources/flow-examples/timer-query-action-sync.json +68 -0
  154. package/resources/flow-examples/webhook-async-sync.json +49 -0
  155. package/resources/flow-examples/webhook-request-reply.json +63 -0
package/dist/server.js ADDED
@@ -0,0 +1,361 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema } from '@modelcontextprotocol/sdk/types.js';
3
+ import { TOOLS } from './tools/definitions.js';
4
+ import { handleToolCall, getDiscoveryState } from './tools/handlers.js';
5
+ import { sanitizeInput } from './tools/helpers.js';
6
+ import { logger } from './api/logger.js';
7
+ import fs from 'fs';
8
+ import { resolveFromRoot } from './paths.js';
9
+ /**
10
+ * Instantiates and configures a new MCP Server instance.
11
+ * By passing the scoped AxiosInstance, we achieve absolute credential isolation.
12
+ */
13
+ export function createMcpServer(client) {
14
+ const mcpServer = new McpServer({
15
+ name: 'elasticio-mcp-server',
16
+ version: '1.0.0'
17
+ }, {
18
+ capabilities: {
19
+ tools: {},
20
+ resources: {},
21
+ prompts: {}
22
+ },
23
+ instructions: fs.readFileSync(resolveFromRoot('resources/docs/system-instructions.md'), 'utf8')
24
+ });
25
+ const server = mcpServer.server;
26
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
27
+ return { tools: TOOLS };
28
+ });
29
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
30
+ const { name, arguments: args } = request.params;
31
+ return await handleToolCall(name, args || {}, client);
32
+ });
33
+ server.setRequestHandler(ListResourcesRequestSchema, async () => {
34
+ return {
35
+ resources: [
36
+ {
37
+ uri: 'elasticio://docs/flow-building-guide',
38
+ name: 'elastic.io Flow Building Guide',
39
+ mimeType: 'text/markdown',
40
+ description: 'Guidelines, schemas, and best practices for creating and editing elastic.io integration flows.'
41
+ },
42
+ {
43
+ uri: 'elasticio://docs/standardized-components-guide',
44
+ name: 'elastic.io Standardized Actions and Triggers Guide',
45
+ mimeType: 'text/markdown',
46
+ description: 'Specifications and usage guidelines for standardized actions and triggers across components.'
47
+ }
48
+ ]
49
+ };
50
+ });
51
+ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
52
+ const { uri } = request.params;
53
+ if (uri === 'elasticio://docs/flow-building-guide') {
54
+ const discoveryState = getDiscoveryState(client);
55
+ discoveryState.flowBuildingGuideRead = true;
56
+ const filePath = resolveFromRoot('resources/docs/flow-building-guide.md');
57
+ const text = fs.readFileSync(filePath, 'utf8');
58
+ return {
59
+ contents: [
60
+ {
61
+ uri,
62
+ mimeType: 'text/markdown',
63
+ text
64
+ }
65
+ ]
66
+ };
67
+ }
68
+ if (uri === 'elasticio://docs/standardized-components-guide') {
69
+ const filePath = resolveFromRoot('resources/docs/standardized-components-guide.md');
70
+ const text = fs.readFileSync(filePath, 'utf8');
71
+ return {
72
+ contents: [
73
+ {
74
+ uri,
75
+ mimeType: 'text/markdown',
76
+ text
77
+ }
78
+ ]
79
+ };
80
+ }
81
+ throw new Error(`Resource not found: ${uri}`);
82
+ });
83
+ server.setRequestHandler(ListPromptsRequestSchema, async () => {
84
+ return {
85
+ prompts: [
86
+ {
87
+ name: 'hello-world-placeholder',
88
+ description: 'A simple testing prompt that welcomes a user by name.',
89
+ arguments: [
90
+ {
91
+ name: 'name',
92
+ description: 'The name of the user to welcome',
93
+ required: true
94
+ }
95
+ ]
96
+ },
97
+ {
98
+ name: 'create-new-flow',
99
+ description: 'Step-by-step assistant to create a brand new integration flow using Playbook A.',
100
+ arguments: [
101
+ {
102
+ name: 'description',
103
+ description: 'A description of what the integration flow should do',
104
+ required: true
105
+ }
106
+ ]
107
+ },
108
+ {
109
+ name: 'update-existing-flow',
110
+ description: 'Modify or update steps and configurations of an existing integration flow using Playbook B.',
111
+ arguments: [
112
+ {
113
+ name: 'flowId',
114
+ description: 'The unique ID of the integration flow to modify',
115
+ required: true
116
+ },
117
+ {
118
+ name: 'modification',
119
+ description: 'Details of what modifications to apply to the flow',
120
+ required: true
121
+ }
122
+ ]
123
+ },
124
+ {
125
+ name: 'debug-flow-failure',
126
+ description: 'Diagnose and debug a failing elastic.io flow using its structure and logs.',
127
+ arguments: [
128
+ {
129
+ name: 'flowId',
130
+ description: 'The unique ID of the failing integration flow',
131
+ required: true
132
+ },
133
+ {
134
+ name: 'limit',
135
+ description: 'Maximum number of log entries to retrieve (default: 20)',
136
+ required: false
137
+ }
138
+ ]
139
+ },
140
+ {
141
+ name: 'create-jsonata-mapping',
142
+ description: 'Help construct a JSONata mapping expression between two flow steps.',
143
+ arguments: [
144
+ {
145
+ name: 'sourceSchema',
146
+ description: 'JSON schema representing the preceding step\'s output payload',
147
+ required: true
148
+ },
149
+ {
150
+ name: 'targetSchema',
151
+ description: 'JSON schema representing the current step\'s input payload requirements',
152
+ required: true
153
+ }
154
+ ]
155
+ }
156
+ ]
157
+ };
158
+ });
159
+ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
160
+ const { name, arguments: rawArgs } = request.params;
161
+ const args = rawArgs ? sanitizeInput(rawArgs) : rawArgs;
162
+ if (name === 'hello-world-placeholder') {
163
+ const targetName = args?.name;
164
+ if (!targetName) {
165
+ throw new Error('name argument is required');
166
+ }
167
+ return {
168
+ description: 'A simple testing prompt that welcomes a user by name.',
169
+ messages: [
170
+ {
171
+ role: 'user',
172
+ content: {
173
+ type: 'text',
174
+ text: `Hello, ${targetName}! Welcome to the elastic.io MCP server. This is a testing placeholder template to verify that prompts are working successfully.`
175
+ }
176
+ }
177
+ ]
178
+ };
179
+ }
180
+ if (name === 'create-new-flow') {
181
+ const desc = args?.description || '';
182
+ return {
183
+ description: 'Interactive wizard to create a new integration flow — guides the user step by step.',
184
+ messages: [
185
+ {
186
+ role: 'user',
187
+ content: {
188
+ type: 'text',
189
+ text: `I want to create a new integration flow: "${desc}".
190
+
191
+ You MUST act as an interactive wizard and follow Playbook A strictly. Key rules:
192
+
193
+ **NEVER build the entire flow silently.** Stop and ask me at every decision point:
194
+ - Which component to use (if multiple matches)
195
+ - Which credentials/secrets to use (if multiple or none exist)
196
+ - Which action/trigger to use
197
+ - Which values for dropdown fields (resolve dynamic select models and present options)
198
+ - How to map fields between steps (resolve dynamic metadata and present the schema)
199
+
200
+ **NEVER use Code components as substitutes for real connectors.** If I say "Salesforce", use the Salesforce component with proper credentials. If credentials don't exist, stop and help me create them.
201
+
202
+ **Build the flow incrementally, step by step:**
203
+ 1. Ask me what the first step should do → discover component → check credentials → select action → configure fields
204
+ 2. Create the flow with just the first step using \`create_flow\`
205
+ 3. Retrieve a real data sample for this step using \`debug_flow_step\` (pass flowId and componentId so the sample is saved to the draft)
206
+ 4. Ask about the next step → discover component → configure → add it via \`update_flow_draft\`
207
+ 5. Retrieve its data sample using \`debug_flow_step\` — use the previous step's real output to build accurate mappers
208
+ 6. Repeat steps 4-5 for each subsequent step
209
+ 7. After all steps are added, show a summary and ask for final confirmation
210
+
211
+ Start by asking me clarifying questions about what this flow should do, if my description above is not detailed enough.
212
+
213
+ **Example of correct behavior (follow this pattern):**
214
+ User: "I want to sync Salesforce contacts to a Google Sheet"
215
+ Assistant: "What type of trigger should this flow use? Should it poll for new/updated contacts on a schedule, or should it run once manually?"
216
+ User: "Poll every 15 minutes"
217
+ Assistant: [calls list_components(workspaceId, search="salesforce")] → gets multiple results → "I found these Salesforce components: 1) salesforce-v2 (id: abc123) 2) salesforce (id: def456, deprecated). Which one would you like to use?"
218
+ User: "salesforce-v2"
219
+ Assistant: [calls list_credentials + list_secrets for abc123] → "I found 1 secret for Salesforce v2: 'My SF Connection' (id: sec789). Should I use this one?"
220
+ User: "Yes"
221
+ Assistant: [calls get_component(abc123)] → "Salesforce v2 has these triggers: Get New and Updated Objects Polling, Bulk Query, Subscribe to PubSub... Which trigger do you need?"
222
+ ...and so on, one question at a time.`
223
+ }
224
+ }
225
+ ]
226
+ };
227
+ }
228
+ if (name === 'update-existing-flow') {
229
+ const flowId = args?.flowId;
230
+ const modification = args?.modification || '';
231
+ if (!flowId) {
232
+ throw new Error('flowId argument is required');
233
+ }
234
+ return {
235
+ description: 'Modify or update steps and configurations of an existing integration flow using Playbook B.',
236
+ messages: [
237
+ {
238
+ role: 'user',
239
+ content: {
240
+ type: 'text',
241
+ text: `I want to update the integration flow with ID "${flowId}". The modifications needed are: "${modification}".
242
+ Please strictly follow Playbook B:
243
+ 1. **Inspect Flow**: Call \`get_flow\` to read the current graph.
244
+ 2. **Deactivate**: If active, call \`stop_flow\` and wait/poll until inactive.
245
+ 3. **Draft Check**: Check if a draft exists with \`get_flow_draft\`.
246
+ 4. **Patch**: Construct modifications conforming strictly to the rules in \`elasticio://docs/flow-building-guide\` (especially using \`$getPassthrough().step_id.body.field\` for all mappers and applying correct JSONata double-quoting (escaped as \\") without outer double-quoting of the whole expression) and update using \`update_flow\`.
247
+ 5. **Activate**: Call \`start_flow\` to restart.`
248
+ }
249
+ }
250
+ ]
251
+ };
252
+ }
253
+ if (name === 'debug-flow-failure') {
254
+ const flowId = args?.flowId;
255
+ if (!flowId) {
256
+ throw new Error('flowId argument is required');
257
+ }
258
+ const limit = args?.limit || '20';
259
+ return {
260
+ description: 'Diagnose and debug a failing elastic.io flow using its structure and logs using Playbook C.',
261
+ messages: [
262
+ {
263
+ role: 'user',
264
+ content: {
265
+ type: 'text',
266
+ text: `Please debug the failing elastic.io flow with ID "${flowId}".
267
+ Please follow Playbook C:
268
+ 1. Call \`get_flow\` and \`get_logs\` with limit=${limit}.
269
+ 2. Compare the flow graph architecture, step inputs, and error logs.
270
+ 3. Suggest a resolution plan and patch/fix the configuration.`
271
+ }
272
+ }
273
+ ]
274
+ };
275
+ }
276
+ if (name === 'create-jsonata-mapping') {
277
+ const sourceSchema = args?.sourceSchema || '';
278
+ const targetSchema = args?.targetSchema || '';
279
+ return {
280
+ description: 'Help construct a JSONata mapping expression between two flow steps.',
281
+ messages: [
282
+ {
283
+ role: 'user',
284
+ content: {
285
+ type: 'text',
286
+ text: `I need to create a JSONata mapping to transform data between two steps in an integration flow.
287
+ Here is the JSON schema of the source output:
288
+ \`\`\`json
289
+ ${sourceSchema}
290
+ \`\`\`
291
+
292
+ Here is the JSON schema of the target input requirement:
293
+ \`\`\`json
294
+ ${targetSchema}
295
+ \`\`\`
296
+
297
+ Please:
298
+ 1. Analyze both schemas to map corresponding fields.
299
+ 2. Formulate a valid JSONata transformation object mapping source properties to target properties.
300
+ 3. Keep the JSONata expression clean, correct, and handle typical edge cases (e.g., check if arrays or optional properties are defined using conditionals).
301
+ 4. Provide the final mapping JSON string.`
302
+ }
303
+ }
304
+ ]
305
+ };
306
+ }
307
+ throw new Error(`Prompt not found: ${name}`);
308
+ });
309
+ server.onerror = (error) => {
310
+ logger.error('[MCP Server Error]', error);
311
+ };
312
+ return mcpServer;
313
+ }
314
+ /**
315
+ * Manage active sessions for SSE Transport (multi-tenant environment)
316
+ */
317
+ export class SessionManager {
318
+ sessions = new Map();
319
+ cleanupInterval;
320
+ registerSession(sessionId, session) {
321
+ this.sessions.set(sessionId, session);
322
+ }
323
+ getSession(sessionId) {
324
+ return this.sessions.get(sessionId);
325
+ }
326
+ removeSession(sessionId) {
327
+ const session = this.sessions.get(sessionId);
328
+ if (session) {
329
+ session.server.close().catch((err) => {
330
+ logger.error(`Error closing server for session ${sessionId}:`, err.message || err, err.stack || '');
331
+ });
332
+ this.sessions.delete(sessionId);
333
+ }
334
+ }
335
+ activeSessionCount() {
336
+ return this.sessions.size;
337
+ }
338
+ startReaper(maxIdleMs = 30 * 60 * 1000) {
339
+ if (this.cleanupInterval)
340
+ return;
341
+ this.cleanupInterval = setInterval(() => {
342
+ const now = Date.now();
343
+ for (const [sessionId, session] of this.sessions.entries()) {
344
+ if (now - session.lastActive > maxIdleMs) {
345
+ logger.info(`[Session Reaper] Cleaning up idle session: ${sessionId}`);
346
+ this.removeSession(sessionId);
347
+ }
348
+ }
349
+ }, 60 * 1000);
350
+ if (this.cleanupInterval && typeof this.cleanupInterval.unref === 'function') {
351
+ this.cleanupInterval.unref();
352
+ }
353
+ }
354
+ stopReaper() {
355
+ if (this.cleanupInterval) {
356
+ clearInterval(this.cleanupInterval);
357
+ this.cleanupInterval = undefined;
358
+ }
359
+ }
360
+ }
361
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA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;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED,WAAW,CAAC,YAAoB,EAAE,GAAG,EAAE,GAAG,IAAI;QAC5C,IAAI,IAAI,CAAC,eAAe;YAAE,OAAO;QACjC,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE;YACtC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,KAAK,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC3D,IAAI,GAAG,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,EAAE,CAAC;oBACzC,MAAM,CAAC,IAAI,CAAC,8CAA8C,SAAS,EAAE,CAAC,CAAC;oBACvE,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QACd,IAAI,IAAI,CAAC,eAAe,IAAI,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;YAC7E,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,UAAU;QACR,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACpC,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACnC,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,41 @@
1
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ export declare const DESTRUCTIVE_TOOL_NAMES: {
3
+ readonly CREATE_FLOW: "create_flow";
4
+ readonly UPDATE_FLOW: "update_flow";
5
+ readonly UPDATE_FLOW_DRAFT: "update_flow_draft";
6
+ readonly START_FLOW: "start_flow";
7
+ readonly STOP_FLOW: "stop_flow";
8
+ readonly RUN_FLOW_NOW: "run_flow_now";
9
+ readonly CREATE_CREDENTIALS: "create_credentials";
10
+ readonly CREATE_AUTH_CLIENT: "create_auth_client";
11
+ readonly CREATE_SECRET: "create_secret";
12
+ readonly EXECUTE_RAW_API_REQUEST: "execute_raw_api_request";
13
+ readonly CREATE_DATA_SAMPLE: "create_data_sample";
14
+ readonly UPDATE_DATA_SAMPLE: "update_data_sample";
15
+ readonly DEBUG_FLOW_STEP: "debug_flow_step";
16
+ };
17
+ /**
18
+ * Check whether a tool call requires confirmation.
19
+ * For execute_raw_api_request, only mutating HTTP methods need it.
20
+ */
21
+ export declare function requiresConfirmation(toolName: string, args: any): boolean;
22
+ /**
23
+ * Build a human-readable preview of the action the tool will perform.
24
+ */
25
+ export declare function buildConfirmationPreview(toolName: string, args: any): string;
26
+ /**
27
+ * Return the confirmation prompt as a tool result the LLM will see.
28
+ */
29
+ export declare function confirmationResult(toolName: string, args: any): {
30
+ content: Array<{
31
+ type: 'text';
32
+ text: string;
33
+ }>;
34
+ isError: boolean;
35
+ };
36
+ /**
37
+ * Returns a new tools array with the `confirmed` property injected into
38
+ * every destructive tool's input schema.
39
+ */
40
+ export declare function withConfirmationSchemas(tools: Tool[]): Tool[];
41
+ //# sourceMappingURL=confirmation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmation.d.ts","sourceRoot":"","sources":["../../src/tools/confirmation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE1D,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;CAczB,CAAC;AAMX;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAMzE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,MAAM,CAgD5E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG;IAC/D,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,EAAE,OAAO,CAAC;CAClB,CAYA;AAQD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,CAgB7D"}
@@ -0,0 +1,120 @@
1
+ export const DESTRUCTIVE_TOOL_NAMES = {
2
+ CREATE_FLOW: 'create_flow',
3
+ UPDATE_FLOW: 'update_flow',
4
+ UPDATE_FLOW_DRAFT: 'update_flow_draft',
5
+ START_FLOW: 'start_flow',
6
+ STOP_FLOW: 'stop_flow',
7
+ RUN_FLOW_NOW: 'run_flow_now',
8
+ CREATE_CREDENTIALS: 'create_credentials',
9
+ CREATE_AUTH_CLIENT: 'create_auth_client',
10
+ CREATE_SECRET: 'create_secret',
11
+ EXECUTE_RAW_API_REQUEST: 'execute_raw_api_request',
12
+ CREATE_DATA_SAMPLE: 'create_data_sample',
13
+ UPDATE_DATA_SAMPLE: 'update_data_sample',
14
+ DEBUG_FLOW_STEP: 'debug_flow_step'
15
+ };
16
+ const DESTRUCTIVE_TOOLS = Object.values(DESTRUCTIVE_TOOL_NAMES);
17
+ const MUTATING_HTTP_METHODS = ['POST', 'PUT', 'PATCH', 'DELETE'];
18
+ /**
19
+ * Check whether a tool call requires confirmation.
20
+ * For execute_raw_api_request, only mutating HTTP methods need it.
21
+ */
22
+ export function requiresConfirmation(toolName, args) {
23
+ if (!DESTRUCTIVE_TOOLS.includes(toolName))
24
+ return false;
25
+ if (toolName === DESTRUCTIVE_TOOL_NAMES.EXECUTE_RAW_API_REQUEST) {
26
+ return MUTATING_HTTP_METHODS.includes((args?.method || '').toUpperCase());
27
+ }
28
+ return true;
29
+ }
30
+ /**
31
+ * Build a human-readable preview of the action the tool will perform.
32
+ */
33
+ export function buildConfirmationPreview(toolName, args) {
34
+ const previews = {
35
+ [DESTRUCTIVE_TOOL_NAMES.CREATE_FLOW]: (a) => {
36
+ const name = a.body?.data?.attributes?.name || '(unnamed)';
37
+ return `Create a new integration flow "${name}".`;
38
+ },
39
+ [DESTRUCTIVE_TOOL_NAMES.UPDATE_FLOW]: (a) => {
40
+ return `Update integration flow ${a.flowId || ''} with the provided patch payload.`;
41
+ },
42
+ [DESTRUCTIVE_TOOL_NAMES.UPDATE_FLOW_DRAFT]: (a) => {
43
+ return `Update the draft of flow ${a.flowId || ''} with the provided payload.`;
44
+ },
45
+ [DESTRUCTIVE_TOOL_NAMES.START_FLOW]: (a) => {
46
+ return `Start (activate) flow ${a.flowId || ''}.`;
47
+ },
48
+ [DESTRUCTIVE_TOOL_NAMES.STOP_FLOW]: (a) => {
49
+ return `Stop (deactivate) flow ${a.flowId || ''}.`;
50
+ },
51
+ [DESTRUCTIVE_TOOL_NAMES.RUN_FLOW_NOW]: (a) => {
52
+ return `Trigger a one-off execution of flow ${a.flowId || ''}.`;
53
+ },
54
+ [DESTRUCTIVE_TOOL_NAMES.CREATE_CREDENTIALS]: (a) => {
55
+ return `Create credentials for component ${a.componentId || '(unknown)'} in workspace ${a.workspaceId || ''}.`;
56
+ },
57
+ [DESTRUCTIVE_TOOL_NAMES.CREATE_AUTH_CLIENT]: (a) => {
58
+ const name = a.name || '(unnamed)';
59
+ return `Create auth client "${name}" (type: ${a.type || '(unknown)'}) for component ${a.componentId || ''}.`;
60
+ },
61
+ [DESTRUCTIVE_TOOL_NAMES.CREATE_SECRET]: (a) => {
62
+ const name = a.name || '(unnamed)';
63
+ return `Create auth secret "${name}" (type: ${a.type || '(unknown)'}) in workspace ${a.workspaceId || ''}.`;
64
+ },
65
+ [DESTRUCTIVE_TOOL_NAMES.EXECUTE_RAW_API_REQUEST]: (a) => {
66
+ return `Execute raw ${a.method || '(unknown)'} request to ${a.path || ''}.`;
67
+ },
68
+ [DESTRUCTIVE_TOOL_NAMES.CREATE_DATA_SAMPLE]: (a) => {
69
+ return `Create a data sample for component ${a.componentId || '(unknown)'} (method: ${a.method || '(unknown)'}) in workspace ${a.workspaceId || ''}.`;
70
+ },
71
+ [DESTRUCTIVE_TOOL_NAMES.UPDATE_DATA_SAMPLE]: (a) => {
72
+ return `Update data sample ${a.dataSampleId || '(unknown)'} with new body data.`;
73
+ },
74
+ [DESTRUCTIVE_TOOL_NAMES.DEBUG_FLOW_STEP]: (a) => {
75
+ return `Execute a debug run of component step with command "${a.command || '(unknown)'}" in workspace ${a.workspaceId || ''}.`;
76
+ }
77
+ };
78
+ const fn = previews[toolName];
79
+ return fn ? fn(args) : `Execute destructive tool "${toolName}".`;
80
+ }
81
+ /**
82
+ * Return the confirmation prompt as a tool result the LLM will see.
83
+ */
84
+ export function confirmationResult(toolName, args) {
85
+ const preview = buildConfirmationPreview(toolName, args);
86
+ const message = `⚠️ Confirmation required.\n\n` +
87
+ `Action: ${preview}\n\n` +
88
+ `This is a destructive operation that will mutate platform state. ` +
89
+ `To proceed, call this tool again with the same parameters and set confirmed: true.`;
90
+ return {
91
+ isError: true,
92
+ content: [{ type: 'text', text: message }]
93
+ };
94
+ }
95
+ const CONFIRMED_PROPERTY = {
96
+ type: 'boolean',
97
+ description: 'Set to true to confirm this destructive operation. If omitted or false, the tool returns a preview of the action instead of executing it.'
98
+ };
99
+ /**
100
+ * Returns a new tools array with the `confirmed` property injected into
101
+ * every destructive tool's input schema.
102
+ */
103
+ export function withConfirmationSchemas(tools) {
104
+ return tools.map((tool) => {
105
+ if (!DESTRUCTIVE_TOOLS.includes(tool.name))
106
+ return tool;
107
+ const schema = tool.inputSchema;
108
+ return {
109
+ ...tool,
110
+ inputSchema: {
111
+ ...schema,
112
+ properties: {
113
+ ...schema.properties,
114
+ confirmed: CONFIRMED_PROPERTY
115
+ }
116
+ }
117
+ };
118
+ });
119
+ }
120
+ //# sourceMappingURL=confirmation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirm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AO,GAAG,wBAAwB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACzD,MAAM,OAAO,GACX,+BAA+B;QAC/B,WAAW,OAAO,MAAM;QACxB,mEAAmE;QACnE,oFAAoF,CAAC;IAEvF,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KAC3C,CAAC;AACJ,CAAC;AAED,MAAM,kBAAkB,GAAG;IACzB,IAAI,EAAE,SAAkB;IACxB,WAAW,EACT,2IAA2I;CAC9I,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAa;IACnD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAExD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAkB,CAAC;QACvC,OAAO;YACL,GAAG,IAAI;YACP,WAAW,EAAE;gBACX,GAAG,MAAM;gBACT,UAAU,EAAE;oBACV,GAAG,MAAM,CAAC,UAAU;oBACpB,SAAS,EAAE,kBAAkB;iBAC9B;aACF;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Centralized constants for the MCP tools layer.
3
+ * Keeps magic numbers, validation lists, and component metadata out of business logic.
4
+ */
5
+ export declare const PAGE_SIZE: {
6
+ readonly CONTRACTS: 20;
7
+ readonly WORKSPACES: 20;
8
+ readonly FLOWS_DEFAULT: 50;
9
+ readonly FLOWS_MAX: 100;
10
+ readonly LOGS_DEFAULT: 50;
11
+ };
12
+ export declare const SEARCH_RESULTS_DEFAULT_LIMIT = 5;
13
+ export declare const MAX_RESPONSE_LENGTH = 200000;
14
+ export declare const ENUM_PRUNE_THRESHOLD = 5;
15
+ export declare const ENUM_PRUNE_KEEP = 3;
16
+ export declare const BARE_FIELD_NAMES: string[];
17
+ export declare const UNSUPPORTED_ROUTER_JSONATA_FUNCTIONS: string[];
18
+ export declare const DEPRECATED_COMPONENTS: Record<string, string>;
19
+ export declare const DEPRECATED_ACTIONS: Record<string, string>;
20
+ export declare const REST_API_READER_FIELDS: string[];
21
+ export declare const PLACEHOLDER_FIELD_VALUES: string[];
22
+ export declare const PLACEHOLDER_VALUES: Array<{
23
+ test: (name: string) => boolean;
24
+ value: any;
25
+ }>;
26
+ export declare const PLACEHOLDER_DEFAULT = "sample_value";
27
+ export declare const COMPONENT_SAMPLE_SCHEMAS: Array<{
28
+ pattern: RegExp;
29
+ sample: () => Record<string, any>;
30
+ }>;
31
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/tools/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,eAAO,MAAM,SAAS;;;;;;CAMZ,CAAC;AAEX,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAI9C,eAAO,MAAM,mBAAmB,SAAU,CAAC;AAI3C,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,eAAO,MAAM,eAAe,IAAI,CAAC;AAIjC,eAAO,MAAM,gBAAgB,UAA8C,CAAC;AAI5E,eAAO,MAAM,oCAAoC,UAIhD,CAAC;AAIF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAExD,CAAC;AAMF,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKrD,CAAC;AAKF,eAAO,MAAM,sBAAsB,UAAuC,CAAC;AAK3E,eAAO,MAAM,wBAAwB,UAAwF,CAAC;AAI9H,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAE,CAcrF,CAAC;AAEF,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAIlD,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,CAoBlG,CAAC"}