@aws/nx-plugin-mcp 1.0.0-rc.7 → 1.0.0-rc.71

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 (195) hide show
  1. package/bin/aws-nx-mcp.js +12317 -10933
  2. package/docs/get_started/building-with-ai.mdx +116 -0
  3. package/docs/get_started/concepts.mdx +67 -0
  4. package/docs/get_started/existing-project.mdx +180 -0
  5. package/docs/get_started/graph-builder.mdx +39 -0
  6. package/docs/get_started/quick-start.mdx +277 -0
  7. package/docs/get_started/tutorials/contribute-generator.mdx +408 -0
  8. package/docs/get_started/tutorials/dungeon-game/1.mdx +1301 -0
  9. package/docs/get_started/tutorials/dungeon-game/2.mdx +237 -0
  10. package/docs/get_started/tutorials/dungeon-game/3.mdx +76 -0
  11. package/docs/get_started/tutorials/dungeon-game/4.mdx +164 -0
  12. package/docs/get_started/tutorials/dungeon-game/overview.mdx +145 -0
  13. package/docs/get_started/tutorials/dungeon-game/wrap-up.mdx +41 -0
  14. package/docs/get_started/tutorials/existing-project.mdx +4 -0
  15. package/docs/get_started/upgrading.mdx +147 -0
  16. package/docs/guides/agentcore-gateway.mdx +490 -0
  17. package/docs/guides/agentcore-harness.mdx +275 -0
  18. package/docs/guides/astro-docs.mdx +8 -0
  19. package/docs/guides/connection/agentcore-gateway-agent.mdx +222 -0
  20. package/docs/guides/connection/agentcore-gateway-gateway.mdx +154 -0
  21. package/docs/guides/connection/agentcore-gateway-mcp.mdx +134 -0
  22. package/docs/guides/connection/py-agent-a2a.mdx +48 -16
  23. package/docs/guides/connection/py-agent-dynamodb.mdx +116 -0
  24. package/docs/guides/connection/py-agent-gateway.mdx +178 -0
  25. package/docs/guides/connection/py-agent-mcp.mdx +43 -14
  26. package/docs/guides/connection/py-agent-rdb.mdx +178 -0
  27. package/docs/guides/connection/py-fast-api-dynamodb.mdx +56 -0
  28. package/docs/guides/connection/py-fast-api-rdb.mdx +184 -0
  29. package/docs/guides/connection/py-mcp-server-dynamodb.mdx +116 -0
  30. package/docs/guides/connection/py-mcp-server-rdb.mdx +187 -0
  31. package/docs/guides/connection/react-agentcore-gateway.mdx +112 -0
  32. package/docs/guides/connection/react-agui.mdx +13 -13
  33. package/docs/guides/connection/react-fastapi.mdx +38 -2
  34. package/docs/guides/connection/react-py-agent.mdx +9 -15
  35. package/docs/guides/connection/react-smithy.mdx +3 -3
  36. package/docs/guides/connection/react-trpc.mdx +1 -1
  37. package/docs/guides/connection/react-ts-agent.mdx +8 -8
  38. package/docs/guides/connection/smithy-dynamodb.mdx +5 -5
  39. package/docs/guides/connection/smithy-rdb.mdx +9 -9
  40. package/docs/guides/connection/trpc-dynamodb.mdx +5 -5
  41. package/docs/guides/connection/trpc-rdb.mdx +6 -6
  42. package/docs/guides/connection/ts-agent-a2a.mdx +14 -11
  43. package/docs/guides/connection/ts-agent-dynamodb.mdx +5 -5
  44. package/docs/guides/connection/ts-agent-gateway.mdx +143 -0
  45. package/docs/guides/connection/ts-agent-mcp.mdx +12 -9
  46. package/docs/guides/connection/ts-agent-rdb.mdx +70 -25
  47. package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +5 -5
  48. package/docs/guides/connection/ts-mcp-server-rdb.mdx +68 -18
  49. package/docs/guides/connection.mdx +122 -5
  50. package/docs/guides/docker-bundling.mdx +69 -12
  51. package/docs/guides/fastapi.mdx +249 -9
  52. package/docs/guides/local-development.mdx +87 -0
  53. package/docs/guides/nx-generator.mdx +4 -3
  54. package/docs/guides/nx-migration.mdx +165 -0
  55. package/docs/guides/py-agent.mdx +264 -49
  56. package/docs/guides/py-dynamodb.mdx +476 -0
  57. package/docs/guides/py-mcp-server.mdx +61 -2
  58. package/docs/guides/py-rdb.mdx +265 -0
  59. package/docs/guides/python-lambda-function.mdx +1 -1
  60. package/docs/guides/react-website-auth.mdx +65 -4
  61. package/docs/guides/react-website.mdx +149 -30
  62. package/docs/guides/runtime-config.mdx +1 -1
  63. package/docs/guides/security.mdx +75 -0
  64. package/docs/guides/smithy-project.mdx +167 -0
  65. package/docs/guides/terraform-project.mdx +2 -2
  66. package/docs/guides/trpc.mdx +53 -16
  67. package/docs/guides/ts-agent.mdx +183 -10
  68. package/docs/guides/ts-dcr-proxy.mdx +569 -0
  69. package/docs/guides/ts-dynamodb.mdx +66 -242
  70. package/docs/guides/ts-lambda-function.mdx +1 -1
  71. package/docs/guides/ts-mcp-server.mdx +109 -29
  72. package/docs/guides/ts-nx-plugin.mdx +3 -3
  73. package/docs/guides/ts-rdb.mdx +113 -467
  74. package/docs/guides/ts-smithy-api.mdx +258 -18
  75. package/docs/guides/typescript-infrastructure.mdx +46 -24
  76. package/docs/guides/typescript-project.mdx +134 -27
  77. package/docs/guides/workspace.mdx +10 -3
  78. package/docs/snippets/agent/architecture.mdx +1 -1
  79. package/docs/snippets/agent/bedrock-deployment.mdx +9 -5
  80. package/docs/snippets/agent/runtime-arn.mdx +23 -2
  81. package/docs/snippets/agent/securing-your-agent.mdx +39 -0
  82. package/docs/snippets/api/access-logging.mdx +33 -0
  83. package/docs/snippets/api/cors-configuration-cdk-note.mdx +1 -1
  84. package/docs/snippets/api/cors-configuration-terraform-note.mdx +1 -1
  85. package/docs/snippets/api/type-safe-api-integrations.mdx +33 -2
  86. package/docs/snippets/api/waf-configuration.mdx +3 -3
  87. package/docs/snippets/connection/a2a-infrastructure.mdx +1 -1
  88. package/docs/snippets/connection/dynamodb-local-development.mdx +2 -2
  89. package/docs/snippets/connection/lambda-dynamodb-access.mdx +1 -1
  90. package/docs/snippets/connection/py-dynamodb-local-development.mdx +7 -0
  91. package/docs/snippets/connection/py-lambda-rdb-ssl-requirements.mdx +7 -0
  92. package/docs/snippets/connection/rdb-api-infrastructure.mdx +51 -19
  93. package/docs/snippets/dynamodb/deploying-table.mdx +166 -0
  94. package/docs/snippets/dynamodb/gsi-config.mdx +38 -0
  95. package/docs/snippets/dynamodb/infrastructure.mdx +33 -0
  96. package/docs/snippets/dynamodb/local-dev-start.mdx +13 -0
  97. package/docs/snippets/dynamodb/local-dev-windows.mdx +15 -0
  98. package/docs/snippets/lambda-function/deploying-your-function.mdx +3 -3
  99. package/docs/snippets/mcp/architecture.mdx +1 -1
  100. package/docs/snippets/mcp/bedrock-deployment.mdx +9 -5
  101. package/docs/snippets/mcp/config.mdx +3 -2
  102. package/docs/snippets/pdk-migration/example/01-migrate-api.mdx +7 -5
  103. package/docs/snippets/pdk-migration/example/02-migrate-website.mdx +29 -10
  104. package/docs/snippets/pdk-migration/example/03-migrate-infra.mdx +4 -4
  105. package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +5 -111
  106. package/docs/snippets/prerequisites.mdx +1 -4
  107. package/docs/snippets/rdb/architecture.mdx +38 -0
  108. package/docs/snippets/rdb/cluster-instances.mdx +31 -0
  109. package/docs/snippets/rdb/deletion-protection.mdx +34 -0
  110. package/docs/snippets/rdb/deploying.mdx +187 -0
  111. package/docs/snippets/rdb/encryption-key-rotation.mdx +30 -0
  112. package/docs/snippets/rdb/engine-version.mdx +63 -0
  113. package/docs/snippets/rdb/infrastructure.mdx +35 -0
  114. package/docs/snippets/rdb/logging-mysql.mdx +5 -0
  115. package/docs/snippets/rdb/logging-postgres.mdx +5 -0
  116. package/docs/snippets/rdb/performance-insights.mdx +34 -0
  117. package/docs/snippets/rdb/rds-proxy.mdx +50 -0
  118. package/docs/snippets/rdb/removal-policy.mdx +57 -0
  119. package/docs/snippets/rdb/serverless-capacity.mdx +32 -0
  120. package/docs/snippets/recommended-prerequisites.mdx +10 -0
  121. package/docs/snippets/required-prerequisites.mdx +1 -4
  122. package/docs/snippets/runtime-config-app-id-note.mdx +8 -0
  123. package/docs/snippets/shared-constructs.mdx +1 -1
  124. package/docs/snippets/trivy-image-scan.mdx +37 -0
  125. package/generators.json +152 -10
  126. package/package.json +1 -1
  127. package/src/agentcore-gateway/agent-connection/schema.json +31 -0
  128. package/src/agentcore-gateway/gateway-connection/schema.json +31 -0
  129. package/src/agentcore-gateway/mcp-connection/schema.json +31 -0
  130. package/src/agentcore-gateway/react-connection/schema.json +31 -0
  131. package/src/agentcore-gateway/schema.json +72 -0
  132. package/src/agentcore-harness/schema.json +53 -0
  133. package/src/connection/schema.json +5 -0
  134. package/src/infra/app/schema.json +5 -0
  135. package/src/init/schema.json +35 -0
  136. package/src/internal/test-matrix/schema.json +21 -0
  137. package/src/license/schema.json +5 -0
  138. package/src/preset/schema.json +16 -5
  139. package/src/py/agent/a2a-connection/schema.json +5 -0
  140. package/src/py/agent/gateway-connection/schema.json +31 -0
  141. package/src/py/agent/mcp-connection/schema.json +5 -0
  142. package/src/py/agent/react-connection/schema.json +5 -0
  143. package/src/py/agent/schema.json +15 -1
  144. package/src/py/api/schema.json +5 -0
  145. package/src/py/dynamodb/agent-connection/schema.json +27 -0
  146. package/src/py/dynamodb/fast-api-connection/schema.json +23 -0
  147. package/src/py/dynamodb/mcp-server-connection/schema.json +27 -0
  148. package/src/py/dynamodb/schema.json +76 -0
  149. package/src/py/fast-api/react/schema.json +5 -0
  150. package/src/py/fast-api/schema.json +6 -0
  151. package/src/py/lambda-function/schema.json +5 -0
  152. package/src/py/mcp-server/schema.json +6 -0
  153. package/src/py/project/schema.json +5 -0
  154. package/src/py/rdb/agent-connection/schema.json +27 -0
  155. package/src/py/rdb/fast-api-connection/schema.json +23 -0
  156. package/src/py/rdb/mcp-server-connection/schema.json +27 -0
  157. package/src/py/rdb/schema.json +78 -0
  158. package/src/smithy/project/schema.json +28 -1
  159. package/src/smithy/react-connection/schema.json +5 -0
  160. package/src/smithy/ts/api/schema.json +6 -0
  161. package/src/terraform/project/schema.json +5 -0
  162. package/src/trpc/backend/schema.json +6 -0
  163. package/src/trpc/react/schema.json +5 -0
  164. package/src/ts/agent/a2a-connection/schema.json +5 -0
  165. package/src/ts/agent/gateway-connection/schema.json +31 -0
  166. package/src/ts/agent/mcp-connection/schema.json +5 -0
  167. package/src/ts/agent/react-connection/schema.json +5 -0
  168. package/src/ts/agent/schema.json +14 -0
  169. package/src/ts/api/schema.json +5 -0
  170. package/src/ts/astro-docs/schema.json +3 -3
  171. package/src/ts/dcr-proxy/schema.json +44 -0
  172. package/src/ts/docs/schema.json +3 -3
  173. package/src/ts/dynamodb/agent-connection/schema.json +5 -0
  174. package/src/ts/dynamodb/mcp-server-connection/schema.json +5 -0
  175. package/src/ts/dynamodb/schema.json +26 -2
  176. package/src/ts/dynamodb/smithy-connection/schema.json +5 -0
  177. package/src/ts/dynamodb/trpc-connection/schema.json +5 -0
  178. package/src/ts/lambda-function/schema.json +5 -0
  179. package/src/ts/lib/schema.json +5 -0
  180. package/src/ts/mcp-server/schema.json +6 -0
  181. package/src/ts/nx-generator/schema.json +5 -0
  182. package/src/ts/nx-migration/schema.json +63 -0
  183. package/src/ts/nx-plugin/schema.json +5 -0
  184. package/src/ts/rdb/agent-connection/schema.json +5 -0
  185. package/src/ts/rdb/mcp-server-connection/schema.json +5 -0
  186. package/src/ts/rdb/schema.json +7 -1
  187. package/src/ts/rdb/smithy-connection/schema.json +5 -0
  188. package/src/ts/rdb/trpc-connection/schema.json +5 -0
  189. package/src/ts/react-website/app/schema.json +12 -6
  190. package/src/ts/react-website/cognito-auth/schema.json +5 -0
  191. package/src/ts/react-website/runtime-config/schema.json +5 -0
  192. package/src/ts/website/app/schema.json +11 -6
  193. package/src/ts/website/auth/schema.json +5 -0
  194. /package/docs/snippets/connection/{lambda-rdb-ssl-requirements.mdx → ts-lambda-rdb-ssl-requirements.mdx} +0 -0
  195. /package/docs/snippets/connection/{mcp-server-rdb-ssl-requirements.mdx → ts-mcp-server-rdb-ssl-requirements.mdx} +0 -0
@@ -1,12 +1,14 @@
1
1
  ---
2
2
  title: tRPC
3
3
  description: Reference documentation for tRPC
4
- generator: ts#trpc-api
4
+ generator: ts#api
5
5
  when:
6
6
  framework: [trpc]
7
7
  infra: [rest-lambda, http-lambda]
8
8
  ---
9
- import { FileTree, Tabs, TabItem } from '@astrojs/starlight/components';
9
+ import { FileTree, Tabs, TabItem, CardGrid } from '@astrojs/starlight/components';
10
+ import Astro from '@astrojs/react';
11
+ import ConnectionCard from '@components/connection-card.astro';
10
12
  import Link from '@components/link.astro';
11
13
  import RunGenerator from '@components/run-generator.astro';
12
14
  import GeneratorParameters from '@components/generator-parameters.astro';
@@ -25,11 +27,11 @@ The tRPC API generator creates a new tRPC API with AWS CDK or Terraform infrastr
25
27
 
26
28
  You can generate a new tRPC API in two ways:
27
29
 
28
- <RunGenerator generator="ts#trpc-api" />
30
+ <RunGenerator generator="ts#api" requiredParameters={{ framework: 'trpc' }} />
29
31
 
30
32
  ### Options
31
33
 
32
- <GeneratorParameters generator="ts#trpc-api" />
34
+ <GeneratorParameters generator="ts#api" />
33
35
 
34
36
  <Snippet name="api/api-choice-note" />
35
37
 
@@ -64,6 +66,7 @@ The generator will create the following project structure in the `<directory>/<a
64
66
  - client
65
67
  - index.ts Type-safe client for machine-to-machine API calls
66
68
  - tsconfig.json TypeScript configuration
69
+ - package.json Project manifest defining the project's package name and dependencies
67
70
  - project.json Project configuration and build targets
68
71
 
69
72
  </FileTree>
@@ -138,7 +141,7 @@ The example `echo` procedure is generated for you in `src/procedures/echo.ts`:
138
141
  export const echo = publicProcedure
139
142
  .input(EchoInputSchema)
140
143
  .output(EchoOutputSchema)
141
- .query((opts) => ({ result: opts.input.message }));
144
+ .query((opts) => ({ message: opts.input.message }));
142
145
  ```
143
146
 
144
147
  To break down the above:
@@ -478,7 +481,7 @@ export interface IIdentityContext {
478
481
 
479
482
  Note that we define an additional _optional_ property on the context. tRPC manages ensuring that this is defined in procedures which have correctly configured this middleware.
480
483
 
481
- Next, the middleware itself. The generator wires the authorizer to accept ID tokens, so `cognito:username` is the canonical username claim; we fall back to `username` for access tokens in case you reconfigure the authorizer:
484
+ Next, the middleware itself:
482
485
 
483
486
  ```ts
484
487
  import { initTRPC, TRPCError } from '@trpc/server';
@@ -503,7 +506,7 @@ export const createIdentityPlugin = () => {
503
506
  | undefined;
504
507
 
505
508
  const sub = claims?.sub;
506
- const username = claims?.['cognito:username'] ?? claims?.username;
509
+ const username = claims?.username;
507
510
 
508
511
  if (!sub || !username) {
509
512
  throw new TRPCError({
@@ -541,14 +544,14 @@ export const me = publicProcedure
541
544
  }));
542
545
  ```
543
546
 
544
- :::tip[Verifying the token]
545
- You don't need `aws-jwt-verify` or any other JWT-verification library here — the API Gateway Cognito User Pools authorizer has already verified the signature, issuer, audience, and expiry by the time your Lambda runs. If any of those checks fail, API Gateway returns `401 Unauthorized` and your handler is never invoked.
547
+ :::tip[No token verification required]
548
+ You don't need `aws-jwt-verify` or any other JWT-verification library here — the API Gateway Cognito User Pools authorizer has already verified the signature, issuer, scopes, and expiry by the time your Lambda runs. If any of those checks fail, API Gateway returns `401 Unauthorized` and your handler is never invoked.
546
549
  :::
547
550
  </OptionFilter>
548
551
 
549
552
  ## Deploying your tRPC API
550
553
 
551
- The tRPC API generator creates CDK or Terraform infrastructure as code based on your selected `iacProvider`. You can use this to deploy your tRPC API.
554
+ The tRPC API generator creates CDK or Terraform infrastructure as code based on your selected `iac`. You can use this to deploy your tRPC API.
552
555
 
553
556
  <Infrastructure>
554
557
  <Fragment slot="cdk">
@@ -556,7 +559,7 @@ The CDK construct for deploying your API lives in the `common/constructs` folder
556
559
 
557
560
  <OptionFilter when={{ auth: ['iam', 'custom'] }} description="CDK usage for IAM or Custom authentication">
558
561
  ```ts {6-8}
559
- import { MyApi } from ':my-scope/common-constructs';
562
+ import { MyApi } from '@my-scope/common-constructs';
560
563
 
561
564
  export class ExampleStack extends Stack {
562
565
  constructor(scope: Construct, id: string) {
@@ -574,8 +577,8 @@ When using `Custom` auth, the construct creates a Lambda Authorizer internally f
574
577
  </OptionFilter>
575
578
 
576
579
  <OptionFilter when={{ auth: 'cognito' }} description="CDK usage with Cognito authentication — pass the identity construct">
577
- ```ts {6,9}
578
- import { MyApi, UserIdentity } from ':my-scope/common-constructs';
580
+ ```ts {6,10}
581
+ import { MyApi, UserIdentity } from '@my-scope/common-constructs';
579
582
 
580
583
  export class ExampleStack extends Stack {
581
584
  constructor(scope: Construct, id: string) {
@@ -630,7 +633,7 @@ module "my_api" {
630
633
  </OptionFilter>
631
634
 
632
635
  <OptionFilter when={{ auth: 'cognito' }} description="Terraform usage with Cognito authentication — supply user pool and client">
633
- ```hcl {1-3, 8-9}
636
+ ```hcl {1-3, 8, 10-11}
634
637
  module "asset_bucket" {
635
638
  source = "../../common/terraform/src/core/asset-bucket"
636
639
  }
@@ -726,12 +729,18 @@ When using `Custom` auth, your API is protected by a Lambda Authorizer that **de
726
729
  <Snippet name="api/waf-configuration" parentHeading="WAF" />
727
730
  </OptionFilter>
728
731
 
732
+ <OptionFilter when={{ infra: 'rest-lambda' }} description="Access logging — REST APIs log requests to CloudWatch by default">
733
+ ### Access logging
734
+
735
+ <Snippet name="api/access-logging" parentHeading="Access logging" />
736
+ </OptionFilter>
737
+
729
738
  ### Integrations
730
739
 
731
740
  <Snippet name="api/type-safe-api-integrations" parentHeading="Integrations" />
732
741
 
733
742
  :::tip[CDK Type-Safe Integrations]
734
- If you selected CDK for your `iacProvider`, when you add or remove a procedure in your tRPC API, these changes will be reflected immediately in the CDK construct without the need to rebuild.
743
+ If you selected CDK for your `iac`, when you add or remove a procedure in your tRPC API, these changes will be reflected immediately in the CDK construct without the need to rebuild.
735
744
  :::
736
745
 
737
746
  <OptionFilter when={{ auth: 'iam' }} description="Granting API invoke access — IAM-authenticated APIs only">
@@ -805,7 +814,7 @@ This will automatically reload when you make changes to your API.
805
814
  You can create a tRPC client to invoke your API in a type-safe manner. If you are calling your tRPC API from another backend, you can use the client in `src/client/index.ts`, for example:
806
815
 
807
816
  ```ts
808
- import { createMyApiClient } from ':my-scope/my-api';
817
+ import { createMyApiClient } from '@my-scope/my-api';
809
818
 
810
819
  const client = createMyApiClient({ url: 'https://my-api-url.example.com/' });
811
820
 
@@ -817,3 +826,31 @@ If you are calling your API from a React website, consider using the <Link path=
817
826
  ## More Information
818
827
 
819
828
  For more information about tRPC, please refer to the [tRPC documentation](https://trpc.io/docs).
829
+
830
+ ## Connections
831
+
832
+ Use the <Link path="guides/connection">`connection`</Link> generator to integrate this project with others in your workspace. The following connections involve this project:
833
+
834
+ <CardGrid>
835
+ <ConnectionCard
836
+ title="React to tRPC"
837
+ description="Call a tRPC API from a React website"
838
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-trpc`}
839
+ source="react"
840
+ target="trpc"
841
+ />
842
+ <ConnectionCard
843
+ title="tRPC API to Relational Database"
844
+ description="Connect a tRPC API to an Aurora relational database"
845
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/trpc-rdb`}
846
+ source="trpc"
847
+ target="aurora"
848
+ />
849
+ <ConnectionCard
850
+ title="tRPC API to TypeScript DynamoDB"
851
+ description="Connect a tRPC API to a DynamoDB table"
852
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/trpc-dynamodb`}
853
+ source="trpc"
854
+ target="dynamodb"
855
+ />
856
+ </CardGrid>
@@ -4,7 +4,9 @@ description: Generate a TypeScript Agent for building AI agents with tools and d
4
4
  generator: ts#agent
5
5
  ---
6
6
 
7
- import { FileTree, Tabs, TabItem } from '@astrojs/starlight/components';
7
+ import { FileTree, Tabs, TabItem, CardGrid } from '@astrojs/starlight/components';
8
+ import Astro from '@astrojs/react';
9
+ import ConnectionCard from '@components/connection-card.astro';
8
10
  import RunGenerator from '@components/run-generator.astro';
9
11
  import NxCommands from '@components/nx-commands.astro';
10
12
  import Link from '@components/link.astro';
@@ -58,6 +60,7 @@ The generator will add the following files to your existing TypeScript project.
58
60
  - init.ts tRPC initialization
59
61
  - router.ts tRPC router with agent procedures
60
62
  - agent.ts Main agent definition with sample tools
63
+ - session.ts Resolves the SessionManager used to persist conversation state
61
64
  - client.ts Vended client for invoking your agent
62
65
  - agent-core-trpc-client.ts Client factory for connecting to agents on AgentCore Runtime
63
66
  - Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
@@ -77,6 +80,7 @@ The entry point uses the [Strands A2A Express Server](https://strandsagents.com/
77
80
  - agent/ (or custom name if specified)
78
81
  - index.ts A2A Express server entry point
79
82
  - agent.ts Main agent definition with sample tools
83
+ - session.ts Resolves the SessionManager used to persist conversation state
80
84
  - Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
81
85
  - package.json Updated with Strands and Express dependencies
82
86
  - project.json Updated with agent serve targets
@@ -94,6 +98,7 @@ The entry point uses [`@ag-ui/aws-strands`](https://www.npmjs.com/package/@ag-ui
94
98
  - agent/ (or custom name if specified)
95
99
  - index.ts AG-UI server entry point (Express + SSE)
96
100
  - agent.ts Main agent definition with sample tools
101
+ - session.ts Resolves the SessionManager used to persist conversation state
97
102
  - Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
98
103
  - package.json Updated with Strands and AG-UI dependencies
99
104
  - project.json Updated with agent serve targets
@@ -183,7 +188,7 @@ const letterCounter = tool({
183
188
  });
184
189
 
185
190
  // Add tools to your agent
186
- export const getAgent = async (sessionId: string) => {
191
+ export const getAgent = async () => {
187
192
  return new Agent({
188
193
  systemPrompt: 'You are a helpful assistant with access to various tools.',
189
194
  tools: [letterCounter],
@@ -261,19 +266,61 @@ Most users will not need to modify `index.ts` — edit `agent.ts` to change tool
261
266
 
262
267
  ### Local Development
263
268
 
264
- The generator configures a target named `<your-agent-name>-serve`, which starts your Agent locally for development and testing.
269
+ To run your Agent (and everything connected to it) locally, use the project's `dev` target:
265
270
 
266
- <NxCommands commands={['agent-serve your-project']} />
271
+ <NxCommands commands={['dev your-project']} />
267
272
 
268
- This command uses `tsx --watch` to automatically restart the server when files change. The agent will be available at `http://localhost:8081` (or the assigned port if you have multiple agents).
273
+ If you have added multiple components to your project (agents, MCP servers, etc.), this starts them all. To run just this agent, target its `<your-agent-name>-dev` target:
274
+
275
+ <NxCommands commands={['agent-dev your-project']} />
276
+
277
+ This uses `tsx --watch` to automatically restart the server when files change. The agent will be available at `http://localhost:8081` (or the assigned port if you have multiple agents).
269
278
 
270
279
  ### Chat with Your Agent
271
280
 
272
- The generator configures a `<your-agent-name>-chat` Nx target that depends on `<your-agent-name>-serve-local`. Running it starts the agent locally and drops you into an interactive terminal chat:
281
+ The generator configures a `<your-agent-name>-chat` Nx target that drops you into an interactive terminal chat with your agent.
282
+
283
+ The chat target runs standalone. By default it connects to your locally running agent, so start the agent's `<your-agent-name>-dev` target first (in a separate terminal):
284
+
285
+ <NxCommands commands={['agent-dev your-project']} />
286
+
287
+ Then, in another terminal, start the chat:
273
288
 
274
289
  <NxCommands commands={['run your-project:agent-chat']} />
275
290
 
276
- For **HTTP** (tRPC over WebSocket) agents, the generator also emits a tiny `scripts/<your-agent-name>/chat.ts` that wraps the generated `<Agent>Client.local({ url })` so you can customize it as you evolve the agent's input shape.
291
+ The generator emits a `scripts/<your-agent-name>/chat.ts` for every protocol. You can customize it as you evolve the agent's input shape. It connects to the local agent by default, or to your deployed agent when `RUNTIME_CONFIG_APP_ID` is set (see [Chat with your deployed agent](#chat-with-your-deployed-agent) below).
292
+
293
+ <OptionFilter when={{ infra: 'agentcore' }} description="Deployed agent chat details">
294
+ #### Chat with your deployed agent
295
+
296
+ To chat with your agent deployed to Bedrock AgentCore, set the `RUNTIME_CONFIG_APP_ID` environment variable to the AppConfig application id of the deployment (output as `RuntimeConfigApplicationId` by the deployed stack). The chat script resolves your agent's runtime ARN from runtime configuration and connects to the deployed endpoint:
297
+
298
+ <Tabs syncKey="auth">
299
+ <TabItem label="IAM" _filter={{ auth: 'iam' }}>
300
+ For IAM-authenticated agents, requests are signed with [SigV4](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv.html) using your default AWS credentials. Ensure the environment has AWS credentials with permission to invoke the runtime:
301
+
302
+ <NxCommands commands={['run your-project:agent-chat']} env={{ RUNTIME_CONFIG_APP_ID: '<app-id>' }} />
303
+ </TabItem>
304
+
305
+ <TabItem label="Cognito" _filter={{ auth: 'cognito' }}>
306
+ For Cognito-authenticated agents, provide a Cognito access token via the `AGENT_ACCESS_TOKEN` environment variable, which is sent as a bearer token:
307
+
308
+ <NxCommands commands={['run your-project:agent-chat']} env={{ RUNTIME_CONFIG_APP_ID: '<app-id>', AGENT_ACCESS_TOKEN: '<access-token>' }} />
309
+
310
+ You can obtain an access token using the AWS CLI's `cognito-idp admin-initiate-auth` command, for example:
311
+
312
+ ```bash
313
+ aws cognito-idp admin-initiate-auth \
314
+ --user-pool-id <user-pool-id> \
315
+ --client-id <user-pool-client-id> \
316
+ --auth-flow ADMIN_NO_SRP_AUTH \
317
+ --auth-parameters USERNAME=<username>,PASSWORD=<password> \
318
+ --query 'AuthenticationResult.AccessToken' \
319
+ --output text
320
+ ```
321
+ </TabItem>
322
+ </Tabs>
323
+ </OptionFilter>
277
324
 
278
325
  <OptionFilter when={{ infra: 'agentcore' }} description="Bedrock AgentCore Runtime deployment details">
279
326
  ## Deploying Your Agent to Bedrock AgentCore Runtime
@@ -292,6 +339,10 @@ The generator configures a `<your-agent-name>-docker` target which copies the `D
292
339
 
293
340
  A `docker` target is also generated which prepares the docker context for all agents if you have multiple defined.
294
341
 
342
+ ### Image Scanning
343
+
344
+ <Snippet name="trivy-image-scan" parentHeading="Image Scanning" />
345
+
295
346
  ### Observability
296
347
 
297
348
  Your agent is automatically configured with observability using the [AWS Distro for Open Telemetry](https://aws.amazon.com/otel/) (ADOT), by configuring auto-instrumentation in your `Dockerfile`.
@@ -299,6 +350,29 @@ Your agent is automatically configured with observability using the [AWS Distro
299
350
  You can find traces in the CloudWatch AWS Console, by selecting "GenAI Observability" in the menu. Note that for traces to be populated you will need to enable [Transaction Search](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Transaction-Search.html).
300
351
 
301
352
  For more details, refer to the [AgentCore documentation on observability](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability-configure.html).
353
+
354
+ ### Session Management
355
+
356
+ The `session` option controls how your agent persists conversation state (message history, tool state, etc.) across invocations, using the Strands SDK's [SessionManager](https://strandsagents.com/docs/user-guide/concepts/agents/session-management/):
357
+
358
+ - **`s3`** (default): The CDK/Terraform infrastructure provisions a dedicated S3 bucket for session data, encrypted with a dedicated KMS key and with all public access blocked; server access logs are delivered to a CloudWatch Logs log group via the same key. The agent's IAM role is granted read/write/list/delete access to the bucket and decrypt/generate-data-key access to the key, and the bucket name is registered alongside the agent's ARN in AppConfig runtime configuration.
359
+ - **`in-memory`**: No bucket is provisioned. Conversation state is kept in memory only for the lifetime of the running process and does not survive restarts or scale-in.
360
+
361
+ This is implemented in the generated `session.ts`, which exports a `getSessionManager()` function resolving a `SessionManager` for the current session.
362
+
363
+ <OptionFilter when={{ protocol: 'ag-ui' }} description="AG-UI session wiring">
364
+ Since AG-UI clones a template agent per conversation thread, `getSessionManager` is wired in as a `sessionManagerProvider` on the `StrandsAgent` config in `index.ts`, so a fresh `SessionManager` is resolved for each thread rather than baked into the shared template agent.
365
+ </OptionFilter>
366
+
367
+ <OptionFilter when={{ protocol: ['http', 'a2a'] }} description="HTTP/A2A session wiring">
368
+ Since `withSessionId` already caches one `Agent` instance per session, `getSessionManager` is called directly inside `getAgent`'s `new Agent({ sessionManager: await getSessionManager() })` call in `agent.ts`.
369
+ </OptionFilter>
370
+
371
+ The session ID itself comes from the AgentCore Runtime session (propagated via the `x-amzn-bedrock-agentcore-runtime-session-id` header for A2A/AG-UI, or the WebSocket connection context for HTTP/tRPC) and is bound to an [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage)-based context so `getCurrentSessionId()` can resolve it anywhere in the request — including in any downstream MCP or A2A clients wired up via the <Link path="/guides/connection">`connection` generator</Link>, so the whole call chain shares a consistent session.
372
+
373
+ :::note[Local Development]
374
+ When running locally (`LOCAL_DEV=true`, set automatically by the `-dev` target), session data is always stored on disk under `tmp/agents/strands/<agent-name>` at the workspace root, regardless of the configured `session` option, for convenience.
375
+ :::
302
376
  </OptionFilter>
303
377
 
304
378
  ## Invoking your Agent
@@ -318,7 +392,7 @@ import { AgentClient } from '../packages/<project>/src/agent/client.js';
318
392
 
319
393
  const client = AgentClient.local({ url: 'http://localhost:8081/ws' });
320
394
 
321
- client.invoke.subscribe({ message: 'what is 1 plus 1?' }, { onData: console.log });
395
+ client.invoke.subscribe({ prompt: 'what is 1 plus 1?' }, { onData: console.log });
322
396
  ```
323
397
 
324
398
  :::tip[Quick Testing]
@@ -352,7 +426,7 @@ const client = AgentClient.withIamAuth({
352
426
  agentRuntimeArn: 'arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/my-agent',
353
427
  });
354
428
 
355
- client.invoke.subscribe({ message: 'what is 1 plus 1?' }, {
429
+ client.invoke.subscribe({ prompt: 'what is 1 plus 1?' }, {
356
430
  onData: (message) => console.log(message),
357
431
  onError: (error) => console.error(error),
358
432
  onComplete: () => console.log('Done'),
@@ -375,7 +449,7 @@ const client = AgentClient.withJwtAuth({
375
449
  accessTokenProvider: async () => `<access-token>`,
376
450
  });
377
451
 
378
- client.invoke.subscribe({ message: 'what is 1 plus 1?' }, {
452
+ client.invoke.subscribe({ prompt: 'what is 1 plus 1?' }, {
379
453
  onData: console.log,
380
454
  });
381
455
  ```
@@ -434,3 +508,102 @@ To invoke your AG-UI agent from a React website, use the <Link path="/guides/con
434
508
 
435
509
  Refer to the <Link path="/guides/connection/react-agui">`connection` generator guide</Link> for details about how the connection is set up.
436
510
  </OptionFilter>
511
+
512
+ ## Securing your Agent
513
+
514
+ <Snippet name="agent/securing-your-agent" parentHeading="Securing your Agent" />
515
+
516
+ ```typescript
517
+ // agent.ts
518
+ import { Agent } from '@strands-agents/sdk';
519
+ import { BedrockModel } from '@strands-agents/sdk/models/bedrock';
520
+
521
+ const model = new BedrockModel({
522
+ modelId: process.env.MODEL_ID,
523
+ guardrailConfig: {
524
+ guardrailIdentifier: process.env.GUARDRAIL_ID!,
525
+ guardrailVersion: process.env.GUARDRAIL_VERSION ?? 'DRAFT',
526
+ },
527
+ });
528
+
529
+ const agent = new Agent({ model, /* ... */ });
530
+ ```
531
+
532
+ See the Strands [Guardrails](https://strandsagents.com/docs/user-guide/safety-security/guardrails/) guide for more detail.
533
+
534
+ ## Connections
535
+
536
+ Use the <Link path="guides/connection">`connection`</Link> generator to integrate this project with others in your workspace. The following connections involve this project:
537
+
538
+ <CardGrid>
539
+ <ConnectionCard
540
+ title="React to TypeScript Agent"
541
+ description="Call a TypeScript Agent from a React website"
542
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-ts-agent`}
543
+ source="react"
544
+ target="strands"
545
+ targetBadge="typescript"
546
+ />
547
+ <ConnectionCard
548
+ title="React to AG-UI Agent"
549
+ description="Call an Agent exposing the AG-UI protocol from a React website via CopilotKit"
550
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-agui`}
551
+ source="react"
552
+ target="copilotkit"
553
+ />
554
+ <ConnectionCard
555
+ title="TypeScript Agent to MCP"
556
+ description="Connect a TypeScript Agent to an MCP server"
557
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-mcp`}
558
+ source="strands"
559
+ sourceBadge="typescript"
560
+ target="mcp"
561
+ />
562
+ <ConnectionCard
563
+ title="TypeScript Agent to A2A Agent"
564
+ description="Connect a TypeScript Agent to a remote A2A agent"
565
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-a2a`}
566
+ source="strands"
567
+ sourceBadge="typescript"
568
+ target="a2a"
569
+ />
570
+ <ConnectionCard
571
+ title="Python Agent to A2A Agent"
572
+ description="Connect a Python Agent to a remote A2A agent"
573
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-agent-a2a`}
574
+ source="strands"
575
+ sourceBadge="python"
576
+ target="a2a"
577
+ />
578
+ <ConnectionCard
579
+ title="TypeScript Agent to Relational Database"
580
+ description="Connect a TypeScript Agent to an Aurora relational database"
581
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-rdb`}
582
+ source="strands"
583
+ sourceBadge="typescript"
584
+ target="aurora"
585
+ />
586
+ <ConnectionCard
587
+ title="TypeScript Agent to TypeScript DynamoDB"
588
+ description="Connect a TypeScript Agent to a DynamoDB table"
589
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-dynamodb`}
590
+ source="strands"
591
+ sourceBadge="typescript"
592
+ target="dynamodb"
593
+ />
594
+ <ConnectionCard
595
+ title="TypeScript Agent to AgentCore Gateway"
596
+ description="Connect a TypeScript Agent to an AgentCore Gateway"
597
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-gateway`}
598
+ source="strands"
599
+ sourceBadge="typescript"
600
+ target="agentcore"
601
+ />
602
+ <ConnectionCard
603
+ title="AgentCore Gateway to Agent"
604
+ description="Front an agent with an AgentCore Gateway as a runtime target"
605
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/agentcore-gateway-agent`}
606
+ source="agentcore"
607
+ target="strands"
608
+ />
609
+ </CardGrid>