@aws/nx-plugin-mcp 1.0.0-rc.9 → 1.0.0-rc.91

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 (200) hide show
  1. package/bin/aws-nx-mcp.js +13439 -11631
  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 +1578 -0
  9. package/docs/get_started/tutorials/dungeon-game/2.mdx +245 -0
  10. package/docs/get_started/tutorials/dungeon-game/3.mdx +66 -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/upgrading.mdx +157 -0
  15. package/docs/guides/agentcore-gateway.mdx +490 -0
  16. package/docs/guides/agentcore-harness.mdx +312 -0
  17. package/docs/guides/astro-docs.mdx +8 -0
  18. package/docs/guides/connection/agentcore-gateway-agent.mdx +222 -0
  19. package/docs/guides/connection/agentcore-gateway-gateway.mdx +154 -0
  20. package/docs/guides/connection/agentcore-gateway-mcp.mdx +134 -0
  21. package/docs/guides/connection/py-agent-a2a.mdx +48 -16
  22. package/docs/guides/connection/py-agent-dynamodb.mdx +115 -0
  23. package/docs/guides/connection/py-agent-gateway.mdx +182 -0
  24. package/docs/guides/connection/py-agent-mcp.mdx +43 -14
  25. package/docs/guides/connection/py-agent-rdb.mdx +169 -0
  26. package/docs/guides/connection/py-fast-api-dynamodb.mdx +56 -0
  27. package/docs/guides/connection/py-fast-api-rdb.mdx +175 -0
  28. package/docs/guides/connection/py-mcp-server-dynamodb.mdx +115 -0
  29. package/docs/guides/connection/py-mcp-server-rdb.mdx +178 -0
  30. package/docs/guides/connection/react-agentcore-gateway.mdx +112 -0
  31. package/docs/guides/connection/react-agui.mdx +33 -14
  32. package/docs/guides/connection/react-fastapi.mdx +39 -3
  33. package/docs/guides/connection/react-py-agent.mdx +10 -16
  34. package/docs/guides/connection/react-smithy.mdx +4 -4
  35. package/docs/guides/connection/react-trpc.mdx +1 -1
  36. package/docs/guides/connection/react-ts-agent.mdx +9 -9
  37. package/docs/guides/connection/smithy-dynamodb.mdx +5 -5
  38. package/docs/guides/connection/smithy-rdb.mdx +9 -9
  39. package/docs/guides/connection/trpc-dynamodb.mdx +4 -4
  40. package/docs/guides/connection/trpc-rdb.mdx +5 -5
  41. package/docs/guides/connection/ts-agent-a2a.mdx +14 -11
  42. package/docs/guides/connection/ts-agent-dynamodb.mdx +35 -36
  43. package/docs/guides/connection/ts-agent-gateway.mdx +147 -0
  44. package/docs/guides/connection/ts-agent-mcp.mdx +12 -9
  45. package/docs/guides/connection/ts-agent-rdb.mdx +61 -25
  46. package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +35 -36
  47. package/docs/guides/connection/ts-mcp-server-rdb.mdx +59 -18
  48. package/docs/guides/connection.mdx +122 -5
  49. package/docs/guides/docker-bundling.mdx +82 -14
  50. package/docs/guides/fastapi.mdx +253 -12
  51. package/docs/guides/local-development.mdx +87 -0
  52. package/docs/guides/nx-generator.mdx +4 -3
  53. package/docs/guides/nx-migration.mdx +165 -0
  54. package/docs/guides/py-agent.mdx +332 -55
  55. package/docs/guides/py-dynamodb.mdx +476 -0
  56. package/docs/guides/py-mcp-server.mdx +57 -2
  57. package/docs/guides/py-rdb.mdx +269 -0
  58. package/docs/guides/python-lambda-function.mdx +1 -1
  59. package/docs/guides/python-project.mdx +31 -0
  60. package/docs/guides/react-website-auth.mdx +104 -5
  61. package/docs/guides/react-website.mdx +409 -95
  62. package/docs/guides/runtime-config.mdx +17 -4
  63. package/docs/guides/security.mdx +75 -0
  64. package/docs/guides/smithy-project.mdx +167 -0
  65. package/docs/guides/terraform-project.mdx +119 -8
  66. package/docs/guides/trpc.mdx +55 -14
  67. package/docs/guides/ts-agent.mdx +207 -23
  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 +111 -29
  72. package/docs/guides/ts-nx-plugin.mdx +4 -4
  73. package/docs/guides/ts-rdb.mdx +116 -466
  74. package/docs/guides/ts-smithy-api.mdx +260 -16
  75. package/docs/guides/typescript-infrastructure.mdx +79 -25
  76. package/docs/guides/typescript-project.mdx +157 -24
  77. package/docs/guides/workspace.mdx +31 -2
  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 +38 -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 +218 -373
  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 +2 -2
  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 +42 -19
  93. package/docs/snippets/dynamodb/deploying-table.mdx +176 -0
  94. package/docs/snippets/dynamodb/encryption-options.mdx +168 -0
  95. package/docs/snippets/dynamodb/gsi-config.mdx +38 -0
  96. package/docs/snippets/dynamodb/infrastructure.mdx +33 -0
  97. package/docs/snippets/dynamodb/local-dev-start.mdx +13 -0
  98. package/docs/snippets/dynamodb/local-dev-windows.mdx +15 -0
  99. package/docs/snippets/experimental-generator.mdx +8 -0
  100. package/docs/snippets/lambda-function/deploying-your-function.mdx +3 -3
  101. package/docs/snippets/mcp/architecture.mdx +1 -1
  102. package/docs/snippets/mcp/bedrock-deployment.mdx +9 -5
  103. package/docs/snippets/mcp/config.mdx +3 -2
  104. package/docs/snippets/mcp/shared-constructs.mdx +4 -5
  105. package/docs/snippets/pdk-migration/example/01-migrate-api.mdx +7 -5
  106. package/docs/snippets/pdk-migration/example/02-migrate-website.mdx +29 -10
  107. package/docs/snippets/pdk-migration/example/03-migrate-infra.mdx +4 -4
  108. package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +5 -111
  109. package/docs/snippets/prerequisites.mdx +1 -4
  110. package/docs/snippets/rdb/admin-credentials.mdx +42 -0
  111. package/docs/snippets/rdb/architecture.mdx +39 -0
  112. package/docs/snippets/rdb/cluster-instances.mdx +31 -0
  113. package/docs/snippets/rdb/deletion-protection.mdx +64 -0
  114. package/docs/snippets/rdb/deploying.mdx +178 -0
  115. package/docs/snippets/rdb/encryption-key-rotation.mdx +30 -0
  116. package/docs/snippets/rdb/engine-version.mdx +63 -0
  117. package/docs/snippets/rdb/infrastructure.mdx +35 -0
  118. package/docs/snippets/rdb/logging-mysql.mdx +5 -0
  119. package/docs/snippets/rdb/logging-postgres.mdx +5 -0
  120. package/docs/snippets/rdb/performance-insights.mdx +36 -0
  121. package/docs/snippets/rdb/rds-proxy.mdx +50 -0
  122. package/docs/snippets/rdb/removal-policy.mdx +57 -0
  123. package/docs/snippets/rdb/serverless-capacity.mdx +32 -0
  124. package/docs/snippets/recommended-prerequisites.mdx +10 -0
  125. package/docs/snippets/required-prerequisites.mdx +1 -4
  126. package/docs/snippets/runtime-config-app-id-note.mdx +8 -0
  127. package/docs/snippets/shared-constructs.mdx +1 -1
  128. package/docs/snippets/trivy-image-scan.mdx +37 -0
  129. package/generators.json +170 -10
  130. package/package.json +1 -1
  131. package/src/agentcore-gateway/agent-connection/schema.json +31 -0
  132. package/src/agentcore-gateway/gateway-connection/schema.json +31 -0
  133. package/src/agentcore-gateway/mcp-connection/schema.json +31 -0
  134. package/src/agentcore-gateway/react-connection/schema.json +31 -0
  135. package/src/agentcore-gateway/schema.json +72 -0
  136. package/src/agentcore-harness/schema.json +53 -0
  137. package/src/connection/schema.json +5 -0
  138. package/src/infra/app/schema.json +5 -0
  139. package/src/init/schema.json +35 -0
  140. package/src/internal/test-matrix/schema.json +21 -0
  141. package/src/license/schema.json +5 -0
  142. package/src/open-api/json-metadata/schema.json +20 -0
  143. package/src/preset/schema.json +16 -5
  144. package/src/py/agent/a2a-connection/schema.json +5 -0
  145. package/src/py/agent/gateway-connection/schema.json +31 -0
  146. package/src/py/agent/mcp-connection/schema.json +5 -0
  147. package/src/py/agent/react-connection/schema.json +5 -0
  148. package/src/py/agent/schema.json +15 -1
  149. package/src/py/api/schema.json +5 -0
  150. package/src/py/dynamodb/agent-connection/schema.json +27 -0
  151. package/src/py/dynamodb/fast-api-connection/schema.json +23 -0
  152. package/src/py/dynamodb/mcp-server-connection/schema.json +27 -0
  153. package/src/py/dynamodb/schema.json +76 -0
  154. package/src/py/fast-api/react/schema.json +5 -0
  155. package/src/py/fast-api/schema.json +6 -0
  156. package/src/py/lambda-function/schema.json +6 -1
  157. package/src/py/mcp-server/schema.json +6 -0
  158. package/src/py/project/schema.json +6 -0
  159. package/src/py/rdb/agent-connection/schema.json +27 -0
  160. package/src/py/rdb/fast-api-connection/schema.json +23 -0
  161. package/src/py/rdb/mcp-server-connection/schema.json +27 -0
  162. package/src/py/rdb/schema.json +78 -0
  163. package/src/smithy/project/schema.json +28 -1
  164. package/src/smithy/react-connection/schema.json +5 -0
  165. package/src/smithy/ts/api/schema.json +6 -0
  166. package/src/terraform/project/schema.json +5 -0
  167. package/src/trpc/backend/schema.json +6 -0
  168. package/src/trpc/react/schema.json +5 -0
  169. package/src/ts/agent/a2a-connection/schema.json +5 -0
  170. package/src/ts/agent/gateway-connection/schema.json +31 -0
  171. package/src/ts/agent/mcp-connection/schema.json +5 -0
  172. package/src/ts/agent/react-connection/schema.json +5 -0
  173. package/src/ts/agent/schema.json +14 -0
  174. package/src/ts/api/schema.json +5 -0
  175. package/src/ts/astro-docs/schema.json +3 -3
  176. package/src/ts/dcr-proxy/schema.json +44 -0
  177. package/src/ts/docs/schema.json +3 -3
  178. package/src/ts/dynamodb/agent-connection/schema.json +5 -0
  179. package/src/ts/dynamodb/mcp-server-connection/schema.json +5 -0
  180. package/src/ts/dynamodb/schema.json +26 -2
  181. package/src/ts/dynamodb/smithy-connection/schema.json +5 -0
  182. package/src/ts/dynamodb/trpc-connection/schema.json +5 -0
  183. package/src/ts/lambda-function/schema.json +5 -0
  184. package/src/ts/lib/schema.json +5 -0
  185. package/src/ts/mcp-server/schema.json +6 -0
  186. package/src/ts/nx-generator/schema.json +5 -0
  187. package/src/ts/nx-migration/schema.json +63 -0
  188. package/src/ts/nx-plugin/schema.json +5 -0
  189. package/src/ts/rdb/agent-connection/schema.json +5 -0
  190. package/src/ts/rdb/mcp-server-connection/schema.json +5 -0
  191. package/src/ts/rdb/schema.json +7 -1
  192. package/src/ts/rdb/smithy-connection/schema.json +5 -0
  193. package/src/ts/rdb/trpc-connection/schema.json +5 -0
  194. package/src/ts/react-website/app/schema.json +12 -6
  195. package/src/ts/react-website/cognito-auth/schema.json +5 -0
  196. package/src/ts/react-website/runtime-config/schema.json +5 -0
  197. package/src/ts/website/app/schema.json +11 -6
  198. package/src/ts/website/auth/schema.json +5 -0
  199. /package/docs/snippets/connection/{lambda-rdb-ssl-requirements.mdx → ts-lambda-rdb-ssl-requirements.mdx} +0 -0
  200. /package/docs/snippets/connection/{mcp-server-rdb-ssl-requirements.mdx → ts-mcp-server-rdb-ssl-requirements.mdx} +0 -0
@@ -0,0 +1,312 @@
1
+ ---
2
+ title: AgentCore Harness
3
+ description: Create an Amazon Bedrock AgentCore Harness project
4
+ generator: agentcore-harness
5
+ ---
6
+
7
+ import { FileTree } from '@astrojs/starlight/components';
8
+ import GeneratorParameters from '@components/generator-parameters.astro';
9
+ import Infrastructure from '@components/infrastructure.astro';
10
+ import Link from '@components/link.astro';
11
+ import NxCommands from '@components/nx-commands.astro';
12
+ import RunGenerator from '@components/run-generator.astro';
13
+ import Snippet from '@components/snippet.astro';
14
+
15
+ Generate an [Amazon Bedrock AgentCore Harness](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/harness.html) project. A Harness is a managed agent loop powered by Strands Agents: it owns deployment defaults for the model, system prompt, tools, memory, skills, environments, truncation, authorization, and execution limits, while the service accepts per-invocation overrides for supported fields. Reusing the same Runtime Session ID continues the same Harness session.
16
+
17
+ ## Usage
18
+
19
+ ### Generate an AgentCore Harness
20
+
21
+ <RunGenerator generator="agentcore-harness" />
22
+
23
+ ### Options
24
+
25
+ <GeneratorParameters generator="agentcore-harness" />
26
+
27
+ ## Generator Output
28
+
29
+ The generator creates a standalone project at `packages/<name>/`. Because AWS runs the agent loop for you, the project holds only the prompt that shapes it and a script for talking to it:
30
+
31
+ <FileTree>
32
+ - packages/\<name>/
33
+ - src/PROMPT.md The Harness system prompt
34
+ - scripts/chat.ts Multi-turn chat client for the deployed Harness
35
+ - project.json Adds the `chat` target
36
+ - README.md Chat and customization instructions
37
+ </FileTree>
38
+
39
+ ### Infrastructure
40
+
41
+ Infrastructure is generated when `infra` is `agentcore` (the default). With `infra: none` no infrastructure is generated — set `HARNESS_ARN` to invoke a Harness managed elsewhere, and re-run the generator with `infra: agentcore` later to add infrastructure; existing project files (including your edits) are preserved.
42
+
43
+ <Snippet name="shared-constructs" />
44
+
45
+ <Infrastructure>
46
+ <Fragment slot="cdk">
47
+ <FileTree>
48
+ - packages/common/constructs/src/app/harnesses/\<name>/
49
+ - \<name>.ts CDK construct containing the Harness and execution role
50
+ </FileTree>
51
+ </Fragment>
52
+ <Fragment slot="terraform">
53
+ <FileTree>
54
+ - packages/common/terraform/src/app/harnesses/\<name>/
55
+ - \<name>.tf Terraform module containing the Harness and execution role
56
+ </FileTree>
57
+ </Fragment>
58
+ </Infrastructure>
59
+
60
+ The generated infrastructure manages the Harness through the native resource (CDK `aws_bedrockagentcore.CfnHarness`, Terraform `aws_bedrockagentcore_harness`) with your generated defaults, creates an IAM execution role with the baseline permissions described below, and uses IAM inbound authorization (no custom JWT authorizer is configured by default).
61
+
62
+ The Harness ARN is registered at `agentcore.harnesses.<ClassName>` in <Link path="guides/runtime-config">Runtime Configuration</Link>, preserving any existing entries.
63
+
64
+ ## Deploying your AgentCore Harness
65
+
66
+ The generator creates CDK or Terraform infrastructure as code based on your selected `iac` provider. You can use this to deploy your Harness through your usual infrastructure workflow.
67
+
68
+ <Infrastructure>
69
+ <Fragment slot="cdk">
70
+ The CDK construct for deploying your Harness lives in the `common/constructs` folder. Instantiate it from a CDK application:
71
+
72
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
73
+ import { MyHarness } from '@my-scope/common-constructs';
74
+ import { Stack, type StackProps } from 'aws-cdk-lib';
75
+ import type { Construct } from 'constructs';
76
+
77
+ export class ApplicationStack extends Stack {
78
+ constructor(scope: Construct, id: string, props?: StackProps) {
79
+ super(scope, id, props);
80
+
81
+ new MyHarness(this, 'MyHarness');
82
+ }
83
+ }
84
+ ```
85
+
86
+ The construct's props interface (`MyHarnessProps`) extends `Partial<Omit<CfnHarnessProps, 'executionRoleArn' | 'allowedTools'>>`, so any native Harness property can be supplied and takes precedence over the generated defaults:
87
+
88
+ ```ts
89
+ const harness = new MyHarness(this, 'MyHarness', {
90
+ maxIterations: 20,
91
+ timeoutSeconds: 600,
92
+ });
93
+ ```
94
+
95
+ The construct also accepts:
96
+
97
+ - `allowedTools` — the tools the Harness may use. Defaults to none, see <a href="#configuring-tools">Configuring tools</a>.
98
+ - `executionRole` — an existing IAM role to use instead of the generated role. A supplied role is used as-is: the baseline permissions are not added to it, and its ARN always feeds the Harness (the raw `executionRoleArn` string cannot be overridden).
99
+ - `modelResourceArns` — the Bedrock model and inference-profile ARNs the generated execution role may invoke, replacing the default list.
100
+ - `vpc`, `vpcSubnets` and `securityGroups` — run the Harness in a VPC so it can reach private resources, see <a href="#running-in-a-vpc">Running in a VPC</a>.
101
+
102
+ Its public members are `harness` (the `CfnHarness`), `executionRole`, `grantPrincipal`, the `harnessArn` getter, `connections` (in a VPC), `addToRolePolicy(statement)` for execution role extensions, and `grantInvokeAccess(grantee)` for authorizing callers.
103
+
104
+ Deploy the stack with your infrastructure project as usual — see the <Link path="guides/typescript-infrastructure">CDK infrastructure guide</Link>.
105
+ </Fragment>
106
+ <Fragment slot="terraform">
107
+ The Terraform module for deploying your Harness is in the `common/terraform` folder. Reference it from a Terraform configuration:
108
+
109
+ ```hcl title="packages/infra/src/main.tf"
110
+ module "my_harness" {
111
+ source = "../../common/terraform/src/app/harnesses/my-harness"
112
+ }
113
+ ```
114
+
115
+ The module exposes the following variables:
116
+
117
+ - `model_id` — the Bedrock model or inference profile the Harness uses by default.
118
+ - `allowed_tools` — the tools the Harness may use. Defaults to none, see <a href="#configuring-tools">Configuring tools</a>.
119
+ - `memory` — the Harness memory configuration, see <a href="#configuring-memory">Configuring memory</a>.
120
+ - `environment_variables`, `max_iterations`, `timeout_seconds` — the corresponding native Harness fields.
121
+ - `execution_role_arn` — an existing IAM role to use instead of the generated role. A supplied role is used as-is: neither the role nor its baseline policy is created, so `model_resource_arns` and `additional_execution_role_policy_statements` cannot be combined with it.
122
+ - `model_resource_arns` — the Bedrock model and inference-profile ARNs the generated execution role may invoke, replacing the default list.
123
+ - `additional_execution_role_policy_statements` — a list of IAM statement objects (`Effect`, `Action`, `Resource`, optional `Sid` and `Condition`) appended to the generated execution role policy.
124
+ - `enable_vpc`, `vpc_id`, `subnet_ids` — run the Harness in a VPC so it can reach private resources, see <a href="#running-in-a-vpc">Running in a VPC</a>.
125
+ - `tags` — tags applied to the resources the module creates.
126
+
127
+ Other provider-native fields are configured by editing the generated `aws_bedrockagentcore_harness` resource in the module itself, see <a href="#customizing-your-harness">Customizing your Harness</a>.
128
+
129
+ The module outputs `harness_id`, `harness_arn`, `execution_role_arn` and `security_group_id`.
130
+
131
+ Deploy with your Terraform project's plan/apply workflow as usual — see the <Link path="guides/terraform-project">Terraform project guide</Link>.
132
+ </Fragment>
133
+ </Infrastructure>
134
+
135
+ :::note[System prompt visibility]
136
+ Your infrastructure reads `packages/<name>/src/PROMPT.md` when you synthesize (CDK) or plan (Terraform), so the prompt is deployment configuration rather than secret storage: its contents appear in the synthesized CloudFormation template or in Terraform state.
137
+ :::
138
+
139
+ ## Granting access to invoke the harness
140
+
141
+ You can grant a caller permissions to invoke the harness as follows:
142
+
143
+ <Infrastructure>
144
+ <Fragment slot="cdk">
145
+ ```ts
146
+ const harness = new MyHarness(this, 'MyHarness');
147
+
148
+ harness.grantInvokeAccess(caller);
149
+ ```
150
+ </Fragment>
151
+ <Fragment slot="terraform">
152
+ ```hcl
153
+ # Attach to the calling principal's role
154
+ resource "aws_iam_role_policy" "invoke_my_harness" {
155
+ name = "InvokeMyHarness"
156
+ role = aws_iam_role.caller.id
157
+
158
+ policy = jsonencode({
159
+ Version = "2012-10-17"
160
+ Statement = [{
161
+ Effect = "Allow"
162
+ Action = [
163
+ "bedrock-agentcore:InvokeHarness",
164
+ "bedrock-agentcore:InvokeAgentRuntime",
165
+ ]
166
+ Resource = [module.my_harness.harness_arn]
167
+ }]
168
+ })
169
+ }
170
+ ```
171
+ </Fragment>
172
+ </Infrastructure>
173
+
174
+ A caller needs both `bedrock-agentcore:InvokeHarness` and `bedrock-agentcore:InvokeAgentRuntime` on the Harness ARN, which is exactly what `grantInvokeAccess` grants.
175
+
176
+ ## Chatting with your Harness
177
+
178
+ The generated `chat` target runs `scripts/chat.ts`, dropping you into an interactive terminal chat with your deployed Harness:
179
+
180
+ <NxCommands commands={['run <project>:chat']} />
181
+
182
+ Every turn of a run shares one session, so the Harness keeps the conversation context until you exit. Credentials come from the standard AWS SDK credential provider chain, and the AWS Region is derived from the Harness ARN.
183
+
184
+ The Harness ARN is resolved in this order:
185
+
186
+ 1. `HARNESS_ARN` (non-empty): used directly, without reading Runtime Configuration:
187
+
188
+ <NxCommands commands={['run <project>:chat']} env={{ HARNESS_ARN: '<harness-arn>' }} />
189
+
190
+ 2. `RUNTIME_CONFIG_APP_ID`: resolves the ARN from the `agentcore.harnesses.<ClassName>` entry published by the deployed infrastructure:
191
+
192
+ <NxCommands commands={['run <project>:chat']} env={{ RUNTIME_CONFIG_APP_ID: '<application-id>' }} />
193
+
194
+ With neither set, the script fails with an error naming both options.
195
+
196
+ ## Customizing your Harness
197
+
198
+ `src/PROMPT.md` is the Harness system prompt: edit it and redeploy to change how the Harness behaves. Everything else is configured where you instantiate the infrastructure, or by editing the generated construct or module directly. Re-running the generator never overwrites existing files (it only adds missing files and merges project metadata), so your edits to the prompt and to the generated infrastructure are preserved.
199
+
200
+ <Infrastructure>
201
+ <Fragment slot="cdk">
202
+ Every native Harness property of the pinned `aws-cdk-lib/aws-bedrockagentcore` module is available through the construct's props — alternate model providers, tool definitions, memory, skills, environment configuration, truncation, custom JWT authorization, and execution limits — and explicit props take precedence over the generated defaults. Alternatively, edit the generated construct in `packages/common/constructs/src/app/harnesses/<name>/<name>.ts`.
203
+ </Fragment>
204
+ <Fragment slot="terraform">
205
+ The module's variables cover the fields most deployments configure — `model_id`, `allowed_tools`, `memory`, `environment_variables`, `max_iterations`, `timeout_seconds` — plus the execution role and VPC placement. Terraform has no equivalent of the CDK construct's prop spread, so the remaining provider-native fields are configured by editing the `aws_bedrockagentcore_harness` resource in `packages/common/terraform/src/app/harnesses/<name>/<name>.tf`: alternate model providers (`gemini_model_config`, `openai_model_config`), `tool` blocks, `skill` blocks, `environment_artifact`, filesystem and lifecycle configuration under `environment`, `truncation`, and `authorizer_configuration` with a `custom_jwt_authorizer`.
206
+ </Fragment>
207
+ </Infrastructure>
208
+
209
+ Omitting authorizer configuration (the default) means IAM inbound authorization; configure a custom JWT authorizer through the native field to change that.
210
+
211
+ ### Configuring tools
212
+
213
+ The Harness deploys with no tools, so it starts with the least capability. Opt in to the tools it may use:
214
+
215
+ <Infrastructure>
216
+ <Fragment slot="cdk">
217
+ ```ts
218
+ new MyHarness(this, 'Harness', { allowedTools: ['@builtin'] });
219
+ ```
220
+ </Fragment>
221
+ <Fragment slot="terraform">
222
+ ```hcl title="packages/infra/src/main.tf"
223
+ module "my_harness" {
224
+ source = "../../common/terraform/src/app/harnesses/my-harness"
225
+ allowed_tools = ["@builtin"]
226
+ }
227
+ ```
228
+ </Fragment>
229
+ </Infrastructure>
230
+
231
+ Narrow `@builtin` to specific patterns such as `@builtin/file_operations` to restrict what the agent loop can do. See [Harness tools](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/harness-tools.html) for the built-in tools you can add.
232
+
233
+ ### Configuring memory
234
+
235
+ The service provisions managed memory for the Harness by default, and the generated execution role is granted access to it — scoped to the memory ARN the service assigns, and only granted while the Harness uses managed memory the infrastructure created. Configure memory explicitly to tune that managed memory, point the Harness at a memory resource you own, or turn memory off:
236
+
237
+ <Infrastructure>
238
+ <Fragment slot="cdk">
239
+ ```ts
240
+ new MyHarness(this, 'MyHarness', {
241
+ memory: { managedMemoryConfiguration: { strategies: ['SUMMARIZATION'] } },
242
+ });
243
+ ```
244
+
245
+ Supplying `memory` at all replaces the default managed memory, so the construct leaves the memory grant off the execution role: add whatever the configuration needs with `addToRolePolicy`.
246
+ </Fragment>
247
+ <Fragment slot="terraform">
248
+ ```hcl
249
+ module "my_harness" {
250
+ source = "../../common/terraform/src/app/harnesses/my-harness"
251
+ memory = {
252
+ managed_memory_configuration = {
253
+ strategies = ["SUMMARIZATION"]
254
+ }
255
+ }
256
+ }
257
+ ```
258
+
259
+ Set exactly one of `managed_memory_configuration` (tune the service's managed memory), `agentcore_memory_configuration` (use a memory resource you own, by ARN) or `disabled` (no memory). Choosing `agentcore_memory_configuration` or `disabled` drops the managed-memory grant from the execution role; for your own memory resource, grant access through `additional_execution_role_policy_statements`.
260
+ </Fragment>
261
+ </Infrastructure>
262
+
263
+ ### Running in a VPC
264
+
265
+ <Infrastructure>
266
+ <Fragment slot="cdk">
267
+ Supply a `vpc` to run the Harness inside it, so it can reach private resources such as a database. The construct implements `IConnectable`, so those resources grant it access the same way they would any other:
268
+
269
+ ```ts
270
+ const harness = new MyHarness(this, 'MyHarness', { vpc });
271
+
272
+ database.connections.allowDefaultPortFrom(harness, 'Harness to database');
273
+ ```
274
+
275
+ The Harness is placed in the VPC's private subnets with egress, in a security group created for it. Override either with `vpcSubnets` and `securityGroups`. Both require `vpc`, and `connections` is only available when the Harness runs in a VPC.
276
+ </Fragment>
277
+ <Fragment slot="terraform">
278
+ Set `enable_vpc` alongside `vpc_id` and `subnet_ids` to run the Harness inside a VPC, so it can reach private resources such as a database:
279
+
280
+ ```hcl
281
+ module "my_harness" {
282
+ source = "../../common/terraform/src/app/harnesses/my-harness"
283
+ enable_vpc = true
284
+ vpc_id = var.vpc_id
285
+ subnet_ids = var.private_subnet_ids
286
+ }
287
+ ```
288
+
289
+ The module creates a security group for the Harness, allowing outbound HTTPS only. Its `security_group_id` output is what resources the Harness must reach reference in their own ingress rules:
290
+
291
+ ```hcl
292
+ resource "aws_vpc_security_group_ingress_rule" "harness_to_database" {
293
+ security_group_id = aws_security_group.database.id
294
+ referenced_security_group_id = module.my_harness.security_group_id
295
+ from_port = 5432
296
+ to_port = 5432
297
+ ip_protocol = "tcp"
298
+ description = "Harness to database"
299
+ }
300
+ ```
301
+
302
+ `security_group_id` is null unless `enable_vpc` is true, and `vpc_id` and `subnet_ids` are both required when it is.
303
+ </Fragment>
304
+ </Infrastructure>
305
+
306
+ ### Per-invocation overrides
307
+
308
+ The values configured in infrastructure are deployment defaults. The service also accepts per-invocation overrides for supported Harness fields (such as models, tools, and skills) in the `InvokeHarness` request; deployment defaults apply wherever a field is not overridden.
309
+
310
+ :::caution[Validate invocation overrides]
311
+ Per-invocation overrides are trusted inputs at the service boundary: any authorized caller can override supported fields. If untrusted users can reach an application that forwards overrides to `InvokeHarness`, validate and authorize them at the application layer (for example, allowlist models and tools), keep the execution role scoped to required resources, and do not grant `bedrock-agentcore:InvokeAgentRuntimeCommand` unless you specifically need it.
312
+ :::
@@ -86,6 +86,14 @@ When run without `--all`, the script only translates files that have changed
86
86
  since the last translation commit on the current branch — meaning you can
87
87
  safely re-run it on every docs PR without re-translating the whole site.
88
88
 
89
+ Translations whose source file no longer exists are deleted, so renaming or
90
+ removing a page does not leave stale copies behind in each locale.
91
+
92
+ Each translation is written as a whole file. The agent is given the source, the
93
+ existing translation, and a diff of what changed, and reuses the existing
94
+ wording for sections the diff left alone — so only prose the diff touched is
95
+ retranslated, and code blocks are copied from the source as-is.
96
+
89
97
  ### Configuring translation
90
98
 
91
99
  Edit `scripts/translate.config.json` to change:
@@ -0,0 +1,222 @@
1
+ ---
2
+ title: AgentCore Gateway to Agent
3
+ description: Front an agent with an AgentCore Gateway as a runtime target
4
+ when:
5
+ sourceType: agentcore-gateway
6
+ targetType:
7
+ - ts#agent
8
+ - py#agent
9
+ ---
10
+ import { FileTree } from '@astrojs/starlight/components';
11
+ import Link from '@components/link.astro';
12
+ import RunGenerator from '@components/run-generator.astro';
13
+ import GeneratorParameters from '@components/generator-parameters.astro';
14
+ import NxCommands from '@components/nx-commands.astro';
15
+ import Infrastructure from '@components/infrastructure.astro';
16
+
17
+ The `connection` generator can register an agent (either <Link path="guides/ts-agent">TypeScript</Link> or <Link path="guides/py-agent">Python</Link>) as an [AgentCore Runtime target](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-target-http-runtime.html) of an <Link path="guides/agentcore-gateway">AgentCore Gateway</Link> generated with `protocol: http`.
18
+
19
+ Once connected, the Gateway proxies requests for the agent under `<gatewayUrl>/<targetName>/invocations`, signing outbound traffic to the runtime with IAM SigV4. This gives your agents a single governed entry point — and since callers only need to reach the Gateway, the agent runtimes themselves can be deployed inside a VPC behind it.
20
+
21
+ ## Prerequisites
22
+
23
+ Before using this generator, ensure you have:
24
+
25
+ 1. An <Link path="guides/agentcore-gateway">`agentcore-gateway`</Link> project generated with `protocol: http`
26
+ 2. An agent component (<Link path="guides/ts-agent">`ts#agent`</Link> or <Link path="guides/py-agent">`py#agent`</Link>) created with `infra: agentcore`. Either `auth: iam` (the Gateway invokes it with its own role) or `auth: cognito` (the Gateway forwards the caller's JWT — see [Forwarding caller identity](#forwarding-caller-identity-to-the-runtime)) works.
27
+
28
+ :::caution[TypeScript HTTP agents]
29
+ A TypeScript `http` agent serves tRPC over WebSocket, and AgentCore Gateway does not support WebSocket or bidirectional streaming — the generator rejects this combination. Generate the agent with the `ag-ui` protocol instead.
30
+ :::
31
+
32
+ ## Usage
33
+
34
+ ### Run the Generator
35
+
36
+ <RunGenerator generator="connection" />
37
+
38
+ Select the Gateway project as the source and the agent project as the target. If the agent project contains multiple components, specify `targetComponent` to disambiguate.
39
+
40
+ ### Options
41
+
42
+ <GeneratorParameters generator="connection" />
43
+
44
+ ## Generator Output
45
+
46
+ The generator wires existing projects together rather than emitting new source files. The following files are modified:
47
+
48
+ <FileTree>
49
+
50
+ - packages/\<gateway>
51
+ - project.json the Gateway's `dev` target gains a dependency on the agent's `<agent>-dev`
52
+ - local-dev.ts `ATTACHED_AGENTS` updated so the local gateway proxies to the agent
53
+
54
+ </FileTree>
55
+
56
+ ## Adding the agent target to your stack
57
+
58
+ The generator **cannot** automatically wire the agent target into your infrastructure because it doesn't know which stack or module instantiates the Gateway. Add a single call to `gateway.addAgent(agent)` yourself.
59
+
60
+ <Infrastructure>
61
+ <Fragment slot="cdk">
62
+ In the stack where you instantiate the Gateway, register the agent as a target:
63
+
64
+ ```ts title="packages/infra/src/stacks/application-stack.ts" {5-8}
65
+ const myAgent = new MyAgent(this, 'MyAgent');
66
+ const myGateway = new MyGateway(this, 'MyGateway');
67
+
68
+ // Register the agent as a runtime target of the Gateway. The target name
69
+ // defaults to the agent's `agentName` (its class name in kebab-case,
70
+ // e.g. `MyAgent` -> `my-agent`), and forms the target's invocation path:
71
+ // <gatewayUrl>/my-agent/invocations
72
+ myGateway.addAgent(myAgent);
73
+ ```
74
+
75
+ To override the default target name, pass `gatewayTargetName`:
76
+
77
+ ```ts
78
+ myGateway.addAgent(myAgent, { gatewayTargetName: 'my-target' });
79
+ ```
80
+
81
+ The construct grants the Gateway's execution role invoke access to the agent runtime and configures the target with the `GATEWAY_IAM_ROLE` credential provider, so the Gateway signs outbound calls with its own role.
82
+
83
+ :::tip[Deploying agents into a VPC]
84
+ Fronting an agent with a Gateway is what makes a VPC-deployed agent reachable: callers talk to the Gateway's public endpoint, and the Gateway reaches the runtime internally. Pass a VPC network configuration to the agent construct:
85
+
86
+ ```ts
87
+ import { RuntimeNetworkConfiguration } from 'aws-cdk-lib/aws-bedrockagentcore';
88
+
89
+ const myAgent = new MyAgent(this, 'MyAgent', {
90
+ // Give each agent its own scope for the network configuration — usingVpc
91
+ // creates a security group named `SecurityGroup` under the scope you pass,
92
+ // so passing `this` for more than one agent collides on the construct id.
93
+ networkConfiguration: RuntimeNetworkConfiguration.usingVpc(
94
+ new Construct(this, 'MyAgentNetwork'),
95
+ {
96
+ vpc,
97
+ vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },
98
+ },
99
+ ),
100
+ });
101
+ ```
102
+
103
+ Use a **private subnet with egress**, not a private isolated subnet: the runtime needs outbound internet access to reach Bedrock and read its configuration from AWS AppConfig.
104
+
105
+ AgentCore Runtime VPC deployments are only supported in certain availability zones. If a deploy fails with `subnets are in unsupported availability zones`, restrict the VPC (or the subnet selection) to the supported zones for your region.
106
+ :::
107
+ </Fragment>
108
+ <Fragment slot="terraform">
109
+ In the Terraform file where you instantiate the Gateway, wire the agent target in:
110
+
111
+ ```hcl title="packages/infra/src/main.tf" {9-20,24-40}
112
+ module "my_agent" {
113
+ source = "../../common/terraform/src/app/agents/my-agent"
114
+ # ...
115
+ }
116
+
117
+ module "my_gateway" {
118
+ source = "../../common/terraform/src/app/gateways/my-gateway"
119
+
120
+ # The Gateway signs outbound calls to the runtime with its own role and
121
+ # validates access at target creation, so it needs invoke access first.
122
+ additional_iam_policy_statements = [
123
+ {
124
+ Effect = "Allow"
125
+ Action = [
126
+ "bedrock-agentcore:InvokeAgentRuntime",
127
+ "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream",
128
+ # A2A targets additionally serve their agent card via the gateway
129
+ "bedrock-agentcore:GetAgentCard",
130
+ ]
131
+ Resource = [
132
+ module.my_agent.agent_core_runtime_arn,
133
+ "${module.my_agent.agent_core_runtime_arn}/*",
134
+ ]
135
+ }
136
+ ]
137
+ }
138
+
139
+ # Register the agent as a runtime target of the Gateway. The target name
140
+ # forms the invocation path: <gatewayUrl>/my-agent/invocations
141
+ resource "aws_bedrockagentcore_gateway_target" "my_agent" {
142
+ gateway_identifier = module.my_gateway.gateway_id
143
+ name = "my-agent"
144
+ # AgentCore fills in a description when none is set, which the provider
145
+ # reports as an inconsistent result after apply — so always set one.
146
+ description = "Agent runtime target my-agent"
147
+
148
+ target_configuration {
149
+ http {
150
+ agentcore_runtime {
151
+ arn = module.my_agent.agent_core_runtime_arn
152
+ }
153
+ }
154
+ }
155
+
156
+ credential_provider_configuration {
157
+ gateway_iam_role {}
158
+ }
159
+ }
160
+ ```
161
+
162
+ :::tip[Deploying agents into a VPC]
163
+ Fronting an agent with a Gateway is what makes a VPC-deployed agent reachable: callers talk to the Gateway's public endpoint, and the Gateway reaches the runtime internally. Set the agent module's VPC variables:
164
+
165
+ ```hcl
166
+ module "my_agent" {
167
+ source = "../../common/terraform/src/app/agents/my-agent"
168
+
169
+ enable_vpc = true
170
+ vpc_id = aws_vpc.my_vpc.id
171
+ subnet_ids = [aws_subnet.private_a.id, aws_subnet.private_b.id]
172
+ }
173
+ ```
174
+
175
+ Use private subnets with egress (a route to a NAT gateway), not private isolated subnets: the runtime needs outbound internet access to reach Bedrock and read its configuration from AWS AppConfig.
176
+ :::
177
+ </Fragment>
178
+ </Infrastructure>
179
+
180
+ ## Invoking the agent through the Gateway
181
+
182
+ Requests to `<gatewayUrl origin>/<targetName>/invocations` are forwarded to the agent runtime without protocol translation, so callers use the same request shape they'd use against the runtime directly — SSE streams (AG-UI), JSON streaming (Python HTTP) and A2A JSON-RPC all proxy through. Callers authenticate with the Gateway (IAM SigV4 or Cognito JWT depending on the Gateway's `auth`) rather than with the agent.
183
+
184
+ To connect a website to the Gateway's agents, use the <Link path="guides/connection/react-agentcore-gateway">`connection` generator</Link>.
185
+
186
+ ## Forwarding caller identity to the runtime
187
+
188
+ By default the Gateway signs outbound calls with its own IAM role (the `GATEWAY_IAM_ROLE` credential provider), so the runtime sees the _Gateway's_ identity, not the caller's. If instead you want the agent to authorize on the caller — for example to read the user's `sub` or `scope` claims — front a **Cognito** agent with a **Cognito** Gateway. The Gateway then forwards the caller's JWT to the runtime unchanged (the `JWT_PASSTHROUGH` credential provider), and the runtime revalidates it.
189
+
190
+ Generate both ends with `auth: cognito` and connect them as above:
191
+
192
+ - an agent (<Link path="guides/ts-agent">`ts#agent`</Link> or <Link path="guides/py-agent">`py#agent`</Link>) created with `auth: cognito`, and
193
+ - a Gateway created with `auth: cognito` fronting the **same** Cognito user pool.
194
+
195
+ Everything else is automatic — `gateway.addAgent(agent)` (CDK) and the generated Terraform runtime module handle the wiring for you based on the agent's `auth`:
196
+
197
+ - the target is created with the `JWT_PASSTHROUGH` credential provider (rather than `GATEWAY_IAM_ROLE`), and
198
+ - the runtime allowlists the `Authorization` header so the forwarded token reaches your agent code. Without this allowlist AgentCore validates the token but strips the header before your container.
199
+
200
+ Callers invoke the Gateway with `Authorization: Bearer <jwt>` (no SigV4), and the agent reads the claims from the `Authorization` header — skipping signature validation, since the runtime's inbound authorizer has already verified the token:
201
+
202
+ ```python title="packages/py_project/.../my_agent/main.py"
203
+ import jwt # PyJWT
204
+
205
+ @app.post('/invocations')
206
+ async def invoke(input: InvokeInput, request: Request):
207
+ token = request.headers['authorization'].removeprefix('Bearer ')
208
+ claims = jwt.decode(token, options={'verify_signature': False})
209
+ # authorize on claims['sub'], claims['scope'], ...
210
+ ```
211
+
212
+ :::note
213
+ JWT passthrough suits a single identity provider whose token audience already covers the runtime. If one Gateway fronts agents across multiple tenants or audiences, use OAuth [on-behalf-of token exchange](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-building-adding-targets-authorization.html) instead.
214
+ :::
215
+
216
+ ## Local Development
217
+
218
+ Running the Gateway locally with:
219
+
220
+ <NxCommands commands={["dev <gateway-name>"]} />
221
+
222
+ starts a local gateway plus every attached agent on its assigned local port. The local gateway proxies `/<targetName>/...` paths to each agent's local server, matching the deployed Gateway's path-based routing.