@elastic.io/mcp 1.0.0-beta

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 (174) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +173 -0
  3. package/README.npm.md +173 -0
  4. package/dist/api/client.d.ts +12 -0
  5. package/dist/api/client.d.ts.map +1 -0
  6. package/dist/api/client.js +129 -0
  7. package/dist/api/client.js.map +1 -0
  8. package/dist/api/jsonapi.d.ts +21 -0
  9. package/dist/api/jsonapi.d.ts.map +1 -0
  10. package/dist/api/jsonapi.js +32 -0
  11. package/dist/api/jsonapi.js.map +1 -0
  12. package/dist/api/logger.d.ts +8 -0
  13. package/dist/api/logger.d.ts.map +1 -0
  14. package/dist/api/logger.js +43 -0
  15. package/dist/api/logger.js.map +1 -0
  16. package/dist/api/samples.d.ts +15 -0
  17. package/dist/api/samples.d.ts.map +1 -0
  18. package/dist/api/samples.js +465 -0
  19. package/dist/api/samples.js.map +1 -0
  20. package/dist/api/verification.d.ts +6 -0
  21. package/dist/api/verification.d.ts.map +1 -0
  22. package/dist/api/verification.js +71 -0
  23. package/dist/api/verification.js.map +1 -0
  24. package/dist/cli.d.ts +3 -0
  25. package/dist/cli.d.ts.map +1 -0
  26. package/dist/cli.js +9 -0
  27. package/dist/cli.js.map +1 -0
  28. package/dist/config.d.ts +15 -0
  29. package/dist/config.d.ts.map +1 -0
  30. package/dist/config.js +44 -0
  31. package/dist/config.js.map +1 -0
  32. package/dist/embeddings/factory.d.ts +7 -0
  33. package/dist/embeddings/factory.d.ts.map +1 -0
  34. package/dist/embeddings/factory.js +25 -0
  35. package/dist/embeddings/factory.js.map +1 -0
  36. package/dist/embeddings/google.d.ts +19 -0
  37. package/dist/embeddings/google.d.ts.map +1 -0
  38. package/dist/embeddings/google.js +132 -0
  39. package/dist/embeddings/google.js.map +1 -0
  40. package/dist/embeddings/types.d.ts +27 -0
  41. package/dist/embeddings/types.d.ts.map +1 -0
  42. package/dist/embeddings/types.js +2 -0
  43. package/dist/embeddings/types.js.map +1 -0
  44. package/dist/index.d.ts +3 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +227 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/paths.d.ts +2 -0
  49. package/dist/paths.d.ts.map +1 -0
  50. package/dist/paths.js +10 -0
  51. package/dist/paths.js.map +1 -0
  52. package/dist/server.d.ts +29 -0
  53. package/dist/server.d.ts.map +1 -0
  54. package/dist/server.js +385 -0
  55. package/dist/server.js.map +1 -0
  56. package/dist/setup.d.ts +3 -0
  57. package/dist/setup.d.ts.map +1 -0
  58. package/dist/setup.js +338 -0
  59. package/dist/setup.js.map +1 -0
  60. package/dist/tools/confirmation.d.ts +37 -0
  61. package/dist/tools/confirmation.d.ts.map +1 -0
  62. package/dist/tools/confirmation.js +120 -0
  63. package/dist/tools/confirmation.js.map +1 -0
  64. package/dist/tools/constants.d.ts +28 -0
  65. package/dist/tools/constants.d.ts.map +1 -0
  66. package/dist/tools/constants.js +92 -0
  67. package/dist/tools/constants.js.map +1 -0
  68. package/dist/tools/definitions.d.ts +3 -0
  69. package/dist/tools/definitions.d.ts.map +1 -0
  70. package/dist/tools/definitions.js +915 -0
  71. package/dist/tools/definitions.js.map +1 -0
  72. package/dist/tools/flow-build.d.ts +18 -0
  73. package/dist/tools/flow-build.d.ts.map +1 -0
  74. package/dist/tools/flow-build.js +295 -0
  75. package/dist/tools/flow-build.js.map +1 -0
  76. package/dist/tools/flow-evidence.d.ts +62 -0
  77. package/dist/tools/flow-evidence.d.ts.map +1 -0
  78. package/dist/tools/flow-evidence.js +128 -0
  79. package/dist/tools/flow-evidence.js.map +1 -0
  80. package/dist/tools/flow-state-machine.d.ts +69 -0
  81. package/dist/tools/flow-state-machine.d.ts.map +1 -0
  82. package/dist/tools/flow-state-machine.js +292 -0
  83. package/dist/tools/flow-state-machine.js.map +1 -0
  84. package/dist/tools/handlers/auth.d.ts +3 -0
  85. package/dist/tools/handlers/auth.d.ts.map +1 -0
  86. package/dist/tools/handlers/auth.js +410 -0
  87. package/dist/tools/handlers/auth.js.map +1 -0
  88. package/dist/tools/handlers/component.d.ts +3 -0
  89. package/dist/tools/handlers/component.d.ts.map +1 -0
  90. package/dist/tools/handlers/component.js +165 -0
  91. package/dist/tools/handlers/component.js.map +1 -0
  92. package/dist/tools/handlers/data-sample.d.ts +3 -0
  93. package/dist/tools/handlers/data-sample.d.ts.map +1 -0
  94. package/dist/tools/handlers/data-sample.js +83 -0
  95. package/dist/tools/handlers/data-sample.js.map +1 -0
  96. package/dist/tools/handlers/dynamic.d.ts +3 -0
  97. package/dist/tools/handlers/dynamic.d.ts.map +1 -0
  98. package/dist/tools/handlers/dynamic.js +139 -0
  99. package/dist/tools/handlers/dynamic.js.map +1 -0
  100. package/dist/tools/handlers/flow.d.ts +9 -0
  101. package/dist/tools/handlers/flow.d.ts.map +1 -0
  102. package/dist/tools/handlers/flow.js +427 -0
  103. package/dist/tools/handlers/flow.js.map +1 -0
  104. package/dist/tools/handlers/log.d.ts +3 -0
  105. package/dist/tools/handlers/log.d.ts.map +1 -0
  106. package/dist/tools/handlers/log.js +92 -0
  107. package/dist/tools/handlers/log.js.map +1 -0
  108. package/dist/tools/handlers/organization.d.ts +3 -0
  109. package/dist/tools/handlers/organization.d.ts.map +1 -0
  110. package/dist/tools/handlers/organization.js +39 -0
  111. package/dist/tools/handlers/organization.js.map +1 -0
  112. package/dist/tools/handlers/raw.d.ts +3 -0
  113. package/dist/tools/handlers/raw.d.ts.map +1 -0
  114. package/dist/tools/handlers/raw.js +80 -0
  115. package/dist/tools/handlers/raw.js.map +1 -0
  116. package/dist/tools/handlers/search.d.ts +3 -0
  117. package/dist/tools/handlers/search.d.ts.map +1 -0
  118. package/dist/tools/handlers/search.js +105 -0
  119. package/dist/tools/handlers/search.js.map +1 -0
  120. package/dist/tools/handlers/session.d.ts +3 -0
  121. package/dist/tools/handlers/session.d.ts.map +1 -0
  122. package/dist/tools/handlers/session.js +22 -0
  123. package/dist/tools/handlers/session.js.map +1 -0
  124. package/dist/tools/handlers.d.ts +12 -0
  125. package/dist/tools/handlers.d.ts.map +1 -0
  126. package/dist/tools/handlers.js +202 -0
  127. package/dist/tools/handlers.js.map +1 -0
  128. package/dist/tools/helpers.d.ts +44 -0
  129. package/dist/tools/helpers.d.ts.map +1 -0
  130. package/dist/tools/helpers.js +195 -0
  131. package/dist/tools/helpers.js.map +1 -0
  132. package/dist/tools/types.d.ts +39 -0
  133. package/dist/tools/types.d.ts.map +1 -0
  134. package/dist/tools/types.js +2 -0
  135. package/dist/tools/types.js.map +1 -0
  136. package/dist/tools/validation.d.ts +35 -0
  137. package/dist/tools/validation.d.ts.map +1 -0
  138. package/dist/tools/validation.js +800 -0
  139. package/dist/tools/validation.js.map +1 -0
  140. package/dist/types/index.d.ts +47 -0
  141. package/dist/types/index.d.ts.map +1 -0
  142. package/dist/types/index.js +2 -0
  143. package/dist/types/index.js.map +1 -0
  144. package/dist/vectorstore/factory.d.ts +7 -0
  145. package/dist/vectorstore/factory.d.ts.map +1 -0
  146. package/dist/vectorstore/factory.js +25 -0
  147. package/dist/vectorstore/factory.js.map +1 -0
  148. package/dist/vectorstore/qdrant.d.ts +11 -0
  149. package/dist/vectorstore/qdrant.d.ts.map +1 -0
  150. package/dist/vectorstore/qdrant.js +107 -0
  151. package/dist/vectorstore/qdrant.js.map +1 -0
  152. package/dist/vectorstore/types.d.ts +28 -0
  153. package/dist/vectorstore/types.d.ts.map +1 -0
  154. package/dist/vectorstore/types.js +2 -0
  155. package/dist/vectorstore/types.js.map +1 -0
  156. package/package.json +66 -0
  157. package/resources/docs/flow-building-guide.md +581 -0
  158. package/resources/docs/rest-api-pagination.md +58 -0
  159. package/resources/docs/standardized-components-guide.md +66 -0
  160. package/resources/docs/system-instructions.md +207 -0
  161. package/resources/flow-examples/batch-flow-1-collect.json +51 -0
  162. package/resources/flow-examples/batch-flow-2-process.json +70 -0
  163. package/resources/flow-examples/code-component-transform.json +65 -0
  164. package/resources/flow-examples/code-component-trigger.json +52 -0
  165. package/resources/flow-examples/code-component-with-credentials-trigger.json +53 -0
  166. package/resources/flow-examples/code-component-with-credentials.json +67 -0
  167. package/resources/flow-examples/filter-step.json +63 -0
  168. package/resources/flow-examples/polling-sync-trigger.json +50 -0
  169. package/resources/flow-examples/router-branching.json +94 -0
  170. package/resources/flow-examples/splitter-re-assemble.json +72 -0
  171. package/resources/flow-examples/splitter-split.json +68 -0
  172. package/resources/flow-examples/timer-query-action-sync.json +68 -0
  173. package/resources/flow-examples/webhook-async-sync.json +49 -0
  174. package/resources/flow-examples/webhook-request-reply.json +63 -0
package/dist/setup.js ADDED
@@ -0,0 +1,338 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import os from 'node:os';
5
+ import readline from 'node:readline';
6
+ const home = os.homedir();
7
+ // Resolve the full path to npx at setup time so clients that don't inherit
8
+ // the user's shell PATH (NVM, fnm, Homebrew, etc.) can still find it.
9
+ import { execSync } from 'node:child_process';
10
+ function resolveNpxPath() {
11
+ const cmd = process.platform === 'win32' ? 'where npx' : 'which npx';
12
+ try {
13
+ const result = execSync(cmd, { encoding: 'utf-8' }).trim();
14
+ // 'where' on Windows may return multiple lines; take the first
15
+ return result.split('\n')[0].trim();
16
+ }
17
+ catch {
18
+ return 'npx';
19
+ }
20
+ }
21
+ const npxPath = resolveNpxPath();
22
+ const npxDir = path.dirname(npxPath);
23
+ // Build a PATH that includes the directory where npx/node live,
24
+ // so clients that don't inherit the user's shell can find node.
25
+ const systemPaths = process.platform === 'win32'
26
+ ? [npxDir, path.join(process.env.SystemRoot || 'C:\\Windows', 'System32')]
27
+ : [npxDir, '/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin'];
28
+ const nodePath = systemPaths.join(path.delimiter);
29
+ function mcpEntry(env) {
30
+ return {
31
+ command: npxPath,
32
+ args: ['-y', '--prefer-online', '@elastic.io/mcp@beta'],
33
+ env: { PATH: nodePath, ...env },
34
+ };
35
+ }
36
+ function writeTomlMcpServer(configPath, env) {
37
+ let content = '';
38
+ try {
39
+ content = fs.readFileSync(configPath, 'utf-8');
40
+ }
41
+ catch { /* file doesn't exist yet */ }
42
+ // Remove all existing elasticio sections (main + sub-tables like .env, .tools.*)
43
+ content = content.replace(/\n?\[mcp_servers\.elasticio\b[^\]]*\]\n((?!\[)[^\n]*\n?)*/g, '');
44
+ // Build TOML section
45
+ // In TOML basic strings (double-quoted), backslashes must be escaped.
46
+ const esc = (s) => s.replace(/\\/g, '\\\\');
47
+ const allEnv = { PATH: nodePath, ...env };
48
+ const envLines = Object.entries(allEnv)
49
+ .map(([k, v]) => `${k} = "${esc(v)}"`)
50
+ .join('\n');
51
+ const section = `
52
+ [mcp_servers.elasticio]
53
+ command = "${esc(npxPath)}"
54
+ args = ["-y", "--prefer-online", "@elastic.io/mcp@beta"]
55
+ startup_timeout_sec = 120
56
+
57
+ [mcp_servers.elasticio.env]
58
+ ${envLines}
59
+ `;
60
+ fs.mkdirSync(path.dirname(configPath), { recursive: true });
61
+ fs.writeFileSync(configPath, content.trimEnd() + '\n' + section, 'utf-8');
62
+ }
63
+ function platformPath(mac, win, linux) {
64
+ if (process.platform === 'darwin')
65
+ return mac;
66
+ if (process.platform === 'win32')
67
+ return win;
68
+ return linux;
69
+ }
70
+ const clients = [
71
+ {
72
+ name: 'Claude Desktop',
73
+ configPath: platformPath(path.join(home, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json'), path.join(home, 'AppData', 'Roaming', 'Claude', 'claude_desktop_config.json'), path.join(home, '.config', 'Claude', 'claude_desktop_config.json')),
74
+ writeConfig(configPath, env) {
75
+ const existing = readJson(configPath);
76
+ existing.mcpServers = existing.mcpServers || {};
77
+ existing.mcpServers['elasticio'] = mcpEntry(env);
78
+ writeJson(configPath, existing);
79
+ },
80
+ },
81
+ {
82
+ name: 'Claude Code',
83
+ configPath: path.join(home, '.claude.json'),
84
+ writeConfig(configPath, env) {
85
+ const existing = readJson(configPath);
86
+ existing.mcpServers = existing.mcpServers || {};
87
+ existing.mcpServers['elasticio'] = mcpEntry(env);
88
+ writeJson(configPath, existing);
89
+ },
90
+ },
91
+ {
92
+ name: 'ChatGPT / Codex',
93
+ configPath: path.join(home, '.codex', 'config.toml'),
94
+ writeConfig(configPath, env) {
95
+ writeTomlMcpServer(configPath, env);
96
+ },
97
+ },
98
+ {
99
+ name: 'Cursor',
100
+ configPath: path.join(home, '.cursor', 'mcp.json'),
101
+ writeConfig(configPath, env) {
102
+ const existing = readJson(configPath);
103
+ existing.mcpServers = existing.mcpServers || {};
104
+ existing.mcpServers['elasticio'] = mcpEntry(env);
105
+ writeJson(configPath, existing);
106
+ },
107
+ },
108
+ {
109
+ name: 'Windsurf',
110
+ configPath: path.join(home, '.codeium', 'windsurf', 'mcp_config.json'),
111
+ writeConfig(configPath, env) {
112
+ const existing = readJson(configPath);
113
+ existing.mcpServers = existing.mcpServers || {};
114
+ existing.mcpServers['elasticio'] = mcpEntry(env);
115
+ writeJson(configPath, existing);
116
+ },
117
+ },
118
+ {
119
+ name: 'Gemini CLI / Gemini IDE (Antigravity)',
120
+ configPath: path.join(home, '.gemini', 'config', 'mcp_config.json'),
121
+ writeConfig(configPath, env) {
122
+ const existing = readJson(configPath);
123
+ existing.mcpServers = existing.mcpServers || {};
124
+ existing.mcpServers['elasticio'] = mcpEntry(env);
125
+ writeJson(configPath, existing);
126
+ },
127
+ },
128
+ {
129
+ name: 'Trae (ByteDance)',
130
+ configPath: path.join(home, '.trae', 'mcp.json'),
131
+ writeConfig(configPath, env) {
132
+ const existing = readJson(configPath);
133
+ existing.mcpServers = existing.mcpServers || {};
134
+ existing.mcpServers['elasticio'] = mcpEntry(env);
135
+ writeJson(configPath, existing);
136
+ },
137
+ },
138
+ {
139
+ name: 'VS Code (Copilot)',
140
+ configPath: platformPath(path.join(home, 'Library', 'Application Support', 'Code', 'User', 'mcp.json'), path.join(home, 'AppData', 'Roaming', 'Code', 'User', 'mcp.json'), path.join(home, '.config', 'Code', 'User', 'mcp.json')),
141
+ writeConfig(configPath, env) {
142
+ const existing = readJson(configPath);
143
+ existing.servers = existing.servers || {};
144
+ existing.servers['elasticio'] = mcpEntry(env);
145
+ writeJson(configPath, existing);
146
+ },
147
+ },
148
+ {
149
+ name: 'Zed',
150
+ configPath: path.join(home, '.config', 'zed', 'settings.json'),
151
+ writeConfig(configPath, env) {
152
+ const existing = readJson(configPath);
153
+ existing.context_servers = existing.context_servers || {};
154
+ existing.context_servers['elasticio'] = {
155
+ command: { path: 'npx', args: ['-y', '--prefer-online', '@elastic.io/mcp@beta'] },
156
+ settings: env,
157
+ };
158
+ writeJson(configPath, existing);
159
+ },
160
+ },
161
+ {
162
+ name: 'Cline (VS Code)',
163
+ configPath: platformPath(path.join(home, 'Library', 'Application Support', 'Code', 'User', 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json'), path.join(home, 'AppData', 'Roaming', 'Code', 'User', 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json'), path.join(home, '.config', 'Code', 'User', 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json')),
164
+ writeConfig(configPath, env) {
165
+ const existing = readJson(configPath);
166
+ existing.mcpServers = existing.mcpServers || {};
167
+ existing.mcpServers['elasticio'] = mcpEntry(env);
168
+ writeJson(configPath, existing);
169
+ },
170
+ },
171
+ {
172
+ name: 'Qwen Code',
173
+ configPath: path.join(home, '.qwen', 'settings.json'),
174
+ writeConfig(configPath, env) {
175
+ const existing = readJson(configPath);
176
+ existing.mcpServers = existing.mcpServers || {};
177
+ existing.mcpServers['elasticio'] = mcpEntry(env);
178
+ writeJson(configPath, existing);
179
+ },
180
+ },
181
+ {
182
+ name: 'Kimi Code',
183
+ configPath: path.join(home, '.kimi-code', 'mcp.json'),
184
+ writeConfig(configPath, env) {
185
+ const existing = readJson(configPath);
186
+ existing.mcpServers = existing.mcpServers || {};
187
+ existing.mcpServers['elasticio'] = mcpEntry(env);
188
+ writeJson(configPath, existing);
189
+ },
190
+ },
191
+ {
192
+ name: 'DeepSeek',
193
+ configPath: path.join(home, '.deepseek', 'mcp.json'),
194
+ writeConfig(configPath, env) {
195
+ const existing = readJson(configPath);
196
+ existing.mcpServers = existing.mcpServers || {};
197
+ existing.mcpServers['elasticio'] = mcpEntry(env);
198
+ writeJson(configPath, existing);
199
+ },
200
+ },
201
+ ];
202
+ function readJson(filePath) {
203
+ try {
204
+ return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
205
+ }
206
+ catch {
207
+ return {};
208
+ }
209
+ }
210
+ function writeJson(filePath, data) {
211
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
212
+ fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n', 'utf-8');
213
+ }
214
+ function detectClients() {
215
+ return clients.filter((c) => {
216
+ // Check if config file or its parent directory exists
217
+ const dir = path.dirname(c.configPath);
218
+ return fs.existsSync(c.configPath) || fs.existsSync(dir);
219
+ });
220
+ }
221
+ function ask(rl, question) {
222
+ return new Promise((resolve) => rl.question(question, resolve));
223
+ }
224
+ const MIN_NODE_MAJOR = 22;
225
+ function checkNodeVersion() {
226
+ const major = parseInt(process.versions.node.split('.')[0], 10);
227
+ if (major < MIN_NODE_MAJOR) {
228
+ console.error(`\n❌ Node.js ${process.versions.node} detected. Minimum required: v${MIN_NODE_MAJOR}.`);
229
+ console.error(` Download the latest LTS from https://nodejs.org/\n`);
230
+ process.exit(1);
231
+ }
232
+ }
233
+ function ensureV2Suffix(url) {
234
+ return url.endsWith('/v2') ? url : `${url.replace(/\/+$/, '')}/v2`;
235
+ }
236
+ /**
237
+ * Parse a curl command string like:
238
+ * curl https://api-sparrow.elastic.io/v2/users/me -u email:apikey
239
+ * Returns { email, apiKey, baseUrl } or null if the string is not a valid curl command.
240
+ */
241
+ function parseCurlString(input) {
242
+ const trimmed = input.trim();
243
+ if (!trimmed.startsWith('curl '))
244
+ return null;
245
+ // Extract URL
246
+ const urlMatch = trimmed.match(/curl\s+(https?:\/\/\S+)/);
247
+ if (!urlMatch)
248
+ return null;
249
+ // Extract -u credentials
250
+ const authMatch = trimmed.match(/-u\s+(\S+)/);
251
+ if (!authMatch)
252
+ return null;
253
+ const url = urlMatch[1];
254
+ const auth = authMatch[1];
255
+ const colonIdx = auth.indexOf(':');
256
+ if (colonIdx === -1)
257
+ return null;
258
+ const email = auth.substring(0, colonIdx);
259
+ const apiKey = auth.substring(colonIdx + 1);
260
+ if (!email || !apiKey)
261
+ return null;
262
+ // Derive base URL: extract origin and ensure /v2 suffix
263
+ const v2Idx = url.indexOf('/v2');
264
+ const baseUrl = v2Idx !== -1 ? url.substring(0, v2Idx + 3) : url;
265
+ return { email, apiKey, baseUrl };
266
+ }
267
+ export async function runSetup() {
268
+ checkNodeVersion();
269
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
270
+ console.log('\n🔧 elastic.io MCP Server Setup\n');
271
+ console.log(` Node.js: ${process.versions.node} (${npxPath})\n`);
272
+ // 1. Collect credentials — accept a curl command or manual entry
273
+ console.log('Paste the curl command from your elastic.io profile page, or press Enter to type credentials manually:');
274
+ const curlOrEmail = await ask(rl, '> ');
275
+ let env;
276
+ const parsed = parseCurlString(curlOrEmail);
277
+ if (parsed) {
278
+ console.log(`\n ✓ Parsed: email=${parsed.email}, base=${parsed.baseUrl}\n`);
279
+ env = {
280
+ ELASTICIO_API_EMAIL: parsed.email,
281
+ ELASTICIO_API_KEY: parsed.apiKey,
282
+ ELASTICIO_API_BASE_URL: parsed.baseUrl,
283
+ };
284
+ }
285
+ else {
286
+ // Manual entry — treat first input as email if it wasn't a curl command
287
+ const email = curlOrEmail.trim() || await ask(rl, 'elastic.io email: ');
288
+ const apiKey = await ask(rl, 'elastic.io API key: ');
289
+ const baseUrl = await ask(rl, 'API base URL (press Enter for https://api.elastic.io): ');
290
+ env = {
291
+ ELASTICIO_API_EMAIL: email.trim(),
292
+ ELASTICIO_API_KEY: apiKey.trim(),
293
+ ELASTICIO_API_BASE_URL: ensureV2Suffix(baseUrl.trim() || 'https://api.elastic.io'),
294
+ };
295
+ }
296
+ // 2. Detect clients
297
+ const detected = detectClients();
298
+ if (detected.length === 0) {
299
+ console.log('\nNo supported AI clients detected. Supported clients:');
300
+ clients.forEach((c) => console.log(` - ${c.name}`));
301
+ console.log('\nInstall one of the above clients and run setup again.');
302
+ rl.close();
303
+ return;
304
+ }
305
+ console.log('\nDetected AI clients:');
306
+ detected.forEach((c, i) => console.log(` ${i + 1}. ${c.name}`));
307
+ const selection = await ask(rl, `\nInstall to (comma-separated numbers, or "all"): `);
308
+ rl.close();
309
+ let selected;
310
+ if (selection.trim().toLowerCase() === 'all') {
311
+ selected = detected;
312
+ }
313
+ else {
314
+ const indices = selection.split(',').map((s) => parseInt(s.trim(), 10) - 1);
315
+ selected = indices.filter((i) => i >= 0 && i < detected.length).map((i) => detected[i]);
316
+ }
317
+ if (selected.length === 0) {
318
+ console.log('No clients selected. Exiting.');
319
+ return;
320
+ }
321
+ // 3. Write configs
322
+ for (const client of selected) {
323
+ try {
324
+ client.writeConfig(client.configPath, env);
325
+ console.log(`✅ ${client.name} — configured (${client.configPath})`);
326
+ }
327
+ catch (err) {
328
+ console.error(`❌ ${client.name} — failed: ${err.message}`);
329
+ }
330
+ }
331
+ console.log('\nDone! Restart your AI client to pick up the new MCP server.\n');
332
+ }
333
+ // Self-execute when run directly
334
+ runSetup().then(() => process.exit(0)).catch((err) => {
335
+ console.error(err);
336
+ process.exit(1);
337
+ });
338
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,QAAQ,MAAM,eAAe,CAAC;AAQrC,MAAM,IAAI,GA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AAC;QACtE,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,IAAI,cAAc,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,iEAAiE,CAAC,CAAC;AACjF,CAAC;AAED,iCAAiC;AACjC,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,37 @@
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
+ * Return the confirmation prompt as a tool result the LLM will see.
24
+ */
25
+ export declare function confirmationResult(toolName: string, args: any): {
26
+ content: Array<{
27
+ type: 'text';
28
+ text: string;
29
+ }>;
30
+ isError: boolean;
31
+ };
32
+ /**
33
+ * Returns a new tools array with the `confirmed` property injected into
34
+ * every destructive tool's input schema.
35
+ */
36
+ export declare function withConfirmationSchemas(tools: Tool[]): Tool[];
37
+ //# 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;AAuDD;;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
+ 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":"confirmation.js","sourceRoot":"","sources":["../../src/tools/confirmation.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,aAAa;IAC1B,iBAAiB,EAAE,mBAAmB;IACtC,UAAU,EAAE,YAAY;IACxB,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;IAC5B,kBAAkB,EAAE,oBAAoB;IACxC,kBAAkB,EAAE,oBAAoB;IACxC,aAAa,EAAE,eAAe;IAC9B,uBAAuB,EAAE,yBAAyB;IAClD,kBAAkB,EAAE,oBAAoB;IACxC,kBAAkB,EAAE,oBAAoB;IACxC,eAAe,EAAE,iBAAiB;CAC1B,CAAC;AAEX,MAAM,iBAAiB,GAAa,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAE1E,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAEjE;;;GAGG;AACH,MAAM,UAAU,o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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,28 @@
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_COMPONENT_ACTIONS: Record<string, Record<string, string>>;
20
+ /**
21
+ * Helper to look up replacement for a deprecated action/trigger within a component.
22
+ * Checks both full prefix (e.g. "core/rest-api-v2") and base repo name (e.g. "rest-api-v2").
23
+ */
24
+ export declare function getDeprecatedActionReplacement(commandPrefix: string, actionId: string): string | undefined;
25
+ export declare const DEPRECATED_ACTIONS: Record<string, string>;
26
+ export declare const REST_API_READER_FIELDS: string[];
27
+ export declare const PLACEHOLDER_FIELD_VALUES: string[];
28
+ //# 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,4BAA4B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA+B/E,CAAC;AAEF;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQ1G;AAGD,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKrD,CAAC;AAKF,eAAO,MAAM,sBAAsB,UAAuC,CAAC;AAK3E,eAAO,MAAM,wBAAwB,UAAwF,CAAC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Centralized constants for the MCP tools layer.
3
+ * Keeps magic numbers, validation lists, and component metadata out of business logic.
4
+ */
5
+ // --- Pagination defaults ---
6
+ export const PAGE_SIZE = {
7
+ CONTRACTS: 20,
8
+ WORKSPACES: 20,
9
+ FLOWS_DEFAULT: 50,
10
+ FLOWS_MAX: 100,
11
+ LOGS_DEFAULT: 50,
12
+ };
13
+ export const SEARCH_RESULTS_DEFAULT_LIMIT = 5;
14
+ // --- Response limits ---
15
+ export const MAX_RESPONSE_LENGTH = 200_000;
16
+ // --- Enum pruning thresholds (pruneMetadataResult) ---
17
+ export const ENUM_PRUNE_THRESHOLD = 5;
18
+ export const ENUM_PRUNE_KEEP = 3;
19
+ // --- Validation: known bare field names that LLMs commonly use without $getPassthrough() ---
20
+ export const BARE_FIELD_NAMES = ['Id', 'Name', 'Phone', 'Website', 'Email'];
21
+ // --- Validation: JSONata functions unsupported in router conditions ---
22
+ export const UNSUPPORTED_ROUTER_JSONATA_FUNCTIONS = [
23
+ '$now', '$millis', '$hour', '$minute', '$second',
24
+ '$year', '$month', '$day', '$toMillis', '$fromMillis',
25
+ '$formatTimestamp', '$parseTimestamp',
26
+ ];
27
+ // --- Deprecated components ---
28
+ export const DEPRECATED_COMPONENTS = {
29
+ 'elasticio/REST-API': 'elasticio/rest-api-client-credentials-auth or elasticio/REST-API-AUTH-SECRETS',
30
+ };
31
+ // --- Deprecated actions/triggers scoped by component ---
32
+ // Maps component command prefix or repository name to its deprecated actions/triggers and their replacements.
33
+ // Checked during flow graph validation to prevent selecting deprecated functions.
34
+ export const DEPRECATED_COMPONENT_ACTIONS = {
35
+ 'core/rest-api-v2': {
36
+ 'httpRequestAction': 'httpRequestAxios',
37
+ 'httpRequestTrigger': 'httpRequestAxiosTrigger',
38
+ },
39
+ 'elasticio/rest-api-v2': {
40
+ 'httpRequestAction': 'httpRequestAxios',
41
+ 'httpRequestTrigger': 'httpRequestAxiosTrigger',
42
+ },
43
+ 'rest-api-v2': {
44
+ 'httpRequestAction': 'httpRequestAxios',
45
+ 'httpRequestTrigger': 'httpRequestAxiosTrigger',
46
+ },
47
+ 'elasticio/slack': {
48
+ 'postMessage': 'makeRawRequest or upsertObject',
49
+ },
50
+ 'core/slack': {
51
+ 'postMessage': 'makeRawRequest or upsertObject',
52
+ },
53
+ 'slack': {
54
+ 'postMessage': 'makeRawRequest or upsertObject',
55
+ },
56
+ 'elasticio/splitter': {
57
+ 'split': 'splitOnJsonataExpression',
58
+ },
59
+ 'core/splitter': {
60
+ 'split': 'splitOnJsonataExpression',
61
+ },
62
+ 'splitter': {
63
+ 'split': 'splitOnJsonataExpression',
64
+ },
65
+ };
66
+ /**
67
+ * Helper to look up replacement for a deprecated action/trigger within a component.
68
+ * Checks both full prefix (e.g. "core/rest-api-v2") and base repo name (e.g. "rest-api-v2").
69
+ */
70
+ export function getDeprecatedActionReplacement(commandPrefix, actionId) {
71
+ if (!commandPrefix || !actionId)
72
+ return undefined;
73
+ const direct = DEPRECATED_COMPONENT_ACTIONS[commandPrefix]?.[actionId];
74
+ if (direct)
75
+ return direct;
76
+ const repoName = commandPrefix.includes('/') ? commandPrefix.split('/')[1] : commandPrefix;
77
+ return DEPRECATED_COMPONENT_ACTIONS[repoName]?.[actionId];
78
+ }
79
+ // Deprecated global map kept for backward compatibility
80
+ export const DEPRECATED_ACTIONS = {
81
+ 'httpRequestAction': 'httpRequestAxios',
82
+ 'httpRequestTrigger': 'httpRequestAxiosTrigger',
83
+ 'postMessage': 'makeRawRequest or upsertObject',
84
+ 'split': 'splitOnJsonataExpression',
85
+ };
86
+ // --- Validation: REST API reader field names that must NOT appear in edge mappers ---
87
+ // These belong in node.fields.reader, not in edge.config.mapper.
88
+ export const REST_API_READER_FIELDS = ['url', 'method', 'headers', 'body'];
89
+ // --- Validation: placeholder/dummy values for dynamic select model fields ---
90
+ // If a field that uses a dynamic select model has one of these values, it was never properly configured.
91
+ export const PLACEHOLDER_FIELD_VALUES = ['default', 'DEFAULT', 'select', 'Select', 'choose', 'Choose', 'none', 'placeholder'];
92
+ //# sourceMappingURL=constants.js.map