@vinkius-core/mcp-fusion-aws 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AwsClient.d.ts +109 -0
- package/dist/AwsClient.d.ts.map +1 -0
- package/dist/AwsClient.js +220 -0
- package/dist/AwsClient.js.map +1 -0
- package/dist/LambdaDiscovery.d.ts +31 -0
- package/dist/LambdaDiscovery.d.ts.map +1 -0
- package/dist/LambdaDiscovery.js +61 -0
- package/dist/LambdaDiscovery.js.map +1 -0
- package/dist/StepFunctionDiscovery.d.ts +32 -0
- package/dist/StepFunctionDiscovery.d.ts.map +1 -0
- package/dist/StepFunctionDiscovery.js +71 -0
- package/dist/StepFunctionDiscovery.js.map +1 -0
- package/dist/ToolSynthesizer.d.ts +61 -0
- package/dist/ToolSynthesizer.d.ts.map +1 -0
- package/dist/ToolSynthesizer.js +294 -0
- package/dist/ToolSynthesizer.js.map +1 -0
- package/dist/createAwsConnector.d.ts +47 -0
- package/dist/createAwsConnector.d.ts.map +1 -0
- package/dist/createAwsConnector.js +117 -0
- package/dist/createAwsConnector.js.map +1 -0
- package/dist/defineAwsTool.d.ts +29 -0
- package/dist/defineAwsTool.d.ts.map +1 -0
- package/dist/defineAwsTool.js +86 -0
- package/dist/defineAwsTool.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +157 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +26 -0
- package/dist/types.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// ToolSynthesizer — AwsLambdaConfig / AwsStepFunctionConfig → defineTool()
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// ── Name Conversion ──────────────────────────────────────
|
|
5
|
+
/**
|
|
6
|
+
* Convert a function/resource name to a valid snake_case tool name.
|
|
7
|
+
*
|
|
8
|
+
* "CreateUser" → "create_user"
|
|
9
|
+
* "my-awesome-lambda" → "my_awesome_lambda"
|
|
10
|
+
* "get_users_v2" → "get_users_v2"
|
|
11
|
+
*
|
|
12
|
+
* @throws {Error} If the resulting name is empty after conversion
|
|
13
|
+
*/
|
|
14
|
+
export function toToolName(resourceName) {
|
|
15
|
+
const result = resourceName
|
|
16
|
+
// PascalCase / camelCase → insert underscore before uppercase
|
|
17
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1_$2')
|
|
18
|
+
.toLowerCase()
|
|
19
|
+
.replace(/[^a-z0-9]+/g, '_')
|
|
20
|
+
.replace(/^_+|_+$/g, '');
|
|
21
|
+
if (result === '') {
|
|
22
|
+
throw new Error(`toToolName: unable to derive a valid tool name from "${resourceName}". ` +
|
|
23
|
+
'Resource names must contain at least one alphanumeric character.');
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
// ── Lambda Synthesis ─────────────────────────────────────
|
|
28
|
+
/**
|
|
29
|
+
* Synthesize tool configs from discovered Lambda functions.
|
|
30
|
+
*
|
|
31
|
+
* **Grouping logic:**
|
|
32
|
+
* - Lambdas with the same `mcp:group` tag → grouped into ONE tool with N actions
|
|
33
|
+
* - Lambdas without `mcp:group` → standalone tools with single `execute` action
|
|
34
|
+
*
|
|
35
|
+
* @throws {Error} If two Lambdas in the same group share an action name
|
|
36
|
+
* @returns Array of tool configs ready for defineTool()
|
|
37
|
+
*/
|
|
38
|
+
export function synthesizeLambdaTools(lambdas, client) {
|
|
39
|
+
const grouped = new Map();
|
|
40
|
+
const standalone = [];
|
|
41
|
+
// ── Partition into groups vs standalone ──
|
|
42
|
+
for (const lambda of lambdas) {
|
|
43
|
+
if (lambda.group) {
|
|
44
|
+
const existing = grouped.get(lambda.group) ?? [];
|
|
45
|
+
existing.push(lambda);
|
|
46
|
+
grouped.set(lambda.group, existing);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
standalone.push(lambda);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const tools = [];
|
|
53
|
+
// ── Grouped tools (N Lambdas → 1 tool with N actions) ──
|
|
54
|
+
for (const [groupName, members] of grouped) {
|
|
55
|
+
const toolName = toToolName(groupName);
|
|
56
|
+
const actions = {};
|
|
57
|
+
for (const lambda of members) {
|
|
58
|
+
if (actions[lambda.actionName]) {
|
|
59
|
+
throw new Error(`Duplicate action "${lambda.actionName}" in group "${groupName}": ` +
|
|
60
|
+
`Lambda "${lambda.functionName}" conflicts with an existing action. ` +
|
|
61
|
+
'Each Lambda in a group must have a unique mcp:action tag.');
|
|
62
|
+
}
|
|
63
|
+
actions[lambda.actionName] = buildLambdaAction(lambda, client);
|
|
64
|
+
}
|
|
65
|
+
tools.push({
|
|
66
|
+
name: toolName,
|
|
67
|
+
config: {
|
|
68
|
+
description: buildGroupDescription(groupName, members),
|
|
69
|
+
tags: extractUniqueTags(members),
|
|
70
|
+
actions,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// ── Standalone tools (1 Lambda → 1 tool with 'execute' action) ──
|
|
75
|
+
for (const lambda of standalone) {
|
|
76
|
+
const toolName = toToolName(lambda.functionName);
|
|
77
|
+
tools.push({
|
|
78
|
+
name: toolName,
|
|
79
|
+
config: {
|
|
80
|
+
description: buildLambdaDescription(lambda),
|
|
81
|
+
tags: extractResourceTags(lambda.tags),
|
|
82
|
+
actions: {
|
|
83
|
+
[lambda.actionName]: buildLambdaAction(lambda, client),
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return tools;
|
|
89
|
+
}
|
|
90
|
+
// ── Step Function Synthesis ──────────────────────────────
|
|
91
|
+
/**
|
|
92
|
+
* Synthesize tool configs from discovered Step Functions.
|
|
93
|
+
*
|
|
94
|
+
* Same grouping logic as Lambda.
|
|
95
|
+
* Execution type determines handler behavior:
|
|
96
|
+
* - EXPRESS → `startSyncExecution` (blocks, returns output)
|
|
97
|
+
* - STANDARD → `startExecution` (fire-and-forget, returns LRO with cognitive rule)
|
|
98
|
+
*
|
|
99
|
+
* @throws {Error} If two state machines in the same group share an action name
|
|
100
|
+
*/
|
|
101
|
+
export function synthesizeStepFunctionTools(stateMachines, client) {
|
|
102
|
+
const grouped = new Map();
|
|
103
|
+
const standalone = [];
|
|
104
|
+
for (const sfn of stateMachines) {
|
|
105
|
+
if (sfn.group) {
|
|
106
|
+
const existing = grouped.get(sfn.group) ?? [];
|
|
107
|
+
existing.push(sfn);
|
|
108
|
+
grouped.set(sfn.group, existing);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
standalone.push(sfn);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const tools = [];
|
|
115
|
+
for (const [groupName, members] of grouped) {
|
|
116
|
+
const toolName = toToolName(groupName);
|
|
117
|
+
const actions = {};
|
|
118
|
+
for (const sfn of members) {
|
|
119
|
+
if (actions[sfn.actionName]) {
|
|
120
|
+
throw new Error(`Duplicate action "${sfn.actionName}" in group "${groupName}": ` +
|
|
121
|
+
`State machine "${sfn.name}" conflicts with an existing action. ` +
|
|
122
|
+
'Each state machine in a group must have a unique mcp:action tag.');
|
|
123
|
+
}
|
|
124
|
+
actions[sfn.actionName] = buildSfnAction(sfn, client);
|
|
125
|
+
}
|
|
126
|
+
tools.push({
|
|
127
|
+
name: toolName,
|
|
128
|
+
config: {
|
|
129
|
+
description: buildGroupDescription(groupName, members),
|
|
130
|
+
tags: extractUniqueTags(members),
|
|
131
|
+
actions,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
for (const sfn of standalone) {
|
|
136
|
+
const toolName = toToolName(sfn.name);
|
|
137
|
+
tools.push({
|
|
138
|
+
name: toolName,
|
|
139
|
+
config: {
|
|
140
|
+
description: buildSfnDescription(sfn),
|
|
141
|
+
tags: extractResourceTags(sfn.tags),
|
|
142
|
+
actions: {
|
|
143
|
+
[sfn.actionName]: buildSfnAction(sfn, client),
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return tools;
|
|
149
|
+
}
|
|
150
|
+
// ── Combined Synthesis ───────────────────────────────────
|
|
151
|
+
/**
|
|
152
|
+
* Synthesize all tools from both Lambda and Step Function configs.
|
|
153
|
+
*/
|
|
154
|
+
export function synthesizeAll(lambdas, stepFunctions, client) {
|
|
155
|
+
return [
|
|
156
|
+
...synthesizeLambdaTools(lambdas, client),
|
|
157
|
+
...synthesizeStepFunctionTools(stepFunctions, client),
|
|
158
|
+
];
|
|
159
|
+
}
|
|
160
|
+
// ── Action Builders ──────────────────────────────────────
|
|
161
|
+
/**
|
|
162
|
+
* Build a Lambda action handler.
|
|
163
|
+
*
|
|
164
|
+
* Handler returns the raw JS object from the Lambda response,
|
|
165
|
+
* letting the MVA Presenter layer handle formatting.
|
|
166
|
+
*/
|
|
167
|
+
function buildLambdaAction(lambda, client) {
|
|
168
|
+
return {
|
|
169
|
+
description: lambda.description || `Invoke Lambda: ${lambda.functionName}`,
|
|
170
|
+
readOnly: lambda.readOnly || undefined,
|
|
171
|
+
destructive: lambda.destructive || undefined,
|
|
172
|
+
handler: async (_ctx, args) => {
|
|
173
|
+
const result = await client.invokeLambda(lambda.functionArn, args);
|
|
174
|
+
if (result.functionError) {
|
|
175
|
+
// Return structured error — MVA pipeline picks this up
|
|
176
|
+
return {
|
|
177
|
+
__error: true,
|
|
178
|
+
code: 'AWS_LAMBDA_ERROR',
|
|
179
|
+
message: `Lambda ${lambda.functionName} failed: ${result.functionError}`,
|
|
180
|
+
details: result.payload,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
// Return raw JS object — MVA Presenter/Egress Firewall acts on this
|
|
184
|
+
return result.payload;
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Build a Step Function action handler.
|
|
190
|
+
*
|
|
191
|
+
* EXPRESS → synchronous execution, returns output.
|
|
192
|
+
* STANDARD → async fire-and-forget with cognitive rule for LLM.
|
|
193
|
+
*/
|
|
194
|
+
function buildSfnAction(sfn, client) {
|
|
195
|
+
if (sfn.executionType === 'express') {
|
|
196
|
+
return buildSfnExpressAction(sfn, client);
|
|
197
|
+
}
|
|
198
|
+
return buildSfnStandardAction(sfn, client);
|
|
199
|
+
}
|
|
200
|
+
/** Express SFN → sync execution, blocks until completion */
|
|
201
|
+
function buildSfnExpressAction(sfn, client) {
|
|
202
|
+
return {
|
|
203
|
+
description: sfn.description || `Execute Step Function (Express): ${sfn.name}`,
|
|
204
|
+
readOnly: sfn.readOnly || undefined,
|
|
205
|
+
destructive: sfn.destructive || undefined,
|
|
206
|
+
handler: async (_ctx, args) => {
|
|
207
|
+
const result = await client.startSyncExecution(sfn.stateMachineArn, args);
|
|
208
|
+
if (result.status !== 'SUCCEEDED') {
|
|
209
|
+
return {
|
|
210
|
+
__error: true,
|
|
211
|
+
code: 'AWS_SFN_ERROR',
|
|
212
|
+
message: `Step Function ${sfn.name} failed: ${result.error}`,
|
|
213
|
+
cause: result.cause,
|
|
214
|
+
status: result.status,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
return result.output;
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/** Standard SFN → fire-and-forget with LRO cognitive rule */
|
|
222
|
+
function buildSfnStandardAction(sfn, client) {
|
|
223
|
+
return {
|
|
224
|
+
description: sfn.description || `Start Step Function (Standard): ${sfn.name}`,
|
|
225
|
+
readOnly: sfn.readOnly || undefined,
|
|
226
|
+
destructive: sfn.destructive || undefined,
|
|
227
|
+
handler: async (_ctx, args) => {
|
|
228
|
+
const result = await client.startExecution(sfn.stateMachineArn, args);
|
|
229
|
+
// LRO: return execution context + cognitive rule for the LLM
|
|
230
|
+
return {
|
|
231
|
+
status: 'RUNNING',
|
|
232
|
+
executionArn: result.executionArn,
|
|
233
|
+
startedAt: result.startDate,
|
|
234
|
+
_instruction: [
|
|
235
|
+
'CRITICAL: This is a long-running background process.',
|
|
236
|
+
'Do NOT assume completion or fabricate results.',
|
|
237
|
+
'Inform the user that the process has been started and is now running.',
|
|
238
|
+
`Execution ARN: ${result.executionArn}`,
|
|
239
|
+
].join(' '),
|
|
240
|
+
};
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
// ── Description Builders ─────────────────────────────────
|
|
245
|
+
function buildLambdaDescription(lambda) {
|
|
246
|
+
const lines = [
|
|
247
|
+
`[Lambda] ${lambda.functionName}`,
|
|
248
|
+
'',
|
|
249
|
+
lambda.description || 'AWS Lambda function',
|
|
250
|
+
'',
|
|
251
|
+
`Runtime: ${lambda.runtime}`,
|
|
252
|
+
];
|
|
253
|
+
return lines.join('\n');
|
|
254
|
+
}
|
|
255
|
+
function buildSfnDescription(sfn) {
|
|
256
|
+
const lines = [
|
|
257
|
+
`[Step Function — ${sfn.executionType.toUpperCase()}] ${sfn.name}`,
|
|
258
|
+
'',
|
|
259
|
+
sfn.description || 'AWS Step Functions state machine',
|
|
260
|
+
];
|
|
261
|
+
return lines.join('\n');
|
|
262
|
+
}
|
|
263
|
+
function buildGroupDescription(groupName, members) {
|
|
264
|
+
const lines = [
|
|
265
|
+
`[AWS] ${groupName}`,
|
|
266
|
+
'',
|
|
267
|
+
`Available actions: ${members.map(m => m.actionName).join(', ')}`,
|
|
268
|
+
];
|
|
269
|
+
return lines.join('\n');
|
|
270
|
+
}
|
|
271
|
+
// ── Tag Helpers ──────────────────────────────────────────
|
|
272
|
+
/** Extract unique non-MCP tags from a group of resources */
|
|
273
|
+
function extractUniqueTags(members) {
|
|
274
|
+
const seen = new Set();
|
|
275
|
+
for (const member of members) {
|
|
276
|
+
for (const [key, value] of Object.entries(member.tags)) {
|
|
277
|
+
if (!key.startsWith('mcp:') && !key.startsWith('aws:')) {
|
|
278
|
+
seen.add(`${key}:${value}`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return [...seen];
|
|
283
|
+
}
|
|
284
|
+
/** Extract non-MCP tags from a single resource */
|
|
285
|
+
function extractResourceTags(tags) {
|
|
286
|
+
const result = [];
|
|
287
|
+
for (const [key, value] of Object.entries(tags)) {
|
|
288
|
+
if (!key.startsWith('mcp:') && !key.startsWith('aws:')) {
|
|
289
|
+
result.push(`${key}:${value}`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return result;
|
|
293
|
+
}
|
|
294
|
+
//# sourceMappingURL=ToolSynthesizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolSynthesizer.js","sourceRoot":"","sources":["../src/ToolSynthesizer.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2EAA2E;AAC3E,+EAA+E;AA6B/E,4DAA4D;AAE5D;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,YAAoB;IAC3C,MAAM,MAAM,GAAG,YAAY;QACvB,8DAA8D;SAC7D,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAE7B,IAAI,MAAM,KAAK,EAAE,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACX,wDAAwD,YAAY,KAAK;YACzE,kEAAkE,CACrE,CAAC;IACN,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,4DAA4D;AAE5D;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CACjC,OAAmC,EACnC,MAAiB;IAEjB,MAAM,OAAO,GAAG,IAAI,GAAG,EAA6B,CAAC;IACrD,MAAM,UAAU,GAAsB,EAAE,CAAC;IAEzC,4CAA4C;IAC5C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,M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,CAAC,MAAM,CAAC,EAAE,CAAC;gBACrD,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC;YAChC,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;AACrB,CAAC;AAED,kDAAkD;AAClD,SAAS,mBAAmB,CAAC,IAAsC;IAC/D,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACrD,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC;QACnC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AwsClient } from './AwsClient.js';
|
|
2
|
+
import { type SynthesizedToolConfig } from './ToolSynthesizer.js';
|
|
3
|
+
import type { AwsConnectorConfig, AwsLambdaConfig, AwsStepFunctionConfig } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The AWS connector — auto-discovers tagged Lambda functions and
|
|
6
|
+
* Step Functions, producing tool configs ready for `defineTool()`.
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { LambdaClient } from '@aws-sdk/client-lambda';
|
|
10
|
+
* import { createLambdaAdapter, createAwsConnector } from '@vinkius-core/mcp-fusion-aws';
|
|
11
|
+
*
|
|
12
|
+
* const aws = await createAwsConnector({
|
|
13
|
+
* lambdaClient: await createLambdaAdapter(new LambdaClient({ region: 'us-east-1' })),
|
|
14
|
+
* pollInterval: 60_000,
|
|
15
|
+
* onChange: () => server.notification({ method: 'notifications/tools/list_changed' }),
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* const registry = new ToolRegistry();
|
|
19
|
+
* for (const tool of aws.tools()) {
|
|
20
|
+
* registry.register(defineTool(tool.name, tool.config));
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export interface AwsConnector {
|
|
25
|
+
/** The underlying AWS client */
|
|
26
|
+
readonly client: AwsClient;
|
|
27
|
+
/** Discovered Lambda function metadata */
|
|
28
|
+
readonly lambdas: readonly AwsLambdaConfig[];
|
|
29
|
+
/** Discovered Step Function metadata */
|
|
30
|
+
readonly stepFunctions: readonly AwsStepFunctionConfig[];
|
|
31
|
+
/** Pre-synthesized tool configs ready for defineTool() */
|
|
32
|
+
tools(): readonly SynthesizedToolConfig[];
|
|
33
|
+
/** Re-discover resources (manual poll). Returns true if the tool list changed. */
|
|
34
|
+
refresh(): Promise<boolean>;
|
|
35
|
+
/** Stop the background polling loop (if active) */
|
|
36
|
+
stop(): void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create an AWS connector that auto-discovers tagged resources.
|
|
40
|
+
*
|
|
41
|
+
* If `pollInterval` is set, starts a background polling loop that
|
|
42
|
+
* re-discovers resources and calls `onChange()` when the tool list changes.
|
|
43
|
+
* This enables zero-downtime hot-reload: the MCP server emits
|
|
44
|
+
* `notifications/tools/list_changed` and the LLM refreshes instantly.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createAwsConnector(config: AwsConnectorConfig): Promise<AwsConnector>;
|
|
47
|
+
//# sourceMappingURL=createAwsConnector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAwsConnector.d.ts","sourceRoot":"","sources":["../src/createAwsConnector.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3C,OAAO,EAAiB,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,EACR,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACxB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,YAAY;IACzB,gCAAgC;IAChC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,wCAAwC;IACxC,QAAQ,CAAC,aAAa,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACzD,0DAA0D;IAC1D,KAAK,IAAI,SAAS,qBAAqB,EAAE,CAAC;IAC1C,kFAAkF;IAClF,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,mDAAmD;IACnD,IAAI,IAAI,IAAI,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACpC,MAAM,EAAE,kBAAkB,GAC3B,OAAO,CAAC,YAAY,CAAC,CA0HvB"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// createAwsConnector — Auto-discovery mode with live state sync
|
|
3
|
+
// ============================================================================
|
|
4
|
+
import { AwsClient } from './AwsClient.js';
|
|
5
|
+
import { LambdaDiscovery } from './LambdaDiscovery.js';
|
|
6
|
+
import { StepFunctionDiscovery } from './StepFunctionDiscovery.js';
|
|
7
|
+
import { synthesizeAll } from './ToolSynthesizer.js';
|
|
8
|
+
/**
|
|
9
|
+
* Create an AWS connector that auto-discovers tagged resources.
|
|
10
|
+
*
|
|
11
|
+
* If `pollInterval` is set, starts a background polling loop that
|
|
12
|
+
* re-discovers resources and calls `onChange()` when the tool list changes.
|
|
13
|
+
* This enables zero-downtime hot-reload: the MCP server emits
|
|
14
|
+
* `notifications/tools/list_changed` and the LLM refreshes instantly.
|
|
15
|
+
*/
|
|
16
|
+
export async function createAwsConnector(config) {
|
|
17
|
+
const enableLambda = config.enableLambda ?? true;
|
|
18
|
+
const enableSfn = config.enableStepFunctions ?? false;
|
|
19
|
+
const client = new AwsClient(enableLambda ? config.lambdaClient : undefined, enableSfn ? config.sfnClient : undefined);
|
|
20
|
+
const discoveryOpts = config.tagFilter
|
|
21
|
+
? { tagFilter: config.tagFilter }
|
|
22
|
+
: {};
|
|
23
|
+
const lambdaDiscovery = enableLambda
|
|
24
|
+
? new LambdaDiscovery(client, discoveryOpts)
|
|
25
|
+
: undefined;
|
|
26
|
+
const sfnDiscovery = enableSfn
|
|
27
|
+
? new StepFunctionDiscovery(client, discoveryOpts)
|
|
28
|
+
: undefined;
|
|
29
|
+
// ── Initial Discovery ──
|
|
30
|
+
let discoveredLambdas = lambdaDiscovery
|
|
31
|
+
? await lambdaDiscovery.discover()
|
|
32
|
+
: [];
|
|
33
|
+
let discoveredSfns = sfnDiscovery
|
|
34
|
+
? await sfnDiscovery.discover()
|
|
35
|
+
: [];
|
|
36
|
+
let synthesized = synthesizeAll(discoveredLambdas, discoveredSfns, client);
|
|
37
|
+
// ── Background Polling (Live State Sync) ──
|
|
38
|
+
let pollTimer = null;
|
|
39
|
+
/**
|
|
40
|
+
* Compute a fingerprint from tool names + descriptions + action annotations
|
|
41
|
+
* for change detection. Detects name changes, description changes,
|
|
42
|
+
* and readOnly/destructive annotation changes.
|
|
43
|
+
*/
|
|
44
|
+
function fingerprint(tools) {
|
|
45
|
+
return tools.map(t => {
|
|
46
|
+
const actionKeys = Object.keys(t.config.actions).sort();
|
|
47
|
+
const actionFingerprints = actionKeys.map(k => {
|
|
48
|
+
const action = t.config.actions[k];
|
|
49
|
+
if (!action)
|
|
50
|
+
return k;
|
|
51
|
+
return `${k}:${action.readOnly ?? ''}:${action.destructive ?? ''}`;
|
|
52
|
+
});
|
|
53
|
+
return `${t.name}|${t.config.description}|${actionFingerprints.join(';')}`;
|
|
54
|
+
}).sort().join('\n');
|
|
55
|
+
}
|
|
56
|
+
let lastFingerprint = fingerprint(synthesized);
|
|
57
|
+
/**
|
|
58
|
+
* Refresh and detect changes. Returns `true` if the tool list changed.
|
|
59
|
+
*/
|
|
60
|
+
async function refresh() {
|
|
61
|
+
discoveredLambdas = lambdaDiscovery
|
|
62
|
+
? await lambdaDiscovery.discover()
|
|
63
|
+
: [];
|
|
64
|
+
discoveredSfns = sfnDiscovery
|
|
65
|
+
? await sfnDiscovery.discover()
|
|
66
|
+
: [];
|
|
67
|
+
const newSynth = synthesizeAll(discoveredLambdas, discoveredSfns, client);
|
|
68
|
+
const newFp = fingerprint(newSynth);
|
|
69
|
+
const changed = newFp !== lastFingerprint;
|
|
70
|
+
synthesized = newSynth;
|
|
71
|
+
lastFingerprint = newFp;
|
|
72
|
+
return changed;
|
|
73
|
+
}
|
|
74
|
+
// Start polling if interval is configured
|
|
75
|
+
if (config.pollInterval != null && config.pollInterval > 0) {
|
|
76
|
+
pollTimer = setInterval(async () => {
|
|
77
|
+
try {
|
|
78
|
+
const changed = await refresh();
|
|
79
|
+
if (changed && config.onChange) {
|
|
80
|
+
config.onChange();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
// Report polling errors via callback if provided
|
|
85
|
+
if (config.onError) {
|
|
86
|
+
config.onError(error);
|
|
87
|
+
}
|
|
88
|
+
// Otherwise silently retry on next cycle —
|
|
89
|
+
// AWS might be temporarily unreachable.
|
|
90
|
+
}
|
|
91
|
+
}, config.pollInterval);
|
|
92
|
+
// Ensure the timer doesn't prevent Node.js from exiting
|
|
93
|
+
if (typeof pollTimer === 'object' && 'unref' in pollTimer) {
|
|
94
|
+
pollTimer.unref();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
client,
|
|
99
|
+
get lambdas() {
|
|
100
|
+
return discoveredLambdas;
|
|
101
|
+
},
|
|
102
|
+
get stepFunctions() {
|
|
103
|
+
return discoveredSfns;
|
|
104
|
+
},
|
|
105
|
+
tools() {
|
|
106
|
+
return synthesized;
|
|
107
|
+
},
|
|
108
|
+
refresh,
|
|
109
|
+
stop() {
|
|
110
|
+
if (pollTimer != null) {
|
|
111
|
+
clearInterval(pollTimer);
|
|
112
|
+
pollTimer = null;
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=createAwsConnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAwsConnector.js","sourceRoot":"","sources":["../src/createAwsConnector.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,gEAAgE;AAChE,+EAA+E;AAE/E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,aAAa,EAA8B,MAAM,sBAAsB,CAAC;AA0CjF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACpC,MAA0B;IAE1B,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,IAAI,CAAC;IACjD,MAAM,SAAS,GAAG,MAAM,CAAC,mBAAmB,IAAI,KAAK,CAAC;IAEtD,MAAM,MAAM,GAAG,IAAI,SAAS,CACxB,YAAY,CAAC,CAAC,CAAE,MAAM,CAAC,YAA0C,CAAC,CAAC,CAAC,SAAS,EAC7E,SAAS,CAAC,CAAC,CAAE,MAAM,CAAC,SAAoC,CAAC,CAAC,CAAC,SAAS,CACvE,CAAC;IAEF,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS;QAClC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE;QACjC,CAAC,CAAC,EAAE,CAAC;IAET,MAAM,eAAe,GAAG,YAAY;QAChC,CAAC,CAAC,IAAI,eAAe,CAAC,MAAM,EAAE,aAAa,CAAC;QAC5C,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,YAAY,GAAG,SAAS;QAC1B,CAAC,CAAC,IAAI,qBA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,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC;IACL,CAAC;IAED,OAAO;QACH,MAAM;QAEN,IAAI,OAAO;YACP,OAAO,iBAAiB,CAAC;QAC7B,CAAC;QAED,IAAI,aAAa;YACb,OAAO,cAAc,CAAC;QAC1B,CAAC;QAED,KAAK;YACD,OAAO,WAAW,CAAC;QACvB,CAAC;QAED,OAAO;QAEP,IAAI;YACA,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;gBACpB,aAAa,CAAC,SAAS,CAAC,CAAC;gBACzB,SAAS,GAAG,IAAI,CAAC;YACrB,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AwsClient } from './AwsClient.js';
|
|
2
|
+
import type { AwsToolConfig } from './types.js';
|
|
3
|
+
import type { SynthesizedToolConfig } from './ToolSynthesizer.js';
|
|
4
|
+
/**
|
|
5
|
+
* Manually define an AWS resource (Lambda or Step Function) as an MCP Fusion tool.
|
|
6
|
+
*
|
|
7
|
+
* For when architects need surgical control: strict params,
|
|
8
|
+
* custom annotations, specific middleware chains.
|
|
9
|
+
*
|
|
10
|
+
* **ARN detection:**
|
|
11
|
+
* - `arn:aws:lambda:...` → invokes via `invokeLambda()`
|
|
12
|
+
* - `arn:aws:states:...` → invokes via `startSyncExecution()` (Express SFN)
|
|
13
|
+
*
|
|
14
|
+
* For Standard Step Functions (async LRO), use `createAwsConnector` auto-mode
|
|
15
|
+
* with the `mcp:sfn-type` tag instead — manual mode assumes sync execution.
|
|
16
|
+
*
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const tool = defineAwsTool('deploy_staging', client, {
|
|
19
|
+
* arn: 'arn:aws:lambda:us-east-1:123456789:function:deploy',
|
|
20
|
+
* description: 'Deploy to staging environment',
|
|
21
|
+
* annotations: { destructiveHint: true },
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* const builder = defineTool(tool.name, tool.config);
|
|
25
|
+
* registry.register(builder);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function defineAwsTool(name: string, client: AwsClient, config: AwsToolConfig): SynthesizedToolConfig;
|
|
29
|
+
//# sourceMappingURL=defineAwsTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineAwsTool.d.ts","sourceRoot":"","sources":["../src/defineAwsTool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAqB,MAAM,sBAAsB,CAAC;AAErF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CACzB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,aAAa,GACtB,qBAAqB,CA+BvB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// defineAwsTool — Manual/surgical mode (like defineN8nTool)
|
|
3
|
+
// ============================================================================
|
|
4
|
+
/**
|
|
5
|
+
* Manually define an AWS resource (Lambda or Step Function) as an MCP Fusion tool.
|
|
6
|
+
*
|
|
7
|
+
* For when architects need surgical control: strict params,
|
|
8
|
+
* custom annotations, specific middleware chains.
|
|
9
|
+
*
|
|
10
|
+
* **ARN detection:**
|
|
11
|
+
* - `arn:aws:lambda:...` → invokes via `invokeLambda()`
|
|
12
|
+
* - `arn:aws:states:...` → invokes via `startSyncExecution()` (Express SFN)
|
|
13
|
+
*
|
|
14
|
+
* For Standard Step Functions (async LRO), use `createAwsConnector` auto-mode
|
|
15
|
+
* with the `mcp:sfn-type` tag instead — manual mode assumes sync execution.
|
|
16
|
+
*
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const tool = defineAwsTool('deploy_staging', client, {
|
|
19
|
+
* arn: 'arn:aws:lambda:us-east-1:123456789:function:deploy',
|
|
20
|
+
* description: 'Deploy to staging environment',
|
|
21
|
+
* annotations: { destructiveHint: true },
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* const builder = defineTool(tool.name, tool.config);
|
|
25
|
+
* registry.register(builder);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function defineAwsTool(name, client, config) {
|
|
29
|
+
const isStepFunction = config.arn.includes(':states:');
|
|
30
|
+
const isReadOnly = config.annotations?.readOnlyHint ?? false;
|
|
31
|
+
const isDestructive = config.annotations?.destructiveHint ?? false;
|
|
32
|
+
const handler = isStepFunction
|
|
33
|
+
? buildSfnHandler(client, config)
|
|
34
|
+
: buildLambdaHandler(client, config);
|
|
35
|
+
const description = config.description
|
|
36
|
+
?? (isStepFunction
|
|
37
|
+
? `[AWS Step Function] ${config.arn}`
|
|
38
|
+
: `[AWS Lambda] ${config.arn}`);
|
|
39
|
+
const action = {
|
|
40
|
+
description: `Execute ${name}`,
|
|
41
|
+
readOnly: isReadOnly || undefined,
|
|
42
|
+
destructive: isDestructive || undefined,
|
|
43
|
+
handler,
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
name,
|
|
47
|
+
config: {
|
|
48
|
+
description,
|
|
49
|
+
tags: [],
|
|
50
|
+
actions: {
|
|
51
|
+
execute: action,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// ── Handler Builders ─────────────────────────────────────
|
|
57
|
+
function buildLambdaHandler(client, config) {
|
|
58
|
+
return async (_ctx, args) => {
|
|
59
|
+
const result = await client.invokeLambda(config.arn, args);
|
|
60
|
+
if (result.functionError) {
|
|
61
|
+
return {
|
|
62
|
+
__error: true,
|
|
63
|
+
code: 'AWS_LAMBDA_ERROR',
|
|
64
|
+
message: `Lambda failed: ${result.functionError}`,
|
|
65
|
+
details: result.payload,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return result.payload;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function buildSfnHandler(client, config) {
|
|
72
|
+
return async (_ctx, args) => {
|
|
73
|
+
const result = await client.startSyncExecution(config.arn, args);
|
|
74
|
+
if (result.status !== 'SUCCEEDED') {
|
|
75
|
+
return {
|
|
76
|
+
__error: true,
|
|
77
|
+
code: 'AWS_SFN_ERROR',
|
|
78
|
+
message: `Step Function failed: ${result.error}`,
|
|
79
|
+
cause: result.cause,
|
|
80
|
+
status: result.status,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return result.output;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=defineAwsTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineAwsTool.js","sourceRoot":"","sources":["../src/defineAwsTool.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,4DAA4D;AAC5D,+EAA+E;AAM/E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,aAAa,CACzB,IAAY,EACZ,MAAiB,EACjB,MAAqB;IAErB,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,EAAE,YAAY,IAAI,KAAK,CAAC;IAC7D,MAAM,aAAa,GAAG,MAAM,CAAC,WAAW,EAAE,eAAe,IAAI,KAAK,CAAC;IAEnE,MAAM,OAAO,GAAG,cAAc;QAC1B,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC;QACjC,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEzC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW;WAC/B,CAAC,cAAc;YACd,CAAC,CAAC,uBAAuB,MAAM,CAAC,GAAG,EAAE;YACrC,CAAC,CAAC,gBAAgB,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;IAExC,MAAM,MAAM,GAA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B,CAAC;QACN,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,CAAC;IACzB,CAAC,CAAC;AACN,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { createAwsConnector } from './createAwsConnector.js';
|
|
2
|
+
export type { AwsConnector } from './createAwsConnector.js';
|
|
3
|
+
export { defineAwsTool } from './defineAwsTool.js';
|
|
4
|
+
export { AwsClient, createLambdaAdapter, createSfnAdapter } from './AwsClient.js';
|
|
5
|
+
export type { LambdaAdapter, SfnAdapter, AwsSdkClientLike, LambdaFunctionSummary, SfnStateMachineSummary, } from './AwsClient.js';
|
|
6
|
+
export { LambdaDiscovery } from './LambdaDiscovery.js';
|
|
7
|
+
export type { LambdaDiscoveryOptions } from './LambdaDiscovery.js';
|
|
8
|
+
export { StepFunctionDiscovery } from './StepFunctionDiscovery.js';
|
|
9
|
+
export type { SfnDiscoveryOptions } from './StepFunctionDiscovery.js';
|
|
10
|
+
export { synthesizeLambdaTools, synthesizeStepFunctionTools, synthesizeAll, toToolName, } from './ToolSynthesizer.js';
|
|
11
|
+
export type { SynthesizedToolConfig, SynthesizedAction } from './ToolSynthesizer.js';
|
|
12
|
+
export type { AwsLambdaConfig, AwsStepFunctionConfig, LambdaInvokeResult, SfnSyncResult, SfnAsyncResult, AwsConnectorConfig, AwsToolConfig, } from './types.js';
|
|
13
|
+
export { MCP_TAGS, DEFAULT_TAG_FILTER, DEFAULT_ACTION_NAME } from './types.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClF,YAAY,EACR,aAAa,EAAE,UAAU,EACzB,gBAAgB,EAChB,qBAAqB,EAAE,sBAAsB,GAChD,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,YAAY,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGtE,OAAO,EACH,qBAAqB,EAAE,2BAA2B,EAClD,aAAa,EAAE,UAAU,GAC5B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGrF,YAAY,EACR,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,aAAa,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// @vinkius-core/mcp-fusion-aws — Barrel Export
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// ── Primary API ──
|
|
5
|
+
export { createAwsConnector } from './createAwsConnector.js';
|
|
6
|
+
export { defineAwsTool } from './defineAwsTool.js';
|
|
7
|
+
// ── Client & Adapters ──
|
|
8
|
+
export { AwsClient, createLambdaAdapter, createSfnAdapter } from './AwsClient.js';
|
|
9
|
+
// ── Discovery ──
|
|
10
|
+
export { LambdaDiscovery } from './LambdaDiscovery.js';
|
|
11
|
+
export { StepFunctionDiscovery } from './StepFunctionDiscovery.js';
|
|
12
|
+
// ── Tool Synthesis ──
|
|
13
|
+
export { synthesizeLambdaTools, synthesizeStepFunctionTools, synthesizeAll, toToolName, } from './ToolSynthesizer.js';
|
|
14
|
+
export { MCP_TAGS, DEFAULT_TAG_FILTER, DEFAULT_ACTION_NAME } from './types.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,+CAA+C;AAC/C,+EAA+E;AAE/E,oBAAoB;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,0BAA0B;AAC1B,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOlF,kBAAkB;AAClB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,uBAAuB;AACvB,OAAO,EACH,qBAAqB,EAAE,2BAA2B,EAClD,aAAa,EAAE,UAAU,GAC5B,MAAM,sBAAsB,CAAC;AAc9B,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|