@aws/nx-plugin-mcp 1.0.0-rc.26 → 1.0.0-rc.28

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.
@@ -74,9 +74,41 @@ The generated construct creates the following AWS resources:
74
74
  - An `AgentCore::Gateway` configured for the MCP protocol with `GatewayAuthorizer.usingAwsIam()` (inbound IAM authentication)
75
75
  - An `AgentCore::PolicyEngine` running in `ENFORCE` mode, attached to the Gateway (omitted when `cedarPolicy: false`)
76
76
  - One `AgentCore::Policy` per `.cedar` file in `policies/`
77
+ - 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>)
77
78
 
78
79
  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.
79
80
 
81
+ #### Architecture
82
+
83
+ The deployed Gateway has the following architecture, with an [AWS WAFv2](https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html) Web ACL in front of the Gateway, which routes on to its downstream MCP server targets:
84
+
85
+ ```d2 inline=true
86
+ direction: right
87
+
88
+ client: Client {
89
+ shape: image
90
+ icon: /nx-plugin-for-aws/icons/aws/client.svg
91
+ }
92
+
93
+ waf: WAF {
94
+ shape: image
95
+ icon: /nx-plugin-for-aws/icons/aws/waf.svg
96
+ }
97
+
98
+ gateway: AgentCore Gateway\n(MCP, IAM auth) {
99
+ shape: image
100
+ icon: /nx-plugin-for-aws/icons/aws/bedrock-agentcore.svg
101
+ }
102
+
103
+ targets: Downstream MCP Servers\n(Gateway targets) {
104
+ shape: rectangle
105
+ }
106
+
107
+ client -> waf
108
+ waf -> gateway
109
+ gateway -> targets
110
+ ```
111
+
80
112
  ## Writing Policies
81
113
 
82
114
  <OptionFilter when={{ cedarPolicy: true }} description="Cedar policies — cedarPolicy: true only">
@@ -234,6 +266,78 @@ The generator adds a `dev` target to the Gateway project, which runs `local-dev.
234
266
 
235
267
  See the connection guide for the full local development story.
236
268
 
269
+ ## Deploying your AgentCore Gateway
270
+
271
+ The AgentCore Gateway generator creates CDK or Terraform infrastructure as code based on your selected `iacProvider`. You can use this to deploy your Gateway.
272
+
273
+ <Infrastructure>
274
+ <Fragment slot="cdk">
275
+ The CDK construct for deploying your Gateway lives in the `common/constructs` folder. You can consume this in a CDK application, for example:
276
+
277
+ ```ts {7} title="packages/infra/src/stacks/application-stack.ts"
278
+ import { MyGateway } from ':my-scope/common-constructs';
279
+
280
+ export class ApplicationStack extends Stack {
281
+ constructor(scope: Construct, id: string, props?: StackProps) {
282
+ super(scope, id, props);
283
+
284
+ new MyGateway(this, 'MyGateway');
285
+ }
286
+ }
287
+ ```
288
+
289
+ This sets up your Gateway infrastructure, including the `AgentCore::Gateway`, its Cedar `PolicyEngine`, and the AWS WAF Web ACL (see [AWS WAF](#aws-waf) below). Register MCP server targets with `gateway.addMcpServer(...)` — see the <Link path="guides/connection/agentcore-gateway-mcp">MCP server connection guide</Link>.
290
+ </Fragment>
291
+ <Fragment slot="terraform">
292
+ The Terraform module for deploying your Gateway is in the `common/terraform` folder. You can use this in a Terraform configuration, for example:
293
+
294
+ ```hcl title="packages/infra/src/main.tf"
295
+ module "my_gateway" {
296
+ source = "../../common/terraform/src/app/gateways/my-gateway"
297
+ }
298
+ ```
299
+
300
+ This sets up your Gateway infrastructure, including the `aws_bedrockagentcore_gateway`, its Cedar policy engine, and the AWS WAF Web ACL (see [AWS WAF](#aws-waf) below). Register MCP server targets with an `aws_bedrockagentcore_gateway_target` resource — see the <Link path="guides/connection/agentcore-gateway-mcp">MCP server connection guide</Link>.
301
+ </Fragment>
302
+ </Infrastructure>
303
+
304
+ ### AWS WAF
305
+
306
+ By default, the generated construct associates an [AWS WAFv2](https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html) Web ACL with the Gateway. AWS WAF inspects every inbound request inline _before_ it reaches a target, protecting your Gateway from web exploits, bot traffic, and volumetric attacks. The Web ACL uses the AWS managed default ruleset ([`AWSManagedRulesCommonRuleSet`](https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-baseline.html#aws-managed-rule-groups-baseline-crs) and [`AWSManagedRulesKnownBadInputsRuleSet`](https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-baseline.html#aws-managed-rule-groups-baseline-known-bad-inputs)), providing protection against common web exploits including the OWASP Top 10. WAF request logs are written to a CloudWatch Logs group.
307
+
308
+ The Web ACL is `REGIONAL` and created in the Gateway's region, as required for AgentCore Gateway associations.
309
+
310
+ :::caution[SizeRestrictions_BODY deviation from defaults]
311
+ The `SizeRestrictions_BODY` rule from `AWSManagedRulesCommonRuleSet` is overridden to `Count` rather than `Block`, since the rule's 8 KB limit is too restrictive for typical MCP tool payloads. Oversized requests will still be recorded as metrics so you can monitor them. See the [AWS WAF body size limits](https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statement-oversize-handling.html) guide for more details.
312
+ :::
313
+
314
+ You can edit the generated Gateway construct to add, remove, or adjust rules (for example, to add [rate-based rules](https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statement-type-rate-based.html) or additional managed rule groups).
315
+
316
+ <Infrastructure>
317
+ <Fragment slot="cdk">
318
+ To opt out (for example, to attach your own Web ACL), set `enableWaf` to `false` when you instantiate the Gateway construct:
319
+
320
+ ```ts {2}
321
+ new MyGateway(this, 'MyGateway', {
322
+ enableWaf: false,
323
+ });
324
+ ```
325
+
326
+ The construct exposes the created Web ACL as `webAcl` for further configuration.
327
+ </Fragment>
328
+ <Fragment slot="terraform">
329
+ To opt out (for example, to attach your own Web ACL), set `enable_waf` to `false` on the Gateway module:
330
+
331
+ ```hcl {2}
332
+ module "my_gateway" {
333
+ enable_waf = false
334
+ }
335
+ ```
336
+
337
+ The module outputs the created Web ACL ARN as `waf_web_acl_arn` for further configuration.
338
+ </Fragment>
339
+ </Infrastructure>
340
+
237
341
  ## Connections
238
342
 
239
343
  Use the <Link path="guides/connection">`connection`</Link> generator to integrate this project with others in your workspace. The following connections involve this project:
@@ -132,31 +132,20 @@ gateway.grantInvokeAccess(myAgent);
132
132
  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.
133
133
  </Fragment>
134
134
  <Fragment slot="terraform">
135
- ```hcl title="packages/infra/src/main.tf" {12-24}
135
+ ```hcl title="packages/infra/src/main.tf" {6-13}
136
136
  module "my_gateway" {
137
137
  source = "../../common/terraform/src/app/gateways/my-gateway"
138
138
  }
139
139
 
140
140
  module "my_agent" {
141
141
  source = "../../common/terraform/src/app/agents/my-agent"
142
- }
143
-
144
- # Grant the agent permission to invoke the Gateway
145
- resource "aws_iam_policy" "agent_invoke_gateway" {
146
- name = "AgentInvokeGatewayPolicy"
147
- policy = jsonencode({
148
- Version = "2012-10-17"
149
- Statement = [{
150
- Effect = "Allow"
151
- Action = "bedrock-agentcore:InvokeGateway"
152
- Resource = module.my_gateway.gateway_arn
153
- }]
154
- })
155
- }
156
142
 
157
- resource "aws_iam_role_policy_attachment" "agent_invoke_gateway" {
158
- role = module.my_agent.agent_core_runtime_role_arn
159
- policy_arn = aws_iam_policy.agent_invoke_gateway.arn
143
+ # Grant the agent permission to invoke the Gateway
144
+ additional_iam_policy_statements = [{
145
+ Effect = "Allow"
146
+ Action = ["bedrock-agentcore:InvokeGateway"]
147
+ Resource = [module.my_gateway.gateway_arn]
148
+ }]
160
149
  }
161
150
  ```
162
151
 
@@ -97,31 +97,20 @@ gateway.grantInvokeAccess(myAgent);
97
97
  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.
98
98
  </Fragment>
99
99
  <Fragment slot="terraform">
100
- ```hcl title="packages/infra/src/main.tf" {12-24}
100
+ ```hcl title="packages/infra/src/main.tf" {6-13}
101
101
  module "my_gateway" {
102
102
  source = "../../common/terraform/src/app/gateways/my-gateway"
103
103
  }
104
104
 
105
105
  module "my_agent" {
106
106
  source = "../../common/terraform/src/app/agents/my-agent"
107
- }
108
-
109
- # Grant the agent permission to invoke the Gateway
110
- resource "aws_iam_policy" "agent_invoke_gateway" {
111
- name = "AgentInvokeGatewayPolicy"
112
- policy = jsonencode({
113
- Version = "2012-10-17"
114
- Statement = [{
115
- Effect = "Allow"
116
- Action = "bedrock-agentcore:InvokeGateway"
117
- Resource = module.my_gateway.gateway_arn
118
- }]
119
- })
120
- }
121
107
 
122
- resource "aws_iam_role_policy_attachment" "agent_invoke_gateway" {
123
- role = module.my_agent.agent_core_runtime_role_arn
124
- policy_arn = aws_iam_policy.agent_invoke_gateway.arn
108
+ # Grant the agent permission to invoke the Gateway
109
+ additional_iam_policy_statements = [{
110
+ Effect = "Allow"
111
+ Action = ["bedrock-agentcore:InvokeGateway"]
112
+ Resource = [module.my_gateway.gateway_arn]
113
+ }]
125
114
  }
126
115
  ```
127
116
 
@@ -169,4 +169,8 @@ module "my_project_agent" {
169
169
 
170
170
  :::note[Custom OIDC Providers]
171
171
  If you require custom JWT authentication with a non-Cognito OIDC provider, you can modify the generated CDK construct or Terraform module for your agent directly. Note that the connection generator will only support `IAM` or `Cognito` authentication.
172
+ :::
173
+
174
+ :::caution[Security Best Practices]
175
+ When implementing your agent's business logic, review the [Bedrock AgentCore Runtime security best practices](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-security-best-practices.html).
172
176
  :::
@@ -164,4 +164,8 @@ module "my_project_mcp_server" {
164
164
 
165
165
  :::note[Custom OIDC Providers]
166
166
  If you require custom JWT authentication with a non-Cognito OIDC provider, you can modify the generated CDK construct or Terraform module for your MCP server directly. Note that the connection generator will only support `IAM` or `Cognito` authentication.
167
+ :::
168
+
169
+ :::caution[Security Best Practices]
170
+ When implementing your MCP server's business logic, review the [Bedrock AgentCore Runtime security best practices](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-security-best-practices.html).
167
171
  :::
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin-mcp",
3
- "version": "1.0.0-rc.26",
3
+ "version": "1.0.0-rc.28",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",