@aws/nx-plugin-mcp 1.0.0-rc.58 → 1.0.0-rc.59

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 (38) hide show
  1. package/bin/aws-nx-mcp.js +17 -1
  2. package/docs/get_started/graph-builder.mdx +4 -1
  3. package/docs/get_started/tutorials/contribute-generator.mdx +2 -2
  4. package/docs/get_started/tutorials/dungeon-game/1.mdx +2 -2
  5. package/docs/guides/agentcore-gateway.mdx +37 -10
  6. package/docs/guides/connection/agentcore-gateway-agent.mdx +282 -0
  7. package/docs/guides/connection/agentcore-gateway-gateway.mdx +2 -2
  8. package/docs/guides/connection/agentcore-gateway-mcp.mdx +2 -2
  9. package/docs/guides/connection/py-agent-a2a.mdx +1 -1
  10. package/docs/guides/connection/py-agent-gateway.mdx +2 -2
  11. package/docs/guides/connection/py-agent-mcp.mdx +3 -3
  12. package/docs/guides/connection/react-agentcore-gateway.mdx +112 -0
  13. package/docs/guides/connection/smithy-rdb.mdx +1 -1
  14. package/docs/guides/connection/trpc-rdb.mdx +1 -1
  15. package/docs/guides/connection/ts-agent-a2a.mdx +1 -1
  16. package/docs/guides/connection/ts-agent-gateway.mdx +1 -1
  17. package/docs/guides/connection/ts-agent-mcp.mdx +1 -1
  18. package/docs/guides/connection.mdx +14 -0
  19. package/docs/guides/fastapi.mdx +1 -1
  20. package/docs/guides/py-agent.mdx +7 -0
  21. package/docs/guides/react-website.mdx +9 -2
  22. package/docs/guides/terraform-project.mdx +1 -1
  23. package/docs/guides/trpc.mdx +2 -2
  24. package/docs/guides/ts-agent.mdx +7 -0
  25. package/docs/guides/ts-smithy-api.mdx +8 -8
  26. package/docs/snippets/agent/bedrock-deployment.mdx +1 -1
  27. package/docs/snippets/agent/runtime-arn.mdx +1 -1
  28. package/docs/snippets/api/cors-configuration-terraform-note.mdx +1 -1
  29. package/docs/snippets/api/type-safe-api-integrations.mdx +2 -2
  30. package/docs/snippets/api/waf-configuration.mdx +2 -2
  31. package/docs/snippets/connection/a2a-infrastructure.mdx +1 -1
  32. package/docs/snippets/mcp/bedrock-deployment.mdx +1 -1
  33. package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +1 -1
  34. package/generators.json +17 -1
  35. package/package.json +1 -1
  36. package/src/agentcore-gateway/agent-connection/schema.json +31 -0
  37. package/src/agentcore-gateway/react-connection/schema.json +31 -0
  38. package/src/agentcore-gateway/schema.json +2 -2
package/bin/aws-nx-mcp.js CHANGED
@@ -54046,6 +54046,20 @@ var generators$1 = {
54046
54046
  "metric": "g65",
54047
54047
  "hidden": true
54048
54048
  },
54049
+ "agentcore-gateway#agent-connection": {
54050
+ "factory": "./src/agentcore-gateway/agent-connection/generator",
54051
+ "schema": "./src/agentcore-gateway/agent-connection/schema.json",
54052
+ "description": "Connect an AgentCore Gateway to an agent, adding the agent as a gateway target",
54053
+ "metric": "g69",
54054
+ "hidden": true
54055
+ },
54056
+ "agentcore-gateway#react-connection": {
54057
+ "factory": "./src/agentcore-gateway/react-connection/generator",
54058
+ "schema": "./src/agentcore-gateway/react-connection/schema.json",
54059
+ "description": "Connect a React website to an AgentCore Gateway fronting agents",
54060
+ "metric": "g70",
54061
+ "hidden": true
54062
+ },
54049
54063
  "connection": {
54050
54064
  "factory": "./src/connection/generator",
54051
54065
  "schema": "./src/connection/schema.json",
@@ -54070,7 +54084,9 @@ var generators$1 = {
54070
54084
  "connection/ts-agent-gateway",
54071
54085
  "connection/py-agent-gateway",
54072
54086
  "connection/agentcore-gateway-mcp",
54073
- "connection/agentcore-gateway-gateway"
54087
+ "connection/agentcore-gateway-gateway",
54088
+ "connection/agentcore-gateway-agent",
54089
+ "connection/react-agentcore-gateway"
54074
54090
  ]
54075
54091
  },
54076
54092
  "license": {
@@ -18,16 +18,19 @@ Drag components from the palette onto the canvas, drag from a component's right
18
18
 
19
19
  Each component on the canvas maps to a generator, and each connection to the <Link path="guides/connection">connection generator</Link>. The commands are emitted in dependency order: the workspace first, then the projects, then the components they host, then the connections wiring them together.
20
20
 
21
+ A website always gets <Link path="guides/react-website-auth">Cognito authentication</Link> added straight after it, since `ts#website` leaves that to a follow-up generator.
22
+
21
23
  An `infra` project is added at the end — <Link path="guides/typescript-infrastructure">`ts#infra`</Link> or <Link path="guides/terraform-project">`terraform#project`</Link>, matching your IaC choice. Every generated project vends constructs for it to instantiate, so this is what you deploy. Because it owns that name, no component on the canvas can be called `infra`.
22
24
 
23
25
  Drag the canvas background to pan around, and drag a component to reposition it. Shift-click to select several components and move them as a group. Click a connection to select it, then press <kbd>Delete</kbd> to remove it (or use the ✕ on the connection itself).
24
26
 
25
27
  The palette lists every project and component type that can take part in a connection, and you can only draw the connections the plugin supports — so a graph that validates is a graph that scaffolds.
26
28
 
27
- Two rules are worth knowing:
29
+ Three rules are worth knowing:
28
30
 
29
31
  - **Components share a host project.** An agent and an MCP server are added _to_ a project rather than being projects of their own. Give them the same host project name to put them in one project, or different names for one project each.
30
32
  - **Some connections constrain their endpoints.** Connecting an agent to another agent requires the target to use the `a2a` protocol, for instance. Where a property setting would break a connection you have drawn, the builder says so against the component and the connection.
33
+ - **Drawing a connection can adjust the target.** Connecting a website to an agent switches that agent to the `ag-ui` protocol, and connecting an agent to another agent switches the target to `a2a` — the protocols those connections are built on. A property you have set yourself is never changed.
31
34
 
32
35
  :::tip[Prefer to build with AI?]
33
36
  The plugin ships an MCP server, so your coding agent can scaffold and connect projects for you. See <Link path="get_started/building-with-ai">Building with AI</Link>.
@@ -182,7 +182,7 @@ So we'll need to make sure we pass those to `generateFiles`, as well as the dire
182
182
 
183
183
  Let's update the generator to do that:
184
184
 
185
- ```ts title="procedure/generator.ts" {8-19}
185
+ ```ts title="procedure/generator.ts" {16-30}
186
186
  import {
187
187
  generateFiles,
188
188
  joinPathFragments,
@@ -230,7 +230,7 @@ Next, we want the generator to hook up the new procedure to the router. This mea
230
230
 
231
231
  We use [GritQL](https://docs.grit.io/) to declaratively search and transform source code. The `addDestructuredImport` helper adds named imports, and `applyGritQL` applies a GritQL pattern to add the procedure to the router's object literal.
232
232
 
233
- ```ts title="procedure/generator.ts" {6, 23-36}
233
+ ```ts title="procedure/generator.ts" {11, 33-46}
234
234
  import {
235
235
  generateFiles,
236
236
  joinPathFragments,
@@ -120,7 +120,7 @@ Below is a list of all files which have been generated by the `ts#api` generator
120
120
 
121
121
  Let us look at these key files:
122
122
 
123
- ```ts {5}
123
+ ```ts {7}
124
124
  // packages/game-api/src/router.ts
125
125
  import { echo } from './procedures/echo.js';
126
126
  import { t } from './init.js';
@@ -135,7 +135,7 @@ export type AppRouter = typeof appRouter;
135
135
  ```
136
136
  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.
137
137
 
138
- ```ts {2-5}
138
+ ```ts {7-10}
139
139
  // packages/game-api/src/procedures/echo.ts
140
140
  import { publicProcedure } from '../init.js';
141
141
  import {
@@ -15,7 +15,12 @@ import Link from '@components/link.astro';
15
15
  import NxCommands from '@components/nx-commands.astro';
16
16
  import OptionFilter from '@components/option-filter.astro';
17
17
 
18
- Generate an [Amazon Bedrock AgentCore Gateway](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway.html) project. An AgentCore Gateway is a managed entry point that aggregates one or more MCP server targets behind a single MCP endpoint, authenticates inbound requests (IAM or Cognito), evaluates every tool call against a [Cedar policy engine](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/policy.html), and signs outbound traffic to MCP servers with IAM SigV4.
18
+ Generate an [Amazon Bedrock AgentCore Gateway](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway.html) project. An AgentCore Gateway is a managed entry point in front of your MCP servers or agents, authenticating inbound requests (IAM or Cognito) and signing outbound traffic to its targets with IAM SigV4.
19
+
20
+ The `protocol` option selects what the Gateway fronts:
21
+
22
+ - **`mcp`** (default) — aggregates one or more MCP server targets behind a single MCP endpoint, and evaluates every tool call against a [Cedar policy engine](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/policy.html).
23
+ - **`http`** — proxies requests directly to [AgentCore Runtime targets](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-target-http-runtime.html) (your agents) via path-based routing (`/<targetName>/invocations`), without aggregation or protocol translation. Use this to front agents with a single governed endpoint — for example so a website can reach agents that are deployed inside a VPC through the Gateway.
19
24
 
20
25
  ## Usage
21
26
 
@@ -33,10 +38,10 @@ The generator creates a new project at `packages/<name>/`, plus a CDK construct
33
38
 
34
39
  <FileTree>
35
40
  - packages/\<name>/
36
- - policies/ Cedar policy source files (omitted when `cedarPolicy: false`)
41
+ - policies/ Cedar policy source files (`mcp` protocol only; omitted when `cedarPolicy: false`)
37
42
  - permit-all.cedar Default Cedar policy that permits authenticated callers
38
43
  - README.md Reference for writing Cedar policies
39
- - local-dev.ts Local gateway aggregating attached MCP servers for local development
44
+ - local-dev.ts Local gateway for local development — aggregates attached MCP servers (`mcp`) or proxies attached agents (`http`)
40
45
  - project.json Adds the `serve` and `dev` targets
41
46
  </FileTree>
42
47
 
@@ -71,9 +76,9 @@ Infrastructure is generated when `infra` is `agentcore` (the default). With `inf
71
76
 
72
77
  The generated construct creates the following AWS resources:
73
78
 
74
- - An `AgentCore::Gateway` configured for the MCP protocol with inbound IAM authentication (default) or Cognito JWT authentication (see <a href="#authentication">Authentication</a>)
75
- - An `AgentCore::PolicyEngine` running in `ENFORCE` mode, attached to the Gateway (omitted when `cedarPolicy: false`)
76
- - One `AgentCore::Policy` per `.cedar` file in `policies/`
79
+ - An `AgentCore::Gateway` with inbound IAM authentication (default) or Cognito JWT authentication (see <a href="#authentication">Authentication</a>). An `mcp` gateway is configured for the MCP protocol; an `http` gateway has no protocol type, which AgentCore requires for its runtime targets
80
+ - An `AgentCore::PolicyEngine` running in `ENFORCE` mode, attached to the Gateway (`mcp` gateways only; omitted when `cedarPolicy: false`)
81
+ - One `AgentCore::Policy` per `.cedar` file in `policies/` (`mcp` gateways only)
77
82
  - An AWS WAFv2 Web ACL associated with the Gateway, with request logging to CloudWatch (enabled by default — see <a href="#aws-waf">AWS WAF</a>)
78
83
 
79
84
  The Gateway URL is automatically registered in the `agentcore.gateways.<ClassName>` namespace of <Link path="guides/runtime-config">Runtime Configuration</Link> so agents can discover it at runtime.
@@ -146,7 +151,7 @@ export class ApplicationStack extends Stack {
146
151
  <Fragment slot="terraform">
147
152
  The generated module requires `user_pool_id` and `user_pool_client_ids` variables:
148
153
 
149
- ```hcl {6-7} title="packages/infra/src/main.tf"
154
+ ```hcl {7-8} title="packages/infra/src/main.tf"
150
155
  module "user_identity" {
151
156
  source = "../../common/terraform/src/core/user-identity"
152
157
  }
@@ -207,7 +212,7 @@ Add new variables where the policies are rendered, for example to pass an agent'
207
212
  <Fragment slot="cdk">
208
213
  In `packages/common/constructs/src/app/gateways/<name>/<name>.ts`, pass `cedarPolicyVariables` through to the shared construct:
209
214
 
210
- ```ts {4-6}
215
+ ```ts {5-6}
211
216
  super(scope, id, {
212
217
  cedarPolicyPath: path.join(
213
218
  ...
@@ -347,11 +352,19 @@ This denies the Python agent role from calling `ts-mcp___divide` while leaving t
347
352
 
348
353
  ## Local Development
349
354
 
350
- The generator adds a `dev` target to the Gateway project, which runs `local-dev.ts`: a local gateway exposing a single MCP endpoint that aggregates every attached MCP server (connected via the <Link path="guides/connection/agentcore-gateway-mcp">`agentcore-gateway#mcp-connection` generator</Link>), with tools prefixed `<target>___<tool>` to match the deployed Gateway. Running it starts the local gateway and all attached MCP servers together:
355
+ The generator adds a `dev` target to the Gateway project, which runs `local-dev.ts`. Running it starts the local gateway and every attached target together:
351
356
 
352
357
  <NxCommands commands={["dev <name>"]} />
353
358
 
354
- See the connection guide for the full local development story.
359
+ <OptionFilter when={{ protocol: 'mcp' }} description="MCP aggregator local gateway">
360
+ The local gateway exposes a single MCP endpoint that aggregates every attached MCP server (connected via the <Link path="guides/connection/agentcore-gateway-mcp">`agentcore-gateway#mcp-connection` generator</Link>), with tools prefixed `<target>___<tool>` to match the deployed Gateway.
361
+ </OptionFilter>
362
+
363
+ <OptionFilter when={{ protocol: 'http' }} description="Path-routing proxy local gateway">
364
+ The local gateway proxies `/<targetName>/...` paths to each attached agent's local server (connected via the <Link path="guides/connection/agentcore-gateway-agent">`agentcore-gateway#agent-connection` generator</Link>), matching the deployed Gateway's path-based routing.
365
+ </OptionFilter>
366
+
367
+ See the connection guides for the full local development story.
355
368
 
356
369
  ## Deploying your AgentCore Gateway
357
370
 
@@ -460,4 +473,18 @@ Use the <Link path="guides/connection">`connection`</Link> generator to integrat
460
473
  sourceBadge="python"
461
474
  target="agentcore"
462
475
  />
476
+ <ConnectionCard
477
+ title="AgentCore Gateway to Agent"
478
+ description="Front an agent with an AgentCore Gateway as a runtime target"
479
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/agentcore-gateway-agent`}
480
+ source="agentcore"
481
+ target="strands"
482
+ />
483
+ <ConnectionCard
484
+ title="React Website to AgentCore Gateway"
485
+ description="Connect a React website to agents through an AgentCore Gateway"
486
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-agentcore-gateway`}
487
+ source="react"
488
+ target="agentcore"
489
+ />
463
490
  </CardGrid>
@@ -0,0 +1,282 @@
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` and `auth: iam`
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
+ networkConfiguration: RuntimeNetworkConfiguration.usingVpc(this, {
91
+ vpc,
92
+ vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },
93
+ }),
94
+ });
95
+ ```
96
+
97
+ 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.
98
+ :::
99
+ </Fragment>
100
+ <Fragment slot="terraform">
101
+ In the Terraform file where you instantiate the Gateway, wire the agent target in:
102
+
103
+ ```hcl title="packages/infra/src/main.tf" {9-20,24-40}
104
+ module "my_agent" {
105
+ source = "../../common/terraform/src/app/agents/my-agent"
106
+ # ...
107
+ }
108
+
109
+ module "my_gateway" {
110
+ source = "../../common/terraform/src/app/gateways/my-gateway"
111
+
112
+ # The Gateway signs outbound calls to the runtime with its own role and
113
+ # validates access at target creation, so it needs invoke access first.
114
+ additional_iam_policy_statements = [
115
+ {
116
+ Effect = "Allow"
117
+ Action = [
118
+ "bedrock-agentcore:InvokeAgentRuntime",
119
+ "bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream",
120
+ # A2A targets additionally serve their agent card via the gateway
121
+ "bedrock-agentcore:GetAgentCard",
122
+ ]
123
+ Resource = [
124
+ module.my_agent.agent_core_runtime_arn,
125
+ "${module.my_agent.agent_core_runtime_arn}/*",
126
+ ]
127
+ }
128
+ ]
129
+ }
130
+
131
+ # Register the agent as a runtime target of the Gateway. The target name
132
+ # forms the invocation path: <gatewayUrl>/my-agent/invocations
133
+ resource "aws_bedrockagentcore_gateway_target" "my_agent" {
134
+ gateway_identifier = module.my_gateway.gateway_id
135
+ name = "my-agent"
136
+ # AgentCore fills in a description when none is set, which the provider
137
+ # reports as an inconsistent result after apply — so always set one.
138
+ description = "Agent runtime target my-agent"
139
+
140
+ target_configuration {
141
+ http {
142
+ agentcore_runtime {
143
+ arn = module.my_agent.agent_core_runtime_arn
144
+ }
145
+ }
146
+ }
147
+
148
+ credential_provider_configuration {
149
+ gateway_iam_role {}
150
+ }
151
+ }
152
+ ```
153
+
154
+ :::tip[Deploying agents into a VPC]
155
+ 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:
156
+
157
+ ```hcl
158
+ module "my_agent" {
159
+ source = "../../common/terraform/src/app/agents/my-agent"
160
+
161
+ enable_vpc = true
162
+ vpc_id = aws_vpc.my_vpc.id
163
+ subnet_ids = [aws_subnet.private_a.id, aws_subnet.private_b.id]
164
+ }
165
+ ```
166
+
167
+ 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.
168
+ :::
169
+ </Fragment>
170
+ </Infrastructure>
171
+
172
+ ## Invoking the agent through the Gateway
173
+
174
+ 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.
175
+
176
+ To connect a website to the Gateway's agents, use the <Link path="guides/connection/react-agentcore-gateway">`connection` generator</Link>.
177
+
178
+ ## Forwarding caller identity to the runtime
179
+
180
+ 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 you want the agent to authorize on the caller — for example to read the user's `sub` or `scope` claims — the Gateway can instead forward the caller's JWT to the runtime unchanged. This requires three changes:
181
+
182
+ 1. **The Gateway accepts JWTs.** Generate the Gateway with `auth: cognito` so its inbound authorizer validates a Cognito (or other OIDC) bearer token.
183
+ 2. **The runtime accepts the same JWTs.** Generate the agent with `auth: cognito` (same user pool) so the runtime revalidates the forwarded token.
184
+ 3. **The target uses the `JWT_PASSTHROUGH` credential provider** instead of `GATEWAY_IAM_ROLE`, and the **runtime allowlists the `Authorization` header** so it reaches your agent code. Without the allowlist, AgentCore validates the token but strips the header before your container.
185
+
186
+ Callers then 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:
187
+
188
+ ```python title="packages/py_project/.../my_agent/main.py"
189
+ import jwt # PyJWT
190
+
191
+ @app.post('/invocations')
192
+ async def invoke(input: InvokeInput, request: Request):
193
+ token = request.headers['authorization'].removeprefix('Bearer ')
194
+ claims = jwt.decode(token, options={'verify_signature': False})
195
+ # authorize on claims['sub'], claims['scope'], ...
196
+ ```
197
+
198
+ <Infrastructure>
199
+ <Fragment slot="cdk">
200
+ Pass `requestHeaderConfiguration` to the agent so the runtime receives the header, and create the target yourself (instead of `gateway.addAgent(agent)`) with the `JWT_PASSTHROUGH` credential provider:
201
+
202
+ ```ts title="packages/infra/src/stacks/application-stack.ts" {5-7,17-19}
203
+ import { CfnGatewayTarget } from 'aws-cdk-lib/aws-bedrockagentcore';
204
+ import { PolicyStatement } from 'aws-cdk-lib/aws-iam';
205
+
206
+ const myAgent = new MyAgent(this, 'MyAgent', {
207
+ identity,
208
+ // Let the runtime receive the forwarded Authorization header.
209
+ requestHeaderConfiguration: { allowlistedHeaders: ['Authorization'] },
210
+ });
211
+ const myGateway = new MyGateway(this, 'MyGateway', { identity });
212
+
213
+ const target = new CfnGatewayTarget(this, 'Target-my-agent', {
214
+ gatewayIdentifier: myGateway.gateway.gatewayId,
215
+ name: myAgent.agentName,
216
+ targetConfiguration: {
217
+ http: { agentcoreRuntime: { arn: myAgent.agentCoreRuntime.agentRuntimeArn } },
218
+ },
219
+ // Forward the caller's validated JWT to the runtime unchanged.
220
+ credentialProviderConfigurations: [
221
+ { credentialProviderType: 'JWT_PASSTHROUGH' },
222
+ ],
223
+ });
224
+
225
+ // The Gateway role still needs invoke access to the runtime.
226
+ myGateway.gateway.role.addToPrincipalPolicy(
227
+ new PolicyStatement({
228
+ actions: ['bedrock-agentcore:InvokeAgentRuntime'],
229
+ resources: [
230
+ myAgent.agentCoreRuntime.agentRuntimeArn,
231
+ `${myAgent.agentCoreRuntime.agentRuntimeArn}/*`,
232
+ ],
233
+ }),
234
+ );
235
+ ```
236
+ </Fragment>
237
+ <Fragment slot="terraform">
238
+ Add a `request_header_configuration` block to the runtime so it receives the header, and configure the target with the `JWT_PASSTHROUGH` credential provider (instead of `gateway_iam_role {}`):
239
+
240
+ ```hcl title="packages/infra/src/main.tf" {5-7,20-22}
241
+ # Let the runtime receive the forwarded Authorization header. Add this block
242
+ # to the runtime resource in the agent module (packages/common/terraform/...).
243
+ resource "aws_bedrockagentcore_agent_runtime" "agent_runtime" {
244
+ # ...
245
+ request_header_configuration {
246
+ request_header_allowlist = ["Authorization"]
247
+ }
248
+ }
249
+
250
+ resource "aws_bedrockagentcore_gateway_target" "my_agent" {
251
+ gateway_identifier = module.my_gateway.gateway_id
252
+ name = "my-agent"
253
+ description = "Agent runtime target my-agent"
254
+
255
+ target_configuration {
256
+ http {
257
+ agentcore_runtime {
258
+ arn = module.my_agent.agent_core_runtime_arn
259
+ }
260
+ }
261
+ }
262
+
263
+ # Forward the caller's validated JWT to the runtime unchanged.
264
+ credential_provider_configuration {
265
+ credential_provider_type = "JWT_PASSTHROUGH"
266
+ }
267
+ }
268
+ ```
269
+ </Fragment>
270
+ </Infrastructure>
271
+
272
+ :::note
273
+ `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.
274
+ :::
275
+
276
+ ## Local Development
277
+
278
+ Running the Gateway locally with:
279
+
280
+ <NxCommands commands={["dev <gateway-name>"]} />
281
+
282
+ 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.
@@ -58,7 +58,7 @@ The generator **cannot** automatically wire the gateway target into your infrast
58
58
  <Fragment slot="cdk">
59
59
  In the stack where you instantiate the Gateways, register the target gateway as a target of the source gateway:
60
60
 
61
- ```ts title="packages/infra/src/stacks/application-stack.ts" {5-6}
61
+ ```ts title="packages/infra/src/stacks/application-stack.ts" {4-7}
62
62
  const innerGateway = new InnerGateway(this, 'InnerGateway');
63
63
  const outerGateway = new OuterGateway(this, 'OuterGateway');
64
64
 
@@ -81,7 +81,7 @@ The construct grants the source gateway's execution role `bedrock-agentcore:Invo
81
81
  <Fragment slot="terraform">
82
82
  In the Terraform file where you instantiate the Gateways, wire the gateway target in:
83
83
 
84
- ```hcl title="packages/infra/src/main.tf" {2-5,11-15,18-36}
84
+ ```hcl title="packages/infra/src/main.tf" {4-6,11,13-19,22-40}
85
85
  module "inner_gateway" {
86
86
  source = "../../common/terraform/src/app/gateways/inner-gateway"
87
87
 
@@ -61,7 +61,7 @@ The generator **cannot** automatically wire the MCP server target into your infr
61
61
  <Fragment slot="cdk">
62
62
  In the stack where you instantiate the Gateway, register the MCP server as a target:
63
63
 
64
- ```ts title="packages/infra/src/stacks/application-stack.ts" {5-6}
64
+ ```ts title="packages/infra/src/stacks/application-stack.ts" {4-7}
65
65
  const myMcpServer = new MyMcpServer(this, 'MyMcpServer');
66
66
  const myGateway = new MyGateway(this, 'MyGateway');
67
67
 
@@ -84,7 +84,7 @@ The construct configures the target with `iamCredentialProvider.service = 'bedro
84
84
  <Fragment slot="terraform">
85
85
  In the Terraform file where you instantiate the Gateway, wire the MCP server target in:
86
86
 
87
- ```hcl title="packages/infra/src/main.tf" {7,11-27}
87
+ ```hcl title="packages/infra/src/main.tf" {7,10-28}
88
88
  module "my_mcp_server" {
89
89
  source = "../../common/terraform/src/app/mcp-servers/my-mcp-server"
90
90
  }
@@ -92,7 +92,7 @@ def get_agent():
92
92
  ```
93
93
  </TabItem>
94
94
  <TabItem label="LangChain" _filter={{ framework: 'langchain' }}>
95
- ```python title="packages/my-project/my_module/agent/agent.py" {4,7-12,14}
95
+ ```python title="packages/my-project/my_module/agent/agent.py" {5,8-13,15}
96
96
  from langchain.agents import create_agent
97
97
  from langchain_aws import ChatBedrockConverse
98
98
  from langchain_core.tools import tool
@@ -91,7 +91,7 @@ def get_agent():
91
91
  `MyGatewayClientStrands.create()` returns a single context-manageable `MCPClient` whose `list_tools_sync()` yields every tool available through the Gateway.
92
92
  </TabItem>
93
93
  <TabItem label="LangChain" _filter={{ framework: 'langchain' }}>
94
- ```python title="packages/example/example/my_agent/agent.py" {4,8,12}
94
+ ```python title="packages/example/example/my_agent/agent.py" {4,7,11}
95
95
  from langchain.agents import create_agent
96
96
  from langchain_aws import ChatBedrockConverse
97
97
 
@@ -134,7 +134,7 @@ gateway.grantInvokeAccess(myAgent);
134
134
  The Gateway URL is automatically registered in the `agentcore.gateways.<ClassName>` namespace of <Link path="guides/runtime-config">Runtime Configuration</Link> by the generated CDK construct, so the agent can discover it at runtime.
135
135
  </Fragment>
136
136
  <Fragment slot="terraform">
137
- ```hcl title="packages/infra/src/main.tf" {6-13}
137
+ ```hcl title="packages/infra/src/main.tf" {8-13}
138
138
  module "my_gateway" {
139
139
  source = "../../common/terraform/src/app/gateways/my-gateway"
140
140
  }
@@ -70,7 +70,7 @@ The generator transforms your agent's `agent.py` to use the MCP server's tools:
70
70
 
71
71
  <Tabs syncKey="agent-framework">
72
72
  <TabItem label="Strands" _filter={{ framework: 'strands' }}>
73
- ```python title="packages/my-project/my_module/agent/agent.py" {4,9-13}
73
+ ```python title="packages/my-project/my_module/agent/agent.py" {4,8,9-13}
74
74
  from contextlib import contextmanager
75
75
  from strands import Agent
76
76
 
@@ -91,7 +91,7 @@ def get_agent():
91
91
  The Strands client is a context manager, entered in a `with` block around the agent.
92
92
  </TabItem>
93
93
  <TabItem label="LangChain" _filter={{ framework: 'langchain' }}>
94
- ```python title="packages/my-project/my_module/agent/agent.py" {4,8,13}
94
+ ```python title="packages/my-project/my_module/agent/agent.py" {4,7,11}
95
95
  from langchain.agents import create_agent
96
96
  from langchain_aws import ChatBedrockConverse
97
97
 
@@ -131,7 +131,7 @@ The MCP server's AgentCore runtime ARN is automatically registered in the `agent
131
131
  <Fragment slot="terraform">
132
132
  After running the connection generator, you need to grant the agent permission to invoke the MCP server in your Terraform configuration:
133
133
 
134
- ```hcl title="packages/infra/src/main.tf" {12-24}
134
+ ```hcl title="packages/infra/src/main.tf" {9-25}
135
135
  module "inventory_mcp_server" {
136
136
  source = "../../common/terraform/src/app/mcp-servers/inventory-mcp"
137
137
  }
@@ -0,0 +1,112 @@
1
+ ---
2
+ title: React Website to AgentCore Gateway
3
+ description: Connect a React website to agents through an AgentCore Gateway
4
+ when:
5
+ sourceType: ts#react-website
6
+ targetType: agentcore-gateway
7
+ ---
8
+ import { FileTree } from '@astrojs/starlight/components';
9
+ import Link from '@components/link.astro';
10
+ import RunGenerator from '@components/run-generator.astro';
11
+ import GeneratorParameters from '@components/generator-parameters.astro';
12
+ import NxCommands from '@components/nx-commands.astro';
13
+ import Infrastructure from '@components/infrastructure.astro';
14
+
15
+ The `connection` generator can connect a <Link path="guides/react-website">React website</Link> to the agents fronted by an <Link path="guides/agentcore-gateway">AgentCore Gateway</Link> generated with `protocol: http`.
16
+
17
+ The browser talks only to the Gateway — requests to `<gatewayUrl>/<targetName>/invocations` are proxied to the agent runtime behind it. Because the website never needs to reach the runtimes directly, the agents can be deployed inside a VPC, with the Gateway as the single governed entry point providing authentication and observability.
18
+
19
+ ## Prerequisites
20
+
21
+ Before using this generator, ensure you have:
22
+
23
+ 1. A <Link path="guides/react-website">React website</Link> project
24
+ 2. An <Link path="guides/agentcore-gateway">`agentcore-gateway`</Link> project generated with `protocol: http`
25
+ 3. At least one AG-UI or HTTP agent attached to the Gateway via the <Link path="guides/connection/agentcore-gateway-agent">Gateway to agent connection generator</Link>
26
+
27
+ The generator creates a website client for **each** AG-UI or HTTP agent attached to the Gateway (A2A targets are skipped — they speak agent-to-agent JSON-RPC, not a browser protocol). It generates the same clients as connecting the website to each agent directly (<Link path="guides/connection/react-agui">AG-UI/CopilotKit</Link> for AG-UI agents, an <Link path="guides/connection/react-py-agent">OpenAPI client</Link> for Python HTTP agents), routed through the Gateway rather than at the runtime.
28
+
29
+ :::note[Authentication]
30
+ The browser authenticates with the **Gateway**, not the agents: SigV4 for an IAM Gateway (via the website's Cognito identity pool), or a JWT bearer token for a Cognito Gateway.
31
+ :::
32
+
33
+ ## Usage
34
+
35
+ ### Run the Generator
36
+
37
+ <RunGenerator generator="connection" />
38
+
39
+ Select the website project as the source and the Gateway project as the target.
40
+
41
+ ### Options
42
+
43
+ <GeneratorParameters generator="connection" />
44
+
45
+ ## Generator Output
46
+
47
+ For each fronted AG-UI agent, the same files as the <Link path="guides/connection/react-agui">React to AG-UI agent connection</Link> are generated (an `AguiProvider`, a `useAgui<Agent>` hook and a themed CopilotKit component module), with the hook reading the Gateway's URL from runtime configuration:
48
+
49
+ <FileTree>
50
+
51
+ - packages/\<website>/src
52
+ - components
53
+ - AguiProvider.tsx CopilotKit provider registering each agent
54
+ - copilot/ Themed chat components
55
+ - hooks
56
+ - useAgui\<Agent>.tsx Connects to the agent via the Gateway's `/<targetName>/invocations` route
57
+
58
+ </FileTree>
59
+
60
+ For each fronted Python HTTP agent, the same files as the <Link path="guides/connection/react-py-agent">React to Python agent connection</Link> are generated (a type-safe OpenAPI client, hooks, and a provider), with the client's base URL routed through the Gateway.
61
+
62
+ The Gateway's URL is registered in the `connection.gateways.<GatewayClassName>` namespace of <Link path="guides/runtime-config">Runtime Configuration</Link>, so it is published to the website's `runtime-config.json`.
63
+
64
+ ## Granting website users access
65
+
66
+ For an **IAM** Gateway, grant the website's authenticated users permission to invoke it (a **Cognito** Gateway needs no grant — the browser authenticates with its JWT bearer token instead):
67
+
68
+ <Infrastructure>
69
+ <Fragment slot="cdk">
70
+ ```ts title="packages/infra/src/stacks/application-stack.ts" {6}
71
+ const identity = new UserIdentity(this, 'UserIdentity');
72
+ new Website(this, 'Website');
73
+
74
+ const myGateway = new MyGateway(this, 'MyGateway');
75
+ myGateway.addAgent(myAgent);
76
+ myGateway.grantInvokeAccess(identity.identityPool.authenticatedRole);
77
+ ```
78
+ </Fragment>
79
+ <Fragment slot="terraform">
80
+ ```hcl title="packages/infra/src/main.tf"
81
+ resource "aws_iam_policy" "gateway_invoke_policy" {
82
+ name = "GatewayInvokePolicy"
83
+
84
+ policy = jsonencode({
85
+ Version = "2012-10-17"
86
+ Statement = [
87
+ {
88
+ Effect = "Allow"
89
+ Action = ["bedrock-agentcore:InvokeGateway"]
90
+ Resource = [module.my_gateway.gateway_arn]
91
+ }
92
+ ]
93
+ })
94
+ }
95
+
96
+ resource "aws_iam_role_policy_attachment" "authenticated_gateway_access" {
97
+ role = module.user_identity.authenticated_role_name
98
+ policy_arn = aws_iam_policy.gateway_invoke_policy.arn
99
+ }
100
+ ```
101
+ </Fragment>
102
+ </Infrastructure>
103
+
104
+ ## Local Development
105
+
106
+ The website's `dev` target gains a dependency on the Gateway project's `dev` target, which starts the local gateway plus every attached agent. The website's runtime configuration is overridden in `local-dev` mode to point the Gateway's URL at the local gateway, so the browser exercises the same `/<targetName>/invocations` routes locally:
107
+
108
+ <NxCommands commands={["dev <website-name>"]} />
109
+
110
+ ## Connecting new agents
111
+
112
+ The generator connects the website to the agents attached to the Gateway **at the time it runs**. After attaching another agent to the Gateway, re-run the connection generator to generate its website client — existing clients are left untouched.
@@ -69,7 +69,7 @@ export interface ServiceContext {
69
69
 
70
70
  The Prisma client is instantiated inside `lambdaHandler` and passed through the service context:
71
71
 
72
- ```ts title="packages/api/src/handler.ts" {1,10}
72
+ ```ts title="packages/api/src/handler.ts" {1,5,10}
73
73
  import { getPrisma as getMyDb } from '@my-scope/my-db';
74
74
 
75
75
  export const lambdaHandler = async (event: APIGatewayProxyEvent) => {
@@ -65,7 +65,7 @@ export const authenticatedProcedure = t.procedure
65
65
 
66
66
  The plugin merges `IMyDbContext` into your procedure context, making `myDb` available as an optional property:
67
67
 
68
- ```ts title="packages/api/src/procedures/users.ts" {8,12}
68
+ ```ts title="packages/api/src/procedures/users.ts" {7-8}
69
69
  import { z } from 'zod';
70
70
  import { authenticatedProcedure } from '../router.js';
71
71
 
@@ -68,7 +68,7 @@ Additionally, it:
68
68
 
69
69
  The generator transforms your agent's `agent.ts` to wrap the remote A2A agent as a tool:
70
70
 
71
- ```ts title="packages/example/src/my-agent/agent.ts" {2,5-11,14}
71
+ ```ts title="packages/example/src/my-agent/agent.ts" {2,5-12,15}
72
72
  import { Agent, tool } from '@strands-agents/sdk';
73
73
  import { RemoteAgentClientStrands } from '@my-scope/agent-connection';
74
74
  import { z } from 'zod';
@@ -99,7 +99,7 @@ gateway.grantInvokeAccess(myAgent);
99
99
  The Gateway URL is automatically registered in the `agentcore.gateways.<ClassName>` namespace of <Link path="guides/runtime-config">Runtime Configuration</Link> by the generated CDK construct, so the agent can discover it at runtime.
100
100
  </Fragment>
101
101
  <Fragment slot="terraform">
102
- ```hcl title="packages/infra/src/main.tf" {6-13}
102
+ ```hcl title="packages/infra/src/main.tf" {8-13}
103
103
  module "my_gateway" {
104
104
  source = "../../common/terraform/src/app/gateways/my-gateway"
105
105
  }
@@ -102,7 +102,7 @@ The MCP server's AgentCore runtime ARN is automatically registered in the `agent
102
102
  <Fragment slot="terraform">
103
103
  After running the connection generator, you need to grant the agent permission to invoke the MCP server in your Terraform configuration:
104
104
 
105
- ```hcl title="packages/infra/src/main.tf" {12-24}
105
+ ```hcl title="packages/infra/src/main.tf" {9-25}
106
106
  module "inventory_mcp_server" {
107
107
  source = "../../common/terraform/src/app/mcp-servers/inventory-mcp"
108
108
  }
@@ -247,6 +247,20 @@ The Connection generator supports the following connections:
247
247
  sourceBadge="python"
248
248
  target="agentcore"
249
249
  />
250
+ <ConnectionCard
251
+ title="AgentCore Gateway to Agent"
252
+ description="Front an agent with an AgentCore Gateway as a runtime target"
253
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/agentcore-gateway-agent`}
254
+ source="agentcore"
255
+ target="strands"
256
+ />
257
+ <ConnectionCard
258
+ title="React Website to AgentCore Gateway"
259
+ description="Connect a React website to agents through an AgentCore Gateway"
260
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-agentcore-gateway`}
261
+ source="react"
262
+ target="agentcore"
263
+ />
250
264
  </CardGrid>
251
265
 
252
266
  :::note[Runtime Configuration]
@@ -542,7 +542,7 @@ This sets up:
542
542
  :::note[Cognito Authentication]
543
543
  If you selected to use `Cognito` authentication, you will need to supply the Cognito configuration:
544
544
 
545
- ```hcl {3, 5-6}
545
+ ```hcl {6-7}
546
546
  module "my_api" {
547
547
  source = "../../common/terraform/src/app/apis/my-api"
548
548
 
@@ -688,4 +688,11 @@ Use the <Link path="guides/connection">`connection`</Link> generator to integrat
688
688
  sourceBadge="python"
689
689
  target="agentcore"
690
690
  />
691
+ <ConnectionCard
692
+ title="AgentCore Gateway to Agent"
693
+ description="Front an agent with an AgentCore Gateway as a runtime target"
694
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/agentcore-gateway-agent`}
695
+ source="agentcore"
696
+ target="strands"
697
+ />
691
698
  </CardGrid>
@@ -145,7 +145,7 @@ By default the distribution uses the default CloudFront domain name (`*.cloudfro
145
145
  <Fragment slot="cdk">
146
146
  Pass the `certificate` and `domainNames` props through in your generated website construct in `packages/common/constructs/src/app/static-websites`:
147
147
 
148
- ```ts {6-9}
148
+ ```ts {6-8}
149
149
  export class MyWebsite extends StaticWebsite {
150
150
  constructor(scope: Construct, id: string) {
151
151
  super(scope, id, {
@@ -272,7 +272,7 @@ With Terraform, runtime configuration is managed through the runtime-config modu
272
272
 
273
273
  Your website Terraform module will deploy the `connection` namespace of the runtime configuration as a `runtime-config.json` file to the root of your S3 bucket.
274
274
 
275
- ```hcl title="packages/infra/src/main.tf" {18-19}
275
+ ```hcl title="packages/infra/src/main.tf" {20-21}
276
276
  module "asset_bucket" {
277
277
  source = "../../common/terraform/src/core/asset-bucket"
278
278
  }
@@ -533,4 +533,11 @@ Use the <Link path="guides/connection">`connection`</Link> generator to integrat
533
533
  source="react"
534
534
  target="copilotkit"
535
535
  />
536
+ <ConnectionCard
537
+ title="React Website to AgentCore Gateway"
538
+ description="Connect a React website to agents through an AgentCore Gateway"
539
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-agentcore-gateway`}
540
+ source="react"
541
+ target="agentcore"
542
+ />
536
543
  </CardGrid>
@@ -84,7 +84,7 @@ Application projects include full deployment capabilities with remote state mana
84
84
 
85
85
  You can start writing your Terraform infrastructure inside `src/main.tf`, for example:
86
86
 
87
- ```diff title="src/main.tf" {2-4}
87
+ ```diff title="src/main.tf" {16-19}
88
88
  -locals {
89
89
  - account_id = data.aws_caller_identity.current.account_id
90
90
  - aws_region = data.aws_region.current.id
@@ -577,7 +577,7 @@ When using `Custom` auth, the construct creates a Lambda Authorizer internally f
577
577
  </OptionFilter>
578
578
 
579
579
  <OptionFilter when={{ auth: 'cognito' }} description="CDK usage with Cognito authentication — pass the identity construct">
580
- ```ts {6,9}
580
+ ```ts {6,10}
581
581
  import { MyApi, UserIdentity } from '@my-scope/common-constructs';
582
582
 
583
583
  export class ExampleStack extends Stack {
@@ -633,7 +633,7 @@ module "my_api" {
633
633
  </OptionFilter>
634
634
 
635
635
  <OptionFilter when={{ auth: 'cognito' }} description="Terraform usage with Cognito authentication — supply user pool and client">
636
- ```hcl {1-3, 8-9}
636
+ ```hcl {1-3, 8, 10-11}
637
637
  module "asset_bucket" {
638
638
  source = "../../common/terraform/src/core/asset-bucket"
639
639
  }
@@ -599,4 +599,11 @@ Use the <Link path="guides/connection">`connection`</Link> generator to integrat
599
599
  sourceBadge="typescript"
600
600
  target="agentcore"
601
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
+ />
602
609
  </CardGrid>
@@ -308,7 +308,7 @@ You must construct the context yourself in both `handler.ts` (the Lambda functio
308
308
 
309
309
  The generator configures structured logging using AWS Lambda Powertools with automatic context injection via Middy middleware.
310
310
 
311
- ```typescript {4}
311
+ ```typescript {3}
312
312
  // handler.ts
313
313
  export const handler = middy<APIGatewayProxyEvent, APIGatewayProxyResult>()
314
314
  .use(captureLambdaHandler(tracer))
@@ -319,7 +319,7 @@ export const handler = middy<APIGatewayProxyEvent, APIGatewayProxyResult>()
319
319
 
320
320
  You can reference the logger from your operation implementations via the context:
321
321
 
322
- ```typescript {6}
322
+ ```typescript {5}
323
323
  // operations/echo.ts
324
324
  import { ServiceContext } from '../context.js';
325
325
  import { Echo as EchoOperation } from '../generated/ssdk/index.js';
@@ -334,7 +334,7 @@ export const Echo: EchoOperation<ServiceContext> = async (input, ctx) => {
334
334
 
335
335
  AWS X-Ray tracing is configured automatically via the `captureLambdaHandler` middleware.
336
336
 
337
- ```typescript {3}
337
+ ```typescript {2}
338
338
  // handler.ts
339
339
  export const handler = middy<APIGatewayProxyEvent, APIGatewayProxyResult>()
340
340
  .use(captureLambdaHandler(tracer))
@@ -345,7 +345,7 @@ export const handler = middy<APIGatewayProxyEvent, APIGatewayProxyResult>()
345
345
 
346
346
  You can add custom subsegments to your traces in your operations:
347
347
 
348
- ```typescript {7, 11, 14}
348
+ ```typescript {6, 10, 13}
349
349
  // operations/echo.ts
350
350
  import { ServiceContext } from '../context.js';
351
351
  import { Echo as EchoOperation } from '../generated/ssdk/index.js';
@@ -368,7 +368,7 @@ export const Echo: EchoOperation<ServiceContext> = async (input, ctx) => {
368
368
 
369
369
  CloudWatch metrics are collected automatically for each request via the `logMetrics` middleware.
370
370
 
371
- ```typescript {5}
371
+ ```typescript {4}
372
372
  // handler.ts
373
373
  export const handler = middy<APIGatewayProxyEvent, APIGatewayProxyResult>()
374
374
  .use(captureLambdaHandler(tracer))
@@ -379,7 +379,7 @@ export const handler = middy<APIGatewayProxyEvent, APIGatewayProxyResult>()
379
379
 
380
380
  You can add custom metrics in your operations:
381
381
 
382
- ```typescript {7}
382
+ ```typescript {6}
383
383
  // operations/echo.ts
384
384
  import { MetricUnit } from '@aws-lambda-powertools/metrics';
385
385
  import { ServiceContext } from '../context.js';
@@ -451,7 +451,7 @@ structure UnauthorizedError {
451
451
 
452
452
  First, expose the resolved identity on the service context in `src/context.ts`. We provide it as a function so that the `UnauthorizedError` is thrown from within an operation (where the Server SDK serializes it to a `403`), rather than from the handler:
453
453
 
454
- ```ts {4-7,15} ins={4-7,15}
454
+ ```ts {5-8,17} ins={5-8,17}
455
455
  import { Logger } from '@aws-lambda-powertools/logger';
456
456
  import { Metrics } from '@aws-lambda-powertools/metrics';
457
457
  import { Tracer } from '@aws-lambda-powertools/tracer';
@@ -710,7 +710,7 @@ This sets up:
710
710
  :::note[Cognito Authentication]
711
711
  If you selected `Cognito` authentication, you will need to supply the Cognito configuration:
712
712
 
713
- ```hcl {3, 5-6}
713
+ ```hcl {6-7}
714
714
  module "my_api" {
715
715
  source = "../../common/terraform/src/app/apis/my-api"
716
716
 
@@ -149,7 +149,7 @@ The `UserIdentity` construct can be generated using the <Link path="/guides/reac
149
149
  <Fragment slot="terraform">
150
150
  The generated module accepts `user_pool_id` and `user_pool_client_ids` variables for Cognito authentication:
151
151
 
152
- ```terraform {8-9}
152
+ ```terraform {11-12}
153
153
  module "user_identity" {
154
154
  source = "../../common/terraform/src/core/user-identity"
155
155
  }
@@ -26,7 +26,7 @@ export class ExampleStack extends Stack {
26
26
  ```
27
27
  </Fragment>
28
28
  <Fragment slot="terraform">
29
- ```terraform {5-6, 10}
29
+ ```terraform {9-10}
30
30
  # Agent
31
31
  module "my_project_agent" {
32
32
  # Relative path to the generated module in the common/terraform project
@@ -9,7 +9,7 @@ Given a CloudFront domain name `<domain_name>`, within the Terraform module for
9
9
  - a `cors_allow_origins` property, set to `["http://localhost:4200", "http://localhost:4300", "https://<domain name>"]`, for HTTP APIs. This restricts the API gateway CORS to this distribution and local host.
10
10
  - an `ALLOWED_ORIGINS` environment variable, set to `"https://<domain_name>"`, for REST APIs. This sets the CloudFront distribution as the only permitted CORS origin (other than local host) in AWS Lambda integrations. Note that this restriction is not applied to preflight OPTIONS - please +1 [this GitHub issue](https://github.com/awslabs/nx-plugin-for-aws/issues/377) to help prioritise addressing this.
11
11
 
12
- ```hcl {4,6,9}
12
+ ```hcl {6,9}
13
13
  module "my_api" {
14
14
  source = "../../common/terraform/src/app/apis/my-api"
15
15
 
@@ -69,7 +69,7 @@ api.integrations.sayHello.handler.addToRolePolicy(new PolicyStatement({
69
69
 
70
70
  If your API uses the `shared` pattern, the shared router Lambda is exposed as `api.integrations.$router`:
71
71
 
72
- ```ts {6}
72
+ ```ts {5}
73
73
  const api = new MyApi(this, 'MyApi', {
74
74
  integrations: MyApi.defaultIntegrations(this).build(),
75
75
  });
@@ -640,7 +640,7 @@ Generated CDK API constructs support two integration patterns:
640
640
 
641
641
  For example, setting `pattern` to `'shared'` creates a single function instead of one per integration:
642
642
 
643
- ```ts {5,11-12}
643
+ ```ts {6}
644
644
  // packages/common/constructs/src/app/apis/my-api.ts
645
645
  export class MyApi<...> extends ... {
646
646
 
@@ -15,7 +15,7 @@ You can edit the generated rest-api construct to add, remove, or adjust rules (f
15
15
  <Fragment slot="cdk">
16
16
  To opt out (for example, to attach your own Web ACL), set `enableWaf` to `false`:
17
17
 
18
- ```ts {4}
18
+ ```ts {3}
19
19
  const api = new MyApi(this, 'MyApi', {
20
20
  integrations: MyApi.defaultIntegrations(this).build(),
21
21
  enableWaf: false,
@@ -25,7 +25,7 @@ const api = new MyApi(this, 'MyApi', {
25
25
  <Fragment slot="terraform">
26
26
  To opt out (for example, to attach your own Web ACL), set `enable_waf` to `false`:
27
27
 
28
- ```hcl {4-5}
28
+ ```hcl {5}
29
29
  module "my_api" {
30
30
  source = "../../common/terraform/src/app/apis/my-api"
31
31
 
@@ -21,7 +21,7 @@ remoteAgent.grantInvokeAccess(myAgent);
21
21
  The remote agent's AgentCore runtime ARN is automatically registered in the `agentcore` namespace of <Link path="guides/runtime-config">Runtime Configuration</Link> by the generated CDK construct, so the host agent can discover it at runtime.
22
22
  </Fragment>
23
23
  <Fragment slot="terraform">
24
- ```hcl title="packages/infra/src/main.tf" {3-6, 11-12, 16-17}
24
+ ```hcl title="packages/infra/src/main.tf" {15-34}
25
25
  module "remote_agent" {
26
26
  source = "../../common/terraform/src/app/agents/remote-agent"
27
27
 
@@ -144,7 +144,7 @@ The `UserIdentity` construct can be generated using the <Link path="/guides/reac
144
144
  <Fragment slot="terraform">
145
145
  The generated module accepts `user_pool_id` and `user_pool_client_ids` variables for Cognito authentication:
146
146
 
147
- ```terraform {8-9}
147
+ ```terraform {11-12}
148
148
  module "user_identity" {
149
149
  source = "../../common/terraform/src/core/user-identity"
150
150
  }
@@ -167,7 +167,7 @@ new MyApi(this, 'MyApi', {
167
167
 
168
168
  You will need to "stub" your service/router for your service to compile if using the `ts#smithy-api` and the TypeScript Server SDK, eg:
169
169
 
170
- ```ts {4}
170
+ ```ts {3}
171
171
  // service.ts
172
172
  export const Service: ApiService<ServiceContext> = {
173
173
  ...
package/generators.json CHANGED
@@ -30,6 +30,20 @@
30
30
  "metric": "g65",
31
31
  "hidden": true
32
32
  },
33
+ "agentcore-gateway#agent-connection": {
34
+ "factory": "./src/agentcore-gateway/agent-connection/generator",
35
+ "schema": "./src/agentcore-gateway/agent-connection/schema.json",
36
+ "description": "Connect an AgentCore Gateway to an agent, adding the agent as a gateway target",
37
+ "metric": "g69",
38
+ "hidden": true
39
+ },
40
+ "agentcore-gateway#react-connection": {
41
+ "factory": "./src/agentcore-gateway/react-connection/generator",
42
+ "schema": "./src/agentcore-gateway/react-connection/schema.json",
43
+ "description": "Connect a React website to an AgentCore Gateway fronting agents",
44
+ "metric": "g70",
45
+ "hidden": true
46
+ },
33
47
  "connection": {
34
48
  "factory": "./src/connection/generator",
35
49
  "schema": "./src/connection/schema.json",
@@ -54,7 +68,9 @@
54
68
  "connection/ts-agent-gateway",
55
69
  "connection/py-agent-gateway",
56
70
  "connection/agentcore-gateway-mcp",
57
- "connection/agentcore-gateway-gateway"
71
+ "connection/agentcore-gateway-gateway",
72
+ "connection/agentcore-gateway-agent",
73
+ "connection/react-agentcore-gateway"
58
74
  ]
59
75
  },
60
76
  "license": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin-mcp",
3
- "version": "1.0.0-rc.58",
3
+ "version": "1.0.0-rc.59",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",
@@ -0,0 +1,31 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "agentcore-gateway#agent-connection",
4
+ "title": "agentcore-gateway#agent-connection",
5
+ "description": "Connect an AgentCore Gateway to an agent, adding the agent as a gateway target",
6
+ "type": "object",
7
+ "properties": {
8
+ "sourceProject": {
9
+ "type": "string",
10
+ "description": "The gateway project"
11
+ },
12
+ "targetProject": {
13
+ "type": "string",
14
+ "description": "The agent project"
15
+ },
16
+ "sourceComponent": {
17
+ "type": "string",
18
+ "description": "The gateway component in the source project"
19
+ },
20
+ "targetComponent": {
21
+ "type": "string",
22
+ "description": "The agent component in the target project"
23
+ },
24
+ "preferInstallDependencies": {
25
+ "type": "boolean",
26
+ "description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
27
+ "default": true
28
+ }
29
+ },
30
+ "required": ["sourceProject", "targetProject"]
31
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "agentcore-gateway#react-connection",
4
+ "title": "agentcore-gateway#react-connection",
5
+ "description": "Connect a React website to an AgentCore Gateway fronting agents",
6
+ "type": "object",
7
+ "properties": {
8
+ "sourceProject": {
9
+ "type": "string",
10
+ "description": "The React website project"
11
+ },
12
+ "targetProject": {
13
+ "type": "string",
14
+ "description": "The gateway project"
15
+ },
16
+ "sourceComponent": {
17
+ "type": "string",
18
+ "description": "The website component in the source project"
19
+ },
20
+ "targetComponent": {
21
+ "type": "string",
22
+ "description": "The gateway component in the target project"
23
+ },
24
+ "preferInstallDependencies": {
25
+ "type": "boolean",
26
+ "description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
27
+ "default": true
28
+ }
29
+ },
30
+ "required": ["sourceProject", "targetProject"]
31
+ }
@@ -27,8 +27,8 @@
27
27
  },
28
28
  "protocol": {
29
29
  "type": "string",
30
- "description": "The inbound protocol exposed by your gateway. Only mcp is supported today; additional protocols may be added in future.",
31
- "enum": ["mcp"],
30
+ "description": "The inbound protocol exposed by your gateway. An mcp gateway aggregates MCP server targets into a single MCP endpoint. An http gateway proxies requests to agent runtime targets via path-based routing, so callers (e.g. a website) can reach agents through the gateway.",
31
+ "enum": ["mcp", "http"],
32
32
  "default": "mcp",
33
33
  "x-priority": "important"
34
34
  },