@aws/nx-plugin-mcp 1.0.0-rc.96 → 1.0.0-rc.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/bin/aws-nx-mcp.js +90 -45
  2. package/docs/get_started/existing-project.mdx +7 -4
  3. package/docs/get_started/quick-start.mdx +58 -5
  4. package/docs/get_started/tutorials/dungeon-game/1.mdx +23 -20
  5. package/docs/get_started/tutorials/dungeon-game/2.mdx +11 -3
  6. package/docs/get_started/tutorials/dungeon-game/3.mdx +4 -0
  7. package/docs/get_started/tutorials/dungeon-game/4.mdx +7 -2
  8. package/docs/get_started/tutorials/dungeon-game/wrap-up.mdx +10 -1
  9. package/docs/guides/agentcore-gateway.mdx +4 -2
  10. package/docs/guides/agentcore-harness.mdx +2 -1
  11. package/docs/guides/astro-docs.mdx +25 -7
  12. package/docs/guides/connection/py-agent-a2a.mdx +2 -0
  13. package/docs/guides/connection/py-agent-dynamodb.mdx +1 -1
  14. package/docs/guides/connection/py-agent-gateway.mdx +3 -0
  15. package/docs/guides/connection/py-agent-mcp.mdx +18 -4
  16. package/docs/guides/connection/py-agent-rdb.mdx +5 -4
  17. package/docs/guides/connection/py-fast-api-dynamodb.mdx +1 -1
  18. package/docs/guides/connection/py-fast-api-rdb.mdx +7 -2
  19. package/docs/guides/connection/py-mcp-server-dynamodb.mdx +1 -1
  20. package/docs/guides/connection/py-mcp-server-rdb.mdx +6 -6
  21. package/docs/guides/connection/react-agui.mdx +34 -25
  22. package/docs/guides/connection/react-fastapi.mdx +114 -116
  23. package/docs/guides/connection/react-py-agent.mdx +4 -0
  24. package/docs/guides/connection/react-smithy.mdx +152 -98
  25. package/docs/guides/connection/react-trpc.mdx +13 -6
  26. package/docs/guides/connection/smithy-dynamodb.mdx +2 -8
  27. package/docs/guides/connection/smithy-rdb.mdx +3 -6
  28. package/docs/guides/connection/trpc-rdb.mdx +6 -6
  29. package/docs/guides/connection/ts-agent-a2a.mdx +4 -4
  30. package/docs/guides/connection/ts-agent-dynamodb.mdx +13 -11
  31. package/docs/guides/connection/ts-agent-gateway.mdx +2 -0
  32. package/docs/guides/connection/ts-agent-mcp.mdx +19 -7
  33. package/docs/guides/connection/ts-agent-rdb.mdx +2 -2
  34. package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +11 -7
  35. package/docs/guides/connection/ts-mcp-server-rdb.mdx +4 -3
  36. package/docs/guides/docker-bundling.mdx +23 -3
  37. package/docs/guides/fastapi.mdx +16 -5
  38. package/docs/guides/license.mdx +30 -6
  39. package/docs/guides/nx-generator.mdx +11 -12
  40. package/docs/guides/py-agent.mdx +129 -54
  41. package/docs/guides/py-mcp-server.mdx +3 -1
  42. package/docs/guides/py-rdb.mdx +13 -4
  43. package/docs/guides/python-lambda-function.mdx +8 -8
  44. package/docs/guides/python-project.mdx +28 -25
  45. package/docs/guides/react-website-auth.mdx +8 -8
  46. package/docs/guides/react-website.mdx +46 -27
  47. package/docs/guides/runtime-config.mdx +24 -4
  48. package/docs/guides/security.mdx +1 -1
  49. package/docs/guides/terraform-project.mdx +8 -2
  50. package/docs/guides/trpc.mdx +96 -12
  51. package/docs/guides/ts-agent.mdx +17 -3
  52. package/docs/guides/ts-dcr-proxy.mdx +24 -6
  53. package/docs/guides/ts-lambda-function.mdx +7 -1
  54. package/docs/guides/ts-mcp-server.mdx +45 -15
  55. package/docs/guides/ts-nx-plugin.mdx +17 -7
  56. package/docs/guides/ts-rdb.mdx +9 -2
  57. package/docs/guides/ts-smithy-api.mdx +76 -7
  58. package/docs/guides/typescript-infrastructure.mdx +27 -11
  59. package/docs/guides/typescript-project.mdx +12 -5
  60. package/docs/guides/workspace.mdx +21 -9
  61. package/docs/snippets/api/type-safe-api-integrations.mdx +2 -0
  62. package/docs/snippets/connection/a2a-infrastructure.mdx +3 -0
  63. package/docs/snippets/connection/infra-project-prerequisite.mdx +8 -0
  64. package/docs/snippets/connection/strands-agent-rdb-ssl-requirements.mdx +1 -1
  65. package/docs/snippets/connection/ts-lambda-rdb-ssl-requirements.mdx +1 -1
  66. package/docs/snippets/connection/ts-mcp-server-rdb-ssl-requirements.mdx +1 -1
  67. package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +1 -1
  68. package/docs/snippets/prerequisites.mdx +1 -1
  69. package/docs/snippets/required-prerequisites.mdx +1 -1
  70. package/package.json +1 -1
  71. package/src/init/schema.json +5 -0
  72. package/src/py/project/schema.json +3 -1
package/bin/aws-nx-mcp.js CHANGED
@@ -21915,19 +21915,22 @@ const kebabCase = (str) => {
21915
21915
  const NX_VERSION = {
21916
21916
  "@a2a-js/sdk": "0.3.14",
21917
21917
  "@aws/aws-distro-opentelemetry-node-autoinstrumentation": "0.12.0",
21918
- "@opentelemetry/propagator-jaeger": "2.10.0",
21918
+ "@opentelemetry/propagator-jaeger": "2.11.0",
21919
21919
  minimatch: "10.2.6",
21920
- "@aws-sdk/client-dynamodb": "3.1121.0",
21921
- "@aws-sdk/client-api-gateway": "3.1121.0",
21922
- "@aws-sdk/client-iam": "3.1121.0",
21923
- "@aws-sdk/client-bedrock-agentcore": "3.1121.0",
21924
- "@aws-sdk/client-bedrock-runtime": "3.1121.0",
21925
- "@aws-sdk/client-s3": "3.1121.0",
21926
- "@aws-sdk/client-sts": "3.1121.0",
21927
- "@aws-sdk/credential-providers": "3.1121.0",
21920
+ "deepmerge-ts": "8.0.2",
21921
+ mysql2: "3.24.3",
21922
+ "@aws-sdk/client-dynamodb": "3.1126.0",
21923
+ "@aws-sdk/client-api-gateway": "3.1126.0",
21924
+ "@aws-sdk/client-iam": "3.1126.0",
21925
+ "@aws-sdk/client-bedrock-agentcore": "3.1126.0",
21926
+ "@aws-sdk/client-bedrock-runtime": "3.1126.0",
21927
+ "@aws-sdk/client-s3": "3.1126.0",
21928
+ "@aws-sdk/client-sts": "3.1126.0",
21929
+ "@aws-sdk/client-cognito-identity-provider": "3.1126.0",
21930
+ "@aws-sdk/credential-providers": "3.1126.0",
21928
21931
  "@aws-sdk/credential-provider-cognito-identity": "3.972.69",
21929
- "@aws-sdk/client-secrets-manager": "3.1121.0",
21930
- "@aws-sdk/rds-signer": "3.1121.0",
21932
+ "@aws-sdk/client-secrets-manager": "3.1126.0",
21933
+ "@aws-sdk/rds-signer": "3.1126.0",
21931
21934
  "@smithy/server-apigateway": "0.3.3",
21932
21935
  "@smithy/server-node": "0.3.3",
21933
21936
  "@aws-lambda-powertools/logger": "2.35.0",
@@ -21935,7 +21938,7 @@ const NX_VERSION = {
21935
21938
  "@aws-lambda-powertools/parameters": "2.35.0",
21936
21939
  "@aws-lambda-powertools/tracer": "2.35.0",
21937
21940
  "@aws-lambda-powertools/parser": "2.35.0",
21938
- "@aws-sdk/client-appconfigdata": "3.1121.0",
21941
+ "@aws-sdk/client-appconfigdata": "3.1126.0",
21939
21942
  "@middy/core": "7.9.2",
21940
21943
  "@nxlv/python": "23.0.0",
21941
21944
  "@nx-extend/terraform": "10.4.1",
@@ -21950,14 +21953,14 @@ const NX_VERSION = {
21950
21953
  "@swc-node/register": "1.12.1",
21951
21954
  "@swc/core": "1.16.1",
21952
21955
  "@modelcontextprotocol/sdk": "1.30.0",
21953
- "@modelcontextprotocol/inspector": "2.4.0",
21956
+ "@modelcontextprotocol/inspector": "2.5.0",
21954
21957
  "@ag-ui/a2ui-toolkit": "0.0.4",
21955
21958
  "@ag-ui/aws-strands": "0.2.3",
21956
- "@ag-ui/client": "0.0.57",
21957
- "@ag-ui/core": "0.0.57",
21958
- "@ag-ui/encoder": "0.0.57",
21959
+ "@ag-ui/client": "0.0.59",
21960
+ "@ag-ui/core": "0.0.59",
21961
+ "@ag-ui/encoder": "0.0.59",
21959
21962
  "agent-chat-cli": "0.3.0",
21960
- "@copilotkit/react-core": "1.69.3",
21963
+ "@copilotkit/react-core": "1.70.1",
21961
21964
  rxjs: "7.8.2",
21962
21965
  "@strands-agents/sdk": "1.15.0",
21963
21966
  "@tanstack/react-router": "1.170.32",
@@ -21965,46 +21968,46 @@ const NX_VERSION = {
21965
21968
  "@tanstack/router-generator": "1.167.33",
21966
21969
  "@tanstack/virtual-file-routes": "1.162.0",
21967
21970
  "@tanstack/router-utils": "1.162.2",
21968
- "@cloudscape-design/board-components": "3.0.221",
21969
- "@cloudscape-design/chat-components": "1.0.165",
21970
- "@cloudscape-design/components": "3.0.1356",
21971
+ "@cloudscape-design/board-components": "3.0.222",
21972
+ "@cloudscape-design/chat-components": "1.0.166",
21973
+ "@cloudscape-design/components": "3.0.1359",
21971
21974
  "@cloudscape-design/global-styles": "1.0.67",
21972
21975
  "@tanstack/react-query": "5.102.8",
21973
21976
  "@tanstack/react-query-devtools": "5.102.8",
21974
21977
  "@trpc/tanstack-react-query": "11.18.0",
21975
21978
  "@trpc/client": "11.18.0",
21976
21979
  "@trpc/server": "11.18.0",
21977
- "@types/node": "26.4.0",
21978
- "@types/aws-lambda": "8.10.162",
21980
+ "@types/node": "26.4.1",
21981
+ "@types/aws-lambda": "8.10.163",
21979
21982
  "@types/cors": "2.8.19",
21980
21983
  "@types/pg": "8.23.1",
21981
21984
  "@types/ws": "8.18.1",
21982
21985
  "@types/express": "5.0.6",
21983
21986
  "@smithy/config-resolver": "4.7.2",
21984
21987
  "@smithy/node-config-provider": "4.6.2",
21985
- "@smithy/node-http-handler": "4.11.3",
21986
- "@smithy/types": "4.17.2",
21988
+ "@smithy/node-http-handler": "4.12.1",
21989
+ "@smithy/types": "4.18.0",
21987
21990
  "@vitest/coverage-v8": "4.1.11",
21988
21991
  "@vitest/ui": "4.1.11",
21989
- "@astrojs/react": "6.0.4",
21990
- "@astrojs/starlight": "0.41.10",
21991
- astro: "7.2.9",
21992
+ "@astrojs/react": "6.0.5",
21993
+ "@astrojs/starlight": "0.42.0",
21994
+ astro: "7.3.1",
21992
21995
  cookie: "2.0.1",
21993
21996
  aws4fetch: "1.0.20",
21994
21997
  "aws-cdk": "2.1139.0",
21995
- "aws-cdk-lib": "2.267.0",
21998
+ "aws-cdk-lib": "2.268.0",
21996
21999
  "aws-xray-sdk-core": "3.12.0",
21997
22000
  constructs: "10.8.1",
21998
22001
  cors: "2.8.6",
21999
22002
  chalk: "6.0.0",
22000
22003
  "class-variance-authority": "0.7.1",
22001
- clsx: "2.1.1",
22004
+ cn: "0.2.5",
22002
22005
  commander: "15.0.0",
22003
22006
  electrodb: "3.9.3",
22004
22007
  esbuild: "0.28.2",
22005
22008
  "event-source-polyfill": "1.0.31",
22006
22009
  "@types/event-source-polyfill": "1.0.5",
22007
- "@biomejs/biome": "2.5.11",
22010
+ "@biomejs/biome": "2.5.12",
22008
22011
  "@prisma/adapter-mariadb": "7.10.0",
22009
22012
  "@prisma/adapter-pg": "7.10.0",
22010
22013
  "@prisma/client": "7.10.0",
@@ -22015,8 +22018,8 @@ const NX_VERSION = {
22015
22018
  husky: "9.1.7",
22016
22019
  "fs-extra": "11.4.0",
22017
22020
  "@types/fs-extra": "11.0.4",
22018
- mariadb: "3.5.3",
22019
- mise: "2026.8.14",
22021
+ mariadb: "3.5.4",
22022
+ mise: "2026.9.1",
22020
22023
  npm: "12.0.2",
22021
22024
  "npm-check-updates": "23.1.0",
22022
22025
  "oidc-client-ts": "3.5.0",
@@ -22025,24 +22028,23 @@ const NX_VERSION = {
22025
22028
  "react-oidc-context": "3.3.1",
22026
22029
  react: "19.2.8",
22027
22030
  "react-dom": "19.2.8",
22028
- rolldown: "1.2.6",
22029
- "rolldown-plugin-dts": "0.28.3",
22031
+ rolldown: "1.2.7",
22032
+ "rolldown-plugin-dts": "0.28.5",
22030
22033
  shx: "0.4.0",
22031
22034
  "simple-git": "3.36.0",
22032
22035
  "source-map-support": "0.5.21",
22033
22036
  "starlight-blog": "0.29.0",
22034
22037
  tailwindcss: "4.3.3",
22035
22038
  "@tailwindcss/vite": "4.3.3",
22036
- tsx: "4.23.12",
22037
- "lucide-react": "1.37.0",
22039
+ tsx: "4.23.13",
22040
+ "lucide-react": "1.40.0",
22038
22041
  "radix-ui": "1.6.7",
22039
- shadcn: "4.19.0",
22042
+ shadcn: "4.21.0",
22040
22043
  "tw-animate-css": "1.4.0",
22041
- "tailwind-merge": "3.6.0",
22042
22044
  vite: "8.2.2",
22043
22045
  typescript: "6.0.3",
22044
22046
  vitest: "4.1.11",
22045
- jsdom: "27.4.0",
22047
+ jsdom: "29.1.1",
22046
22048
  zod: "4.5.4",
22047
22049
  ws: "8.21.3"
22048
22050
  }.nx;
@@ -55046,6 +55048,41 @@ const addToExistingProjectTool = (server, generators) => {
55046
55048
  });
55047
55049
  };
55048
55050
  //#endregion
55051
+ //#region ../nx-plugin/src/mcp-server/tools/best-practices.ts
55052
+ /**
55053
+ * Guide pages documenting behaviour that spans generators, so no single
55054
+ * generator owns them and `generator-guide` never returns them. Each is
55055
+ * described for the agent so it can pick the ones relevant to its task.
55056
+ */
55057
+ const BEST_PRACTICE_PAGES = {
55058
+ workspace: "Workspace layout, configuration and common commands",
55059
+ "typescript-project": "Conventions for TypeScript projects",
55060
+ "python-project": "Conventions for Python projects",
55061
+ security: "Security controls vended infrastructure carries, and the shared responsibility model",
55062
+ "runtime-config": "How generated projects discover one another through AWS AppConfig",
55063
+ "docker-bundling": "Building and deploying container images",
55064
+ "local-development": "Running projects locally with the serve and dev targets"
55065
+ };
55066
+ const BEST_PRACTICE_PAGE_NAMES = Object.keys(BEST_PRACTICE_PAGES);
55067
+ /**
55068
+ * Add a tool which serves the cross-cutting guide pages. Kept separate from
55069
+ * `general-guidance` so an agent fetches only the pages its task needs rather
55070
+ * than every page on every call.
55071
+ */
55072
+ const addBestPracticesTool = (server, generators) => {
55073
+ server.registerTool("best-practices", {
55074
+ title: "Best Practices",
55075
+ description: "Tool to retrieve guidance which spans generators, rather than applying to one in particular. Request the pages relevant to your task:\n" + Object.entries(BEST_PRACTICE_PAGES).map(([page, description]) => `- \`${page}\`: ${description}`).join("\n"),
55076
+ inputSchema: {
55077
+ packageManager: PackageManagerSchema.optional(),
55078
+ pages: array(_enum(BEST_PRACTICE_PAGE_NAMES)).min(1).describe("The guide pages to retrieve.")
55079
+ }
55080
+ }, async ({ packageManager, pages }) => ({ content: [{
55081
+ type: "text",
55082
+ text: await fetchGuidePages(pages, generators, packageManager)
55083
+ }] }));
55084
+ };
55085
+ //#endregion
55049
55086
  //#region ../nx-plugin/src/utils/iac-providers.ts
55050
55087
  /**
55051
55088
  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -55089,9 +55126,20 @@ Refer to the \`general-guidance\` tool for full workspace documentation includin
55089
55126
  };
55090
55127
  //#endregion
55091
55128
  //#region ../nx-plugin/src/mcp-server/tools/general-guidance.ts
55129
+ /**
55130
+ * The cross-cutting pages every agent needs regardless of task, inlined here
55131
+ * so a workspace's conventions land without a second tool call. The rest are
55132
+ * served on demand by `best-practices`.
55133
+ */
55134
+ const GENERAL_GUIDANCE_PAGES = [
55135
+ "workspace",
55136
+ "typescript-project",
55137
+ "python-project"
55138
+ ];
55092
55139
  const TOOL_SELECTION_GUIDE = `## Tool Selection Guide
55093
55140
 
55094
55141
  - Use the \`general-guidance\` tool for guidance and best practices for working with Nx and the Nx Plugin for AWS.
55142
+ - Use the \`best-practices\` tool for guidance which spans generators rather than applying to one in particular, such as workspace layout, security, runtime configuration, container builds and local development.
55095
55143
  - Use the \`create-workspace-command\` tool to discover how to create a workspace to start a new project.
55096
55144
  - Use the \`add-to-existing-project\` tool when adding the plugin to an existing Nx workspace or non-Nx monorepo, or when troubleshooting configuration errors in such a workspace.
55097
55145
  - Use the \`upgrade-workspace\` tool when upgrading Nx or the Nx Plugin for AWS to a newer version.
@@ -55170,13 +55218,9 @@ ${PACKAGE_MANAGERS.map((pm) => ` \`\`\`bash
55170
55218
 
55171
55219
  ## Detailed Guides
55172
55220
 
55173
- Please refer to the below documentation for important details regarding workspaces and working with TypeScript or Python projects.
55221
+ Please refer to the below documentation for important details regarding workspaces and working with TypeScript or Python projects. Use the \`best-practices\` tool for the remaining cross-cutting guides (${BEST_PRACTICE_PAGE_NAMES.filter((p) => !GENERAL_GUIDANCE_PAGES.includes(p)).map((p) => `\`${p}\``).join(", ")}).
55174
55222
 
55175
- ${await fetchGuidePages([
55176
- "workspace",
55177
- "typescript-project",
55178
- "python-project"
55179
- ], generators)}
55223
+ ${await fetchGuidePages([...GENERAL_GUIDANCE_PAGES], generators)}
55180
55224
 
55181
55225
  `
55182
55226
  }] }));
@@ -55865,6 +55909,7 @@ on AWS, if the generators apply to your use case.
55865
55909
  ${TOOL_SELECTION_GUIDE}
55866
55910
  ` });
55867
55911
  addGeneralGuidanceTool(server, generators);
55912
+ addBestPracticesTool(server, generators);
55868
55913
  addCreateWorkspaceCommandTool(server);
55869
55914
  addListGeneratorsTool(server, generators);
55870
55915
  addGeneratorGuideTool(server, generators);
@@ -56,7 +56,7 @@ Nx and the plugin are distributed as npm packages, so a project with no Node.js
56
56
  }
57
57
  ```
58
58
 
59
- Create that file, then run `nx init` and [add the plugin](#adding-the-plugin) as usual. Your existing language tooling is untouched — Nx projects generated by the plugin (including <Link path="guides/py-project">Python projects</Link>) live alongside your existing code, and you can wire your existing build into Nx incrementally.
59
+ Create that file, then run `nx init` and [add the plugin](#adding-the-plugin) as usual. Your existing language tooling is untouched — Nx projects generated by the plugin (including <Link path="guides/python-project">Python projects</Link>) live alongside your existing code, and you can wire your existing build into Nx incrementally.
60
60
 
61
61
  To bring your existing projects under Nx, you have a few options depending on the language:
62
62
 
@@ -124,12 +124,15 @@ It creates or updates the following files:
124
124
  - tsconfig.json a root TypeScript config referencing your workspace's projects, which Nx's TypeScript sync keeps up to date
125
125
  - tsconfig.base.json the shared compiler options the plugin's TypeScript projects extend (see below for what it carries)
126
126
  - pnpm-workspace.yaml (pnpm only) allow-lists the build scripts the plugin's dependencies need (`@swc/core`, `esbuild`, `nx`, `sharp`)
127
- - package.json convenience scripts for common tasks, plus the `@aws/nx-plugin`, `@aws/nx-plugin-mcp`, `nx`, `@nx/js`, `@nx/workspace`, `typescript` and Biome dev dependencies
127
+ - package.json convenience scripts for common tasks, a `prepare` script that installs the git hooks, plus the `@aws/nx-plugin`, `@aws/nx-plugin-mcp`, `nx`, `@nx/js`, `@nx/workspace`, `typescript`, husky and Biome dev dependencies
128
128
  - biome.json default Biome formatter and linter configuration
129
+ - .git-secrets/ the vendored [git-secrets](https://github.com/awslabs/git-secrets) script, with `.gitallowed` for false positives and a `.husky/pre-commit` hook that runs it — see <Link path="guides/workspace#git-secrets">Git Secrets</Link>
129
130
  - .mcp.json configures the MCP server for supported coding agents unless disabled (also .cursor/, .kiro/, .gemini/, .vscode/ and .codex/ equivalents). It runs the workspace's own `@aws/nx-plugin-mcp`, so the server always matches the version installed in your workspace
130
131
  </FileTree>
131
132
 
132
- The <Link path="get_started/building-with-ai">MCP server</Link> configuration can be disabled with `--mcp=false`.
133
+ The <Link path="get_started/building-with-ai">MCP server</Link> configuration can be disabled with `--mcp=false`, and the credential scanning hooks with `--gitSecrets=false`.
134
+
135
+ Files you already have are preserved: an existing `.husky/pre-commit` hook or `prepare` script is left as it is, and the generator prints what to add so credential scanning runs alongside your own checks. An existing `.gitallowed` keeps every pattern it has.
133
136
 
134
137
  <Drawer title="tsconfig.base.json" trigger="Click here to see the compiler options a created tsconfig.base.json carries.">
135
138
  The plugin's TypeScript projects rely on these compiler options. If a `tsconfig.base.json` already exists it is left as-is, so if you keep your own these are the options to align with:
@@ -159,7 +162,7 @@ pnpm skips install scripts for packages that aren't allow-listed. `init` allow-l
159
162
 
160
163
  #### `nx sync` hangs, or `plugin worker ... exited before the connection was established`
161
164
 
162
- If two different `nx` versions are present in the same node_modules tree (run `npm ls nx` to confirm), their plugin-worker IPC deadlocks. The `init` generator pins the root `nx` devDependency to the version the plugin's own `@nx/*` packages resolve, but a later install of another `@nx/*` package at a different patch version can reintroduce the mismatch. Align every `nx` and `@nx/*` entry in your root `package.json` to a single version and reinstall.
165
+ If two different `nx` versions are present in the same node_modules tree (run `npm ls nx` to confirm), their plugin-worker IPC deadlocks. `init` declares the `nx` and `@nx/*` versions the plugin is built against, but it never downgrades a version your workspace already has: a workspace already on a newer `nx` keeps it, and the plugin's own `@nx/*` packages pull in their own copy alongside it. Align every `nx` and `@nx/*` entry in your root `package.json` — and, where your package manager uses one, the dependency catalog — to a single version, then reinstall.
163
166
 
164
167
  #### `ts.readConfigFile is not a function`
165
168
 
@@ -3,6 +3,7 @@ title: Quick Start Guide
3
3
  description: "A quick start on how to use @aws/nx-plugin."
4
4
  ---
5
5
  import { Steps } from '@astrojs/starlight/components';
6
+ import Drawer from '@components/drawer.astro';
6
7
  import Link from '@components/link.astro';
7
8
  import Snippet from '@components/snippet.astro';
8
9
  import CreateNxWorkspaceCommand from '@components/create-nx-workspace-command.astro';
@@ -42,6 +43,8 @@ You will be prompted for your preferred infrastructure as code (IaC) provider, e
42
43
  <CreateNxWorkspaceCommand workspace="my-project" iac="terraform" />
43
44
  </Fragment>
44
45
  </Infrastructure>
46
+
47
+ You are also prompted for the container engine used by generators which build container images. Accept the default (`infer`) to select Docker if it is installed, otherwise Finch.
45
48
  :::
46
49
 
47
50
  Once complete, navigate to the project directory:
@@ -122,8 +125,12 @@ Changes to both your website and API will be reflected in real-time as both the
122
125
  Open `packages/infra/src/stacks/application-stack.ts` and add the following code:
123
126
 
124
127
  ```typescript
128
+ import {
129
+ DemoApi,
130
+ DemoWebsite,
131
+ UserIdentity,
132
+ } from '@my-project/common-constructs';
125
133
  import { Stack, StackProps } from 'aws-cdk-lib';
126
- import { DemoApi, DemoWebsite, UserIdentity } from '@my-project/common-constructs';
127
134
  import { Construct } from 'constructs';
128
135
 
129
136
  export class ApplicationStack extends Stack {
@@ -178,8 +185,8 @@ resource "aws_iam_policy" "api_invoke_policy" {
178
185
  Version = "2012-10-17"
179
186
  Statement = [
180
187
  {
181
- Effect = "Allow"
182
- Action = "execute-api:Invoke"
188
+ Effect = "Allow"
189
+ Action = "execute-api:Invoke"
183
190
  Resource = "${module.demo_api.api_execution_arn}/*/*"
184
191
  }
185
192
  ]
@@ -218,12 +225,20 @@ Next, run the following command to build your project:
218
225
 
219
226
  <PackageManagerShortCommand commands={["build"]} />
220
227
 
221
- :::tip[Fixing Lint Errors]
222
- If you encounter any lint errors, you can run the following command to automatically fix them.
228
+ :::tip[Fixing Lint and Formatting Errors]
229
+ If you encounter any lint or formatting errors, you can run the following command to automatically fix them.
223
230
 
224
231
  <PackageManagerShortCommand commands={["lint"]} />
225
232
  :::
226
233
 
234
+ :::tip[The workspace is out of sync]
235
+ If the build reports `The workspace is out of sync`, accept the prompt to sync the workspace or run the following sync command directly before retrying the build:
236
+
237
+ <NxCommands commands={["sync"]} />
238
+
239
+ This writes the TypeScript project references and `package.json` dependency entries your imports require.
240
+ :::
241
+
227
242
  Bootstrap your infrastructure:
228
243
 
229
244
  <Infrastructure>
@@ -272,6 +287,44 @@ This command will first run `terraform plan` to show you what changes will be ma
272
287
 
273
288
  Your website will be available at `http://localhost:4200`, and will point to the resources you deployed for the API and authentication.
274
289
 
290
+ To sign in, you will need to [create a user in the Cognito user pool](https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-create-user-accounts.html).
291
+
292
+ <Drawer title="Creating a user with the AWS CLI" trigger="Click here for instructions using the AWS CLI">
293
+
294
+ The following command creates a user in a user pool. You can find the user pool id in your deployment outputs, or in the [Amazon Cognito console](https://console.aws.amazon.com/cognito/). Substitute values for username, email, first and last name, and the temporary password.
295
+
296
+ ```sh
297
+ aws cognito-idp admin-create-user \
298
+ --user-pool-id <user pool id> \
299
+ --username <username> \
300
+ --user-attributes Name=email,Value=<email> Name=email_verified,Value=true Name=given_name,Value=<first name> Name=family_name,Value=<last name> \
301
+ --temporary-password '<temporary password>' \
302
+ --message-action SUPPRESS
303
+ ```
304
+
305
+ The first time you sign in as this user you are prompted to choose a new password, then to set up multi-factor authentication with either a code sent by SMS or a time-based one time password from an authenticator app.
306
+
307
+ </Drawer>
308
+
309
+ Your website is also served from CloudFront. Open its distribution domain name (which is printed to your terminal after deployment) to use the version running entirely on AWS.
310
+
311
+ ## Step 6: Clean Up
312
+
313
+ When you have finished, delete the resources you deployed to avoid ongoing costs:
314
+
315
+ <Infrastructure>
316
+ <Fragment slot="cdk">
317
+ <NxCommands commands={['destroy-sandbox infra']} />
318
+ </Fragment>
319
+ <Fragment slot="terraform">
320
+ <NxCommands commands={['destroy infra']} />
321
+ </Fragment>
322
+ </Infrastructure>
323
+
324
+ :::note[Retained Resources]
325
+ The Cognito user pool is created with deletion protection enabled, so it is not removed automatically. Delete it (and the IAM role Cognito uses to send SMS messages) manually if you no longer need them.
326
+ :::
327
+
275
328
  ---
276
329
 
277
330
  Congratulations! 🎉 You have successfully built and deployed a full-stack application using `@aws/nx-plugin`!
@@ -130,8 +130,9 @@ Below is a list of all files which have been generated by the `ts#api` generator
130
130
  - local-server.ts used when running the tRPC server locally
131
131
  - **router.ts** defines the tRPC router and all procedures
132
132
  - project.json
133
+ - vitest.config.mts test configuration
133
134
  - ...
134
- - vitest.workspace.ts
135
+ - vitest.config.mts root test configuration which discovers every project's tests
135
136
  </FileTree>
136
137
 
137
138
  Let us look at these key files:
@@ -151,13 +152,10 @@ export type AppRouter = typeof appRouter;
151
152
  ```
152
153
  The router defines the tRPC router for your API and is the place where you will declare all of your API methods. As you can see above, we have a method called `echo` with it's implementation in the `./procedures/echo.ts` file. The Lambda handler entrypoint is in `handler.ts`, which is configured automatically by the generator.
153
154
 
154
- ```ts {7-10}
155
+ ```ts {4-6}
155
156
  // packages/game-api/src/procedures/echo.ts
156
157
  import { publicProcedure } from '../init.js';
157
- import {
158
- EchoInputSchema,
159
- EchoOutputSchema,
160
- } from '../schema/echo.js';
158
+ import { EchoInputSchema, EchoOutputSchema } from '../schema/index.js';
161
159
 
162
160
  export const echo = publicProcedure
163
161
  .input(EchoInputSchema)
@@ -284,7 +282,10 @@ export class GameApi<
284
282
  } as FunctionProps,
285
283
  buildDefaultIntegration: (op, props: FunctionProps) => {
286
284
  const handler = new Function(scope, `GameApi${op}Handler`, props);
287
- handler.addEnvironment('RUNTIME_CONFIG_APP_ID', rc.appConfigApplicationId);
285
+ handler.addEnvironment(
286
+ 'RUNTIME_CONFIG_APP_ID',
287
+ rc.appConfigApplicationId,
288
+ );
288
289
  rc.grantReadAppConfig(handler);
289
290
  return {
290
291
  handler,
@@ -903,9 +904,7 @@ export class StoryAgent extends Construct implements IGrantable, IConnectable {
903
904
  }
904
905
  ```
905
906
 
906
- This configures a CDK `AgentRuntimeArtifact` which uploads your agent Docker image to ECR, and hosts it using AgentCore Runtime. Because we chose `--auth=cognito`, the construct requires the user pool/client identity and authorizes AgentCore Runtime invocations through Cognito, forwarding the caller's `Authorization` header. It also provisions the session bucket the Story Agent's `session.py` reads back at runtime — a KMS-encrypted S3 bucket with server access logs delivered to CloudWatch Logs — grants the agent read/write access to it, grants it access to invoke Bedrock models, and registers its ARN and bucket name in `RuntimeConfig` so both the agent (at runtime, via AppConfig) and the Game API (at synth time, via `invocationUrl`) can find it.
907
-
908
- You may notice an extra `Dockerfile`, that references the Docker image from the `story` project, allowing us to co-locate the Dockerfile and agent source code.
907
+ This configures a CDK `AgentRuntimeArtifact` which packages your agent's built code as a zip asset and hosts it using AgentCore Runtime. Because we chose `--auth=cognito`, the construct requires the user pool/client identity and authorizes AgentCore Runtime invocations through Cognito, forwarding the caller's `Authorization` header. It also provisions the session bucket the Story Agent's `session.py` reads back at runtime — a KMS-encrypted S3 bucket with server access logs delivered to CloudWatch Logs — grants the agent read/write access to it, grants it access to invoke Bedrock models, and registers its ARN and bucket name in `RuntimeConfig` so both the agent (at runtime, via AppConfig) and the Game API (at synth time, via `invocationUrl`) can find it.
909
908
 
910
909
  </details>
911
910
 
@@ -965,7 +964,6 @@ The `ts#mcp-server` generator generates these files.
965
964
  - sample-guidance.ts example resource
966
965
  - stdio.ts entry point for MCP with STDIO transport
967
966
  - http.ts entry point for MCP with Streamable HTTP transport
968
- - Dockerfile builds the image for AgentCore Runtime
969
967
  - rolldown.config.ts configuration for bundling the MCP server for deployment to AgentCore
970
968
  - common/constructs/
971
969
  - src
@@ -1277,9 +1275,12 @@ The `connection` generator generates/updates these files. Let us examine some of
1277
1275
  ```tsx
1278
1276
  // packages/game-ui/src/hooks/useGameApi.tsx
1279
1277
  import { useContext } from 'react';
1280
- import { GameApiTRPCContext } from '../components/GameApiClientProvider';
1278
+ import {
1279
+ GameApiTRPCContext,
1280
+ type GameApiTRPCContextValue,
1281
+ } from '../components/GameApiClientProvider';
1281
1282
 
1282
- export const useGameApi = () => {
1283
+ export const useGameApi = (): GameApiTRPCContextValue['optionsProxy'] => {
1283
1284
  const container = useContext(GameApiTRPCContext);
1284
1285
  if (!container) {
1285
1286
  throw new Error('useGameApi must be used within GameApiClientProvider');
@@ -1287,7 +1288,7 @@ export const useGameApi = () => {
1287
1288
  return container.optionsProxy;
1288
1289
  };
1289
1290
 
1290
- export const useGameApiClient = () => {
1291
+ export const useGameApiClient = (): GameApiTRPCContextValue['client'] => {
1291
1292
  const container = useContext(GameApiTRPCContext);
1292
1293
  if (!container) {
1293
1294
  throw new Error(
@@ -1399,6 +1400,7 @@ The `connection` generator generates/updates these files:
1399
1400
  - copilot/
1400
1401
  - **index.tsx** Shadcn-themed `CopilotChat` / `CopilotSidebar` / `CopilotPopup`
1401
1402
  - ShadcnAssistantMessage.tsx, ShadcnUserMessage.tsx, ShadcnChatInput.tsx, ShadcnCursor.tsx, copilot.css
1403
+ - story-agent-chat.tsx a `CopilotChat` pre-bound to the Story Agent's `agentId`
1402
1404
  - hooks/
1403
1405
  - **useAguiStoryAgent.tsx** Builds an `HttpAgent`, injects the Cognito bearer token, and pads `threadId` to AgentCore's 33-char session id
1404
1406
  - **main.tsx** Wraps `<App />` in `<AguiProvider>`
@@ -1478,6 +1480,8 @@ new ApplicationStage(app, 'dungeon-adventure-infra-sandbox', {
1478
1480
  },
1479
1481
  });
1480
1482
 
1483
+ // Define other instances of stages, such as beta and prod, below
1484
+
1481
1485
  app.synth();
1482
1486
  ```
1483
1487
 
@@ -1525,7 +1529,7 @@ The `run-many` command will run a target on multiple listed subprojects (`--all`
1525
1529
 
1526
1530
  You can also trigger a build (or any other task) for a single project target by running the target on the project directly. For example, to build the `@dungeon-adventure/infra` project, run the following command:
1527
1531
 
1528
- <NxCommands commands={['build infra']} />
1532
+ <NxCommands commands={['build @dungeon-adventure/infra']} />
1529
1533
 
1530
1534
  You can also omit the scope, and use the Nx shorthand syntax if you prefer:
1531
1535
 
@@ -1559,21 +1563,20 @@ Then, run the following command for a full build:
1559
1563
 
1560
1564
  <PackageManagerShortCommand commands={["build"]} />
1561
1565
 
1562
- You will be prompted with the following:
1566
+ You may be prompted with the following:
1563
1567
 
1564
1568
  ```bash
1565
1569
  NX The workspace is out of sync
1566
1570
 
1567
- [@nx/js:typescript-sync]: Some TypeScript configuration files are missing project references to the projects they depend on or contain outdated project references.
1568
-
1569
- This will result in an error in CI.
1571
+ [@nx/js:typescript-sync]: Some TypeScript configuration files are missing project references to the projects they depend on, contain stale project references, or have duplicate project references.
1572
+ [@aws/nx-plugin:ts#sync]: Some files are out of sync.
1570
1573
 
1571
1574
  ? Would you like to sync the identified changes to get your workspace up to date? …
1572
1575
  Yes, sync the changes and run the tasks
1573
1576
  No, run the tasks without syncing the changes
1574
1577
  ```
1575
1578
 
1576
- This message indicates that NX has detected some files which can be updated automatically for you. In this case, it is referring to the `tsconfig.json` files which do not have Typescript references set up on references projects.
1579
+ This message indicates that NX has detected some files which can be updated automatically for you. In this case, it is referring to the `tsconfig.json` files which do not have Typescript references set up on referenced projects, and to the workspace dependencies the `@aws/nx-plugin` sync generator declares for you.
1577
1580
 
1578
1581
  Select the **Yes, sync the changes and run the tasks** option to proceed. You should notice all of you IDE related import errors get automatically resolved as the sync generator will add the missing typescript references automatically!
1579
1582
 
@@ -170,11 +170,19 @@ The `DungeonDb` construct registers the deployed table name in <Link path="guide
170
170
 
171
171
  There's no need to deploy to AWS to try out our API — the `dev` target runs the Game API against [DynamoDB Local](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html). Because we connected the Game API to the `DungeonDb` project in Module 1, this target also starts DynamoDB Local automatically.
172
172
 
173
- First, fix any lint issues:
173
+ The procedures and MCP server we just wrote import `@dungeon-adventure/dungeon-db`, a new cross-project import, so start by syncing the workspace:
174
+
175
+ <NxCommands commands={["sync"]} />
176
+
177
+ <Aside type="tip" title="Why this step is needed">
178
+ `nx sync` declares `@dungeon-adventure/dungeon-db` in the `game-api` and `inventory` `package.json` files and adds the matching TypeScript project references for you, saving you from needing to add this by hand when declaring dependencies between projects.
179
+ </Aside>
180
+
181
+ Then fix any lint issues:
174
182
 
175
183
  <PackageManagerShortCommand commands={["lint"]} />
176
184
 
177
- Then build the codebase:
185
+ And build the codebase:
178
186
 
179
187
  <PackageManagerShortCommand commands={["build"]} />
180
188
 
@@ -240,6 +248,6 @@ We can try out the MCP server's tools with the [MCP Inspector](https://github.co
240
248
 
241
249
  <NxCommands commands={["mcp-server-inspect inventory"]} />
242
250
 
243
- This serves the MCP server locally (booting DynamoDB Local too) and launches the MCP Inspector at `http://localhost:6274` pre-configured to connect to it. Click **Connect**, switch to the **Tools** tab, click **List Tools**, and try `add-to-inventory` (e.g. `playerName: Alice`, `itemName: Rusty Sword`, `emoji: ⚔️`) followed by `list-inventory-items` to see it persisted to DynamoDB Local. Stop the server (`Ctrl+C`) when you're done.
251
+ This serves the MCP server locally (booting DynamoDB Local too) and launches the MCP Inspector at `http://localhost:6274` pre-configured to connect to it. Toggle the switch next to the `localhost:8000` server to connect, switch to the **Tools** tab, and try `add-to-inventory` (e.g. `playerName: Alice`, `itemName: Rusty Sword`, `emoji: ⚔️`) followed by `list-inventory-items` to see it persisted to DynamoDB Local. Stop the server (`Ctrl+C`) when you're done.
244
252
 
245
253
  Congratulations, you have built and tested your first tRPC API and MCP server against a local DynamoDB table! 🎉🎉🎉
@@ -47,6 +47,10 @@ If you encounter any lint errors, run the following command to automatically fix
47
47
  <PackageManagerShortCommand commands={["lint"]} />
48
48
  </Aside>
49
49
 
50
+ <Aside type="tip" title="The workspace is out of sync">
51
+ If the build reports `The workspace is out of sync`, run `nx sync` and build again.
52
+ </Aside>
53
+
50
54
  ### Chat with your Agent
51
55
 
52
56
  The generated `agent-chat` target opens an interactive REPL against your agent. It runs standalone and connects to your locally-running agent, so first start the agent's local server in one terminal:
@@ -27,7 +27,7 @@ Start the full local stack — the game-ui dev server together with a local Game
27
27
 
28
28
  <NxCommands commands={["dev game-ui"]} />
29
29
 
30
- The `dev` target on `game-ui` has `dependsOn` on `game-api:dev` and `dungeon_adventure.story:agent-dev`, so Nx spins up every project's local server in parallel. Through the connections we set up in Module 1, those in turn boot the Inventory MCP server and DynamoDB Local. Make sure your container engine is running, then open the dev server in a browser.
30
+ The `dev` target on `game-ui` has `dependsOn` on `game-api:dev` and `dungeon_adventure.story:agent-dev`, so Nx spins up every project's local server in parallel. Through the connections we set up in Module 1, those in turn boot the Inventory MCP server and DynamoDB Local. Make sure your container engine is running, then open the dev server at `http://localhost:4200/` in a browser.
31
31
 
32
32
  <Aside type="tip" title="No login locally">
33
33
  In `local-dev` mode the `CognitoAuth` component skips the Cognito login flow (there's no user pool running locally), so you'll land straight on the game without signing in. You'll create a real account when we deploy to AWS at the end of this module.
@@ -48,6 +48,7 @@ When you ran the `connection` generator for `game-ui → story` in <Link path="g
48
48
  - copilot/
49
49
  - index.tsx Re-exports themed `CopilotChat` / `CopilotSidebar` / `CopilotPopup`.
50
50
  - ShadcnAssistantMessage.tsx, ShadcnUserMessage.tsx, ShadcnChatInput.tsx, ShadcnCursor.tsx, copilot.css
51
+ - story-agent-chat.tsx A `CopilotChat` pre-bound to the Story Agent's `agentId`.
51
52
  - hooks/
52
53
  - useAguiStoryAgent.tsx Instantiates an `@ag-ui/client` `HttpAgent` pointing at the deployed Story Agent and pads `threadId` to AgentCore's 33-character minimum session id.
53
54
  - main.tsx Wraps `<App />` in `<AguiProvider>`
@@ -90,7 +91,7 @@ The `$playerName` syntax tells `@tanstack/react-router` to treat `playerName` as
90
91
  </TabItem>
91
92
  </Tabs>
92
93
 
93
- Once saved, the dev server at `http://localhost:4200/` should now let you start an adventure and chat with the Story Agent.
94
+ Once saved, the dev server should now let you start an adventure and chat with the Story Agent.
94
95
 
95
96
  <Image src={gameSelectPng} alt="game-select.png" width="600" height="309" />
96
97
  <div style="margin-top: -100px; margin-left: 100px;">
@@ -146,6 +147,10 @@ dungeon-adventure-infra-sandbox-Application.UserIdentityUserIdentityUserPoolIdXX
146
147
 
147
148
  Navigate to your CloudFront URL (`GameUIDistributionDomainName` from the CDK outputs), sign up for a new account, and play your game running entirely on AWS!
148
149
 
150
+ :::note[Signing up for the first time]
151
+ Cognito emails you a code to confirm your account, then asks you to set up multi-factor authentication (an authenticator app or an SMS code) before your first sign-in — the user pool `ts#website#auth` vends requires MFA. See <Link path="guides/react-website-auth#multi-factor-authentication-mfa">Multi-factor authentication</Link> for how to relax that.
152
+ :::
153
+
149
154
  ## Task 6: Mixing local and deployed components
150
155
 
151
156
  You've seen two ends of the spectrum: everything local (`dev`) and everything deployed. During day-to-day development it's often useful to mix the two — for example, iterate on website code against the *real* deployed API and agent, or run the API locally against the *real* DynamoDB table.
@@ -38,4 +38,13 @@ We recommend you try your hand at extending the codebase with the following capa
38
38
 
39
39
  This will prompt you for a list of stacks to delete which should comprise of the `dungeon-adventure-infra-sandbox/Application/GameUI/waf` and `dungeon-adventure-infra-sandbox/Application`.
40
40
 
41
- 2. Enter `Y` to continue. CloudFormation will destroy your stacks.
41
+ 2. Enter `y` to continue. CloudFormation will destroy your stacks.
42
+
43
+ :::caution[Two resources are kept on purpose]
44
+ Deleting the stacks leaves two resources behind, so a teardown can't take your users or their stories with it:
45
+
46
+ - The **Cognito user pool**, which `ts#website#auth` creates with deletion protection enabled.
47
+ - The **Story Agent's session bucket**, which holds the conversation history and defaults to `RemovalPolicy.RETAIN`.
48
+
49
+ Delete them by hand once you no longer need them — for the user pool, turn deletion protection off first.
50
+ :::