@aws/nx-plugin-mcp 1.0.0-rc.4 → 1.0.0-rc.41

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 (163) hide show
  1. package/bin/aws-nx-mcp.js +2240 -1030
  2. package/docs/get_started/building-with-ai.mdx +116 -0
  3. package/docs/get_started/concepts.mdx +52 -0
  4. package/docs/get_started/existing-project.mdx +176 -0
  5. package/docs/get_started/quick-start.mdx +266 -0
  6. package/docs/get_started/tutorials/contribute-generator.mdx +405 -0
  7. package/docs/get_started/tutorials/dungeon-game/1.mdx +1205 -0
  8. package/docs/get_started/tutorials/dungeon-game/2.mdx +237 -0
  9. package/docs/get_started/tutorials/dungeon-game/3.mdx +76 -0
  10. package/docs/get_started/tutorials/dungeon-game/4.mdx +162 -0
  11. package/docs/get_started/tutorials/dungeon-game/overview.mdx +144 -0
  12. package/docs/get_started/tutorials/dungeon-game/wrap-up.mdx +41 -0
  13. package/docs/get_started/tutorials/existing-project.mdx +4 -0
  14. package/docs/guides/agentcore-gateway.mdx +376 -0
  15. package/docs/guides/connection/agentcore-gateway-gateway.mdx +154 -0
  16. package/docs/guides/connection/agentcore-gateway-mcp.mdx +134 -0
  17. package/docs/guides/connection/py-agent-a2a.mdx +47 -15
  18. package/docs/guides/connection/py-agent-dynamodb.mdx +116 -0
  19. package/docs/guides/connection/py-agent-gateway.mdx +176 -0
  20. package/docs/guides/connection/py-agent-mcp.mdx +42 -13
  21. package/docs/guides/connection/py-agent-rdb.mdx +178 -0
  22. package/docs/guides/connection/py-fast-api-dynamodb.mdx +56 -0
  23. package/docs/guides/connection/py-fast-api-rdb.mdx +184 -0
  24. package/docs/guides/connection/py-mcp-server-dynamodb.mdx +116 -0
  25. package/docs/guides/connection/py-mcp-server-rdb.mdx +187 -0
  26. package/docs/guides/connection/react-agui.mdx +4 -4
  27. package/docs/guides/connection/react-fastapi.mdx +38 -2
  28. package/docs/guides/connection/react-py-agent.mdx +7 -13
  29. package/docs/guides/connection/react-smithy.mdx +3 -3
  30. package/docs/guides/connection/react-trpc.mdx +1 -1
  31. package/docs/guides/connection/react-ts-agent.mdx +8 -8
  32. package/docs/guides/connection/smithy-dynamodb.mdx +4 -4
  33. package/docs/guides/connection/smithy-rdb.mdx +5 -5
  34. package/docs/guides/connection/trpc-dynamodb.mdx +4 -4
  35. package/docs/guides/connection/trpc-rdb.mdx +5 -5
  36. package/docs/guides/connection/ts-agent-a2a.mdx +12 -9
  37. package/docs/guides/connection/ts-agent-dynamodb.mdx +3 -3
  38. package/docs/guides/connection/ts-agent-gateway.mdx +141 -0
  39. package/docs/guides/connection/ts-agent-mcp.mdx +11 -8
  40. package/docs/guides/connection/ts-agent-rdb.mdx +66 -21
  41. package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +3 -3
  42. package/docs/guides/connection/ts-mcp-server-rdb.mdx +66 -16
  43. package/docs/guides/connection.mdx +104 -5
  44. package/docs/guides/docker-bundling.mdx +68 -8
  45. package/docs/guides/fastapi.mdx +244 -4
  46. package/docs/guides/license.mdx +264 -109
  47. package/docs/guides/local-development.mdx +87 -0
  48. package/docs/guides/nx-generator.mdx +7 -2
  49. package/docs/guides/py-agent.mdx +257 -49
  50. package/docs/guides/py-dynamodb.mdx +476 -0
  51. package/docs/guides/py-mcp-server.mdx +61 -2
  52. package/docs/guides/py-rdb.mdx +254 -0
  53. package/docs/guides/react-website-auth.mdx +58 -1
  54. package/docs/guides/react-website.mdx +130 -19
  55. package/docs/guides/security.mdx +75 -0
  56. package/docs/guides/terraform-project.mdx +1 -1
  57. package/docs/guides/trpc.mdx +45 -9
  58. package/docs/guides/ts-agent.mdx +149 -9
  59. package/docs/guides/ts-dynamodb.mdx +62 -239
  60. package/docs/guides/ts-mcp-server.mdx +66 -3
  61. package/docs/guides/ts-nx-plugin.mdx +1 -1
  62. package/docs/guides/ts-rdb.mdx +117 -470
  63. package/docs/guides/ts-smithy-api.mdx +183 -4
  64. package/docs/guides/typescript-infrastructure.mdx +9 -1
  65. package/docs/guides/typescript-project.mdx +5 -10
  66. package/docs/guides/workspace.mdx +2 -2
  67. package/docs/snippets/agent/architecture.mdx +1 -1
  68. package/docs/snippets/agent/bedrock-deployment.mdx +4 -0
  69. package/docs/snippets/agent/runtime-arn.mdx +21 -0
  70. package/docs/snippets/agent/securing-your-agent.mdx +39 -0
  71. package/docs/snippets/api/access-logging.mdx +33 -0
  72. package/docs/snippets/api/type-safe-api-integrations.mdx +31 -0
  73. package/docs/snippets/api/waf-configuration.mdx +1 -1
  74. package/docs/snippets/connection/dynamodb-local-development.mdx +2 -2
  75. package/docs/snippets/connection/py-dynamodb-local-development.mdx +7 -0
  76. package/docs/snippets/connection/py-lambda-rdb-ssl-requirements.mdx +7 -0
  77. package/docs/snippets/connection/rdb-api-infrastructure.mdx +50 -18
  78. package/docs/snippets/dynamodb/deploying-table.mdx +166 -0
  79. package/docs/snippets/dynamodb/gsi-config.mdx +38 -0
  80. package/docs/snippets/dynamodb/infrastructure.mdx +33 -0
  81. package/docs/snippets/dynamodb/local-dev-start.mdx +13 -0
  82. package/docs/snippets/dynamodb/local-dev-windows.mdx +15 -0
  83. package/docs/snippets/mcp/architecture.mdx +1 -1
  84. package/docs/snippets/mcp/bedrock-deployment.mdx +4 -0
  85. package/docs/snippets/mcp/config.mdx +3 -2
  86. package/docs/snippets/rdb/architecture.mdx +38 -0
  87. package/docs/snippets/rdb/cluster-instances.mdx +31 -0
  88. package/docs/snippets/rdb/deletion-protection.mdx +34 -0
  89. package/docs/snippets/rdb/deploying.mdx +187 -0
  90. package/docs/snippets/rdb/encryption-key-rotation.mdx +30 -0
  91. package/docs/snippets/rdb/engine-version.mdx +63 -0
  92. package/docs/snippets/rdb/infrastructure.mdx +35 -0
  93. package/docs/snippets/rdb/logging.mdx +32 -0
  94. package/docs/snippets/rdb/rds-proxy.mdx +50 -0
  95. package/docs/snippets/rdb/removal-policy.mdx +57 -0
  96. package/docs/snippets/rdb/serverless-capacity.mdx +32 -0
  97. package/docs/snippets/required-prerequisites.mdx +1 -1
  98. package/docs/snippets/trivy-image-scan.mdx +27 -0
  99. package/generators.json +101 -2
  100. package/package.json +1 -1
  101. package/src/agentcore-gateway/gateway-connection/schema.json +31 -0
  102. package/src/agentcore-gateway/mcp-connection/schema.json +31 -0
  103. package/src/agentcore-gateway/schema.json +70 -0
  104. package/src/connection/schema.json +5 -0
  105. package/src/infra/app/schema.json +5 -0
  106. package/src/init/schema.json +35 -0
  107. package/src/license/schema.json +11 -0
  108. package/src/preset/schema.json +11 -5
  109. package/src/py/agent/a2a-connection/schema.json +5 -0
  110. package/src/py/agent/gateway-connection/schema.json +31 -0
  111. package/src/py/agent/mcp-connection/schema.json +5 -0
  112. package/src/py/agent/react-connection/schema.json +5 -0
  113. package/src/py/agent/schema.json +6 -1
  114. package/src/py/api/schema.json +5 -0
  115. package/src/py/dynamodb/agent-connection/schema.json +27 -0
  116. package/src/py/dynamodb/fast-api-connection/schema.json +23 -0
  117. package/src/py/dynamodb/mcp-server-connection/schema.json +27 -0
  118. package/src/py/dynamodb/schema.json +75 -0
  119. package/src/py/fast-api/react/schema.json +5 -0
  120. package/src/py/fast-api/schema.json +5 -0
  121. package/src/py/lambda-function/schema.json +5 -0
  122. package/src/py/mcp-server/schema.json +5 -0
  123. package/src/py/project/schema.json +5 -0
  124. package/src/py/rdb/agent-connection/schema.json +27 -0
  125. package/src/py/rdb/fast-api-connection/schema.json +23 -0
  126. package/src/py/rdb/mcp-server-connection/schema.json +27 -0
  127. package/src/py/rdb/schema.json +77 -0
  128. package/src/smithy/project/schema.json +5 -0
  129. package/src/smithy/react-connection/schema.json +5 -0
  130. package/src/smithy/ts/api/schema.json +5 -0
  131. package/src/terraform/project/schema.json +5 -0
  132. package/src/trpc/backend/schema.json +5 -0
  133. package/src/trpc/react/schema.json +5 -0
  134. package/src/ts/agent/a2a-connection/schema.json +5 -0
  135. package/src/ts/agent/gateway-connection/schema.json +31 -0
  136. package/src/ts/agent/mcp-connection/schema.json +5 -0
  137. package/src/ts/agent/react-connection/schema.json +5 -0
  138. package/src/ts/agent/schema.json +5 -0
  139. package/src/ts/api/schema.json +5 -0
  140. package/src/ts/astro-docs/schema.json +3 -3
  141. package/src/ts/docs/schema.json +3 -3
  142. package/src/ts/dynamodb/agent-connection/schema.json +5 -0
  143. package/src/ts/dynamodb/mcp-server-connection/schema.json +5 -0
  144. package/src/ts/dynamodb/schema.json +25 -2
  145. package/src/ts/dynamodb/smithy-connection/schema.json +5 -0
  146. package/src/ts/dynamodb/trpc-connection/schema.json +5 -0
  147. package/src/ts/lambda-function/schema.json +5 -0
  148. package/src/ts/lib/schema.json +5 -0
  149. package/src/ts/mcp-server/schema.json +5 -0
  150. package/src/ts/nx-generator/schema.json +5 -0
  151. package/src/ts/nx-plugin/schema.json +5 -0
  152. package/src/ts/rdb/agent-connection/schema.json +5 -0
  153. package/src/ts/rdb/mcp-server-connection/schema.json +5 -0
  154. package/src/ts/rdb/schema.json +6 -1
  155. package/src/ts/rdb/smithy-connection/schema.json +5 -0
  156. package/src/ts/rdb/trpc-connection/schema.json +5 -0
  157. package/src/ts/react-website/app/schema.json +11 -6
  158. package/src/ts/react-website/cognito-auth/schema.json +5 -0
  159. package/src/ts/react-website/runtime-config/schema.json +5 -0
  160. package/src/ts/website/app/schema.json +11 -6
  161. package/src/ts/website/auth/schema.json +5 -0
  162. /package/docs/snippets/connection/{lambda-rdb-ssl-requirements.mdx → ts-lambda-rdb-ssl-requirements.mdx} +0 -0
  163. /package/docs/snippets/connection/{mcp-server-rdb-ssl-requirements.mdx → ts-mcp-server-rdb-ssl-requirements.mdx} +0 -0
@@ -0,0 +1,141 @@
1
+ ---
2
+ title: TypeScript Agent to Gateway
3
+ description: Connect a TypeScript Agent to an AgentCore Gateway
4
+ when:
5
+ sourceType: ts#agent
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 your <Link path="guides/ts-agent">TypeScript Agent</Link> to an <Link path="guides/agentcore-gateway">AgentCore Gateway</Link>.
16
+
17
+ The generator wires the agent so it authenticates to the Gateway with IAM SigV4 when deployed, and connects to the local gateway started by the Gateway project when running locally.
18
+
19
+ ## Prerequisites
20
+
21
+ Before using this generator, ensure you have:
22
+
23
+ 1. A TypeScript project with a <Link path="guides/ts-agent">Agent</Link> component (`infra: agentcore`)
24
+ 2. A <Link path="guides/agentcore-gateway">`agentcore-gateway`</Link> project
25
+
26
+ ## Usage
27
+
28
+ ### Run the Generator
29
+
30
+ <RunGenerator generator="connection" />
31
+
32
+ Select the agent project as the source and the Gateway project as the target.
33
+
34
+ ### Options
35
+
36
+ <GeneratorParameters generator="connection" />
37
+
38
+ ## Generator Output
39
+
40
+ The generator emits shared core client files into your `agent-connection` package, plus a per-Gateway wrapper, and modifies your agent:
41
+
42
+ <FileTree>
43
+
44
+ - packages/common/agent-connection
45
+ - src
46
+ - core/
47
+ - agentcore-endpoints.ts Framework-agnostic ARN/URL resolution
48
+ - agentcore-gateway-mcp-transport.ts Framework-agnostic Gateway MCP transport
49
+ - agentcore-gateway-mcp-client-strands.ts Strands MCP client for the deployed Gateway
50
+ - app/
51
+ - \<gateway-kebab>-client-strands.ts Per-Gateway Strands client wrapper
52
+ - index.ts Re-exports the Gateway client
53
+
54
+ </FileTree>
55
+
56
+ Additionally, the generator:
57
+
58
+ - Modifies your agent's `agent.ts` to import the Gateway client class, call `<Gateway>ClientStrands.create()`, and register the returned client in the `tools` array
59
+ - Wires the agent's `<agent>-dev` target to depend on the Gateway's `dev` target
60
+ - Installs the required SigV4 / MCP dependencies
61
+
62
+ ## Using the connected Gateway
63
+
64
+ The generator transforms your agent's `agent.ts` to use the Gateway client:
65
+
66
+ ```ts title="packages/example/src/my-agent/agent.ts" {2,5,8}
67
+ import { Agent } from '@strands-agents/sdk';
68
+ import { MyGatewayClientStrands } from ':my-scope/agent-connection';
69
+
70
+ export const getAgent = async () => {
71
+ const myGateway = await MyGatewayClientStrands.create();
72
+ return new Agent({
73
+ systemPrompt: '...',
74
+ tools: [myGateway],
75
+ });
76
+ };
77
+ ```
78
+
79
+ When deployed (`LOCAL_DEV` unset), the client points at the Gateway's MCP endpoint and authenticates with SigV4. When `LOCAL_DEV=true`, it points at the local gateway started by the Gateway project's `dev` target, so the same `agent.ts` works uniformly in both modes.
80
+
81
+ The session ID is propagated to downstream MCP servers automatically via the `X-Amzn-Bedrock-AgentCore-Runtime-Session-Id` header.
82
+
83
+ ## Infrastructure
84
+
85
+ After running the generator you must grant the agent permission to invoke the Gateway.
86
+
87
+ <Infrastructure>
88
+ <Fragment slot="cdk">
89
+ ```ts title="packages/infra/src/stacks/application-stack.ts" {5}
90
+ const gateway = new MyGateway(this, 'MyGateway');
91
+ const myAgent = new MyAgent(this, 'MyAgent');
92
+
93
+ // Grant the agent permissions to invoke the Gateway
94
+ gateway.grantInvokeAccess(myAgent);
95
+ ```
96
+
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
+ </Fragment>
99
+ <Fragment slot="terraform">
100
+ ```hcl title="packages/infra/src/main.tf" {6-13}
101
+ module "my_gateway" {
102
+ source = "../../common/terraform/src/app/gateways/my-gateway"
103
+ }
104
+
105
+ module "my_agent" {
106
+ source = "../../common/terraform/src/app/agents/my-agent"
107
+
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
+ }]
114
+ }
115
+ ```
116
+
117
+ The Gateway URL is automatically registered in the `agentcore.gateways.<ClassName>` namespace of <Link path="guides/runtime-config">Runtime Configuration</Link> by the generated Terraform module, so the agent can discover it at runtime.
118
+ </Fragment>
119
+ </Infrastructure>
120
+
121
+ ## Local Development
122
+
123
+ The generator configures the agent's `dev` target to:
124
+
125
+ 1. Start the connected Gateway's local gateway and every attached MCP server
126
+ 2. Set `LOCAL_DEV=true` so the generated client points at the local gateway instead of the deployed Gateway
127
+
128
+ Run the agent locally with:
129
+
130
+ <NxCommands commands={["<agent-name>-dev <project-name>"]} />
131
+
132
+ To run the agent locally **against the deployed Gateway** instead (for example, to exercise Cedar policies), use the agent's `serve` target. Without `LOCAL_DEV` set, the client resolves the deployed Gateway URL from runtime configuration and SigV4-signs requests with your local AWS credentials:
133
+
134
+ <NxCommands commands={["<agent-name>-serve <project-name>"]} />
135
+
136
+ ### Local fidelity
137
+
138
+ The local gateway stands in for the deployed Gateway, so:
139
+
140
+ - **No Cedar policy evaluation.** Every tool is visible to the agent regardless of policies. Use the `serve` target to exercise policies against the deployed Gateway.
141
+ - **Tool-name prefixing is preserved.** Each local MCP server's tools are wrapped to expose names of the form `<target-name>___<tool-name>`, matching what the deployed Gateway emits. This keeps an agent's system prompt and the Cedar action names you reference consistent across local and deployed runs.
@@ -47,9 +47,12 @@ The generator creates a shared `agent-connection` package and modifies your agen
47
47
  - packages/common/agent-connection
48
48
  - src
49
49
  - app
50
- - \<mcp-server-name>-client.ts High-level client for the connected MCP server
50
+ - \<mcp-server-name>-client-strands.ts High-level Strands client for the connected MCP server
51
51
  - core
52
- - agentcore-mcp-client.ts Low-level AgentCore MCP client with SigV4/JWT authentication
52
+ - agentcore-endpoints.ts Framework-agnostic ARN/URL resolution
53
+ - agentcore-fetch.ts Framework-agnostic SigV4 / JWT / session-forwarding fetch
54
+ - agentcore-mcp-transport.ts Framework-agnostic MCP transport
55
+ - agentcore-mcp-client-strands.ts Strands MCP client wrapping the transport
53
56
  - index.ts Exports all clients
54
57
  - project.json
55
58
  - tsconfig.json
@@ -58,7 +61,7 @@ The generator creates a shared `agent-connection` package and modifies your agen
58
61
 
59
62
  Additionally, it:
60
63
  - Transforms your agent's `agent.ts` to import and use the MCP server's tools
61
- - Updates the agent's `serve-local` target to depend on the MCP server's serve target
64
+ - Updates the agent's `dev` target to depend on the MCP server's serve target
62
65
  - Installs required dependencies
63
66
 
64
67
  ## Using the Connected MCP Server
@@ -67,10 +70,10 @@ The generator transforms your agent's `agent.ts` to use the MCP server's tools:
67
70
 
68
71
  ```ts title="packages/example/src/my-agent/agent.ts" {2,5,8}
69
72
  import { Agent, tool } from '@strands-agents/sdk';
70
- import { MyMcpServerClient } from ':my-scope/agent-connection';
73
+ import { MyMcpServerClientStrands } from ':my-scope/agent-connection';
71
74
 
72
75
  export const getAgent = async (sessionId: string) => {
73
- const myMcpServerClient = await MyMcpServerClient.create(sessionId);
76
+ const myMcpServerClient = await MyMcpServerClientStrands.create(sessionId);
74
77
  return new Agent({
75
78
  systemPrompt: '...',
76
79
  tools: [myMcpServerClient],
@@ -133,12 +136,12 @@ The MCP server's AgentCore runtime ARN is automatically registered in the `agent
133
136
 
134
137
  ## Local Development
135
138
 
136
- The generator configures the agent's `serve-local` target to:
139
+ The generator configures the agent's `dev` target to:
137
140
  1. Start the connected MCP server(s) automatically
138
- 2. Set `SERVE_LOCAL=true` so the generated client uses direct HTTP transport instead of AgentCore
141
+ 2. Set `LOCAL_DEV=true` so the generated client uses direct HTTP transport instead of AgentCore
139
142
 
140
143
  Run the agent locally with:
141
144
 
142
- <NxCommands commands={["<agent-name>-serve-local <project-name>"]} />
145
+ <NxCommands commands={["<agent-name>-dev <project-name>"]} />
143
146
 
144
147
  This will start both the agent and all connected MCP servers, with the agent connecting to the MCP servers directly via HTTP on their assigned local ports.
@@ -46,15 +46,11 @@ The generator modifies two files in your agent's source directory:
46
46
 
47
47
  </FileTree>
48
48
 
49
- Additionally, the agent's `<agent-name>-serve-local` target is updated to depend on the database's `serve-local` target.
49
+ Additionally, the agent's `<agent-name>-dev` target is updated to depend on the database's `dev` target.
50
50
 
51
- ## How It Works
51
+ ## Using the Database in Agent Tools
52
52
 
53
- The Prisma client is instantiated inside `getAgent()`. Since the `ts#agent` generator configures a single Agent per session, the client is also reused for the lifetime of the session.
54
-
55
- ### Agent Definition
56
-
57
- `getAgent` is updated to import and call the Prisma getter at the top of its body:
53
+ The Prisma client is instantiated inside `getAgent()`. Since the `ts#agent` generator configures a single Agent per session, the client is also reused for the lifetime of the session:
58
54
 
59
55
  ```ts title="packages/my-service/src/my-agent/agent.ts" {1,4}
60
56
  import { getPrisma as getMyDb } from ':my-scope/my-db';
@@ -66,7 +62,6 @@ export const getAgent = async () => {
66
62
  };
67
63
  ```
68
64
 
69
-
70
65
  ## Multiple Databases
71
66
 
72
67
  Running the generator again with a different target adds the second database alongside the first:
@@ -91,10 +86,21 @@ The generated agent construct implements `IGrantable` and `IConnectable`, so you
91
86
  <Fragment slot="cdk">
92
87
 
93
88
  ```ts title="packages/infra/src/stacks/application-stack.ts"
89
+ import { SecurityGroup } from 'aws-cdk-lib/aws-ec2';
90
+ import { RuntimeNetworkConfiguration } from 'aws-cdk-lib/aws-bedrockagentcore';
94
91
  import { MyDatabase } from ':my-scope/common-constructs';
95
92
 
96
93
  const db = new MyDatabase(this, 'Db', { vpc, ... });
97
- const myAgent = new MyAgent(this, 'MyAgent', { vpc, ... });
94
+
95
+ const myAgent = new MyAgent(this, 'MyAgent', {
96
+ networkConfiguration: RuntimeNetworkConfiguration.usingVpc(this, {
97
+ vpc,
98
+ vpcSubnets: { subnetType: SubnetType.PRIVATE_WITH_EGRESS },
99
+ securityGroups: [
100
+ new SecurityGroup(this, 'MyAgentSecurityGroup', { vpc, allowAllOutbound: true }),
101
+ ],
102
+ }),
103
+ });
98
104
 
99
105
  db.allowDefaultPortFrom(myAgent);
100
106
  db.grantConnect(myAgent);
@@ -102,30 +108,69 @@ db.grantConnect(myAgent);
102
108
 
103
109
  `allowDefaultPortFrom` opens the security group rule so the agent runtime can reach the database port. `grantConnect` grants IAM `rds-db:connect` permission to the agent's execution role.
104
110
 
111
+
105
112
  </Fragment>
106
113
  <Fragment slot="terraform">
107
114
 
108
- Pass the database module outputs into your agent module so it can reach the database and read its runtime configuration:
115
+ Run the agent inside the same VPC as the database, grant it `rds-db:connect` via `additional_iam_policy_statements`, and open the network path with a pair of security group rules. The `aws_vpc.main` and `aws_subnet` resources are defined in the database deployment guide:
109
116
 
110
117
  ```hcl title="packages/infra/src/main.tf"
111
118
  module "my_database" {
112
119
  source = "../../common/terraform/src/app/dbs/my-database"
113
- vpc_id = module.vpc.vpc_id
114
- database_subnet_ids = module.vpc.private_isolated_subnet_ids
120
+ vpc_id = aws_vpc.main.id
121
+ database_subnet_ids = aws_subnet.database[*].id
122
+ lambda_subnet_ids = aws_subnet.private[*].id
115
123
  }
116
124
 
117
125
  module "my_agent" {
118
- source = "../../common/terraform/src/app/agents/my-agent"
126
+ source = "../../common/terraform/src/app/agents/my-agent"
127
+ enable_vpc = true
128
+ vpc_id = aws_vpc.main.id
129
+ subnet_ids = aws_subnet.private[*].id
130
+
131
+ appconfig_application_id = module.runtime_config_appconfig.application_id
132
+ appconfig_application_arn = module.runtime_config_appconfig.application_arn
133
+
134
+ additional_iam_policy_statements = [
135
+ {
136
+ Effect = "Allow"
137
+ Action = ["rds-db:connect"]
138
+ Resource = [
139
+ "arn:aws:rds-db:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:dbuser:${module.my_database.connect_resource_id}/${module.my_database.database_runtime_user}"
140
+ ]
141
+ }
142
+ ]
143
+ }
119
144
 
120
- appconfig_application_id = module.my_database.appconfig_application_id
121
- database_cluster_resource_id = module.my_database.cluster_resource_id
122
- database_runtime_user = module.my_database.database_runtime_user
123
- database_security_group_id = module.my_database.security_group_id
124
- database_port = module.my_database.cluster_port
145
+ resource "aws_vpc_security_group_ingress_rule" "agent_to_database" {
146
+ description = "Allow the agent runtime to connect to the database"
147
+ security_group_id = module.my_database.security_group_id
148
+ referenced_security_group_id = module.my_agent.security_group_id
149
+ from_port = module.my_database.cluster_port
150
+ to_port = module.my_database.cluster_port
151
+ ip_protocol = "tcp"
152
+ }
153
+
154
+ resource "aws_vpc_security_group_egress_rule" "agent_to_database" {
155
+ description = "Allow outbound traffic from the agent runtime to the database"
156
+ security_group_id = module.my_agent.security_group_id
157
+ referenced_security_group_id = module.my_database.security_group_id
158
+ from_port = module.my_database.cluster_port
159
+ to_port = module.my_database.cluster_port
160
+ ip_protocol = "tcp"
125
161
  }
126
162
  ```
127
163
 
128
- Ensure the agent's execution role has `rds-db:connect` permission and that its security group can reach the database security group on the database port.
164
+ `appconfig_application_id`/`appconfig_application_arn` come from the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application declared once in your root module, not from the database module. Include the `database` namespace when instantiating it so the database module's runtime configuration entry is deployed:
165
+
166
+ ```hcl title="packages/infra/src/main.tf"
167
+ module "runtime_config_appconfig" {
168
+ source = "../../common/terraform/src/core/runtime-config/appconfig"
169
+
170
+ application_name = "my-app-runtime-config"
171
+ namespaces = ["connection", "agentcore", "database"]
172
+ }
173
+ ```
129
174
 
130
175
  </Fragment>
131
176
  </Infrastructure>
@@ -136,6 +181,6 @@ Ensure the agent's execution role has `rds-db:connect` permission and that its s
136
181
 
137
182
  ## Local Development
138
183
 
139
- <NxCommands commands={["<agent-name>-serve-local <project-name>"]} />
184
+ <NxCommands commands={["<agent-name>-dev <project-name>"]} />
140
185
 
141
- This starts the agent and all connected databases. The `SERVE_LOCAL=true` environment variable causes each Prisma client to connect to its local Docker database instead of Aurora.
186
+ This starts the agent and all connected databases. The `LOCAL_DEV=true` environment variable causes each Prisma client to connect to its local Docker database instead of Aurora.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: MCP Server to DynamoDB
3
- description: Connect a TypeScript MCP Server to a DynamoDB table
3
+ description: Connect a TypeScript MCP Server to a TypeScript DynamoDB project
4
4
  when:
5
5
  sourceType: ts#mcp-server
6
6
  targetType: ts#dynamodb
@@ -12,7 +12,7 @@ import NxCommands from '@components/nx-commands.astro';
12
12
  import Infrastructure from '@components/infrastructure.astro';
13
13
  import Snippet from '@components/snippet.astro';
14
14
 
15
- The `connection` generator wires a <Link path="guides/ts-mcp-server">TypeScript MCP Server</Link> to a <Link path="guides/ts-dynamodb">DynamoDB</Link> project, configuring local development so both start together automatically.
15
+ The `connection` generator wires a <Link path="guides/ts-mcp-server">TypeScript MCP Server</Link> to a <Link path="guides/ts-dynamodb">TypeScript DynamoDB</Link> project, configuring local development so both start together automatically.
16
16
 
17
17
  ## Prerequisites
18
18
 
@@ -35,7 +35,7 @@ Select your MCP server project as the source and your DynamoDB project as the ta
35
35
 
36
36
  ## Generator Output
37
37
 
38
- The generator updates the MCP server's `<mcp-server-name>-serve-local` target in `project.json` to depend on the DynamoDB project's `serve-local` target. No source files are modified.
38
+ The generator updates the MCP server's `<mcp-server-name>-dev` target in `project.json` to depend on the DynamoDB project's `dev` target. No source files are modified.
39
39
 
40
40
  ## Using DynamoDB in Tools
41
41
 
@@ -46,9 +46,9 @@ The generator modifies two files in your MCP server's source directory:
46
46
 
47
47
  </FileTree>
48
48
 
49
- Additionally, the `<mcp-server-name>-serve-local` target is updated to depend on the database's `serve-local` target.
49
+ Additionally, the `<mcp-server-name>-dev` target is updated to depend on the database's `dev` target.
50
50
 
51
- ## How It Works
51
+ ## Using the Database in MCP Tools
52
52
 
53
53
  The Prisma client is fetched inside `createServer` and available to all tools and resources registered there:
54
54
 
@@ -85,10 +85,21 @@ The generated MCP server construct implements `IGrantable` and `IConnectable`, s
85
85
  <Fragment slot="cdk">
86
86
 
87
87
  ```ts title="packages/infra/src/stacks/application-stack.ts"
88
+ import { SecurityGroup } from 'aws-cdk-lib/aws-ec2';
89
+ import { RuntimeNetworkConfiguration } from 'aws-cdk-lib/aws-bedrockagentcore';
88
90
  import { MyDatabase } from ':my-scope/common-constructs';
89
91
 
90
92
  const db = new MyDatabase(this, 'Db', { vpc, ... });
91
- const myMcpServer = new MyMcpServer(this, 'MyMcpServer', { vpc, ... });
93
+
94
+ const myMcpServer = new MyMcpServer(this, 'MyMcpServer', {
95
+ networkConfiguration: RuntimeNetworkConfiguration.usingVpc(this, {
96
+ vpc,
97
+ vpcSubnets: { subnetType: SubnetType.PRIVATE_WITH_EGRESS },
98
+ securityGroups: [
99
+ new SecurityGroup(this, 'MyMcpServerSecurityGroup', { vpc, allowAllOutbound: true }),
100
+ ],
101
+ }),
102
+ });
92
103
 
93
104
  db.allowDefaultPortFrom(myMcpServer);
94
105
  db.grantConnect(myMcpServer);
@@ -96,40 +107,79 @@ db.grantConnect(myMcpServer);
96
107
 
97
108
  `allowDefaultPortFrom` opens the security group rule so the MCP server runtime can reach the database port. `grantConnect` grants IAM `rds-db:connect` permission to the server's execution role.
98
109
 
110
+
99
111
  </Fragment>
100
112
  <Fragment slot="terraform">
101
113
 
102
- Pass the database module outputs into your MCP server module so it can reach the database and read its runtime configuration:
114
+ Run the MCP server inside the same VPC as the database, grant it `rds-db:connect` via `additional_iam_policy_statements`, and open the network path with a pair of security group rules. The `aws_vpc.main` and `aws_subnet` resources are defined in the database deployment guide:
103
115
 
104
116
  ```hcl title="packages/infra/src/main.tf"
105
117
  module "my_database" {
106
118
  source = "../../common/terraform/src/app/dbs/my-database"
107
- vpc_id = module.vpc.vpc_id
108
- database_subnet_ids = module.vpc.private_isolated_subnet_ids
119
+ vpc_id = aws_vpc.main.id
120
+ database_subnet_ids = aws_subnet.database[*].id
121
+ lambda_subnet_ids = aws_subnet.private[*].id
109
122
  }
110
123
 
111
124
  module "my_mcp_server" {
112
- source = "../../common/terraform/src/app/mcp-servers/my-mcp-server"
125
+ source = "../../common/terraform/src/app/mcp-servers/my-mcp-server"
126
+ enable_vpc = true
127
+ vpc_id = aws_vpc.main.id
128
+ subnet_ids = aws_subnet.private[*].id
129
+
130
+ appconfig_application_id = module.runtime_config_appconfig.application_id
131
+ appconfig_application_arn = module.runtime_config_appconfig.application_arn
132
+
133
+ additional_iam_policy_statements = [
134
+ {
135
+ Effect = "Allow"
136
+ Action = ["rds-db:connect"]
137
+ Resource = [
138
+ "arn:aws:rds-db:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:dbuser:${module.my_database.connect_resource_id}/${module.my_database.database_runtime_user}"
139
+ ]
140
+ }
141
+ ]
142
+ }
143
+
144
+ resource "aws_vpc_security_group_ingress_rule" "mcp_server_to_database" {
145
+ description = "Allow the MCP server runtime to connect to the database"
146
+ security_group_id = module.my_database.security_group_id
147
+ referenced_security_group_id = module.my_mcp_server.security_group_id
148
+ from_port = module.my_database.cluster_port
149
+ to_port = module.my_database.cluster_port
150
+ ip_protocol = "tcp"
151
+ }
113
152
 
114
- appconfig_application_id = module.my_database.appconfig_application_id
115
- database_cluster_resource_id = module.my_database.cluster_resource_id
116
- database_runtime_user = module.my_database.database_runtime_user
117
- database_security_group_id = module.my_database.security_group_id
118
- database_port = module.my_database.cluster_port
153
+ resource "aws_vpc_security_group_egress_rule" "mcp_server_to_database" {
154
+ description = "Allow outbound traffic from the MCP server runtime to the database"
155
+ security_group_id = module.my_mcp_server.security_group_id
156
+ referenced_security_group_id = module.my_database.security_group_id
157
+ from_port = module.my_database.cluster_port
158
+ to_port = module.my_database.cluster_port
159
+ ip_protocol = "tcp"
119
160
  }
120
161
  ```
121
162
 
122
- Ensure the MCP server's execution role has `rds-db:connect` permission and that its security group can reach the database security group on the database port.
163
+ `appconfig_application_id`/`appconfig_application_arn` come from the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application declared once in your root module, not from the database module. Include the `database` namespace when instantiating it so the database module's runtime configuration entry is deployed:
164
+
165
+ ```hcl title="packages/infra/src/main.tf"
166
+ module "runtime_config_appconfig" {
167
+ source = "../../common/terraform/src/core/runtime-config/appconfig"
168
+
169
+ application_name = "my-app-runtime-config"
170
+ namespaces = ["connection", "agentcore", "database"]
171
+ }
172
+ ```
123
173
 
124
174
  </Fragment>
125
175
  </Infrastructure>
126
176
 
127
177
  ### SSL Requirements When Connecting Without RDS Proxy
128
178
 
129
- <Snippet name="connection/mcp-server-rdb-ssl-requirements" parentHeading="SSL Requirements When Connecting Without RDS Proxy" />
179
+ <Snippet name="connection/ts-mcp-server-rdb-ssl-requirements" parentHeading="SSL Requirements When Connecting Without RDS Proxy" />
130
180
 
131
181
  ## Local Development
132
182
 
133
- <NxCommands commands={["<mcp-server-name>-serve-local <project-name>"]} />
183
+ <NxCommands commands={["<mcp-server-name>-dev <project-name>"]} />
134
184
 
135
- This starts the MCP server and all connected databases. The `SERVE_LOCAL=true` environment variable causes each Prisma client to connect to its local Docker database instead of Aurora.
185
+ This starts the MCP server and all connected databases. The `LOCAL_DEV=true` environment variable causes each Prisma client to connect to its local Docker database instead of Aurora.
@@ -6,9 +6,21 @@ import Astro from '@astrojs/react';
6
6
  import { CardGrid, LinkButton } from '@astrojs/starlight/components';
7
7
  import Link from '@components/link.astro';
8
8
  import ConnectionCard from '@components/connection-card.astro';
9
+ import RunGenerator from '@components/run-generator.astro';
10
+ import GeneratorParameters from '@components/generator-parameters.astro';
9
11
 
10
12
  This generator is used to connect projects together, such as websites calling APIs. Simply select the source project (for example the project that will call your API) and target project (for example your API project), and this generator will handle integrating the two.
11
13
 
14
+ ## Usage
15
+
16
+ ### Run the Generator
17
+
18
+ <RunGenerator generator="connection" />
19
+
20
+ ### Options
21
+
22
+ <GeneratorParameters generator="connection" />
23
+
12
24
  ### Supported Connections
13
25
 
14
26
  The Connection generator supports the following connections:
@@ -113,28 +125,55 @@ The Connection generator supports the following connections:
113
125
  target="aurora"
114
126
  />
115
127
  <ConnectionCard
116
- title="MCP Server to Relational Database"
128
+ title="TypeScript MCP Server to Relational Database"
117
129
  description="Connect a TypeScript MCP Server to an Aurora relational database"
118
130
  href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-mcp-server-rdb`}
119
131
  source="mcp"
132
+ sourceBadge="typescript"
133
+ target="aurora"
134
+ />
135
+ <ConnectionCard
136
+ title="FastAPI to Python Relational Database"
137
+ description="Connect a FastAPI to a Python Aurora relational database"
138
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-fast-api-rdb`}
139
+ source="fastapi"
120
140
  target="aurora"
141
+ targetBadge="python"
121
142
  />
122
143
  <ConnectionCard
123
- title="tRPC API to DynamoDB"
144
+ title="Python Agent to Python Relational Database"
145
+ description="Connect a Python Agent to a Python Aurora relational database"
146
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-agent-rdb`}
147
+ source="strands"
148
+ sourceBadge="python"
149
+ target="aurora"
150
+ targetBadge="python"
151
+ />
152
+ <ConnectionCard
153
+ title="Python MCP Server to Python Relational Database"
154
+ description="Connect a Python MCP Server to a Python Aurora relational database"
155
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-mcp-server-rdb`}
156
+ source="mcp"
157
+ sourceBadge="python"
158
+ target="aurora"
159
+ targetBadge="python"
160
+ />
161
+ <ConnectionCard
162
+ title="tRPC API to TypeScript DynamoDB"
124
163
  description="Connect a tRPC API to a DynamoDB table"
125
164
  href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/trpc-dynamodb`}
126
165
  source="trpc"
127
166
  target="dynamodb"
128
167
  />
129
168
  <ConnectionCard
130
- title="Smithy API to DynamoDB"
169
+ title="Smithy API to TypeScript DynamoDB"
131
170
  description="Connect a Smithy API to a DynamoDB table"
132
171
  href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/smithy-dynamodb`}
133
172
  source="smithy"
134
173
  target="dynamodb"
135
174
  />
136
175
  <ConnectionCard
137
- title="TypeScript Agent to DynamoDB"
176
+ title="TypeScript Agent to TypeScript DynamoDB"
138
177
  description="Connect a TypeScript Agent to a DynamoDB table"
139
178
  href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-dynamodb`}
140
179
  source="strands"
@@ -142,14 +181,74 @@ The Connection generator supports the following connections:
142
181
  target="dynamodb"
143
182
  />
144
183
  <ConnectionCard
145
- title="MCP Server to DynamoDB"
184
+ title="MCP Server to TypeScript DynamoDB"
146
185
  description="Connect a TypeScript MCP Server to a DynamoDB table"
147
186
  href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-mcp-server-dynamodb`}
148
187
  source="mcp"
149
188
  target="dynamodb"
150
189
  />
190
+ <ConnectionCard
191
+ title="FastAPI to Python DynamoDB"
192
+ description="Connect a FastAPI to a DynamoDB table"
193
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-fast-api-dynamodb`}
194
+ source="fastapi"
195
+ target="dynamodb"
196
+ targetBadge="python"
197
+ />
198
+ <ConnectionCard
199
+ title="Python Agent to Python DynamoDB"
200
+ description="Connect a Python Agent to a DynamoDB table"
201
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-agent-dynamodb`}
202
+ source="strands"
203
+ sourceBadge="python"
204
+ target="dynamodb"
205
+ targetBadge="python"
206
+ />
207
+ <ConnectionCard
208
+ title="Python MCP Server to Python DynamoDB"
209
+ description="Connect a Python MCP Server to a DynamoDB table"
210
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-mcp-server-dynamodb`}
211
+ source="mcp"
212
+ sourceBadge="python"
213
+ target="dynamodb"
214
+ targetBadge="python"
215
+ />
216
+ <ConnectionCard
217
+ title="AgentCore Gateway to MCP Server"
218
+ description="Aggregate an MCP server behind an AgentCore Gateway"
219
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/agentcore-gateway-mcp`}
220
+ source="agentcore"
221
+ target="mcp"
222
+ />
223
+ <ConnectionCard
224
+ title="AgentCore Gateway to AgentCore Gateway"
225
+ description="Aggregate an AgentCore Gateway behind another AgentCore Gateway"
226
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/agentcore-gateway-gateway`}
227
+ source="agentcore"
228
+ target="agentcore"
229
+ />
230
+ <ConnectionCard
231
+ title="TypeScript Agent to AgentCore Gateway"
232
+ description="Connect a TypeScript Agent to an AgentCore Gateway"
233
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-gateway`}
234
+ source="strands"
235
+ sourceBadge="typescript"
236
+ target="agentcore"
237
+ />
238
+ <ConnectionCard
239
+ title="Python Agent to AgentCore Gateway"
240
+ description="Connect a Python Agent to an AgentCore Gateway"
241
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-agent-gateway`}
242
+ source="strands"
243
+ sourceBadge="python"
244
+ target="agentcore"
245
+ />
151
246
  </CardGrid>
152
247
 
153
248
  :::note[Runtime Configuration]
154
249
  The connection generator makes use of <Link path="guides/runtime-config">Runtime Configuration</Link> to pass deploy-time values (such as API URLs, Cognito settings, and agent runtime ARNs) between generated projects and components at runtime so they can discover and connect to one another.
155
250
  :::
251
+
252
+ :::tip[Local Development]
253
+ Connected projects can be run on your machine with the `serve` and `dev` targets. See the <Link path="guides/local-development">Local Development</Link> guide for details.
254
+ :::