@aws/nx-plugin 1.0.0-rc.11 → 1.0.0-rc.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-THIRD-PARTY +81 -3
- package/generators.json +31 -1
- package/package.json +2 -2
- package/sdk/agentcore-gateway.d.ts +6 -0
- package/sdk/agentcore-gateway.js +11 -0
- package/sdk/agentcore-gateway.js.map +1 -0
- package/sdk/license.d.ts +4 -4
- package/sdk/license.js +5 -4
- package/sdk/license.js.map +1 -1
- package/sdk/py.d.ts +6 -6
- package/sdk/py.js +7 -7
- package/sdk/py.js.map +1 -1
- package/sdk/ts.d.ts +18 -14
- package/sdk/ts.js +38 -32
- package/sdk/ts.js.map +1 -1
- package/src/agentcore-gateway/files/cedar/policies/README.md +52 -0
- package/src/agentcore-gateway/files/cedar/policies/permit-all.cedar +11 -0
- package/src/agentcore-gateway/files/project/serve-local.ts.template +133 -0
- package/src/agentcore-gateway/generator.d.ts +25 -0
- package/src/agentcore-gateway/generator.js +129 -0
- package/src/agentcore-gateway/generator.js.map +1 -0
- package/src/agentcore-gateway/mcp-connection/generator.d.ts +19 -0
- package/src/agentcore-gateway/mcp-connection/generator.js +79 -0
- package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -0
- package/src/agentcore-gateway/mcp-connection/schema.d.ts +12 -0
- package/src/agentcore-gateway/mcp-connection/schema.json +26 -0
- package/src/agentcore-gateway/schema.d.ts +16 -0
- package/src/agentcore-gateway/schema.json +65 -0
- package/src/connection/generator.d.ts +1 -1
- package/src/connection/generator.js +64 -46
- package/src/connection/generator.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +9 -9
- package/src/mcp-server/schema-registry.d.ts +9 -3
- package/src/mcp-server/schema-registry.js +22 -6
- package/src/mcp-server/schema-registry.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +3 -1
- package/src/py/agent/__snapshots__/generator.spec.ts.snap +629 -7
- package/src/py/agent/a2a-connection/files/agent-connection/app/__targetAgentSnakeCase___client.py.template +9 -3
- package/src/py/agent/a2a-connection/generator.js +1 -1
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/files/http/init.py.template +5 -23
- package/src/py/agent/gateway-connection/files/agent-connection/app/__gatewaySnakeCase___client.py.template +35 -0
- package/src/py/agent/gateway-connection/generator.d.ts +10 -0
- package/src/py/agent/gateway-connection/generator.js +106 -0
- package/src/py/agent/gateway-connection/generator.js.map +1 -0
- package/src/py/agent/gateway-connection/schema.d.ts +12 -0
- package/src/py/agent/gateway-connection/schema.json +26 -0
- package/src/py/agent/generator.js +27 -22
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +8 -4
- package/src/py/agent/mcp-connection/files/agent-connection/app/__mcpServerSnakeCase___client.py.template +9 -3
- package/src/py/agent/mcp-connection/generator.js +2 -72
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +5 -22
- package/src/py/fast-api/files/app/__name__/init.py.template +5 -22
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +58 -3
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +619 -2
- package/src/ts/agent/a2a-connection/files/agent-connection/app/__targetAgentKebabCase__-client.ts.template +10 -6
- package/src/ts/agent/gateway-connection/files/agent-connection/app/__gatewayKebabCase__-client.ts.template +30 -0
- package/src/ts/agent/gateway-connection/generator.d.ts +10 -0
- package/src/ts/agent/gateway-connection/generator.js +106 -0
- package/src/ts/agent/gateway-connection/generator.js.map +1 -0
- package/src/ts/agent/gateway-connection/schema.d.ts +12 -0
- package/src/ts/agent/gateway-connection/schema.json +26 -0
- package/src/ts/agent/generator.js +23 -19
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +9 -4
- package/src/ts/agent/mcp-connection/files/agent-connection/app/__mcpServerKebabCase__-client.ts.template +9 -6
- package/src/ts/agent/mcp-connection/generator.js +1 -13
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +58 -3
- package/src/ts/nx-generator/generator.js +29 -0
- package/src/ts/nx-generator/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +86 -39
- package/src/utils/agent-chat/agent-chat.d.ts +31 -0
- package/src/utils/agent-chat/agent-chat.js +30 -0
- package/src/utils/agent-chat/agent-chat.js.map +1 -0
- package/src/utils/agent-chat/files/a2a/chat.ts.template +33 -0
- package/src/utils/agent-chat/files/ag-ui/chat.ts.template +17 -0
- package/src/utils/agent-chat/files/common/agentcore.ts.template +81 -0
- package/src/utils/agent-chat/files/http-py/chat.ts.template +43 -0
- package/src/utils/agent-chat/files/http-ts/chat.ts.template +54 -0
- package/src/utils/agent-connection/agent-connection.d.ts +17 -0
- package/src/utils/agent-connection/agent-connection.js +94 -0
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-client.ts.template +78 -0
- package/src/utils/agent-connection/files/core-runtime-config/runtime-config.ts.template +22 -32
- package/src/utils/agent-connection/files/py-core-gateway/agentcore_gateway_mcp_client.py.template +78 -0
- package/src/utils/agent-connection/files/py-core-runtime-config/runtime_config.py.template +5 -18
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +8 -0
- package/src/utils/agent-core-constructs/agent-core-constructs.js +54 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +4 -0
- package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +37 -0
- package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +293 -0
- package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/readiness-probe/index.js.template +55 -0
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.tf.template +242 -0
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/render-cedar.cjs.template +13 -0
- package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +55 -2
- package/src/utils/agent-core-constructs/files/terraform/core/agentcore-gateway/gateway.tf.template +14 -0
- package/src/utils/versions.d.ts +46 -44
- package/src/utils/versions.js +45 -43
- package/src/utils/versions.js.map +1 -1
- package/src/py/agent/scripts/http/chat.ts.template +0 -38
- package/src/ts/agent/scripts/http/chat.ts.template +0 -35
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
3
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
4
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
5
|
+
import {
|
|
6
|
+
CallToolRequestSchema,
|
|
7
|
+
ListToolsRequestSchema,
|
|
8
|
+
} from '@modelcontextprotocol/sdk/types.js';
|
|
9
|
+
import express from 'express';
|
|
10
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
11
|
+
|
|
12
|
+
const PORT = parseInt(process.env.PORT || '<%- port %>');
|
|
13
|
+
const PREFIX_SEPARATOR = '___';
|
|
14
|
+
const SESSION_HEADER = 'x-amzn-bedrock-agentcore-runtime-session-id';
|
|
15
|
+
|
|
16
|
+
interface AttachedMcpServer {
|
|
17
|
+
name: string;
|
|
18
|
+
url: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// MCP servers attached to this gateway, maintained by the
|
|
22
|
+
// `agentcore-gateway#mcp-connection` generator.
|
|
23
|
+
const ATTACHED_MCP_SERVERS: AttachedMcpServer[] = [<% attachedMcpServers.forEach((s) => { %>
|
|
24
|
+
{ name: '<%- s.name %>', url: 'http://localhost:<%- s.port %>/mcp' },<% }); %>
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
// Forwards the inbound request's AgentCore session header to upstream calls
|
|
28
|
+
const sessionContext = new AsyncLocalStorage<string | undefined>();
|
|
29
|
+
|
|
30
|
+
const createUpstreamClient = async (url: string): Promise<Client> => {
|
|
31
|
+
const fetchWithSession: typeof fetch = async (input, init) => {
|
|
32
|
+
const headers = new Headers(init?.headers);
|
|
33
|
+
const sessionId = sessionContext.getStore();
|
|
34
|
+
if (sessionId) headers.set(SESSION_HEADER, sessionId);
|
|
35
|
+
return fetch(input, { ...init, headers });
|
|
36
|
+
};
|
|
37
|
+
const client = new Client({ name: '<%- nameKebabCase %>', version: '1.0.0' });
|
|
38
|
+
await client.connect(
|
|
39
|
+
new StreamableHTTPClientTransport(new URL(url), {
|
|
40
|
+
fetch: fetchWithSession,
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
return client;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Local gateway for <%- nameClassName %>: a single MCP endpoint aggregating
|
|
48
|
+
* every attached MCP server, with tools exposed as `<target>___<tool>` to
|
|
49
|
+
* match the deployed AgentCore Gateway. Unlike the real gateway, Cedar
|
|
50
|
+
* policies are not evaluated and there is no semantic tool search.
|
|
51
|
+
*/
|
|
52
|
+
const createServer = async (): Promise<Server> => {
|
|
53
|
+
const server = new Server(
|
|
54
|
+
{ name: '<%- nameKebabCase %>', version: '1.0.0' },
|
|
55
|
+
{ capabilities: { tools: {} } },
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
59
|
+
const lists = await Promise.all(
|
|
60
|
+
ATTACHED_MCP_SERVERS.map(async (s) => {
|
|
61
|
+
const client = await createUpstreamClient(s.url);
|
|
62
|
+
try {
|
|
63
|
+
const { tools } = await client.listTools();
|
|
64
|
+
return tools.map((t) => ({
|
|
65
|
+
...t,
|
|
66
|
+
name: `${s.name}${PREFIX_SEPARATOR}${t.name}`,
|
|
67
|
+
}));
|
|
68
|
+
} finally {
|
|
69
|
+
await client.close();
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
return { tools: lists.flat() };
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
77
|
+
const name = request.params.name;
|
|
78
|
+
const upstream = ATTACHED_MCP_SERVERS.find((s) =>
|
|
79
|
+
name.startsWith(`${s.name}${PREFIX_SEPARATOR}`),
|
|
80
|
+
);
|
|
81
|
+
if (!upstream) {
|
|
82
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
83
|
+
}
|
|
84
|
+
const client = await createUpstreamClient(upstream.url);
|
|
85
|
+
try {
|
|
86
|
+
return await client.callTool({
|
|
87
|
+
...request.params,
|
|
88
|
+
name: name.slice(upstream.name.length + PREFIX_SEPARATOR.length),
|
|
89
|
+
});
|
|
90
|
+
} finally {
|
|
91
|
+
await client.close();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return server;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const app = express();
|
|
99
|
+
app.use(express.json());
|
|
100
|
+
|
|
101
|
+
app.post('/mcp', async (req, res) => {
|
|
102
|
+
const sessionId = req.headers[SESSION_HEADER];
|
|
103
|
+
await sessionContext.run(
|
|
104
|
+
typeof sessionId === 'string' ? sessionId : undefined,
|
|
105
|
+
async () => {
|
|
106
|
+
try {
|
|
107
|
+
const server = await createServer();
|
|
108
|
+
const transport = new StreamableHTTPServerTransport({
|
|
109
|
+
sessionIdGenerator: undefined,
|
|
110
|
+
});
|
|
111
|
+
res.on('close', () => {
|
|
112
|
+
transport.close();
|
|
113
|
+
server.close();
|
|
114
|
+
});
|
|
115
|
+
await server.connect(transport);
|
|
116
|
+
await transport.handleRequest(req, res, req.body);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.error('Error handling MCP request:', error);
|
|
119
|
+
if (!res.headersSent) {
|
|
120
|
+
res.status(500).json({
|
|
121
|
+
jsonrpc: '2.0',
|
|
122
|
+
error: { code: -32603, message: 'Internal server error' },
|
|
123
|
+
id: null,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
app.listen(PORT, () => {
|
|
132
|
+
console.log(`<%- nameKebabCase %>: local gateway listening on port ${PORT}`);
|
|
133
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { type GeneratorCallback, type ProjectConfiguration, type Tree } from '@nx/devkit';
|
|
6
|
+
import { type NxGeneratorInfo } from '../utils/nx';
|
|
7
|
+
import type { AgentcoreGatewayGeneratorSchema } from './schema';
|
|
8
|
+
export declare const AGENTCORE_GATEWAY_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
|
+
export declare const agentcoreGatewayGenerator: (tree: Tree, options: AgentcoreGatewayGeneratorSchema) => Promise<GeneratorCallback>;
|
|
10
|
+
/**
|
|
11
|
+
* Gateway details stored in the gateway project's metadata.
|
|
12
|
+
*/
|
|
13
|
+
export interface AgentCoreGatewayMetadata {
|
|
14
|
+
name: string;
|
|
15
|
+
rc: string;
|
|
16
|
+
protocol: string;
|
|
17
|
+
auth: string;
|
|
18
|
+
port: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Read a gateway project's metadata, validating it was generated by the
|
|
22
|
+
* agentcore-gateway generator.
|
|
23
|
+
*/
|
|
24
|
+
export declare const readAgentCoreGatewayMetadata: (project: ProjectConfiguration) => AgentCoreGatewayMetadata;
|
|
25
|
+
export default agentcoreGatewayGenerator;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readAgentCoreGatewayMetadata = exports.agentcoreGatewayGenerator = exports.AGENTCORE_GATEWAY_GENERATOR_INFO = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const agent_core_constructs_1 = require("../utils/agent-core-constructs/agent-core-constructs");
|
|
10
|
+
const format_1 = require("../utils/format");
|
|
11
|
+
const iac_1 = require("../utils/iac");
|
|
12
|
+
const metrics_1 = require("../utils/metrics");
|
|
13
|
+
const names_1 = require("../utils/names");
|
|
14
|
+
const npm_scope_1 = require("../utils/npm-scope");
|
|
15
|
+
const nx_1 = require("../utils/nx");
|
|
16
|
+
const port_1 = require("../utils/port");
|
|
17
|
+
const shared_constructs_1 = require("../utils/shared-constructs");
|
|
18
|
+
const versions_1 = require("../utils/versions");
|
|
19
|
+
exports.AGENTCORE_GATEWAY_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
20
|
+
const agentcoreGatewayGenerator = async (tree, options) => {
|
|
21
|
+
const name = (0, names_1.kebabCase)(options.name);
|
|
22
|
+
const nameClassName = (0, names_1.toClassName)(name);
|
|
23
|
+
const parentDir = options.directory ?? 'packages';
|
|
24
|
+
const subDir = options.subDirectory ?? name;
|
|
25
|
+
const projectRoot = (0, devkit_1.joinPathFragments)(parentDir, subDir);
|
|
26
|
+
const fullyQualifiedName = `${(0, npm_scope_1.getNpmScopePrefix)(tree)}${name}`;
|
|
27
|
+
// Protocol / auth are fixed to mcp / iam in v1 — the enums accept only
|
|
28
|
+
// these values, but we still persist the resolved value in metadata so
|
|
29
|
+
// that connection generators can read it uniformly (and future additions
|
|
30
|
+
// are non-breaking).
|
|
31
|
+
const protocol = options.protocol ?? 'mcp';
|
|
32
|
+
const auth = options.auth ?? 'iam';
|
|
33
|
+
const cedarPolicy = options.cedarPolicy ?? true;
|
|
34
|
+
const infra = options.infra ?? 'agentcore';
|
|
35
|
+
// serve-local.ts is the local gateway: a continuous MCP aggregator chaining
|
|
36
|
+
// onto attached MCP servers' serve-local targets (added by the
|
|
37
|
+
// mcp-connection generator), so a single `nx run <agent>:<agent>-serve-local`
|
|
38
|
+
// boots the gateway and every attached MCP server together.
|
|
39
|
+
//
|
|
40
|
+
// `serve` exists for parity with other generators; the deployed Gateway is
|
|
41
|
+
// a managed AWS resource, so `serve`-mode agents talk to it via runtime
|
|
42
|
+
// config and the local gateway sits idle.
|
|
43
|
+
const localGatewayTarget = (port) => ({
|
|
44
|
+
executor: 'nx:run-commands',
|
|
45
|
+
continuous: true,
|
|
46
|
+
options: {
|
|
47
|
+
command: 'tsx serve-local.ts',
|
|
48
|
+
cwd: '{projectRoot}',
|
|
49
|
+
env: { PORT: `${port}` },
|
|
50
|
+
},
|
|
51
|
+
dependsOn: [],
|
|
52
|
+
});
|
|
53
|
+
let project;
|
|
54
|
+
if ((0, nx_1.projectExists)(tree, fullyQualifiedName)) {
|
|
55
|
+
project = (0, nx_1.readProjectConfigurationUnqualified)(tree, fullyQualifiedName);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
(0, devkit_1.addProjectConfiguration)(tree, fullyQualifiedName, {
|
|
59
|
+
name: fullyQualifiedName,
|
|
60
|
+
root: projectRoot,
|
|
61
|
+
projectType: 'library',
|
|
62
|
+
sourceRoot: projectRoot,
|
|
63
|
+
tags: [],
|
|
64
|
+
targets: {},
|
|
65
|
+
metadata: {
|
|
66
|
+
generator: exports.AGENTCORE_GATEWAY_GENERATOR_INFO.id,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
project = (0, nx_1.readProjectConfigurationUnqualified)(tree, fullyQualifiedName);
|
|
70
|
+
}
|
|
71
|
+
const port = (0, port_1.assignPort)(tree, project, 8100);
|
|
72
|
+
// Re-run: keep existing targets (their dependsOn may have been populated
|
|
73
|
+
// by the mcp-connection generator), just ensure both exist.
|
|
74
|
+
project.targets ??= {};
|
|
75
|
+
project.targets[`${name}-serve`] ??= localGatewayTarget(port);
|
|
76
|
+
project.targets[`${name}-serve-local`] ??= localGatewayTarget(port);
|
|
77
|
+
(0, devkit_1.updateProjectConfiguration)(tree, project.name, project);
|
|
78
|
+
// Scaffold the gateway project: serve-local.ts (+ Cedar policies if requested)
|
|
79
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'project'), projectRoot, { nameClassName, nameKebabCase: name, port, attachedMcpServers: [] }, { overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting });
|
|
80
|
+
if (cedarPolicy) {
|
|
81
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'cedar'), projectRoot, { nameClassName }, { overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting });
|
|
82
|
+
}
|
|
83
|
+
(0, nx_1.addGeneratorMetadata)(tree, fullyQualifiedName, exports.AGENTCORE_GATEWAY_GENERATOR_INFO, {
|
|
84
|
+
name,
|
|
85
|
+
rc: nameClassName,
|
|
86
|
+
protocol,
|
|
87
|
+
auth,
|
|
88
|
+
port,
|
|
89
|
+
});
|
|
90
|
+
// serve-local.ts dependencies (+ ejs for Cedar policy rendering in the
|
|
91
|
+
// shared gateway construct)
|
|
92
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, (0, versions_1.withVersions)(['@modelcontextprotocol/sdk', 'express']), (0, versions_1.withVersions)(['tsx', '@types/express', 'ejs', '@types/ejs']));
|
|
93
|
+
// Wire up infra (CDK or Terraform); re-running with infra=agentcore adds
|
|
94
|
+
// the infrastructure to a previously infra-less gateway.
|
|
95
|
+
if (infra === 'agentcore') {
|
|
96
|
+
const iac = await (0, iac_1.resolveIac)(tree, options.iac);
|
|
97
|
+
await (0, shared_constructs_1.sharedConstructsGenerator)(tree, { iac });
|
|
98
|
+
await (0, agent_core_constructs_1.addAgentCoreGatewayInfra)(tree, {
|
|
99
|
+
gatewayNameClassName: nameClassName,
|
|
100
|
+
gatewayNameKebabCase: name,
|
|
101
|
+
projectName: fullyQualifiedName,
|
|
102
|
+
projectDirectory: projectRoot,
|
|
103
|
+
cedarPolicy,
|
|
104
|
+
iac,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
await (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [
|
|
108
|
+
exports.AGENTCORE_GATEWAY_GENERATOR_INFO,
|
|
109
|
+
]);
|
|
110
|
+
await (0, format_1.formatFilesInSubtree)(tree);
|
|
111
|
+
return () => {
|
|
112
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
exports.agentcoreGatewayGenerator = agentcoreGatewayGenerator;
|
|
116
|
+
/**
|
|
117
|
+
* Read a gateway project's metadata, validating it was generated by the
|
|
118
|
+
* agentcore-gateway generator.
|
|
119
|
+
*/
|
|
120
|
+
const readAgentCoreGatewayMetadata = (project) => {
|
|
121
|
+
const metadata = project.metadata;
|
|
122
|
+
if (metadata?.generator !== exports.AGENTCORE_GATEWAY_GENERATOR_INFO.id) {
|
|
123
|
+
throw new Error(`Project '${project.name}' was not generated by the '${exports.AGENTCORE_GATEWAY_GENERATOR_INFO.id}' generator.`);
|
|
124
|
+
}
|
|
125
|
+
return metadata;
|
|
126
|
+
};
|
|
127
|
+
exports.readAgentCoreGatewayMetadata = readAgentCoreGatewayMetadata;
|
|
128
|
+
exports.default = exports.agentcoreGatewayGenerator;
|
|
129
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/agentcore-gateway/generator.ts"],"names":[],"mappings":";;;AAAA;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W;YAC7B,WAAW;YACX,GAAG;SACJ,CAAC,CAAC;IACL,CAAC;IAED,MAAM,IAAA,yCAA+B,EAAC,IAAI,EAAE;QAC1C,wCAAgC;KACjC,CAAC,CAAC;IAEH,MAAM,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;IACjC,OAAO,GAAG,EAAE;QACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC,CAAC;AA9HW,QAAA,yBAAyB,6BA8HpC;AAaF;;;GAGG;AACI,MAAM,4BAA4B,GAAG,CAC1C,OAA6B,EACH,EAAE;IAC5B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAe,CAAC;IACzC,IAAI,QAAQ,EAAE,SAAS,KAAK,wCAAgC,CAAC,EAAE,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CACb,YAAY,OAAO,CAAC,IAAI,+BAA+B,wCAAgC,CAAC,EAAE,cAAc,CACzG,CAAC;IACJ,CAAC;IACD,OAAO,QAAoC,CAAC;AAC9C,CAAC,CAAC;AAVW,QAAA,4BAA4B,gCAUvC;AAEF,kBAAe,iCAAyB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
6
|
+
import { type NxGeneratorInfo } from '../../utils/nx';
|
|
7
|
+
import type { AgentcoreGatewayMcpConnectionGeneratorSchema } from './schema';
|
|
8
|
+
export declare const AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
|
+
/**
|
|
10
|
+
* Connect an AgentCore Gateway to an MCP server.
|
|
11
|
+
*
|
|
12
|
+
* Chains the gateway's serve-local target to the MCP server's serve-local
|
|
13
|
+
* target, and registers the server in the gateway's local serve-local.ts so
|
|
14
|
+
* the local gateway aggregates its tools. Users must still call
|
|
15
|
+
* `gateway.addMcpServer(...)` in their application stack to create the
|
|
16
|
+
* actual CDK/Terraform resource.
|
|
17
|
+
*/
|
|
18
|
+
export declare const agentcoreGatewayMcpConnectionGenerator: (tree: Tree, options: AgentcoreGatewayMcpConnectionGeneratorSchema) => Promise<GeneratorCallback>;
|
|
19
|
+
export default agentcoreGatewayMcpConnectionGenerator;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.agentcoreGatewayMcpConnectionGenerator = exports.AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const ast_1 = require("../../utils/ast");
|
|
10
|
+
const format_1 = require("../../utils/format");
|
|
11
|
+
const metrics_1 = require("../../utils/metrics");
|
|
12
|
+
const names_1 = require("../../utils/names");
|
|
13
|
+
const nx_1 = require("../../utils/nx");
|
|
14
|
+
const generator_1 = require("../generator");
|
|
15
|
+
exports.AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
16
|
+
/**
|
|
17
|
+
* Connect an AgentCore Gateway to an MCP server.
|
|
18
|
+
*
|
|
19
|
+
* Chains the gateway's serve-local target to the MCP server's serve-local
|
|
20
|
+
* target, and registers the server in the gateway's local serve-local.ts so
|
|
21
|
+
* the local gateway aggregates its tools. Users must still call
|
|
22
|
+
* `gateway.addMcpServer(...)` in their application stack to create the
|
|
23
|
+
* actual CDK/Terraform resource.
|
|
24
|
+
*/
|
|
25
|
+
const agentcoreGatewayMcpConnectionGenerator = async (tree, options) => {
|
|
26
|
+
const sourceProject = (0, nx_1.readProjectConfigurationUnqualified)(tree, options.sourceProject);
|
|
27
|
+
const targetProject = (0, nx_1.readProjectConfigurationUnqualified)(tree, options.targetProject);
|
|
28
|
+
const gateway = (0, generator_1.readAgentCoreGatewayMetadata)(sourceProject);
|
|
29
|
+
const mcpComponent = options.targetComponent;
|
|
30
|
+
if (!mcpComponent) {
|
|
31
|
+
throw new Error(`Target project '${options.targetProject}' has no MCP server component metadata. Did you run the 'ts#mcp-server' or 'py#mcp-server' generator?`);
|
|
32
|
+
}
|
|
33
|
+
if (gateway.protocol !== 'mcp') {
|
|
34
|
+
throw new Error(`Gateway '${gateway.name}' has protocol='${gateway.protocol}'. MCP server targets can only be attached to MCP-protocol gateways.`);
|
|
35
|
+
}
|
|
36
|
+
if (mcpComponent.auth && mcpComponent.auth !== 'iam') {
|
|
37
|
+
throw new Error(`MCP server '${mcpComponent.name}' uses auth='${mcpComponent.auth}'. Gateway->MCP connections currently require the MCP server to use IAM authentication.`);
|
|
38
|
+
}
|
|
39
|
+
const gatewayKebabCase = (0, names_1.kebabCase)(gateway.rc);
|
|
40
|
+
const gatewayServeLocalTargetName = `${gatewayKebabCase}-serve-local`;
|
|
41
|
+
// The target name must match what the deployed Gateway uses
|
|
42
|
+
// (`mcpServerName` on the MCP construct, derived from the project's class
|
|
43
|
+
// name) so `<target>___<tool>` resolves identically locally and deployed.
|
|
44
|
+
// Component-level `name` would clash whenever two MCP server projects
|
|
45
|
+
// both default to `mcp-server`.
|
|
46
|
+
const mcpTargetName = (0, names_1.kebabCase)(mcpComponent.rc);
|
|
47
|
+
const mcpComponentName = mcpComponent.name ?? 'mcp-server';
|
|
48
|
+
const mcpServeLocalTargetName = `${mcpComponentName}-serve-local`;
|
|
49
|
+
const mcpPort = mcpComponent.port ?? 8000;
|
|
50
|
+
// 1. Wire serve-local chain
|
|
51
|
+
if (sourceProject.targets?.[gatewayServeLocalTargetName]) {
|
|
52
|
+
(0, nx_1.addDependencyToTargetIfNotPresent)(sourceProject, gatewayServeLocalTargetName, {
|
|
53
|
+
projects: [targetProject.name],
|
|
54
|
+
target: mcpServeLocalTargetName,
|
|
55
|
+
});
|
|
56
|
+
(0, devkit_1.updateProjectConfiguration)(tree, sourceProject.name, sourceProject);
|
|
57
|
+
}
|
|
58
|
+
// 2. Register the MCP server in the gateway's local serve-local.ts
|
|
59
|
+
const serveTsPath = (0, devkit_1.joinPathFragments)(sourceProject.root, 'serve-local.ts');
|
|
60
|
+
if (tree.exists(serveTsPath)) {
|
|
61
|
+
const entry = `{ name: '${mcpTargetName}', url: 'http://localhost:${mcpPort}/mcp' }`;
|
|
62
|
+
await (0, ast_1.applyGritQL)(tree, serveTsPath, `or {
|
|
63
|
+
\`const ATTACHED_MCP_SERVERS: AttachedMcpServer[] = []\` => \`const ATTACHED_MCP_SERVERS: AttachedMcpServer[] = [${entry}]\`,
|
|
64
|
+
\`const ATTACHED_MCP_SERVERS: AttachedMcpServer[] = [$items]\` => \`const ATTACHED_MCP_SERVERS: AttachedMcpServer[] = [${entry}, $items]\` where {
|
|
65
|
+
$items <: not contains \`'${mcpTargetName}'\`
|
|
66
|
+
}
|
|
67
|
+
}`);
|
|
68
|
+
}
|
|
69
|
+
await (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [
|
|
70
|
+
exports.AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO,
|
|
71
|
+
]);
|
|
72
|
+
await (0, format_1.formatFilesInSubtree)(tree);
|
|
73
|
+
return () => {
|
|
74
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
exports.agentcoreGatewayMcpConnectionGenerator = agentcoreGatewayMcpConnectionGenerator;
|
|
78
|
+
exports.default = exports.agentcoreGatewayMcpConnectionGenerator;
|
|
79
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/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AA,sCAAsC,0CAoFjD;AAEF,kBAAe,8CAAsC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { ComponentMetadata } from '../../utils/nx';
|
|
6
|
+
|
|
7
|
+
export interface AgentcoreGatewayMcpConnectionGeneratorSchema {
|
|
8
|
+
sourceProject: string;
|
|
9
|
+
targetProject: string;
|
|
10
|
+
sourceComponent?: ComponentMetadata;
|
|
11
|
+
targetComponent?: ComponentMetadata;
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "agentcore-gateway#mcp-connection",
|
|
4
|
+
"title": "agentcore-gateway#mcp-connection",
|
|
5
|
+
"description": "Connect an AgentCore Gateway to an MCP server",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"sourceProject": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The gateway project"
|
|
11
|
+
},
|
|
12
|
+
"targetProject": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The MCP server project"
|
|
15
|
+
},
|
|
16
|
+
"sourceComponent": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "The gateway component in the source project"
|
|
19
|
+
},
|
|
20
|
+
"targetComponent": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "The MCP server component in the target project"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": ["sourceProject", "targetProject"]
|
|
26
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { IacOption } from '../utils/iac';
|
|
6
|
+
|
|
7
|
+
export interface AgentcoreGatewayGeneratorSchema {
|
|
8
|
+
name: string;
|
|
9
|
+
directory?: string;
|
|
10
|
+
subDirectory?: string;
|
|
11
|
+
protocol?: 'mcp';
|
|
12
|
+
auth?: 'iam';
|
|
13
|
+
cedarPolicy?: boolean;
|
|
14
|
+
infra?: 'agentcore' | 'none';
|
|
15
|
+
iac: IacOption;
|
|
16
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "agentcore-gateway",
|
|
4
|
+
"title": "agentcore-gateway",
|
|
5
|
+
"description": "Generate an AgentCore Gateway project",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The name of your AgentCore Gateway project",
|
|
11
|
+
"$default": {
|
|
12
|
+
"$source": "argv",
|
|
13
|
+
"index": 0
|
|
14
|
+
},
|
|
15
|
+
"x-prompt": "What would you like to call your AgentCore Gateway?",
|
|
16
|
+
"x-priority": "important"
|
|
17
|
+
},
|
|
18
|
+
"directory": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "Parent directory where the gateway project is placed.",
|
|
21
|
+
"default": "packages"
|
|
22
|
+
},
|
|
23
|
+
"subDirectory": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "The sub directory the project is placed in. By default this is the project name."
|
|
26
|
+
},
|
|
27
|
+
"protocol": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "The inbound protocol exposed by your gateway. Only mcp is supported today; additional protocols may be added in future.",
|
|
30
|
+
"enum": ["mcp"],
|
|
31
|
+
"default": "mcp",
|
|
32
|
+
"x-priority": "important"
|
|
33
|
+
},
|
|
34
|
+
"auth": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "The method used to authenticate inbound requests to your gateway. Only iam is supported today; cognito and custom-jwt may be added in future.",
|
|
37
|
+
"enum": ["iam"],
|
|
38
|
+
"default": "iam",
|
|
39
|
+
"x-priority": "important"
|
|
40
|
+
},
|
|
41
|
+
"cedarPolicy": {
|
|
42
|
+
"type": "boolean",
|
|
43
|
+
"description": "Whether to include a Cedar policy engine enforcing fine-grained authorization on the gateway.",
|
|
44
|
+
"default": true,
|
|
45
|
+
"x-priority": "important"
|
|
46
|
+
},
|
|
47
|
+
"infra": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"description": "The type of infrastructure to host your gateway. Select none for no hosting.",
|
|
50
|
+
"x-prompt": "How would you like to host your gateway?",
|
|
51
|
+
"enum": ["agentcore", "none"],
|
|
52
|
+
"default": "agentcore",
|
|
53
|
+
"x-priority": "important"
|
|
54
|
+
},
|
|
55
|
+
"iac": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"description": "The preferred IaC provider. By default this is inherited from your initial selection.",
|
|
58
|
+
"enum": ["inherit", "cdk", "terraform"],
|
|
59
|
+
"x-priority": "important",
|
|
60
|
+
"default": "inherit",
|
|
61
|
+
"x-prompt": "Which provider would you like to manage your infrastructure? (default: inherit)"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": ["name"]
|
|
65
|
+
}
|
|
@@ -10,7 +10,7 @@ import type { ConnectionGeneratorSchema } from './schema';
|
|
|
10
10
|
* These can be project-level types (determined by introspection) or
|
|
11
11
|
* component generator ids (from component metadata).
|
|
12
12
|
*/
|
|
13
|
-
declare const SUPPORTED_PROJECT_TYPES: readonly ["ts#trpc-api", "py#fast-api", "react", "smithy", "ts#rdb", "ts#dynamodb"];
|
|
13
|
+
declare const SUPPORTED_PROJECT_TYPES: readonly ["ts#trpc-api", "py#fast-api", "react", "smithy", "ts#rdb", "ts#dynamodb", "agentcore-gateway"];
|
|
14
14
|
type ProjectType = (typeof SUPPORTED_PROJECT_TYPES)[number];
|
|
15
15
|
export type Connection = {
|
|
16
16
|
source: string;
|