@kairos-sdk/core 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -5
- package/dist/chunk-KQSNT3HZ.js +809 -0
- package/dist/chunk-KQSNT3HZ.js.map +1 -0
- package/dist/{chunk-QQJDLS5A.js → chunk-RYGYNOR6.js} +121 -895
- package/dist/chunk-RYGYNOR6.js.map +1 -0
- package/dist/cli.cjs +19 -4
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +4 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +19 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -10
- package/dist/mcp-server.cjs +2080 -0
- package/dist/mcp-server.cjs.map +1 -0
- package/dist/mcp-server.d.cts +1 -0
- package/dist/mcp-server.d.ts +1 -0
- package/dist/mcp-server.js +509 -0
- package/dist/mcp-server.js.map +1 -0
- package/package.json +16 -5
- package/dist/chunk-QQJDLS5A.js.map +0 -1
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_REGISTRY,
|
|
4
|
+
FileLibrary,
|
|
5
|
+
N8nApiClient,
|
|
6
|
+
N8nFieldStripper,
|
|
7
|
+
N8nValidator,
|
|
8
|
+
NodeRegistry,
|
|
9
|
+
PromptBuilder,
|
|
10
|
+
TelemetryReader,
|
|
11
|
+
nullLogger
|
|
12
|
+
} from "./chunk-RYGYNOR6.js";
|
|
13
|
+
|
|
14
|
+
// src/mcp-server.ts
|
|
15
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
16
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
17
|
+
import { z } from "zod";
|
|
18
|
+
|
|
19
|
+
// src/validation/node-syncer.ts
|
|
20
|
+
var TRIGGER_PATTERNS = [/trigger/i, /Trigger$/];
|
|
21
|
+
var NodeSyncer = class {
|
|
22
|
+
baseRegistry;
|
|
23
|
+
constructor() {
|
|
24
|
+
this.baseRegistry = new Map(DEFAULT_REGISTRY.map((d) => [d.type, d]));
|
|
25
|
+
}
|
|
26
|
+
sync(liveNodes) {
|
|
27
|
+
const merged = new Map(this.baseRegistry);
|
|
28
|
+
let newNodes = 0;
|
|
29
|
+
for (const node of liveNodes) {
|
|
30
|
+
const versions = Array.isArray(node.version) ? node.version : [node.version];
|
|
31
|
+
const isTrigger = TRIGGER_PATTERNS.some((p) => p.test(node.name));
|
|
32
|
+
const credentialType = node.credentials?.[0]?.name;
|
|
33
|
+
const existing = merged.get(node.name);
|
|
34
|
+
if (existing) {
|
|
35
|
+
const allVersions = /* @__PURE__ */ new Set([...existing.safeTypeVersions, ...versions]);
|
|
36
|
+
merged.set(node.name, {
|
|
37
|
+
...existing,
|
|
38
|
+
safeTypeVersions: [...allVersions].sort((a, b) => a - b)
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
newNodes++;
|
|
42
|
+
merged.set(node.name, {
|
|
43
|
+
type: node.name,
|
|
44
|
+
safeTypeVersions: versions.sort((a, b) => a - b),
|
|
45
|
+
requiredParams: [],
|
|
46
|
+
...credentialType ? { credentialType } : {},
|
|
47
|
+
...isTrigger ? { isTrigger: true } : {}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const definitions = [...merged.values()];
|
|
52
|
+
const registry = new NodeRegistry(definitions);
|
|
53
|
+
const catalogText = this.buildCatalog(definitions);
|
|
54
|
+
return { registry, catalogText, nodeCount: definitions.length, newNodes };
|
|
55
|
+
}
|
|
56
|
+
buildCatalog(definitions) {
|
|
57
|
+
const triggers = definitions.filter((d) => d.isTrigger);
|
|
58
|
+
const regular = definitions.filter((d) => !d.isTrigger);
|
|
59
|
+
const formatEntry = (d) => {
|
|
60
|
+
const versions = d.safeTypeVersions.join(", ");
|
|
61
|
+
const cred = d.credentialType ? ` \u2014 cred: ${d.credentialType}` : "";
|
|
62
|
+
return `${d.type} typeVersion: ${versions}${cred}`;
|
|
63
|
+
};
|
|
64
|
+
const triggerLines = triggers.map(formatEntry).join("\n");
|
|
65
|
+
const regularLines = regular.map(formatEntry).join("\n");
|
|
66
|
+
return `## NODE CATALOG \u2014 synced from your n8n instance (${definitions.length} node types)
|
|
67
|
+
|
|
68
|
+
### Triggers:
|
|
69
|
+
${triggerLines}
|
|
70
|
+
|
|
71
|
+
### Regular nodes:
|
|
72
|
+
${regularLines}`;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/mcp-server.ts
|
|
77
|
+
import { readFileSync } from "fs";
|
|
78
|
+
import { dirname, join } from "path";
|
|
79
|
+
import { fileURLToPath } from "url";
|
|
80
|
+
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
81
|
+
var pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
|
|
82
|
+
var library = new FileLibrary();
|
|
83
|
+
var validator = new N8nValidator();
|
|
84
|
+
var nodeSyncer = new NodeSyncer();
|
|
85
|
+
var lastSync = null;
|
|
86
|
+
var stripper = new N8nFieldStripper();
|
|
87
|
+
var promptBuilder = new PromptBuilder();
|
|
88
|
+
function getTelemetryReader() {
|
|
89
|
+
try {
|
|
90
|
+
return new TelemetryReader();
|
|
91
|
+
} catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function isAllowed(action) {
|
|
96
|
+
const key = `KAIROS_MCP_ALLOW_${action.toUpperCase()}`;
|
|
97
|
+
return process.env[key] === "true";
|
|
98
|
+
}
|
|
99
|
+
function getApiClient() {
|
|
100
|
+
const baseUrl = process.env["N8N_BASE_URL"];
|
|
101
|
+
const apiKey = process.env["N8N_API_KEY"];
|
|
102
|
+
if (!baseUrl || !apiKey) {
|
|
103
|
+
throw new Error("N8N_BASE_URL and N8N_API_KEY environment variables are required for n8n operations");
|
|
104
|
+
}
|
|
105
|
+
return new N8nApiClient(baseUrl, apiKey, nullLogger);
|
|
106
|
+
}
|
|
107
|
+
async function autoSync() {
|
|
108
|
+
if (lastSync) return lastSync;
|
|
109
|
+
const baseUrl = process.env["N8N_BASE_URL"];
|
|
110
|
+
const apiKey = process.env["N8N_API_KEY"];
|
|
111
|
+
if (!baseUrl || !apiKey) return null;
|
|
112
|
+
try {
|
|
113
|
+
const client = new N8nApiClient(baseUrl, apiKey, nullLogger);
|
|
114
|
+
const nodeTypes = await client.getNodeTypes();
|
|
115
|
+
if (nodeTypes.length === 0) return null;
|
|
116
|
+
lastSync = nodeSyncer.sync(nodeTypes);
|
|
117
|
+
validator = new N8nValidator(lastSync.registry);
|
|
118
|
+
return lastSync;
|
|
119
|
+
} catch {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
var server = new McpServer({
|
|
124
|
+
name: "kairos",
|
|
125
|
+
version: pkg.version
|
|
126
|
+
});
|
|
127
|
+
server.tool(
|
|
128
|
+
"kairos_prompt",
|
|
129
|
+
"Get the specialized n8n workflow generation context. Returns a system prompt with node catalog, connection rules, validation rules, plus library matches and failure patterns for the given description. Feed this to yourself as context, then generate the workflow JSON.",
|
|
130
|
+
{
|
|
131
|
+
description: z.string().describe("Plain-English description of the workflow to build"),
|
|
132
|
+
name: z.string().optional().describe("Optional workflow name override")
|
|
133
|
+
},
|
|
134
|
+
async ({ description, name }) => {
|
|
135
|
+
const baseUrl = process.env["N8N_BASE_URL"];
|
|
136
|
+
const apiKey = process.env["N8N_API_KEY"];
|
|
137
|
+
if (!baseUrl || !apiKey) {
|
|
138
|
+
return {
|
|
139
|
+
content: [{
|
|
140
|
+
type: "text",
|
|
141
|
+
text: JSON.stringify({ error: "N8N_BASE_URL and N8N_API_KEY are required. Kairos needs to sync your n8n instance's node types to generate accurate workflows." })
|
|
142
|
+
}],
|
|
143
|
+
isError: true
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
await library.initialize();
|
|
147
|
+
const syncResult = await autoSync();
|
|
148
|
+
const matches = await library.search(description);
|
|
149
|
+
const telemetryReader = getTelemetryReader();
|
|
150
|
+
const failureRates = await telemetryReader?.getFailureRates() ?? [];
|
|
151
|
+
const request = { description, ...name ? { name } : {} };
|
|
152
|
+
const built = promptBuilder.build(request, matches, failureRates, syncResult?.catalogText);
|
|
153
|
+
const systemText = built.system.map((block) => block.text).join("\n\n---\n\n");
|
|
154
|
+
return {
|
|
155
|
+
content: [{
|
|
156
|
+
type: "text",
|
|
157
|
+
text: JSON.stringify({
|
|
158
|
+
mode: built.mode,
|
|
159
|
+
matchCount: matches.length,
|
|
160
|
+
topMatchScore: matches[0]?.score ?? null,
|
|
161
|
+
nodeCatalog: syncResult ? "synced" : "static",
|
|
162
|
+
nodeCount: syncResult?.nodeCount ?? null,
|
|
163
|
+
systemPrompt: systemText,
|
|
164
|
+
userMessage: built.userMessage,
|
|
165
|
+
outputFormat: {
|
|
166
|
+
description: "Generate a JSON object with this exact structure. The workflow field contains the n8n workflow. credentialsNeeded lists services requiring credentials.",
|
|
167
|
+
schema: {
|
|
168
|
+
workflow: {
|
|
169
|
+
name: "string \u2014 descriptive workflow name",
|
|
170
|
+
nodes: "array \u2014 n8n node objects with id (UUID v4), type, typeVersion, name, position, parameters",
|
|
171
|
+
connections: "object \u2014 keyed by source node NAME, maps to target nodes",
|
|
172
|
+
settings: 'object \u2014 include executionOrder: "v1"'
|
|
173
|
+
},
|
|
174
|
+
credentialsNeeded: [{
|
|
175
|
+
service: 'string \u2014 e.g. "Slack"',
|
|
176
|
+
credentialType: 'string \u2014 e.g. "slackOAuth2Api"',
|
|
177
|
+
description: "string \u2014 what the user needs to set up"
|
|
178
|
+
}]
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}, null, 2)
|
|
182
|
+
}]
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
server.tool(
|
|
187
|
+
"kairos_validate",
|
|
188
|
+
"Validate n8n workflow JSON against 23 structural rules. Returns pass/fail with specific issues. If validation fails, fix the issues and call this again. Errors block deployment; warnings are advisory.",
|
|
189
|
+
{
|
|
190
|
+
workflow: z.string().describe("The workflow JSON string to validate")
|
|
191
|
+
},
|
|
192
|
+
async ({ workflow: workflowStr }) => {
|
|
193
|
+
let parsed;
|
|
194
|
+
try {
|
|
195
|
+
parsed = JSON.parse(workflowStr);
|
|
196
|
+
} catch (e) {
|
|
197
|
+
return {
|
|
198
|
+
content: [{
|
|
199
|
+
type: "text",
|
|
200
|
+
text: JSON.stringify({
|
|
201
|
+
valid: false,
|
|
202
|
+
error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}`
|
|
203
|
+
}, null, 2)
|
|
204
|
+
}]
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
const result = validator.validate(parsed);
|
|
208
|
+
const errors = result.issues.filter((i) => i.severity === "error");
|
|
209
|
+
const warnings = result.issues.filter((i) => i.severity === "warn");
|
|
210
|
+
return {
|
|
211
|
+
content: [{
|
|
212
|
+
type: "text",
|
|
213
|
+
text: JSON.stringify({
|
|
214
|
+
valid: result.valid,
|
|
215
|
+
errorCount: errors.length,
|
|
216
|
+
warningCount: warnings.length,
|
|
217
|
+
errors: errors.map((i) => ({
|
|
218
|
+
rule: i.rule,
|
|
219
|
+
message: i.message,
|
|
220
|
+
nodeId: i.nodeId ?? null
|
|
221
|
+
})),
|
|
222
|
+
warnings: warnings.map((i) => ({
|
|
223
|
+
rule: i.rule,
|
|
224
|
+
message: i.message,
|
|
225
|
+
nodeId: i.nodeId ?? null
|
|
226
|
+
})),
|
|
227
|
+
deployable: errors.length === 0
|
|
228
|
+
}, null, 2)
|
|
229
|
+
}]
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
server.tool(
|
|
234
|
+
"kairos_deploy",
|
|
235
|
+
"Deploy a validated workflow to n8n. Pass the workflow JSON that passed kairos_validate. Strips server-assigned fields automatically. Requires N8N_BASE_URL and N8N_API_KEY.",
|
|
236
|
+
{
|
|
237
|
+
workflow: z.string().describe("The validated workflow JSON string to deploy"),
|
|
238
|
+
activate: z.boolean().default(false).describe("Activate the workflow immediately after deployment")
|
|
239
|
+
},
|
|
240
|
+
async ({ workflow: workflowStr, activate }) => {
|
|
241
|
+
if (!isAllowed("deploy")) {
|
|
242
|
+
return {
|
|
243
|
+
content: [{
|
|
244
|
+
type: "text",
|
|
245
|
+
text: JSON.stringify({ error: "Deploy is disabled. Set KAIROS_MCP_ALLOW_DEPLOY=true to enable." })
|
|
246
|
+
}],
|
|
247
|
+
isError: true
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
let parsed;
|
|
251
|
+
try {
|
|
252
|
+
parsed = JSON.parse(workflowStr);
|
|
253
|
+
} catch (e) {
|
|
254
|
+
return {
|
|
255
|
+
content: [{
|
|
256
|
+
type: "text",
|
|
257
|
+
text: JSON.stringify({ error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}` })
|
|
258
|
+
}]
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
const validation = validator.validate(parsed);
|
|
262
|
+
const errors = validation.issues.filter((i) => i.severity === "error");
|
|
263
|
+
if (errors.length > 0) {
|
|
264
|
+
return {
|
|
265
|
+
content: [{
|
|
266
|
+
type: "text",
|
|
267
|
+
text: JSON.stringify({
|
|
268
|
+
error: "Workflow has validation errors \u2014 fix them before deploying",
|
|
269
|
+
errors: errors.map((i) => ({ rule: i.rule, message: i.message }))
|
|
270
|
+
}, null, 2)
|
|
271
|
+
}]
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
const client = getApiClient();
|
|
275
|
+
const stripped = stripper.stripForCreate(parsed);
|
|
276
|
+
const response = await client.createWorkflow(stripped);
|
|
277
|
+
if (activate) {
|
|
278
|
+
if (!isAllowed("activate")) {
|
|
279
|
+
return {
|
|
280
|
+
content: [{
|
|
281
|
+
type: "text",
|
|
282
|
+
text: JSON.stringify({
|
|
283
|
+
workflowId: response.id,
|
|
284
|
+
name: response.name,
|
|
285
|
+
activated: false,
|
|
286
|
+
warning: "Workflow deployed but activation is disabled. Set KAIROS_MCP_ALLOW_ACTIVATE=true to enable.",
|
|
287
|
+
url: `${process.env["N8N_BASE_URL"]}/workflow/${response.id}`
|
|
288
|
+
}, null, 2)
|
|
289
|
+
}]
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
await client.activateWorkflow(response.id);
|
|
293
|
+
}
|
|
294
|
+
await library.initialize();
|
|
295
|
+
await library.save(parsed, {
|
|
296
|
+
description: parsed.name,
|
|
297
|
+
generationMode: "scratch",
|
|
298
|
+
generationAttempts: 1
|
|
299
|
+
});
|
|
300
|
+
return {
|
|
301
|
+
content: [{
|
|
302
|
+
type: "text",
|
|
303
|
+
text: JSON.stringify({
|
|
304
|
+
workflowId: response.id,
|
|
305
|
+
name: response.name,
|
|
306
|
+
activated: activate,
|
|
307
|
+
url: `${process.env["N8N_BASE_URL"]}/workflow/${response.id}`
|
|
308
|
+
}, null, 2)
|
|
309
|
+
}]
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
);
|
|
313
|
+
server.tool(
|
|
314
|
+
"kairos_search",
|
|
315
|
+
"Search the local workflow library for similar past builds. Returns matching workflows with scores, useful for finding examples and reusing patterns.",
|
|
316
|
+
{
|
|
317
|
+
query: z.string().describe("Search query \u2014 a workflow description or keywords"),
|
|
318
|
+
limit: z.number().default(5).describe("Maximum number of results")
|
|
319
|
+
},
|
|
320
|
+
async ({ query, limit }) => {
|
|
321
|
+
await library.initialize();
|
|
322
|
+
const matches = await library.search(query);
|
|
323
|
+
return {
|
|
324
|
+
content: [{
|
|
325
|
+
type: "text",
|
|
326
|
+
text: JSON.stringify(
|
|
327
|
+
matches.slice(0, limit).map((m) => ({
|
|
328
|
+
score: Number(m.score.toFixed(3)),
|
|
329
|
+
mode: m.mode,
|
|
330
|
+
description: m.workflow.description,
|
|
331
|
+
nodeCount: m.workflow.workflow.nodes.length,
|
|
332
|
+
nodes: m.workflow.workflow.nodes.map((n) => n.name),
|
|
333
|
+
failurePatterns: m.workflow.failurePatterns ?? []
|
|
334
|
+
})),
|
|
335
|
+
null,
|
|
336
|
+
2
|
|
337
|
+
)
|
|
338
|
+
}]
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
);
|
|
342
|
+
server.tool(
|
|
343
|
+
"kairos_sync",
|
|
344
|
+
"Sync the node catalog from your live n8n instance. Fetches all installed node types and versions so Kairos knows exactly what your n8n supports. Automatically called by kairos_prompt when n8n credentials are set, but you can call this manually to force a refresh.",
|
|
345
|
+
{},
|
|
346
|
+
async () => {
|
|
347
|
+
const baseUrl = process.env["N8N_BASE_URL"];
|
|
348
|
+
const apiKey = process.env["N8N_API_KEY"];
|
|
349
|
+
if (!baseUrl || !apiKey) {
|
|
350
|
+
return {
|
|
351
|
+
content: [{
|
|
352
|
+
type: "text",
|
|
353
|
+
text: JSON.stringify({ error: "N8N_BASE_URL and N8N_API_KEY are required for sync." })
|
|
354
|
+
}],
|
|
355
|
+
isError: true
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
lastSync = null;
|
|
359
|
+
const result = await autoSync();
|
|
360
|
+
if (!result) {
|
|
361
|
+
return {
|
|
362
|
+
content: [{
|
|
363
|
+
type: "text",
|
|
364
|
+
text: JSON.stringify({ error: "Failed to fetch node types from n8n. Check your credentials and that your instance is running." })
|
|
365
|
+
}],
|
|
366
|
+
isError: true
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
return {
|
|
370
|
+
content: [{
|
|
371
|
+
type: "text",
|
|
372
|
+
text: JSON.stringify({
|
|
373
|
+
synced: true,
|
|
374
|
+
nodeCount: result.nodeCount,
|
|
375
|
+
newNodes: result.newNodes,
|
|
376
|
+
message: `Synced ${result.nodeCount} node types from your n8n instance (${result.newNodes} not in default catalog).`
|
|
377
|
+
}, null, 2)
|
|
378
|
+
}]
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
);
|
|
382
|
+
server.tool(
|
|
383
|
+
"kairos_list",
|
|
384
|
+
"List all workflows deployed on the connected n8n instance.",
|
|
385
|
+
{},
|
|
386
|
+
async () => {
|
|
387
|
+
const client = getApiClient();
|
|
388
|
+
const workflows = await client.listWorkflows();
|
|
389
|
+
return {
|
|
390
|
+
content: [{
|
|
391
|
+
type: "text",
|
|
392
|
+
text: JSON.stringify(workflows, null, 2)
|
|
393
|
+
}]
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
server.tool(
|
|
398
|
+
"kairos_get",
|
|
399
|
+
"Get the full JSON definition of a specific workflow by ID.",
|
|
400
|
+
{
|
|
401
|
+
workflow_id: z.string().describe("The n8n workflow ID")
|
|
402
|
+
},
|
|
403
|
+
async ({ workflow_id }) => {
|
|
404
|
+
const client = getApiClient();
|
|
405
|
+
const workflow = await client.getWorkflow(workflow_id);
|
|
406
|
+
return {
|
|
407
|
+
content: [{
|
|
408
|
+
type: "text",
|
|
409
|
+
text: JSON.stringify(workflow, null, 2)
|
|
410
|
+
}]
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
server.tool(
|
|
415
|
+
"kairos_activate",
|
|
416
|
+
"Activate a deployed workflow so it starts running on triggers.",
|
|
417
|
+
{
|
|
418
|
+
workflow_id: z.string().describe("The n8n workflow ID to activate")
|
|
419
|
+
},
|
|
420
|
+
async ({ workflow_id }) => {
|
|
421
|
+
if (!isAllowed("activate")) {
|
|
422
|
+
return {
|
|
423
|
+
content: [{
|
|
424
|
+
type: "text",
|
|
425
|
+
text: JSON.stringify({ error: "Activate is disabled. Set KAIROS_MCP_ALLOW_ACTIVATE=true to enable." })
|
|
426
|
+
}],
|
|
427
|
+
isError: true
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
const client = getApiClient();
|
|
431
|
+
await client.activateWorkflow(workflow_id);
|
|
432
|
+
return {
|
|
433
|
+
content: [{
|
|
434
|
+
type: "text",
|
|
435
|
+
text: `Activated workflow ${workflow_id}`
|
|
436
|
+
}]
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
);
|
|
440
|
+
server.tool(
|
|
441
|
+
"kairos_deactivate",
|
|
442
|
+
"Deactivate a running workflow.",
|
|
443
|
+
{
|
|
444
|
+
workflow_id: z.string().describe("The n8n workflow ID to deactivate")
|
|
445
|
+
},
|
|
446
|
+
async ({ workflow_id }) => {
|
|
447
|
+
const client = getApiClient();
|
|
448
|
+
await client.deactivateWorkflow(workflow_id);
|
|
449
|
+
return {
|
|
450
|
+
content: [{
|
|
451
|
+
type: "text",
|
|
452
|
+
text: `Deactivated workflow ${workflow_id}`
|
|
453
|
+
}]
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
);
|
|
457
|
+
server.tool(
|
|
458
|
+
"kairos_delete",
|
|
459
|
+
"Delete a workflow from n8n. This is irreversible.",
|
|
460
|
+
{
|
|
461
|
+
workflow_id: z.string().describe("The n8n workflow ID to delete")
|
|
462
|
+
},
|
|
463
|
+
async ({ workflow_id }) => {
|
|
464
|
+
if (!isAllowed("delete")) {
|
|
465
|
+
return {
|
|
466
|
+
content: [{
|
|
467
|
+
type: "text",
|
|
468
|
+
text: JSON.stringify({ error: "Delete is disabled. Set KAIROS_MCP_ALLOW_DELETE=true to enable." })
|
|
469
|
+
}],
|
|
470
|
+
isError: true
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
const client = getApiClient();
|
|
474
|
+
await client.deleteWorkflow(workflow_id);
|
|
475
|
+
return {
|
|
476
|
+
content: [{
|
|
477
|
+
type: "text",
|
|
478
|
+
text: `Deleted workflow ${workflow_id}`
|
|
479
|
+
}]
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
server.tool(
|
|
484
|
+
"kairos_executions",
|
|
485
|
+
"List recent executions for a workflow, showing status and timing.",
|
|
486
|
+
{
|
|
487
|
+
workflow_id: z.string().optional().describe("Filter to a specific workflow ID (omit for all)"),
|
|
488
|
+
limit: z.number().default(20).describe("Maximum number of executions to return")
|
|
489
|
+
},
|
|
490
|
+
async ({ workflow_id, limit }) => {
|
|
491
|
+
const client = getApiClient();
|
|
492
|
+
const executions = await client.getExecutions(workflow_id, { limit });
|
|
493
|
+
return {
|
|
494
|
+
content: [{
|
|
495
|
+
type: "text",
|
|
496
|
+
text: JSON.stringify(executions, null, 2)
|
|
497
|
+
}]
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
);
|
|
501
|
+
async function main() {
|
|
502
|
+
const transport = new StdioServerTransport();
|
|
503
|
+
await server.connect(transport);
|
|
504
|
+
}
|
|
505
|
+
main().catch((err) => {
|
|
506
|
+
console.error("Kairos MCP server failed to start:", err);
|
|
507
|
+
process.exit(1);
|
|
508
|
+
});
|
|
509
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mcp-server.ts","../src/validation/node-syncer.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * Kairos MCP Server — decomposed architecture.\n *\n * The host LLM (Claude, GPT, Gemini, whatever) generates the workflow.\n * Kairos provides the knowledge (system prompt, library, failure patterns)\n * and guardrails (validator, deployer). Zero Anthropic API key needed.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { z } from 'zod'\nimport { FileLibrary } from './library/file-library.js'\nimport { N8nValidator } from './validation/validator.js'\nimport { N8nFieldStripper } from './providers/n8n/stripper.js'\nimport { N8nApiClient } from './providers/n8n/api-client.js'\nimport { PromptBuilder } from './generation/prompt-builder.js'\nimport { TelemetryReader } from './telemetry/reader.js'\nimport { NodeSyncer, type SyncResult } from './validation/node-syncer.js'\nimport { nullLogger } from './utils/logger.js'\nimport type { N8nWorkflow } from './types/workflow.js'\nimport { readFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\nconst pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8')) as { version: string }\n\nconst library = new FileLibrary()\nlet validator = new N8nValidator()\nconst nodeSyncer = new NodeSyncer()\nlet lastSync: SyncResult | null = null\nconst stripper = new N8nFieldStripper()\nconst promptBuilder = new PromptBuilder()\n\nfunction getTelemetryReader(): TelemetryReader | null {\n try {\n return new TelemetryReader()\n } catch {\n return null\n }\n}\n\nfunction isAllowed(action: 'deploy' | 'activate' | 'delete'): boolean {\n const key = `KAIROS_MCP_ALLOW_${action.toUpperCase()}`\n return process.env[key] === 'true'\n}\n\nfunction getApiClient(): N8nApiClient {\n const baseUrl = process.env['N8N_BASE_URL']\n const apiKey = process.env['N8N_API_KEY']\n if (!baseUrl || !apiKey) {\n throw new Error('N8N_BASE_URL and N8N_API_KEY environment variables are required for n8n operations')\n }\n return new N8nApiClient(baseUrl, apiKey, nullLogger)\n}\n\nasync function autoSync(): Promise<SyncResult | null> {\n if (lastSync) return lastSync\n const baseUrl = process.env['N8N_BASE_URL']\n const apiKey = process.env['N8N_API_KEY']\n if (!baseUrl || !apiKey) return null\n try {\n const client = new N8nApiClient(baseUrl, apiKey, nullLogger)\n const nodeTypes = await client.getNodeTypes()\n if (nodeTypes.length === 0) return null\n lastSync = nodeSyncer.sync(nodeTypes)\n validator = new N8nValidator(lastSync.registry)\n return lastSync\n } catch {\n return null\n }\n}\n\nconst server = new McpServer({\n name: 'kairos',\n version: pkg.version,\n})\n\n// ── Core generation tools (no API key needed) ──────────────────────────────\n\nserver.tool(\n 'kairos_prompt',\n 'Get the specialized n8n workflow generation context. Returns a system prompt with node catalog, connection rules, validation rules, plus library matches and failure patterns for the given description. Feed this to yourself as context, then generate the workflow JSON.',\n {\n description: z.string().describe('Plain-English description of the workflow to build'),\n name: z.string().optional().describe('Optional workflow name override'),\n },\n async ({ description, name }) => {\n const baseUrl = process.env['N8N_BASE_URL']\n const apiKey = process.env['N8N_API_KEY']\n if (!baseUrl || !apiKey) {\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify({ error: 'N8N_BASE_URL and N8N_API_KEY are required. Kairos needs to sync your n8n instance\\'s node types to generate accurate workflows.' }),\n }],\n isError: true,\n }\n }\n\n await library.initialize()\n const syncResult = await autoSync()\n const matches = await library.search(description)\n const telemetryReader = getTelemetryReader()\n const failureRates = await telemetryReader?.getFailureRates() ?? []\n\n const request = { description, ...(name ? { name } : {}) }\n const built = promptBuilder.build(request, matches, failureRates, syncResult?.catalogText)\n\n const systemText = built.system.map(block => block.text).join('\\n\\n---\\n\\n')\n\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify({\n mode: built.mode,\n matchCount: matches.length,\n topMatchScore: matches[0]?.score ?? null,\n nodeCatalog: syncResult ? 'synced' : 'static',\n nodeCount: syncResult?.nodeCount ?? null,\n systemPrompt: systemText,\n userMessage: built.userMessage,\n outputFormat: {\n description: 'Generate a JSON object with this exact structure. The workflow field contains the n8n workflow. credentialsNeeded lists services requiring credentials.',\n schema: {\n workflow: {\n name: 'string — descriptive workflow name',\n nodes: 'array — n8n node objects with id (UUID v4), type, typeVersion, name, position, parameters',\n connections: 'object — keyed by source node NAME, maps to target nodes',\n settings: 'object — include executionOrder: \"v1\"',\n },\n credentialsNeeded: [{\n service: 'string — e.g. \"Slack\"',\n credentialType: 'string — e.g. \"slackOAuth2Api\"',\n description: 'string — what the user needs to set up',\n }],\n },\n },\n }, null, 2),\n }],\n }\n },\n)\n\nserver.tool(\n 'kairos_validate',\n 'Validate n8n workflow JSON against 23 structural rules. Returns pass/fail with specific issues. If validation fails, fix the issues and call this again. Errors block deployment; warnings are advisory.',\n {\n workflow: z.string().describe('The workflow JSON string to validate'),\n },\n async ({ workflow: workflowStr }) => {\n let parsed: N8nWorkflow\n try {\n parsed = JSON.parse(workflowStr) as N8nWorkflow\n } catch (e) {\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify({\n valid: false,\n error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}`,\n }, null, 2),\n }],\n }\n }\n\n const result = validator.validate(parsed)\n const errors = result.issues.filter(i => i.severity === 'error')\n const warnings = result.issues.filter(i => i.severity === 'warn')\n\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify({\n valid: result.valid,\n errorCount: errors.length,\n warningCount: warnings.length,\n errors: errors.map(i => ({\n rule: i.rule,\n message: i.message,\n nodeId: i.nodeId ?? null,\n })),\n warnings: warnings.map(i => ({\n rule: i.rule,\n message: i.message,\n nodeId: i.nodeId ?? null,\n })),\n deployable: errors.length === 0,\n }, null, 2),\n }],\n }\n },\n)\n\nserver.tool(\n 'kairos_deploy',\n 'Deploy a validated workflow to n8n. Pass the workflow JSON that passed kairos_validate. Strips server-assigned fields automatically. Requires N8N_BASE_URL and N8N_API_KEY.',\n {\n workflow: z.string().describe('The validated workflow JSON string to deploy'),\n activate: z.boolean().default(false).describe('Activate the workflow immediately after deployment'),\n },\n async ({ workflow: workflowStr, activate }) => {\n if (!isAllowed('deploy')) {\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify({ error: 'Deploy is disabled. Set KAIROS_MCP_ALLOW_DEPLOY=true to enable.' }),\n }],\n isError: true,\n }\n }\n\n let parsed: N8nWorkflow\n try {\n parsed = JSON.parse(workflowStr) as N8nWorkflow\n } catch (e) {\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify({ error: `Invalid JSON: ${e instanceof Error ? e.message : String(e)}` }),\n }],\n }\n }\n\n const validation = validator.validate(parsed)\n const errors = validation.issues.filter(i => i.severity === 'error')\n if (errors.length > 0) {\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify({\n error: 'Workflow has validation errors — fix them before deploying',\n errors: errors.map(i => ({ rule: i.rule, message: i.message })),\n }, null, 2),\n }],\n }\n }\n\n const client = getApiClient()\n const stripped = stripper.stripForCreate(parsed)\n const response = await client.createWorkflow(stripped)\n\n if (activate) {\n if (!isAllowed('activate')) {\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify({\n workflowId: response.id,\n name: response.name,\n activated: false,\n warning: 'Workflow deployed but activation is disabled. Set KAIROS_MCP_ALLOW_ACTIVATE=true to enable.',\n url: `${process.env['N8N_BASE_URL']}/workflow/${response.id}`,\n }, null, 2),\n }],\n }\n }\n await client.activateWorkflow(response.id)\n }\n\n // Save to library for future retrieval\n await library.initialize()\n await library.save(parsed, {\n description: parsed.name,\n generationMode: 'scratch',\n generationAttempts: 1,\n })\n\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify({\n workflowId: response.id,\n name: response.name,\n activated: activate,\n url: `${process.env['N8N_BASE_URL']}/workflow/${response.id}`,\n }, null, 2),\n }],\n }\n },\n)\n\nserver.tool(\n 'kairos_search',\n 'Search the local workflow library for similar past builds. Returns matching workflows with scores, useful for finding examples and reusing patterns.',\n {\n query: z.string().describe('Search query — a workflow description or keywords'),\n limit: z.number().default(5).describe('Maximum number of results'),\n },\n async ({ query, limit }) => {\n await library.initialize()\n const matches = await library.search(query)\n\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify(\n matches.slice(0, limit).map(m => ({\n score: Number(m.score.toFixed(3)),\n mode: m.mode,\n description: m.workflow.description,\n nodeCount: m.workflow.workflow.nodes.length,\n nodes: m.workflow.workflow.nodes.map(n => n.name),\n failurePatterns: m.workflow.failurePatterns ?? [],\n })),\n null,\n 2,\n ),\n }],\n }\n },\n)\n\nserver.tool(\n 'kairos_sync',\n 'Sync the node catalog from your live n8n instance. Fetches all installed node types and versions so Kairos knows exactly what your n8n supports. Automatically called by kairos_prompt when n8n credentials are set, but you can call this manually to force a refresh.',\n {},\n async () => {\n const baseUrl = process.env['N8N_BASE_URL']\n const apiKey = process.env['N8N_API_KEY']\n if (!baseUrl || !apiKey) {\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify({ error: 'N8N_BASE_URL and N8N_API_KEY are required for sync.' }),\n }],\n isError: true,\n }\n }\n\n lastSync = null\n const result = await autoSync()\n if (!result) {\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify({ error: 'Failed to fetch node types from n8n. Check your credentials and that your instance is running.' }),\n }],\n isError: true,\n }\n }\n\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify({\n synced: true,\n nodeCount: result.nodeCount,\n newNodes: result.newNodes,\n message: `Synced ${result.nodeCount} node types from your n8n instance (${result.newNodes} not in default catalog).`,\n }, null, 2),\n }],\n }\n },\n)\n\n// ── n8n management tools (need N8N_BASE_URL + N8N_API_KEY) ─────────────────\n\nserver.tool(\n 'kairos_list',\n 'List all workflows deployed on the connected n8n instance.',\n {},\n async () => {\n const client = getApiClient()\n const workflows = await client.listWorkflows()\n\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify(workflows, null, 2),\n }],\n }\n },\n)\n\nserver.tool(\n 'kairos_get',\n 'Get the full JSON definition of a specific workflow by ID.',\n {\n workflow_id: z.string().describe('The n8n workflow ID'),\n },\n async ({ workflow_id }) => {\n const client = getApiClient()\n const workflow = await client.getWorkflow(workflow_id)\n\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify(workflow, null, 2),\n }],\n }\n },\n)\n\nserver.tool(\n 'kairos_activate',\n 'Activate a deployed workflow so it starts running on triggers.',\n {\n workflow_id: z.string().describe('The n8n workflow ID to activate'),\n },\n async ({ workflow_id }) => {\n if (!isAllowed('activate')) {\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify({ error: 'Activate is disabled. Set KAIROS_MCP_ALLOW_ACTIVATE=true to enable.' }),\n }],\n isError: true,\n }\n }\n\n const client = getApiClient()\n await client.activateWorkflow(workflow_id)\n\n return {\n content: [{\n type: 'text' as const,\n text: `Activated workflow ${workflow_id}`,\n }],\n }\n },\n)\n\nserver.tool(\n 'kairos_deactivate',\n 'Deactivate a running workflow.',\n {\n workflow_id: z.string().describe('The n8n workflow ID to deactivate'),\n },\n async ({ workflow_id }) => {\n const client = getApiClient()\n await client.deactivateWorkflow(workflow_id)\n\n return {\n content: [{\n type: 'text' as const,\n text: `Deactivated workflow ${workflow_id}`,\n }],\n }\n },\n)\n\nserver.tool(\n 'kairos_delete',\n 'Delete a workflow from n8n. This is irreversible.',\n {\n workflow_id: z.string().describe('The n8n workflow ID to delete'),\n },\n async ({ workflow_id }) => {\n if (!isAllowed('delete')) {\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify({ error: 'Delete is disabled. Set KAIROS_MCP_ALLOW_DELETE=true to enable.' }),\n }],\n isError: true,\n }\n }\n\n const client = getApiClient()\n await client.deleteWorkflow(workflow_id)\n\n return {\n content: [{\n type: 'text' as const,\n text: `Deleted workflow ${workflow_id}`,\n }],\n }\n },\n)\n\nserver.tool(\n 'kairos_executions',\n 'List recent executions for a workflow, showing status and timing.',\n {\n workflow_id: z.string().optional().describe('Filter to a specific workflow ID (omit for all)'),\n limit: z.number().default(20).describe('Maximum number of executions to return'),\n },\n async ({ workflow_id, limit }) => {\n const client = getApiClient()\n const executions = await client.getExecutions(workflow_id, { limit })\n\n return {\n content: [{\n type: 'text' as const,\n text: JSON.stringify(executions, null, 2),\n }],\n }\n },\n)\n\nasync function main() {\n const transport = new StdioServerTransport()\n await server.connect(transport)\n}\n\nmain().catch((err: unknown) => {\n console.error('Kairos MCP server failed to start:', err)\n process.exit(1)\n})\n","import type { N8nNodeTypeInfo } from '../providers/n8n/types.js'\nimport type { NodeDefinition } from './registry.js'\nimport { NodeRegistry, DEFAULT_REGISTRY } from './registry.js'\n\nconst TRIGGER_PATTERNS = [/trigger/i, /Trigger$/]\n\nexport interface SyncResult {\n registry: NodeRegistry\n catalogText: string\n nodeCount: number\n newNodes: number\n}\n\nexport class NodeSyncer {\n private readonly baseRegistry: Map<string, NodeDefinition>\n\n constructor() {\n this.baseRegistry = new Map(DEFAULT_REGISTRY.map(d => [d.type, d]))\n }\n\n sync(liveNodes: N8nNodeTypeInfo[]): SyncResult {\n const merged = new Map(this.baseRegistry)\n let newNodes = 0\n\n for (const node of liveNodes) {\n const versions = Array.isArray(node.version) ? node.version : [node.version]\n const isTrigger = TRIGGER_PATTERNS.some(p => p.test(node.name))\n const credentialType = node.credentials?.[0]?.name\n\n const existing = merged.get(node.name)\n if (existing) {\n const allVersions = new Set([...existing.safeTypeVersions, ...versions])\n merged.set(node.name, {\n ...existing,\n safeTypeVersions: [...allVersions].sort((a, b) => a - b),\n })\n } else {\n newNodes++\n merged.set(node.name, {\n type: node.name,\n safeTypeVersions: versions.sort((a, b) => a - b),\n requiredParams: [],\n ...(credentialType ? { credentialType } : {}),\n ...(isTrigger ? { isTrigger: true } : {}),\n })\n }\n }\n\n const definitions = [...merged.values()]\n const registry = new NodeRegistry(definitions)\n const catalogText = this.buildCatalog(definitions)\n\n return { registry, catalogText, nodeCount: definitions.length, newNodes }\n }\n\n private buildCatalog(definitions: NodeDefinition[]): string {\n const triggers = definitions.filter(d => d.isTrigger)\n const regular = definitions.filter(d => !d.isTrigger)\n\n const formatEntry = (d: NodeDefinition): string => {\n const versions = d.safeTypeVersions.join(', ')\n const cred = d.credentialType ? ` — cred: ${d.credentialType}` : ''\n return `${d.type} typeVersion: ${versions}${cred}`\n }\n\n const triggerLines = triggers.map(formatEntry).join('\\n')\n const regularLines = regular.map(formatEntry).join('\\n')\n\n return `## NODE CATALOG — synced from your n8n instance (${definitions.length} node types)\n\n### Triggers:\n${triggerLines}\n\n### Regular nodes:\n${regularLines}`\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAUA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,SAAS;;;ACRlB,IAAM,mBAAmB,CAAC,YAAY,UAAU;AASzC,IAAM,aAAN,MAAiB;AAAA,EACL;AAAA,EAEjB,cAAc;AACZ,SAAK,eAAe,IAAI,IAAI,iBAAiB,IAAI,OAAK,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAAA,EACpE;AAAA,EAEA,KAAK,WAA0C;AAC7C,UAAM,SAAS,IAAI,IAAI,KAAK,YAA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AAA,MACL,SAAS,CAAC;AAAA,QACR,MAAM;AAAA,QACN,MAAM,oBAAoB,WAAW;AAAA,MACvC,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEA,OAAO;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,IACE,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,iDAAiD;AAAA,IAC7F,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,SAAS,wCAAwC;AAAA,EACjF;AAAA,EACA,OAAO,EAAE,aAAa,MAAM,MAAM;AAChC,UAAM,SAAS,aAAa;AAC5B,UAAM,aAAa,MAAM,OAAO,cAAc,aAAa,EAAE,MAAM,CAAC;AAEpE,WAAO;AAAA,MACL,SAAS,CAAC;AAAA,QACR,MAAM;AAAA,QACN,MAAM,KAAK,UAAU,YAAY,MAAM,CAAC;AAAA,MAC1C,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEA,eAAe,OAAO;AACpB,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAChC;AAEA,KAAK,EAAE,MAAM,CAAC,QAAiB;AAC7B,UAAQ,MAAM,sCAAsC,GAAG;AACvD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kairos-sdk/core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "LLM-powered n8n workflow generation
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "LLM-powered n8n workflow generation — use as an SDK or MCP server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"bin": {
|
|
10
|
-
"kairos": "dist/cli.js"
|
|
10
|
+
"kairos": "dist/cli.js",
|
|
11
|
+
"kairos-mcp": "dist/mcp-server.js"
|
|
11
12
|
},
|
|
12
13
|
"exports": {
|
|
13
14
|
".": {
|
|
@@ -42,7 +43,9 @@
|
|
|
42
43
|
"llm",
|
|
43
44
|
"workflow-generation",
|
|
44
45
|
"kairos",
|
|
45
|
-
"no-code"
|
|
46
|
+
"no-code",
|
|
47
|
+
"mcp",
|
|
48
|
+
"model-context-protocol"
|
|
46
49
|
],
|
|
47
50
|
"repository": {
|
|
48
51
|
"type": "git",
|
|
@@ -57,7 +60,15 @@
|
|
|
57
60
|
"peerDependencies": {
|
|
58
61
|
"@anthropic-ai/sdk": ">=0.30.0"
|
|
59
62
|
},
|
|
60
|
-
"
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"@anthropic-ai/sdk": {
|
|
65
|
+
"optional": true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"dependencies": {
|
|
69
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
70
|
+
"zod": "^4.4.3"
|
|
71
|
+
},
|
|
61
72
|
"devDependencies": {
|
|
62
73
|
"@anthropic-ai/sdk": "^0.36.0",
|
|
63
74
|
"@types/node": "^20.0.0",
|