@aws/nx-plugin-mcp 1.0.0-rc.16 → 1.0.0-rc.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/aws-nx-mcp.js CHANGED
@@ -19753,6 +19753,13 @@ var generators$1 = {
19753
19753
  "metric": "g49",
19754
19754
  "hidden": true
19755
19755
  },
19756
+ "agentcore-gateway#gateway-connection": {
19757
+ "factory": "./src/agentcore-gateway/gateway-connection/generator",
19758
+ "schema": "./src/agentcore-gateway/gateway-connection/schema.json",
19759
+ "description": "Connect an AgentCore Gateway to another AgentCore Gateway",
19760
+ "metric": "g52",
19761
+ "hidden": true
19762
+ },
19756
19763
  "connection": {
19757
19764
  "factory": "./src/connection/generator",
19758
19765
  "schema": "./src/connection/schema.json",
@@ -19776,7 +19783,8 @@ var generators$1 = {
19776
19783
  "connection/ts-agent-rdb",
19777
19784
  "connection/ts-agent-gateway",
19778
19785
  "connection/py-agent-gateway",
19779
- "connection/agentcore-gateway-mcp"
19786
+ "connection/agentcore-gateway-mcp",
19787
+ "connection/agentcore-gateway-gateway"
19780
19788
  ]
19781
19789
  },
19782
19790
  "license": {
@@ -235,5 +235,6 @@ See the connection guide for the full local development story.
235
235
  ## Next steps
236
236
 
237
237
  - Connect an MCP server: <Link path="guides/connection/agentcore-gateway-mcp">`agentcore-gateway#mcp-connection`</Link>
238
+ - Connect another Gateway: <Link path="guides/connection/agentcore-gateway-gateway">`agentcore-gateway#gateway-connection`</Link>
238
239
  - Connect a TypeScript Agent: <Link path="guides/connection/ts-agent-gateway">`ts#agent#gateway-connection`</Link>
239
240
  - Connect a Python Agent: <Link path="guides/connection/py-agent-gateway">`py#agent#gateway-connection`</Link>
@@ -0,0 +1,154 @@
1
+ ---
2
+ title: AgentCore Gateway to AgentCore Gateway
3
+ description: Connect an AgentCore Gateway to another AgentCore Gateway
4
+ when:
5
+ sourceType: agentcore-gateway
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 register an <Link path="guides/agentcore-gateway">AgentCore Gateway</Link> as a target of another AgentCore Gateway. This lets you compose gateways hierarchically — for example a team-level gateway aggregating several domain gateways, each of which fronts its own MCP servers.
16
+
17
+ Once connected, the source Gateway aggregates the target Gateway's tools into its single MCP endpoint. Since the target Gateway already prefixes its tools with its own target names, tools surface through the source Gateway as `<gateway-target-name>___<target-name>___<tool-name>` — each gateway in the chain adds one prefix. Both gateways evaluate their own Cedar policies: the source Gateway authorizes the caller for the prefixed action, then the target Gateway authorizes the source Gateway's execution role for the inner action.
18
+
19
+ ## Prerequisites
20
+
21
+ Before using this generator, ensure you have:
22
+
23
+ 1. Two <Link path="guides/agentcore-gateway">`agentcore-gateway`</Link> projects
24
+
25
+ Both gateways must have `protocol: mcp`, and the target gateway must have `auth: iam` — the source gateway invokes the target signing with its own execution role, so only the target's inbound auth needs to be IAM. The generator validates this, and also rejects connections that would create a cycle between gateways, which would otherwise recurse infinitely on `tools/list`.
26
+
27
+ ## Usage
28
+
29
+ ### Run the Generator
30
+
31
+ <RunGenerator generator="connection" />
32
+
33
+ Select the aggregating Gateway project as the source and the Gateway to be aggregated as the target.
34
+
35
+ ### Options
36
+
37
+ <GeneratorParameters generator="connection" />
38
+
39
+ ## Generator Output
40
+
41
+ The generator wires existing projects together rather than emitting new source files. The following files are modified:
42
+
43
+ <FileTree>
44
+
45
+ - packages/\<source-gateway>
46
+ - project.json `<source-gateway>-serve-local` gains a dependency on the target gateway's `<target-gateway>-serve-local`
47
+ - serve-local.ts `ATTACHED_MCP_SERVERS` updated so the local gateway aggregates the target gateway
48
+
49
+ </FileTree>
50
+
51
+ The source Gateway project's `<source-gateway>-serve-local` target gains a dependency on the target Gateway's `<target-gateway>-serve-local` target, so running the source Gateway locally also starts the target gateway (and, transitively, every MCP server attached to it). The target gateway is also registered in the source Gateway project's `serve-local.ts` so the local gateway aggregates its tools.
52
+
53
+ ## Adding the gateway target to your stack
54
+
55
+ The generator **cannot** automatically wire the gateway target into your infrastructure because it doesn't know which stack or module instantiates the Gateways. Add a single call to `gateway.addGateway(targetGateway)` yourself.
56
+
57
+ <Infrastructure>
58
+ <Fragment slot="cdk">
59
+ In the stack where you instantiate the Gateways, register the target gateway as a target of the source gateway:
60
+
61
+ ```ts title="packages/infra/src/stacks/application-stack.ts" {5-6}
62
+ const innerGateway = new InnerGateway(this, 'InnerGateway');
63
+ const outerGateway = new OuterGateway(this, 'OuterGateway');
64
+
65
+ // Register the inner gateway as a target of the outer gateway. The target
66
+ // name defaults to the inner gateway's `gatewayName` (its class name in
67
+ // kebab-case, e.g. `InnerGateway` -> `inner-gateway`).
68
+ outerGateway.addGateway(innerGateway);
69
+ ```
70
+
71
+ The Gateway target name (the target gateway's `gatewayName` by default) prefixes Cedar action names on the source gateway — the action format is ``AgentCore::Action::"<gatewayTargetName>___<targetName>___<toolName>"``. See the <Link path="guides/agentcore-gateway">Writing Policies section</Link>. Keep the target name short and stable; changing it later invalidates any Cedar policies that reference the old name.
72
+
73
+ To override the default target name, pass `gatewayTargetName`:
74
+
75
+ ```ts
76
+ outerGateway.addGateway(innerGateway, { gatewayTargetName: 'inner' });
77
+ ```
78
+
79
+ The construct grants the source gateway's execution role `bedrock-agentcore:InvokeGateway` access to the target gateway, and configures the target with `iamCredentialProvider.service = 'bedrock-agentcore'` so the source gateway signs outbound calls using its own execution role. The target is created after the target gateway and all of its own targets, since AgentCore fetches the target's tools during creation.
80
+ </Fragment>
81
+ <Fragment slot="terraform">
82
+ In the Terraform file where you instantiate the Gateways, wire the gateway target in:
83
+
84
+ ```hcl title="packages/infra/src/main.tf" {2-5,11-15,18-36}
85
+ module "inner_gateway" {
86
+ source = "../../common/terraform/src/app/gateways/inner-gateway"
87
+
88
+ # Target ids of the inner gateway's own targets (e.g. its MCP servers), so
89
+ # its gateway_url is not consumed until it serves their tools.
90
+ tool_dependencies = [aws_bedrockagentcore_gateway_target.my_mcp_server.target_id]
91
+ }
92
+
93
+ module "outer_gateway" {
94
+ source = "../../common/terraform/src/app/gateways/outer-gateway"
95
+ policy_dependencies = [aws_bedrockagentcore_gateway_target.inner_gateway.target_id]
96
+
97
+ additional_iam_policy_statements = [
98
+ {
99
+ Effect = "Allow"
100
+ Action = ["bedrock-agentcore:InvokeGateway"]
101
+ Resource = [module.inner_gateway.gateway_arn]
102
+ }
103
+ ]
104
+ }
105
+
106
+ # Register the inner gateway as a target of the outer gateway
107
+ resource "aws_bedrockagentcore_gateway_target" "inner_gateway" {
108
+ gateway_identifier = module.outer_gateway.gateway_id
109
+ name = "inner-gateway"
110
+
111
+ target_configuration {
112
+ mcp {
113
+ mcp_server {
114
+ endpoint = module.inner_gateway.gateway_url
115
+ }
116
+ }
117
+ }
118
+
119
+ credential_provider_configuration {
120
+ gateway_iam_role {
121
+ service = "bedrock-agentcore"
122
+ }
123
+ }
124
+ }
125
+ ```
126
+
127
+ The target `name` (`inner-gateway` above) prefixes Cedar action names on the outer gateway — see the <Link path="guides/agentcore-gateway">Writing Policies section</Link>. The `additional_iam_policy_statements` entry grants the outer gateway's execution role invoke access to the inner gateway, which is required both to fetch the inner gateway's tools at target creation time and to route calls at runtime. `policy_dependencies` ensures Cedar policies referencing this target's actions are created after the target has registered them.
128
+
129
+ :::note[Target ordering]
130
+ AgentCore fetches the inner gateway's tools when the `aws_bedrockagentcore_gateway_target` is created, so the inner gateway must already be serving them. Set the inner gateway's `tool_dependencies` to its own targets' ids: its `gateway_url` then flows through a readiness probe that polls `tools/list` until those tools are served, so the outer gateway's target waits for the inner gateway to be ready.
131
+ :::
132
+ </Fragment>
133
+ </Infrastructure>
134
+
135
+ ## Cedar policies across chained gateways
136
+
137
+ Each gateway in the chain evaluates its own policy set:
138
+
139
+ 1. The **source gateway** evaluates the original caller (e.g. an agent's execution role) against the prefixed action, e.g. `AgentCore::Action::"inner-gateway___my-mcp___add"`.
140
+ 2. The **target gateway** evaluates the source gateway's execution role against the inner action, e.g. `AgentCore::Action::"my-mcp___add"`.
141
+
142
+ This means a tool call through a gateway chain must be permitted at every hop. The default `permit-all.cedar` permits any caller in the same AWS account, which includes the source gateway's role; if you write narrower policies on the target gateway, remember that the principal it sees is the *source gateway's* role, not the original caller.
143
+
144
+ ## Local Development
145
+
146
+ Running the source Gateway locally with:
147
+
148
+ <NxCommands commands={["<source-gateway-name>-serve-local"]} />
149
+
150
+ starts the local source gateway, the local target gateway, and every MCP server attached to either, each on its assigned local port. Tool names are prefixed at each hop exactly as deployed (`<gateway-target-name>___<target-name>___<tool-name>`), so agent prompts and Cedar action names remain consistent across local and deployed runs.
151
+
152
+ :::caution[Local fidelity]
153
+ Local development uses **local stand-in gateways** — lightweight MCP aggregators started by each Gateway project, not the AgentCore Gateway service. As a consequence, **Cedar policies are not evaluated locally** at either hop. To exercise Cedar policies, run the agent's `serve` target instead (see the <Link path="guides/connection/ts-agent-gateway">TypeScript</Link> / <Link path="guides/connection/py-agent-gateway">Python</Link> agent-connection guides) so the locally-running agent calls the deployed Gateway.
154
+ :::
@@ -181,6 +181,13 @@ The Connection generator supports the following connections:
181
181
  source="agentcore"
182
182
  target="mcp"
183
183
  />
184
+ <ConnectionCard
185
+ title="AgentCore Gateway to AgentCore Gateway"
186
+ description="Aggregate an AgentCore Gateway behind another AgentCore Gateway"
187
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/agentcore-gateway-gateway`}
188
+ source="agentcore"
189
+ target="agentcore"
190
+ />
184
191
  <ConnectionCard
185
192
  title="TypeScript Agent to AgentCore Gateway"
186
193
  description="Connect a TypeScript Agent to an AgentCore Gateway"
@@ -172,6 +172,37 @@ module "my_api" {
172
172
  </Fragment>
173
173
  </Infrastructure>
174
174
 
175
+ #### Customising Options Per-Operation
176
+
177
+ <Infrastructure>
178
+ <Fragment slot="cdk">
179
+ To customise the options used to create the default integration for _specific_ operations (without affecting the others), you can use the `withOperationOptions` method. For example, if you would like to increase the Lambda function timeout for just one operation:
180
+
181
+ ```ts {4-6}
182
+ const api = new MyApi(this, 'MyApi', {
183
+ integrations: MyApi.defaultIntegrations(this)
184
+ .withOperationOptions({
185
+ sayHello: {
186
+ timeout: Duration.seconds(60),
187
+ },
188
+ })
189
+ .build(),
190
+ });
191
+
192
+ // The selected operations remain default integrations, so they're still typed accordingly:
193
+ api.integrations.sayHello.handler.addToRolePolicy(new PolicyStatement({ ... }));
194
+ ```
195
+
196
+ The options you specify are merged with the default integration options (and any options set via `withDefaultOptions`). Note that you cannot specify options for operations which you have replaced via `withOverrides`, since these no longer use the default integration.
197
+
198
+ You will encounter a type error if the same operation is targeted by both `withOperationOptions` and `withOverrides`, regardless of the order in which you call them.
199
+
200
+ </Fragment>
201
+ <Fragment slot="terraform">
202
+ To customise options for specific operations with Terraform, you need to edit the generated Terraform module to configure individual Lambda functions per operation (see the [Explicit Integrations](#explicit-integrations) section below).
203
+ </Fragment>
204
+ </Infrastructure>
205
+
175
206
  #### Overriding Integrations
176
207
 
177
208
  <Infrastructure>
package/generators.json CHANGED
@@ -16,6 +16,13 @@
16
16
  "metric": "g49",
17
17
  "hidden": true
18
18
  },
19
+ "agentcore-gateway#gateway-connection": {
20
+ "factory": "./src/agentcore-gateway/gateway-connection/generator",
21
+ "schema": "./src/agentcore-gateway/gateway-connection/schema.json",
22
+ "description": "Connect an AgentCore Gateway to another AgentCore Gateway",
23
+ "metric": "g52",
24
+ "hidden": true
25
+ },
19
26
  "connection": {
20
27
  "factory": "./src/connection/generator",
21
28
  "schema": "./src/connection/schema.json",
@@ -39,7 +46,8 @@
39
46
  "connection/ts-agent-rdb",
40
47
  "connection/ts-agent-gateway",
41
48
  "connection/py-agent-gateway",
42
- "connection/agentcore-gateway-mcp"
49
+ "connection/agentcore-gateway-mcp",
50
+ "connection/agentcore-gateway-gateway"
43
51
  ]
44
52
  },
45
53
  "license": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin-mcp",
3
- "version": "1.0.0-rc.16",
3
+ "version": "1.0.0-rc.18",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",
@@ -0,0 +1,26 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "agentcore-gateway#gateway-connection",
4
+ "title": "agentcore-gateway#gateway-connection",
5
+ "description": "Connect an AgentCore Gateway to another AgentCore Gateway",
6
+ "type": "object",
7
+ "properties": {
8
+ "sourceProject": {
9
+ "type": "string",
10
+ "description": "The gateway project to add the target gateway to"
11
+ },
12
+ "targetProject": {
13
+ "type": "string",
14
+ "description": "The gateway project to register as a target"
15
+ },
16
+ "sourceComponent": {
17
+ "type": "string",
18
+ "description": "The gateway component in the source project"
19
+ },
20
+ "targetComponent": {
21
+ "type": "string",
22
+ "description": "The gateway component in the target project"
23
+ }
24
+ },
25
+ "required": ["sourceProject", "targetProject"]
26
+ }