@aws/nx-plugin 1.0.0-rc.44 → 1.0.0-rc.46
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/generators.json +13 -7
- package/package.json +1 -1
- package/src/agentcore-gateway/files/cedar/policies/README.md +9 -0
- package/src/agentcore-gateway/files/cedar/policies/permit-all.cedar +15 -0
- package/src/agentcore-gateway/generator.js +12 -5
- package/src/agentcore-gateway/generator.js.map +1 -1
- package/src/agentcore-gateway/schema.d.js.map +1 -1
- package/src/agentcore-gateway/schema.d.ts +1 -1
- package/src/agentcore-gateway/schema.json +3 -2
- package/src/mcp-server/tools/general-guidance.js +1 -1
- package/src/mcp-server/tools/general-guidance.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +5 -2
- package/src/py/agent/gateway-connection/generator.js +1 -1
- package/src/py/agent/gateway-connection/generator.js.map +1 -1
- package/src/py/rdb/__snapshots__/generator.spec.ts.snap +17 -0
- package/src/py/rdb/files/Dockerfile.create-db-user.template +4 -0
- package/src/py/rdb/files/Dockerfile.migration.template +4 -0
- package/src/py/rdb/generator.js +5 -0
- package/src/py/rdb/generator.js.map +1 -1
- package/src/sdk/ts.d.ts +2 -0
- package/src/sdk/ts.js +2 -0
- package/src/sdk/ts.js.map +1 -1
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +5 -1
- package/src/ts/agent/files/deploy/Dockerfile.template +5 -1
- package/src/ts/agent/gateway-connection/generator.js +1 -1
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/generator.js +6 -0
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/dcr-proxy/__snapshots__/generator.spec.ts.snap +982 -0
- package/src/ts/dcr-proxy/generator.d.ts +10 -0
- package/src/ts/dcr-proxy/generator.js +98 -0
- package/src/ts/dcr-proxy/generator.js.map +1 -0
- package/src/ts/dcr-proxy/schema.d.js +6 -0
- package/src/ts/dcr-proxy/schema.d.js.map +1 -0
- package/src/ts/dcr-proxy/schema.d.ts +13 -0
- package/src/ts/dcr-proxy/schema.json +44 -0
- package/src/ts/mcp-server/files/Dockerfile.template +5 -1
- package/src/ts/mcp-server/generator.js +1 -0
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/nx-plugin/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/nx-plugin/files/mcp-server/resources/GENERAL_GUIDANCE.md.template +1 -1
- package/src/ts/nx-plugin/files/mcp-server/utils.ts.template +1 -1
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +7 -0
- package/src/ts/rdb/files/Dockerfile.template +7 -0
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +13 -4
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +11 -6
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +12 -2
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +1 -0
- package/src/utils/agent-core-constructs/agent-core-constructs.js +2 -0
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +38 -3
- package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +13 -3
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.tf.template +22 -1
- package/src/utils/commands.js +1 -1
- package/src/utils/commands.js.map +1 -1
- package/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.d.ts +38 -0
- package/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.js +93 -0
- package/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.js.map +1 -0
- package/src/utils/dcr-proxy-constructs/files/cdk/app/dcr-proxies/__nameKebabCase__/__nameKebabCase__.ts.template +227 -0
- package/src/utils/dcr-proxy-constructs/files/project/src/handlers/authorization-server-metadata.ts.template +39 -0
- package/src/utils/dcr-proxy-constructs/files/project/src/handlers/authorize.ts.template +26 -0
- package/src/utils/dcr-proxy-constructs/files/project/src/handlers/mcp-proxy.ts.template +89 -0
- package/src/utils/dcr-proxy-constructs/files/project/src/handlers/protected-resource-metadata.ts.template +13 -0
- package/src/utils/dcr-proxy-constructs/files/project/src/handlers/register.ts.template +70 -0
- package/src/utils/dcr-proxy-constructs/files/project/src/handlers/token.ts.template +75 -0
- package/src/utils/dcr-proxy-constructs/files/terraform/app/dcr-proxies/__nameKebabCase__/__nameKebabCase__.tf.template +410 -0
- package/src/utils/docker.d.ts +4 -3
- package/src/utils/docker.js +11 -7
- package/src/utils/docker.js.map +1 -1
- package/src/utils/format.d.ts +1 -1
- package/src/utils/format.js +3 -2
- package/src/utils/format.js.map +1 -1
- package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +11 -6
- package/src/utils/identity-constructs/identity-constructs.js +14 -3
- package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
- package/src/utils/init.js +4 -0
- package/src/utils/init.js.map +1 -1
- package/src/utils/versions.d.ts +4 -1
- package/src/utils/versions.js +9 -1
- package/src/utils/versions.js.map +1 -1
- package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +3 -0
|
@@ -0,0 +1,10 @@
|
|
|
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 { TsDcrProxyGeneratorSchema } from './schema';
|
|
8
|
+
export declare const TS_DCR_PROXY_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
|
+
export declare const tsDcrProxyGenerator: (tree: Tree, options: TsDcrProxyGeneratorSchema) => Promise<GeneratorCallback>;
|
|
10
|
+
export default tsDcrProxyGenerator;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { addDependenciesToPackageJson, generateFiles, joinPathFragments, OverwriteStrategy, updateProjectConfiguration } from "@nx/devkit";
|
|
5
|
+
import tsProjectGenerator from "../lib/generator.js";
|
|
6
|
+
import { addTypeScriptBundleTarget } from "../../utils/bundle/bundle.js";
|
|
7
|
+
import { addDcrProxyInfra, DCR_PROXY_HANDLERS } from "../../utils/dcr-proxy-constructs/dcr-proxy-constructs.js";
|
|
8
|
+
import { formatFilesInSubtree } from "../../utils/format.js";
|
|
9
|
+
import { resolveIac } from "../../utils/iac.js";
|
|
10
|
+
import { installDependencies } from "../../utils/install.js";
|
|
11
|
+
import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
|
|
12
|
+
import { kebabCase, toClassName } from "../../utils/names.js";
|
|
13
|
+
import { getNpmScopePrefix } from "../../utils/npm-scope.js";
|
|
14
|
+
import { getGeneratorInfo, readProjectConfigurationUnqualified } from "../../utils/nx.js";
|
|
15
|
+
import { sortObjectKeys } from "../../utils/object.js";
|
|
16
|
+
import { sharedConstructsGenerator } from "../../utils/shared-constructs.js";
|
|
17
|
+
import { withVersions } from "../../utils/versions.js";
|
|
18
|
+
export const TS_DCR_PROXY_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
19
|
+
export const tsDcrProxyGenerator = async (tree, options)=>{
|
|
20
|
+
const name = kebabCase(options.name ? options.name : 'dcr-proxy');
|
|
21
|
+
const nameClassName = toClassName(name);
|
|
22
|
+
const iac = await resolveIac(tree, options.iac);
|
|
23
|
+
// The handlers live in a standalone TypeScript project so they can be bundled
|
|
24
|
+
// (rolldown) into deployable artifacts referenced by both CDK and Terraform.
|
|
25
|
+
const namespace = getNpmScopePrefix(tree);
|
|
26
|
+
const proxyProjectName = `${namespace}${name}`;
|
|
27
|
+
let projectExists;
|
|
28
|
+
try {
|
|
29
|
+
readProjectConfigurationUnqualified(tree, proxyProjectName);
|
|
30
|
+
projectExists = true;
|
|
31
|
+
} catch {
|
|
32
|
+
projectExists = false;
|
|
33
|
+
}
|
|
34
|
+
if (!projectExists) {
|
|
35
|
+
await tsProjectGenerator(tree, {
|
|
36
|
+
name,
|
|
37
|
+
directory: options.directory,
|
|
38
|
+
subDirectory: options.subDirectory,
|
|
39
|
+
preferInstallDependencies: false
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const projectConfig = readProjectConfigurationUnqualified(tree, proxyProjectName);
|
|
43
|
+
const proxyRoot = projectConfig.root;
|
|
44
|
+
// Place the Lambda handlers in the project source
|
|
45
|
+
generateFiles(tree, joinPathFragments(import.meta.dirname, '..', '..', 'utils', 'dcr-proxy-constructs', 'files', 'project'), proxyRoot, {
|
|
46
|
+
nameClassName,
|
|
47
|
+
nameKebabCase: name
|
|
48
|
+
}, {
|
|
49
|
+
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
50
|
+
});
|
|
51
|
+
// The token handler imports @aws-sdk/client-secrets-manager (provided by the
|
|
52
|
+
// Lambda runtime but needed for type-checking and local dev) and the handlers
|
|
53
|
+
// are typed against @types/aws-lambda.
|
|
54
|
+
addDependenciesToPackageJson(tree, withVersions([
|
|
55
|
+
'@aws-sdk/client-secrets-manager'
|
|
56
|
+
]), withVersions([
|
|
57
|
+
'@types/aws-lambda'
|
|
58
|
+
]));
|
|
59
|
+
// Bundle each handler independently to dist/<root>/bundle/<handler>/index.js
|
|
60
|
+
for (const handler of DCR_PROXY_HANDLERS){
|
|
61
|
+
await addTypeScriptBundleTarget(tree, projectConfig, {
|
|
62
|
+
targetFilePath: `src/handlers/${handler}.ts`,
|
|
63
|
+
bundleOutputDir: handler,
|
|
64
|
+
external: [
|
|
65
|
+
/@aws-sdk\/.*/
|
|
66
|
+
],
|
|
67
|
+
platform: 'node'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
projectConfig.targets = sortObjectKeys(projectConfig.targets);
|
|
71
|
+
updateProjectConfiguration(tree, projectConfig.name, projectConfig);
|
|
72
|
+
const bundlePathsFromRoot = Object.fromEntries(DCR_PROXY_HANDLERS.map((handler)=>[
|
|
73
|
+
handler,
|
|
74
|
+
joinPathFragments('dist', proxyRoot, 'bundle', handler)
|
|
75
|
+
]));
|
|
76
|
+
await sharedConstructsGenerator(tree, {
|
|
77
|
+
iac
|
|
78
|
+
});
|
|
79
|
+
await addDcrProxyInfra(tree, {
|
|
80
|
+
dcrProxyNameClassName: nameClassName,
|
|
81
|
+
dcrProxyNameKebabCase: name,
|
|
82
|
+
proxyProjectName,
|
|
83
|
+
bundlePathsFromRoot,
|
|
84
|
+
iac
|
|
85
|
+
});
|
|
86
|
+
await addGeneratorMetricsIfApplicable(tree, [
|
|
87
|
+
TS_DCR_PROXY_GENERATOR_INFO
|
|
88
|
+
]);
|
|
89
|
+
await formatFilesInSubtree(tree);
|
|
90
|
+
return ()=>installDependencies(tree, options.preferInstallDependencies, {
|
|
91
|
+
languages: [
|
|
92
|
+
'typescript'
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
export default tsDcrProxyGenerator;
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/dcr-proxy/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addDependenciesToPackageJson,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport tsProjectGenerator from '../../ts/lib/generator';\nimport { addTypeScriptBundleTarget } from '../../utils/bundle/bundle';\nimport {\n addDcrProxyInfra,\n DCR_PROXY_HANDLERS,\n type DcrProxyHandler,\n} from '../../utils/dcr-proxy-constructs/dcr-proxy-constructs';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { kebabCase, toClassName } from '../../utils/names';\nimport { getNpmScopePrefix } from '../../utils/npm-scope';\nimport {\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport { sharedConstructsGenerator } from '../../utils/shared-constructs';\nimport { withVersions } from '../../utils/versions';\nimport type { TsDcrProxyGeneratorSchema } from './schema';\n\nexport const TS_DCR_PROXY_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsDcrProxyGenerator = async (\n tree: Tree,\n options: TsDcrProxyGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const name = kebabCase(options.name ? options.name : 'dcr-proxy');\n const nameClassName = toClassName(name);\n\n const iac = await resolveIac(tree, options.iac);\n\n // The handlers live in a standalone TypeScript project so they can be bundled\n // (rolldown) into deployable artifacts referenced by both CDK and Terraform.\n const namespace = getNpmScopePrefix(tree);\n const proxyProjectName = `${namespace}${name}`;\n\n let projectExists: boolean;\n try {\n readProjectConfigurationUnqualified(tree, proxyProjectName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await tsProjectGenerator(tree, {\n name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n preferInstallDependencies: false,\n });\n }\n\n const projectConfig = readProjectConfigurationUnqualified(\n tree,\n proxyProjectName,\n );\n const proxyRoot = projectConfig.root;\n\n // Place the Lambda handlers in the project source\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n '..',\n '..',\n 'utils',\n 'dcr-proxy-constructs',\n 'files',\n 'project',\n ),\n proxyRoot,\n { nameClassName, nameKebabCase: name },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n // The token handler imports @aws-sdk/client-secrets-manager (provided by the\n // Lambda runtime but needed for type-checking and local dev) and the handlers\n // are typed against @types/aws-lambda.\n addDependenciesToPackageJson(\n tree,\n withVersions(['@aws-sdk/client-secrets-manager']),\n withVersions(['@types/aws-lambda']),\n );\n\n // Bundle each handler independently to dist/<root>/bundle/<handler>/index.js\n for (const handler of DCR_PROXY_HANDLERS) {\n await addTypeScriptBundleTarget(tree, projectConfig, {\n targetFilePath: `src/handlers/${handler}.ts`,\n bundleOutputDir: handler,\n external: [/@aws-sdk\\/.*/], // lambda runtime provides the aws sdk\n platform: 'node',\n });\n }\n\n projectConfig.targets = sortObjectKeys(projectConfig.targets);\n updateProjectConfiguration(tree, projectConfig.name, projectConfig);\n\n const bundlePathsFromRoot = Object.fromEntries(\n DCR_PROXY_HANDLERS.map((handler) => [\n handler,\n joinPathFragments('dist', proxyRoot, 'bundle', handler),\n ]),\n ) as Record<DcrProxyHandler, string>;\n\n await sharedConstructsGenerator(tree, { iac });\n\n await addDcrProxyInfra(tree, {\n dcrProxyNameClassName: nameClassName,\n dcrProxyNameKebabCase: name,\n proxyProjectName,\n bundlePathsFromRoot,\n iac,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_DCR_PROXY_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsDcrProxyGenerator;\n"],"names":["addDependenciesToPackageJson","generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","tsProjectGenerator","addTypeScriptBundleTarget","addDcrProxyInfra","DCR_PROXY_HANDLERS","formatFilesInSubtree","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","toClassName","getNpmScopePrefix","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","sharedConstructsGenerator","withVersions","TS_DCR_PROXY_GENERATOR_INFO","filename","tsDcrProxyGenerator","tree","options","name","nameClassName","iac","namespace","proxyProjectName","projectExists","directory","subDirectory","preferInstallDependencies","projectConfig","proxyRoot","root","dirname","nameKebabCase","overwriteStrategy","KeepExisting","handler","targetFilePath","bundleOutputDir","external","platform","targets","bundlePathsFromRoot","Object","fromEntries","map","dcrProxyNameClassName","dcrProxyNameKebabCase","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAE5BC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,OAAOC,wBAAwB,sBAAyB;AACxD,SAASC,yBAAyB,QAAQ,+BAA4B;AACtE,SACEC,gBAAgB,EAChBC,kBAAkB,QAEb,2DAAwD;AAC/D,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,SAAS,EAAEC,WAAW,QAAQ,uBAAoB;AAC3D,SAASC,iBAAiB,QAAQ,2BAAwB;AAC1D,SACEC,gBAAgB,EAEhBC,mCAAmC,QAC9B,oBAAiB;AACxB,SAASC,cAAc,QAAQ,wBAAqB;AACpD,SAASC,yBAAyB,QAAQ,mCAAgC;AAC1E,SAASC,YAAY,QAAQ,0BAAuB;AAGpD,OAAO,MAAMC,8BAA+CL,iBAC1D,YAAYM,QAAQ,EACpB;AAEF,OAAO,MAAMC,sBAAsB,OACjCC,MACAC;IAEA,MAAMC,OAAOb,UAAUY,QAAQC,IAAI,GAAGD,QAAQC,IAAI,GAAG;IACrD,MAAMC,gBAAgBb,YAAYY;IAElC,MAAME,MAAM,MAAMlB,WAAWc,MAAMC,QAAQG,GAAG;IAE9C,8EAA8E;IAC9E,6EAA6E;IAC7E,MAAMC,YAAYd,kBAAkBS;IACpC,MAAMM,mBAAmB,GAAGD,YAAYH,MAAM;IAE9C,IAAIK;IACJ,IAAI;QACFd,oCAAoCO,MAAMM;QAC1CC,gBAAgB;IAClB,EAAE,OAAM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AyB,EAAE;YAC3DoB,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAe/B,oBAAoB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/dcr-proxy/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { IacOption } from '../../utils/iac';\n\nexport interface TsDcrProxyGeneratorSchema {\n name?: string;\n directory?: string;\n subDirectory?: string;\n iac: IacOption;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAGD,WAMC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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 TsDcrProxyGeneratorSchema {
|
|
8
|
+
name?: string;
|
|
9
|
+
directory?: string;
|
|
10
|
+
subDirectory?: string;
|
|
11
|
+
iac: IacOption;
|
|
12
|
+
preferInstallDependencies?: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "ts#dcr-proxy",
|
|
4
|
+
"title": "ts#dcr-proxy",
|
|
5
|
+
"description": "Generate an OAuth Dynamic Client Registration (DCR) proxy construct for Cognito-authenticated MCP servers",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The name of your DCR proxy, used for its TypeScript handler project, the construct/module class name, and its directory under common/constructs or common/terraform",
|
|
11
|
+
"default": "dcr-proxy",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
|
+
},
|
|
16
|
+
"x-prompt": "What would you like to call your DCR proxy?",
|
|
17
|
+
"x-priority": "important"
|
|
18
|
+
},
|
|
19
|
+
"directory": {
|
|
20
|
+
"description": "The directory to store the DCR proxy handler project in.",
|
|
21
|
+
"type": "string",
|
|
22
|
+
"alias": "dir",
|
|
23
|
+
"x-priority": "important",
|
|
24
|
+
"default": "packages"
|
|
25
|
+
},
|
|
26
|
+
"subDirectory": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "The sub directory the handler project is placed in. By default this is the project name."
|
|
29
|
+
},
|
|
30
|
+
"iac": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "The preferred IaC provider (cdk or terraform). By default this is inherited from your initial selection.",
|
|
33
|
+
"enum": ["inherit", "cdk", "terraform"],
|
|
34
|
+
"x-priority": "important",
|
|
35
|
+
"default": "inherit",
|
|
36
|
+
"x-prompt": "Which provider would you like to manage your infrastructure? (default: inherit)"
|
|
37
|
+
},
|
|
38
|
+
"preferInstallDependencies": {
|
|
39
|
+
"type": "boolean",
|
|
40
|
+
"description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
|
|
41
|
+
"default": true
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -7,7 +7,11 @@ WORKDIR /app
|
|
|
7
7
|
|
|
8
8
|
# Add AWS Distro for OpenTelemetry for observability
|
|
9
9
|
# https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability-configure.html
|
|
10
|
-
|
|
10
|
+
# The override pins @opentelemetry/propagator-jaeger above the version the
|
|
11
|
+
# autoinstrumentation package resolves transitively, clearing CVE-2026-59892.
|
|
12
|
+
RUN npm init -y \
|
|
13
|
+
&& npm pkg set "overrides.@opentelemetry/propagator-jaeger=<%- jaegerVersion %>" \
|
|
14
|
+
&& npm install @aws/aws-distro-opentelemetry-node-autoinstrumentation@<%- adotVersion %>
|
|
11
15
|
|
|
12
16
|
# Copy bundled streamable http server
|
|
13
17
|
COPY index.js /app
|
|
@@ -51,6 +51,7 @@ export const tsMcpServerGenerator = async (tree, options)=>{
|
|
|
51
51
|
esm,
|
|
52
52
|
distDir,
|
|
53
53
|
adotVersion: TS_VERSIONS['@aws/aws-distro-opentelemetry-node-autoinstrumentation'],
|
|
54
|
+
jaegerVersion: TS_VERSIONS['@opentelemetry/propagator-jaeger'],
|
|
54
55
|
nodeBaseImage: BASE_IMAGES.node,
|
|
55
56
|
npmVersion: TS_VERSIONS.npm
|
|
56
57
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/mcp-server/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addDependenciesToPackageJson,\n detectPackageManager,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readJson,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { ensureLicenseExceptions } from '../../license/config';\nimport { MCP_INSPECTOR_EXCEPTIONS } from '../../license/known-exceptions';\nimport { addMcpServerInfra } from '../../utils/agent-core-constructs/agent-core-constructs';\nimport { addTypeScriptBundleTarget } from '../../utils/bundle/bundle';\nimport { resolveContainers } from '../../utils/containers';\nimport { addDockerScanTarget } from '../../utils/docker';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FsCommands } from '../../utils/fs';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { isEsmWorkspace } from '../../utils/module-format';\nimport { kebabCase, toClassName } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addComponentDevTarget,\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport { assignPort } from '../../utils/port';\nimport { sharedConstructsGenerator } from '../../utils/shared-constructs';\nimport { BASE_IMAGES, TS_VERSIONS, withVersions } from '../../utils/versions';\nimport type { TsMcpServerGeneratorSchema } from './schema';\n\nexport const TS_MCP_SERVER_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsMcpServerGenerator = async (\n tree: Tree,\n options: TsMcpServerGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const project = readProjectConfigurationUnqualified(tree, options.project);\n\n if (!tree.exists(joinPathFragments(project.root, 'tsconfig.json'))) {\n throw new Error(\n `Unsupported project ${options.project}. Expected a TypeScript project (with a tsconfig.json)`,\n );\n }\n\n const defaultName = `${kebabCase(project.name.split('/').pop())}-mcp-server`;\n const name = kebabCase(options.name || defaultName);\n const mcpServerNameClassName = toClassName(name);\n const mcpTargetPrefix = options.name ? name : 'mcp-server';\n const targetSourceDirRelativeToProjectRoot = joinPathFragments(\n 'src',\n mcpTargetPrefix,\n );\n const targetSourceDir = joinPathFragments(\n project.root,\n targetSourceDirRelativeToProjectRoot,\n );\n const relativeSourceDir = targetSourceDir.replace(project.root + '/', './');\n const distDir = joinPathFragments('dist', project.root);\n\n const infra = options.infra ?? 'agentcore';\n\n if (infra === 'none' && options.auth && options.auth !== 'iam') {\n console.warn(\n 'Warning: auth is ignored when no infrastructure is configured (no infrastructure is generated)',\n );\n }\n\n const auth = options.auth ?? 'iam';\n\n const projectPackageJsonPath = joinPathFragments(\n project.root,\n 'package.json',\n );\n\n // Generate esm if the module system is esm, otherwise commonjs. Projects\n // don't typically have their own package.json (dependencies are declared in\n // the workspace root), so fall back to the workspace format when absent.\n const esm = tree.exists(projectPackageJsonPath)\n ? readJson(tree, projectPackageJsonPath).type === 'module'\n : isEsmWorkspace(tree);\n\n // Generate example server\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n targetSourceDir,\n {\n name,\n esm,\n distDir,\n adotVersion:\n TS_VERSIONS['@aws/aws-distro-opentelemetry-node-autoinstrumentation'],\n nodeBaseImage: BASE_IMAGES.node,\n npmVersion: TS_VERSIONS.npm,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Add dependencies\n const deps = withVersions([\n '@modelcontextprotocol/sdk',\n 'zod',\n 'express',\n '@aws-lambda-powertools/parameters',\n '@aws-sdk/client-appconfigdata',\n ]);\n const devDeps = withVersions([\n 'tsx',\n '@types/express',\n '@modelcontextprotocol/inspector',\n ]);\n\n // Add hosting based on infra\n if (infra === 'agentcore') {\n const containers = await resolveContainers(tree, 'inherit');\n const dockerImageTag = `${getNpmScope(tree)}-${name}:latest`;\n\n // Add bundle target\n await addTypeScriptBundleTarget(tree, project, {\n targetFilePath: `${targetSourceDirRelativeToProjectRoot}/http.ts`,\n bundleOutputDir: joinPathFragments('mcp', name),\n });\n\n const dockerOutputDir = joinPathFragments(\n 'dist',\n project.root,\n 'bundle',\n 'mcp',\n name,\n );\n const dockerTargetName = `${mcpTargetPrefix}-docker`;\n\n const fs = new FsCommands(tree);\n project.targets[dockerTargetName] = {\n cache: true,\n outputs: [`{workspaceRoot}/${dockerOutputDir}/Dockerfile`],\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.cp(\n `${targetSourceDir}/Dockerfile`,\n `${dockerOutputDir}/Dockerfile`,\n ),\n `${containers} build --platform linux/arm64 -t ${dockerImageTag} ${dockerOutputDir}`,\n ],\n parallel: false,\n },\n dependsOn: ['bundle'],\n };\n\n addDependencyToTargetIfNotPresent(project, 'docker', dockerTargetName);\n addDependencyToTargetIfNotPresent(project, 'build', 'docker');\n\n addDockerScanTarget(tree, {\n project,\n containerEngine: containers,\n trivyTargetName: `${mcpTargetPrefix}-trivy`,\n dockerTargetName,\n imageTags: [dockerImageTag],\n });\n\n // Add shared constructs\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac });\n\n // Add the construct to deploy the mcp server\n await addMcpServerInfra(tree, {\n mcpServerNameKebabCase: name,\n mcpServerNameClassName,\n projectName: project.name,\n dockerImageTag,\n dockerOutputDir,\n iac,\n auth,\n containers,\n });\n } else {\n // No Dockerfile needed for non-hosted MCP\n tree.delete(joinPathFragments(targetSourceDir, 'Dockerfile'));\n }\n\n addDependenciesToPackageJson(tree, deps, devDeps);\n // Add to the project's package.json too if it has one (e.g. nx plugins),\n // otherwise dependencies live in the workspace root only.\n if (tree.exists(projectPackageJsonPath)) {\n addDependenciesToPackageJson(tree, deps, devDeps, projectPackageJsonPath);\n }\n\n // @modelcontextprotocol/sdk declares zod as a peer dependency with a wide range\n // (^3.25 || ^4.0). Yarn does not dedupe the peer to the workspace's pinned zod, so\n // without a resolution it installs a separate zod under the SDK's own node_modules.\n // The two zod copies have structurally incompatible types, which breaks type\n // inference for registerTool inputSchema. Scope the resolution to the SDK so\n // other consumers (e.g. @tanstack/router-generator pinning zod@3) are unaffected.\n if (detectPackageManager() === 'yarn') {\n updateJson(tree, 'package.json', (packageJson) => {\n packageJson.resolutions = {\n ...packageJson.resolutions,\n '**/@modelcontextprotocol/sdk/zod': TS_VERSIONS['zod'],\n };\n return packageJson;\n });\n }\n\n const localDevPort = assignPort(tree, project, 8000, {\n component: { info: TS_MCP_SERVER_GENERATOR_INFO, name: mcpTargetPrefix },\n });\n\n const mcpTargets = {\n ...project.targets,\n // Add targets for running the MCP server\n [`${mcpTargetPrefix}-serve-stdio`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/stdio.ts`],\n cwd: '{projectRoot}',\n },\n },\n [`${mcpTargetPrefix}-serve`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/http.ts`],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n },\n },\n },\n [`${mcpTargetPrefix}-dev`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/http.ts`],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n LOCAL_DEV: 'true',\n },\n },\n },\n [`${mcpTargetPrefix}-inspect`]: {\n executor: 'nx:run-commands',\n continuous: true,\n // Launch the inspector against the locally served HTTP server. The dev\n // target starts the server and any connected dependencies (e.g. a local\n // database).\n dependsOn: [`${mcpTargetPrefix}-dev`],\n options: {\n commands: [\n `mcp-inspector --transport http --server-url http://localhost:${localDevPort}/mcp`,\n ],\n cwd: '{projectRoot}',\n },\n },\n [`${mcpTargetPrefix}-inspect-stdio`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [\n `mcp-inspector -- tsx --watch ${relativeSourceDir}/stdio.ts`,\n ],\n cwd: '{projectRoot}',\n },\n },\n };\n\n // Aggregate `<mcp>-dev` under the project-level `dev` target.\n addComponentDevTarget(mcpTargets, `${mcpTargetPrefix}-dev`);\n\n updateProjectConfiguration(tree, project.name, {\n ...project,\n // Sort targets so their order is stable regardless of insertion order on\n // first run vs re-run.\n targets: sortObjectKeys(mcpTargets),\n });\n\n addComponentGeneratorMetadata(\n tree,\n project.name,\n TS_MCP_SERVER_GENERATOR_INFO,\n targetSourceDirRelativeToProjectRoot,\n mcpTargetPrefix,\n {\n port: localDevPort,\n rc: mcpServerNameClassName,\n auth,\n },\n );\n\n await addGeneratorMetricsIfApplicable(tree, [TS_MCP_SERVER_GENERATOR_INFO]);\n\n await ensureLicenseExceptions(tree, MCP_INSPECTOR_EXCEPTIONS);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsMcpServerGenerator;\n"],"names":["addDependenciesToPackageJson","detectPackageManager","generateFiles","joinPathFragments","OverwriteStrategy","readJson","updateJson","updateProjectConfiguration","ensureLicenseExceptions","MCP_INSPECTOR_EXCEPTIONS","addMcpServerInfra","addTypeScriptBundleTarget","resolveContainers","addDockerScanTarget","formatFilesInSubtree","FsCommands","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","isEsmWorkspace","kebabCase","toClassName","getNpmScope","addComponentDevTarget","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","assignPort","sharedConstructsGenerator","BASE_IMAGES","TS_VERSIONS","withVersions","TS_MCP_SERVER_GENERATOR_INFO","filename","tsMcpServerGenerator","tree","options","project","exists","root","Error","defaultName","name","split","pop","mcpServerNameClassName","mcpTargetPrefix","targetSourceDirRelativeToProjectRoot","targetSourceDir","relativeSourceDir","replace","distDir","infra","auth","console","warn","projectPackageJsonPath","esm","type","dirname","adotVersion","nodeBaseImage","node","npmVersion","npm","overwriteStrategy","KeepExisting","deps","devDeps","containers","dockerImageTag","targetFilePath","bundleOutputDir","dockerOutputDir","dockerTargetName","fs","targets","cache","outputs","executor","commands","cp","parallel","dependsOn","containerEngine","trivyTargetName","imageTags","iac","mcpServerNameKebabCase","projectName","delete","packageJson","resolutions","localDevPort","component","info","mcpTargets","continuous","cwd","env","PORT","LOCAL_DEV","port","rc","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAC5BC,oBAAoB,EAEpBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,QAAQ,EAERC,UAAU,EACVC,0BAA0B,QACrB,aAAa;AACpB,SAASC,uBAAuB,QAAQ,0BAAuB;AAC/D,SAASC,wBAAwB,QAAQ,oCAAiC;AAC1E,SAASC,iBAAiB,QAAQ,6DAA0D;AAC5F,SAASC,yBAAyB,QAAQ,+BAA4B;AACtE,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SAASC,mBAAmB,QAAQ,wBAAqB;AACzD,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,UAAU,QAAQ,oBAAiB;AAC5C,SAASC,UAAU,QAAQ,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BACnF;gBACDK,KAAK;YACP;QACF;QACA,CAAC,GAAGpD,gBAAgB,cAAc,CAAC,CAAC,EAAE;YACpCiC,UAAU;YACVkB,YAAY;YACZ7D,SAAS;gBACP4C,UAAU;oBACR,CAAC,6BAA6B,EAAE/B,kBAAkB,SAAS,CAAC;iBAC7D;gBACDiD,KAAK;YACP;QACF;IACF;IAEA,8DAA8D;IAC9D7E,sBAAsB2E,YAAY,GAAGlD,gBAAgB,IAAI,CAAC;IAE1DzC,2BAA2B8B,MAAME,QAAQK,IAAI,EAAE;QAC7C,GAAGL,OAAO;QACV,yEAAyE;QACzE,uBAAuB;QACvBuC,SAASlD,eAAesE;IAC1B;IAEA1E,8BACEa,MACAE,QAAQK,IAAI,EACZV,8BACAe,sCACAD,iBACA;QACEwD,MAAMT;QACNU,IAAI1D;QACJQ;IACF;IAGF,MAAMrC,gCAAgCmB,MAAM;QAACH;KAA6B;IAE1E,MAAM1B,wBAAwB6B,MAAM5B;IAEpC,MAAMK,qBAAqBuB;IAC3B,OAAO,IACLpB,oBAAoBoB,MAAMC,QAAQoE,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAevE,qBAAqB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/mcp-server/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addDependenciesToPackageJson,\n detectPackageManager,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readJson,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { ensureLicenseExceptions } from '../../license/config';\nimport { MCP_INSPECTOR_EXCEPTIONS } from '../../license/known-exceptions';\nimport { addMcpServerInfra } from '../../utils/agent-core-constructs/agent-core-constructs';\nimport { addTypeScriptBundleTarget } from '../../utils/bundle/bundle';\nimport { resolveContainers } from '../../utils/containers';\nimport { addDockerScanTarget } from '../../utils/docker';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FsCommands } from '../../utils/fs';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { isEsmWorkspace } from '../../utils/module-format';\nimport { kebabCase, toClassName } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addComponentDevTarget,\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport { assignPort } from '../../utils/port';\nimport { sharedConstructsGenerator } from '../../utils/shared-constructs';\nimport { BASE_IMAGES, TS_VERSIONS, withVersions } from '../../utils/versions';\nimport type { TsMcpServerGeneratorSchema } from './schema';\n\nexport const TS_MCP_SERVER_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsMcpServerGenerator = async (\n tree: Tree,\n options: TsMcpServerGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const project = readProjectConfigurationUnqualified(tree, options.project);\n\n if (!tree.exists(joinPathFragments(project.root, 'tsconfig.json'))) {\n throw new Error(\n `Unsupported project ${options.project}. Expected a TypeScript project (with a tsconfig.json)`,\n );\n }\n\n const defaultName = `${kebabCase(project.name.split('/').pop())}-mcp-server`;\n const name = kebabCase(options.name || defaultName);\n const mcpServerNameClassName = toClassName(name);\n const mcpTargetPrefix = options.name ? name : 'mcp-server';\n const targetSourceDirRelativeToProjectRoot = joinPathFragments(\n 'src',\n mcpTargetPrefix,\n );\n const targetSourceDir = joinPathFragments(\n project.root,\n targetSourceDirRelativeToProjectRoot,\n );\n const relativeSourceDir = targetSourceDir.replace(project.root + '/', './');\n const distDir = joinPathFragments('dist', project.root);\n\n const infra = options.infra ?? 'agentcore';\n\n if (infra === 'none' && options.auth && options.auth !== 'iam') {\n console.warn(\n 'Warning: auth is ignored when no infrastructure is configured (no infrastructure is generated)',\n );\n }\n\n const auth = options.auth ?? 'iam';\n\n const projectPackageJsonPath = joinPathFragments(\n project.root,\n 'package.json',\n );\n\n // Generate esm if the module system is esm, otherwise commonjs. Projects\n // don't typically have their own package.json (dependencies are declared in\n // the workspace root), so fall back to the workspace format when absent.\n const esm = tree.exists(projectPackageJsonPath)\n ? readJson(tree, projectPackageJsonPath).type === 'module'\n : isEsmWorkspace(tree);\n\n // Generate example server\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n targetSourceDir,\n {\n name,\n esm,\n distDir,\n adotVersion:\n TS_VERSIONS['@aws/aws-distro-opentelemetry-node-autoinstrumentation'],\n jaegerVersion: TS_VERSIONS['@opentelemetry/propagator-jaeger'],\n nodeBaseImage: BASE_IMAGES.node,\n npmVersion: TS_VERSIONS.npm,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Add dependencies\n const deps = withVersions([\n '@modelcontextprotocol/sdk',\n 'zod',\n 'express',\n '@aws-lambda-powertools/parameters',\n '@aws-sdk/client-appconfigdata',\n ]);\n const devDeps = withVersions([\n 'tsx',\n '@types/express',\n '@modelcontextprotocol/inspector',\n ]);\n\n // Add hosting based on infra\n if (infra === 'agentcore') {\n const containers = await resolveContainers(tree, 'inherit');\n const dockerImageTag = `${getNpmScope(tree)}-${name}:latest`;\n\n // Add bundle target\n await addTypeScriptBundleTarget(tree, project, {\n targetFilePath: `${targetSourceDirRelativeToProjectRoot}/http.ts`,\n bundleOutputDir: joinPathFragments('mcp', name),\n });\n\n const dockerOutputDir = joinPathFragments(\n 'dist',\n project.root,\n 'bundle',\n 'mcp',\n name,\n );\n const dockerTargetName = `${mcpTargetPrefix}-docker`;\n\n const fs = new FsCommands(tree);\n project.targets[dockerTargetName] = {\n cache: true,\n outputs: [`{workspaceRoot}/${dockerOutputDir}/Dockerfile`],\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.cp(\n `${targetSourceDir}/Dockerfile`,\n `${dockerOutputDir}/Dockerfile`,\n ),\n `${containers} build --platform linux/arm64 -t ${dockerImageTag} ${dockerOutputDir}`,\n ],\n parallel: false,\n },\n dependsOn: ['bundle'],\n };\n\n addDependencyToTargetIfNotPresent(project, 'docker', dockerTargetName);\n addDependencyToTargetIfNotPresent(project, 'build', 'docker');\n\n addDockerScanTarget(tree, {\n project,\n containerEngine: containers,\n trivyTargetName: `${mcpTargetPrefix}-trivy`,\n dockerTargetName,\n imageTags: [dockerImageTag],\n });\n\n // Add shared constructs\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac });\n\n // Add the construct to deploy the mcp server\n await addMcpServerInfra(tree, {\n mcpServerNameKebabCase: name,\n mcpServerNameClassName,\n projectName: project.name,\n dockerImageTag,\n dockerOutputDir,\n iac,\n auth,\n containers,\n });\n } else {\n // No Dockerfile needed for non-hosted MCP\n tree.delete(joinPathFragments(targetSourceDir, 'Dockerfile'));\n }\n\n addDependenciesToPackageJson(tree, deps, devDeps);\n // Add to the project's package.json too if it has one (e.g. nx plugins),\n // otherwise dependencies live in the workspace root only.\n if (tree.exists(projectPackageJsonPath)) {\n addDependenciesToPackageJson(tree, deps, devDeps, projectPackageJsonPath);\n }\n\n // @modelcontextprotocol/sdk declares zod as a peer dependency with a wide range\n // (^3.25 || ^4.0). Yarn does not dedupe the peer to the workspace's pinned zod, so\n // without a resolution it installs a separate zod under the SDK's own node_modules.\n // The two zod copies have structurally incompatible types, which breaks type\n // inference for registerTool inputSchema. Scope the resolution to the SDK so\n // other consumers (e.g. @tanstack/router-generator pinning zod@3) are unaffected.\n if (detectPackageManager() === 'yarn') {\n updateJson(tree, 'package.json', (packageJson) => {\n packageJson.resolutions = {\n ...packageJson.resolutions,\n '**/@modelcontextprotocol/sdk/zod': TS_VERSIONS['zod'],\n };\n return packageJson;\n });\n }\n\n const localDevPort = assignPort(tree, project, 8000, {\n component: { info: TS_MCP_SERVER_GENERATOR_INFO, name: mcpTargetPrefix },\n });\n\n const mcpTargets = {\n ...project.targets,\n // Add targets for running the MCP server\n [`${mcpTargetPrefix}-serve-stdio`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/stdio.ts`],\n cwd: '{projectRoot}',\n },\n },\n [`${mcpTargetPrefix}-serve`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/http.ts`],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n },\n },\n },\n [`${mcpTargetPrefix}-dev`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/http.ts`],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n LOCAL_DEV: 'true',\n },\n },\n },\n [`${mcpTargetPrefix}-inspect`]: {\n executor: 'nx:run-commands',\n continuous: true,\n // Launch the inspector against the locally served HTTP server. The dev\n // target starts the server and any connected dependencies (e.g. a local\n // database).\n dependsOn: [`${mcpTargetPrefix}-dev`],\n options: {\n commands: [\n `mcp-inspector --transport http --server-url http://localhost:${localDevPort}/mcp`,\n ],\n cwd: '{projectRoot}',\n },\n },\n [`${mcpTargetPrefix}-inspect-stdio`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [\n `mcp-inspector -- tsx --watch ${relativeSourceDir}/stdio.ts`,\n ],\n cwd: '{projectRoot}',\n },\n },\n };\n\n // Aggregate `<mcp>-dev` under the project-level `dev` target.\n addComponentDevTarget(mcpTargets, `${mcpTargetPrefix}-dev`);\n\n updateProjectConfiguration(tree, project.name, {\n ...project,\n // Sort targets so their order is stable regardless of insertion order on\n // first run vs re-run.\n targets: sortObjectKeys(mcpTargets),\n });\n\n addComponentGeneratorMetadata(\n tree,\n project.name,\n TS_MCP_SERVER_GENERATOR_INFO,\n targetSourceDirRelativeToProjectRoot,\n mcpTargetPrefix,\n {\n port: localDevPort,\n rc: mcpServerNameClassName,\n auth,\n },\n );\n\n await addGeneratorMetricsIfApplicable(tree, [TS_MCP_SERVER_GENERATOR_INFO]);\n\n await ensureLicenseExceptions(tree, MCP_INSPECTOR_EXCEPTIONS);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsMcpServerGenerator;\n"],"names":["addDependenciesToPackageJson","detectPackageManager","generateFiles","joinPathFragments","OverwriteStrategy","readJson","updateJson","updateProjectConfiguration","ensureLicenseExceptions","MCP_INSPECTOR_EXCEPTIONS","addMcpServerInfra","addTypeScriptBundleTarget","resolveContainers","addDockerScanTarget","formatFilesInSubtree","FsCommands","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","isEsmWorkspace","kebabCase","toClassName","getNpmScope","addComponentDevTarget","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","assignPort","sharedConstructsGenerator","BASE_IMAGES","TS_VERSIONS","withVersions","TS_MCP_SERVER_GENERATOR_INFO","filename","tsMcpServerGenerator","tree","options","project","exists","root","Error","defaultName","name","split","pop","mcpServerNameClassName","mcpTargetPrefix","targetSourceDirRelativeToProjectRoot","targetSourceDir","relativeSourceDir","replace","distDir","infra","auth","console","warn","projectPackageJsonPath","esm","type","dirname","adotVersion","jaegerVersion","nodeBaseImage","node","npmVersion","npm","overwriteStrategy","KeepExisting","deps","devDeps","containers","dockerImageTag","targetFilePath","bundleOutputDir","dockerOutputDir","dockerTargetName","fs","targets","cache","outputs","executor","commands","cp","parallel","dependsOn","containerEngine","trivyTargetName","imageTags","iac","mcpServerNameKebabCase","projectName","delete","packageJson","resolutions","localDevPort","component","info","mcpTargets","continuous","cwd","env","PORT","LOCAL_DEV","port","rc","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAC5BC,oBAAoB,EAEpBC,aAA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#nx-plugin generator > should generate MCP server files > test-plugin
|
|
|
127
127
|
- pnpm add -w -D <package>
|
|
128
128
|
- yarn add -D <package>
|
|
129
129
|
- npm install --legacy-peer-deps -D <package>
|
|
130
|
-
- bun
|
|
130
|
+
- bun add -D <package>
|
|
131
131
|
- (Omit -D for production dependencies)
|
|
132
132
|
- When specifying project names as arguments to generators, prefer the _fully qualified_ project name, for example \`@workspace-name/project-name\`. Check the \`project.json\` file for the specific package to find its fully qualified name
|
|
133
133
|
- When no generator exists for a specific framework required, look for more generic project generators if availalbe and build on top of these.
|
|
@@ -482,7 +482,7 @@ export const buildInstallCommand = (pm: string, pkg: string) =>
|
|
|
482
482
|
pnpm: \`pnpm add -Dw \${pkg}\`,
|
|
483
483
|
yarn: \`yarn add -D \${pkg}\`,
|
|
484
484
|
npm: \`npm install --legacy-peer-deps -D \${pkg}\`,
|
|
485
|
-
bun: \`bun
|
|
485
|
+
bun: \`bun add -D \${pkg}\`,
|
|
486
486
|
})[pm];
|
|
487
487
|
|
|
488
488
|
const renderSchema = (schema: any) =>
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
- pnpm add -w -D <package>
|
|
31
31
|
- yarn add -D <package>
|
|
32
32
|
- npm install --legacy-peer-deps -D <package>
|
|
33
|
-
- bun
|
|
33
|
+
- bun add -D <package>
|
|
34
34
|
- (Omit -D for production dependencies)
|
|
35
35
|
- When specifying project names as arguments to generators, prefer the _fully qualified_ project name, for example `@workspace-name/project-name`. Check the `project.json` file for the specific package to find its fully qualified name
|
|
36
36
|
- When no generator exists for a specific framework required, look for more generic project generators if availalbe and build on top of these.
|
|
@@ -56,7 +56,7 @@ export const buildInstallCommand = (pm: string, pkg: string) =>
|
|
|
56
56
|
pnpm: `pnpm add -Dw ${pkg}`,
|
|
57
57
|
yarn: `yarn add -D ${pkg}`,
|
|
58
58
|
npm: `npm install --legacy-peer-deps -D ${pkg}`,
|
|
59
|
-
bun: `bun
|
|
59
|
+
bun: `bun add -D ${pkg}`,
|
|
60
60
|
})[pm];
|
|
61
61
|
|
|
62
62
|
const renderSchema = (schema: any) =>
|
|
@@ -4669,6 +4669,13 @@ exports[`ts#rdb generator > should generate the aurora shared construct 4`] = `
|
|
|
4669
4669
|
# Upgrade npm to a version free of known HIGH/CRITICAL vulnerabilities
|
|
4670
4670
|
RUN npm install -g npm@12.0.1
|
|
4671
4671
|
|
|
4672
|
+
# Patch OS packages beyond the base image's pinned release, and drop the
|
|
4673
|
+
# runtime's convenience copy of the AWS SDK (the handler bundle inlines its
|
|
4674
|
+
# own dependencies), keeping the image free of known HIGH/CRITICAL
|
|
4675
|
+
# vulnerabilities
|
|
4676
|
+
RUN microdnf upgrade -y --releasever latest && microdnf clean all \\
|
|
4677
|
+
&& rm -rf /var/runtime/node_modules/@aws-sdk
|
|
4678
|
+
|
|
4672
4679
|
WORKDIR \${LAMBDA_TASK_ROOT}
|
|
4673
4680
|
|
|
4674
4681
|
# npm blocks dependency install scripts by default; allow prisma's so its
|
|
@@ -3,6 +3,13 @@ FROM public.ecr.aws/lambda/nodejs:24
|
|
|
3
3
|
# Upgrade npm to a version free of known HIGH/CRITICAL vulnerabilities
|
|
4
4
|
RUN npm install -g npm@<%= npmVersion %>
|
|
5
5
|
|
|
6
|
+
# Patch OS packages beyond the base image's pinned release, and drop the
|
|
7
|
+
# runtime's convenience copy of the AWS SDK (the handler bundle inlines its
|
|
8
|
+
# own dependencies), keeping the image free of known HIGH/CRITICAL
|
|
9
|
+
# vulnerabilities
|
|
10
|
+
RUN microdnf upgrade -y --releasever latest && microdnf clean all \
|
|
11
|
+
&& rm -rf /var/runtime/node_modules/@aws-sdk
|
|
12
|
+
|
|
6
13
|
WORKDIR ${LAMBDA_TASK_ROOT}
|
|
7
14
|
|
|
8
15
|
# npm blocks dependency install scripts by default; allow prisma's so its
|
|
@@ -961,7 +961,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
961
961
|
|
|
962
962
|
exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > biome.json 1`] = `
|
|
963
963
|
"{
|
|
964
|
-
"$schema": "https://biomejs.dev/schemas/2.4
|
|
964
|
+
"$schema": "https://biomejs.dev/schemas/2.5.4/schema.json",
|
|
965
965
|
"root": true,
|
|
966
966
|
"formatter": {
|
|
967
967
|
"enabled": true,
|
|
@@ -986,7 +986,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
986
986
|
"linter": {
|
|
987
987
|
"enabled": true,
|
|
988
988
|
"rules": {
|
|
989
|
-
"
|
|
989
|
+
"preset": "none",
|
|
990
990
|
"correctness": {
|
|
991
991
|
"noUndeclaredDependencies": "warn"
|
|
992
992
|
}
|
|
@@ -1820,6 +1820,9 @@ export class StaticWebsite extends Construct {
|
|
|
1820
1820
|
destinationBucket: this.websiteBucket,
|
|
1821
1821
|
// Files in the distribution's edge caches will be invalidated after files are uploaded to the destination bucket.
|
|
1822
1822
|
distribution: this.cloudFrontDistribution,
|
|
1823
|
+
// Exclude the runtime config from this deployment's sync so its default pruning
|
|
1824
|
+
// never deletes the file managed separately by RuntimeConfigDeployment below.
|
|
1825
|
+
exclude: [DEFAULT_RUNTIME_CONFIG_FILENAME],
|
|
1823
1826
|
memoryLimit: 1024,
|
|
1824
1827
|
});
|
|
1825
1828
|
|
|
@@ -2674,7 +2677,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2674
2677
|
|
|
2675
2678
|
exports[`react-website generator > Tanstack router integration > should generate website with router correctly > biome.json 1`] = `
|
|
2676
2679
|
"{
|
|
2677
|
-
"$schema": "https://biomejs.dev/schemas/2.4
|
|
2680
|
+
"$schema": "https://biomejs.dev/schemas/2.5.4/schema.json",
|
|
2678
2681
|
"root": true,
|
|
2679
2682
|
"formatter": {
|
|
2680
2683
|
"enabled": true,
|
|
@@ -2699,7 +2702,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2699
2702
|
"linter": {
|
|
2700
2703
|
"enabled": true,
|
|
2701
2704
|
"rules": {
|
|
2702
|
-
"
|
|
2705
|
+
"preset": "none",
|
|
2703
2706
|
"correctness": {
|
|
2704
2707
|
"noUndeclaredDependencies": "warn"
|
|
2705
2708
|
}
|
|
@@ -3538,6 +3541,9 @@ export class StaticWebsite extends Construct {
|
|
|
3538
3541
|
destinationBucket: this.websiteBucket,
|
|
3539
3542
|
// Files in the distribution's edge caches will be invalidated after files are uploaded to the destination bucket.
|
|
3540
3543
|
distribution: this.cloudFrontDistribution,
|
|
3544
|
+
// Exclude the runtime config from this deployment's sync so its default pruning
|
|
3545
|
+
// never deletes the file managed separately by RuntimeConfigDeployment below.
|
|
3546
|
+
exclude: [DEFAULT_RUNTIME_CONFIG_FILENAME],
|
|
3541
3547
|
memoryLimit: 1024,
|
|
3542
3548
|
});
|
|
3543
3549
|
|
|
@@ -5163,6 +5169,9 @@ export class StaticWebsite extends Construct {
|
|
|
5163
5169
|
destinationBucket: this.websiteBucket,
|
|
5164
5170
|
// Files in the distribution's edge caches will be invalidated after files are uploaded to the destination bucket.
|
|
5165
5171
|
distribution: this.cloudFrontDistribution,
|
|
5172
|
+
// Exclude the runtime config from this deployment's sync so its default pruning
|
|
5173
|
+
// never deletes the file managed separately by RuntimeConfigDeployment below.
|
|
5174
|
+
exclude: [DEFAULT_RUNTIME_CONFIG_FILENAME],
|
|
5166
5175
|
memoryLimit: 1024,
|
|
5167
5176
|
});
|
|
5168
5177
|
|
|
@@ -118,7 +118,7 @@ import {
|
|
|
118
118
|
import { LogGroup, RetentionDays } from 'aws-cdk-lib/aws-logs';
|
|
119
119
|
import { Construct } from 'constructs';
|
|
120
120
|
import { RuntimeConfig } from './runtime-config.js';
|
|
121
|
-
import { Distribution } from 'aws-cdk-lib/aws-cloudfront';
|
|
121
|
+
import { CfnDistribution, Distribution } from 'aws-cdk-lib/aws-cloudfront';
|
|
122
122
|
import { suppressRules } from './checkov.js';
|
|
123
123
|
|
|
124
124
|
const WEB_CLIENT_ID = 'WebClient';
|
|
@@ -334,9 +334,7 @@ export class UserIdentity extends Construct {
|
|
|
334
334
|
const lazilyComputedCallbackUrls = Lazy.list({
|
|
335
335
|
produce: () =>
|
|
336
336
|
['http://localhost:4200', 'http://localhost:4300'].concat(
|
|
337
|
-
this.
|
|
338
|
-
(d) => \`https://\${d.domainName}\`,
|
|
339
|
-
),
|
|
337
|
+
this.findCloudFrontDomainNames().map((domain) => \`https://\${domain}\`),
|
|
340
338
|
),
|
|
341
339
|
});
|
|
342
340
|
|
|
@@ -386,10 +384,17 @@ export class UserIdentity extends Construct {
|
|
|
386
384
|
}).node.addDependency(userPoolClient, userPool, userPoolDomain);
|
|
387
385
|
};
|
|
388
386
|
|
|
389
|
-
|
|
387
|
+
// Includes each distribution's default domain name plus any custom domain names (aliases) configured on it.
|
|
388
|
+
private findCloudFrontDomainNames = (): string[] =>
|
|
390
389
|
Stack.of(this)
|
|
391
390
|
.node.findAll()
|
|
392
|
-
.filter((child) => child instanceof Distribution)
|
|
391
|
+
.filter((child): child is Distribution => child instanceof Distribution)
|
|
392
|
+
.flatMap((d) => {
|
|
393
|
+
const cfnDistribution = d.node.defaultChild as CfnDistribution;
|
|
394
|
+
const distributionConfig =
|
|
395
|
+
cfnDistribution.distributionConfig as CfnDistribution.DistributionConfigProperty;
|
|
396
|
+
return [d.domainName, ...(distributionConfig.aliases ?? [])];
|
|
397
|
+
});
|
|
393
398
|
}
|
|
394
399
|
"
|
|
395
400
|
`;
|
|
@@ -241,11 +241,21 @@ resource "aws_cloudfront_distribution" "website" {
|
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
# Add CloudFront domain to user pool client callback URLs
|
|
244
|
+
# Add CloudFront domain and any custom domain names to user pool client callback URLs.
|
|
245
|
+
# Keyed by statically-known values so for_each keys are resolvable at plan time; the
|
|
246
|
+
# CloudFront domain is only known at apply time, so it appears in the value, not the key.
|
|
247
|
+
locals {
|
|
248
|
+
callback_urls = merge(
|
|
249
|
+
{ cloudfront = "https://\${aws_cloudfront_distribution.website.domain_name}" },
|
|
250
|
+
{ for domain in var.custom_domain_names : domain => "https://\${domain}" },
|
|
251
|
+
)
|
|
252
|
+
}
|
|
253
|
+
|
|
245
254
|
module "add_callback_url" {
|
|
246
255
|
source = "../user-identity/add-callback-url"
|
|
256
|
+
for_each = local.callback_urls
|
|
247
257
|
|
|
248
|
-
callback_url =
|
|
258
|
+
callback_url = each.value
|
|
249
259
|
|
|
250
260
|
depends_on = [aws_cloudfront_distribution.website]
|
|
251
261
|
}
|
|
@@ -53,6 +53,7 @@ export interface AddAgentCoreGatewayInfraProps {
|
|
|
53
53
|
projectName: string;
|
|
54
54
|
projectDirectory: string;
|
|
55
55
|
cedarPolicy: boolean;
|
|
56
|
+
auth: AgentCoreAuth;
|
|
56
57
|
}
|
|
57
58
|
export declare const addAgentCoreGatewayInfra: (tree: Tree, options: AddAgentCoreGatewayInfraProps & IACProvider) => Promise<void>;
|
|
58
59
|
export {};
|
|
@@ -107,6 +107,7 @@ const addAgentCoreGatewayCDKInfra = async (tree, options)=>{
|
|
|
107
107
|
nameKebabCase: options.gatewayNameKebabCase,
|
|
108
108
|
projectDirectory: options.projectDirectory,
|
|
109
109
|
cedarPolicy: options.cedarPolicy,
|
|
110
|
+
auth: options.auth,
|
|
110
111
|
...esmVars(tree)
|
|
111
112
|
}, {
|
|
112
113
|
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
@@ -126,6 +127,7 @@ const addAgentCoreGatewayTerraformInfra = (tree, options)=>{
|
|
|
126
127
|
nameKebabCase: options.gatewayNameKebabCase,
|
|
127
128
|
projectDirectory: options.projectDirectory,
|
|
128
129
|
cedarPolicy: options.cedarPolicy,
|
|
130
|
+
auth: options.auth,
|
|
129
131
|
boto3Version: PY_VERSIONS.boto3,
|
|
130
132
|
httpxVersion: PY_VERSIONS.httpx,
|
|
131
133
|
mcpVersion: PY_VERSIONS.mcp,
|