@aws/nx-plugin-mcp 1.0.0-rc.8 → 1.0.0-rc.80
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 +14210 -13550
- package/docs/get_started/building-with-ai.mdx +116 -0
- package/docs/get_started/concepts.mdx +67 -0
- package/docs/get_started/existing-project.mdx +180 -0
- package/docs/get_started/graph-builder.mdx +39 -0
- package/docs/get_started/quick-start.mdx +277 -0
- package/docs/get_started/tutorials/contribute-generator.mdx +408 -0
- package/docs/get_started/tutorials/dungeon-game/1.mdx +1578 -0
- package/docs/get_started/tutorials/dungeon-game/2.mdx +245 -0
- package/docs/get_started/tutorials/dungeon-game/3.mdx +66 -0
- package/docs/get_started/tutorials/dungeon-game/4.mdx +164 -0
- package/docs/get_started/tutorials/dungeon-game/overview.mdx +145 -0
- package/docs/get_started/tutorials/dungeon-game/wrap-up.mdx +41 -0
- package/docs/get_started/upgrading.mdx +147 -0
- package/docs/guides/agentcore-gateway.mdx +490 -0
- package/docs/guides/agentcore-harness.mdx +275 -0
- package/docs/guides/astro-docs.mdx +8 -0
- package/docs/guides/connection/agentcore-gateway-agent.mdx +222 -0
- package/docs/guides/connection/agentcore-gateway-gateway.mdx +154 -0
- package/docs/guides/connection/agentcore-gateway-mcp.mdx +134 -0
- package/docs/guides/connection/py-agent-a2a.mdx +48 -16
- package/docs/guides/connection/py-agent-dynamodb.mdx +116 -0
- package/docs/guides/connection/py-agent-gateway.mdx +182 -0
- package/docs/guides/connection/py-agent-mcp.mdx +43 -14
- package/docs/guides/connection/py-agent-rdb.mdx +178 -0
- package/docs/guides/connection/py-fast-api-dynamodb.mdx +56 -0
- package/docs/guides/connection/py-fast-api-rdb.mdx +184 -0
- package/docs/guides/connection/py-mcp-server-dynamodb.mdx +116 -0
- package/docs/guides/connection/py-mcp-server-rdb.mdx +187 -0
- package/docs/guides/connection/react-agentcore-gateway.mdx +112 -0
- package/docs/guides/connection/react-agui.mdx +33 -14
- package/docs/guides/connection/react-fastapi.mdx +39 -3
- package/docs/guides/connection/react-py-agent.mdx +10 -16
- package/docs/guides/connection/react-smithy.mdx +5 -5
- package/docs/guides/connection/react-trpc.mdx +2 -2
- package/docs/guides/connection/react-ts-agent.mdx +9 -9
- package/docs/guides/connection/smithy-dynamodb.mdx +6 -6
- package/docs/guides/connection/smithy-rdb.mdx +10 -10
- package/docs/guides/connection/trpc-dynamodb.mdx +5 -5
- package/docs/guides/connection/trpc-rdb.mdx +6 -6
- package/docs/guides/connection/ts-agent-a2a.mdx +14 -11
- package/docs/guides/connection/ts-agent-dynamodb.mdx +5 -5
- package/docs/guides/connection/ts-agent-gateway.mdx +147 -0
- package/docs/guides/connection/ts-agent-mcp.mdx +12 -9
- package/docs/guides/connection/ts-agent-rdb.mdx +70 -25
- package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +5 -5
- package/docs/guides/connection/ts-mcp-server-rdb.mdx +68 -18
- package/docs/guides/connection.mdx +122 -5
- package/docs/guides/docker-bundling.mdx +81 -12
- package/docs/guides/fastapi.mdx +252 -15
- package/docs/guides/local-development.mdx +87 -0
- package/docs/guides/nx-generator.mdx +4 -3
- package/docs/guides/nx-migration.mdx +165 -0
- package/docs/guides/py-agent.mdx +332 -55
- package/docs/guides/py-dynamodb.mdx +476 -0
- package/docs/guides/py-mcp-server.mdx +57 -2
- package/docs/guides/py-rdb.mdx +265 -0
- package/docs/guides/python-lambda-function.mdx +1 -1
- package/docs/guides/react-website-auth.mdx +104 -5
- package/docs/guides/react-website.mdx +413 -99
- package/docs/guides/runtime-config.mdx +1 -1
- package/docs/guides/security.mdx +75 -0
- package/docs/guides/smithy-project.mdx +167 -0
- package/docs/guides/terraform-project.mdx +2 -2
- package/docs/guides/trpc.mdx +54 -17
- package/docs/guides/ts-agent.mdx +207 -23
- package/docs/guides/ts-dcr-proxy.mdx +569 -0
- package/docs/guides/ts-dynamodb.mdx +66 -242
- package/docs/guides/ts-lambda-function.mdx +1 -1
- package/docs/guides/ts-mcp-server.mdx +111 -29
- package/docs/guides/ts-nx-plugin.mdx +4 -4
- package/docs/guides/ts-rdb.mdx +114 -468
- package/docs/guides/ts-smithy-api.mdx +259 -19
- package/docs/guides/typescript-infrastructure.mdx +46 -24
- package/docs/guides/typescript-project.mdx +134 -27
- package/docs/guides/workspace.mdx +10 -3
- package/docs/snippets/agent/architecture.mdx +1 -1
- package/docs/snippets/agent/bedrock-deployment.mdx +9 -5
- package/docs/snippets/agent/runtime-arn.mdx +23 -2
- package/docs/snippets/agent/securing-your-agent.mdx +39 -0
- package/docs/snippets/api/access-logging.mdx +38 -0
- package/docs/snippets/api/cors-configuration-cdk-note.mdx +1 -1
- package/docs/snippets/api/cors-configuration-terraform-note.mdx +1 -1
- package/docs/snippets/api/type-safe-api-integrations.mdx +69 -50
- package/docs/snippets/api/waf-configuration.mdx +3 -3
- package/docs/snippets/connection/a2a-infrastructure.mdx +1 -1
- package/docs/snippets/connection/dynamodb-local-development.mdx +2 -2
- package/docs/snippets/connection/lambda-dynamodb-access.mdx +1 -1
- package/docs/snippets/connection/py-dynamodb-local-development.mdx +7 -0
- package/docs/snippets/connection/py-lambda-rdb-ssl-requirements.mdx +7 -0
- package/docs/snippets/connection/rdb-api-infrastructure.mdx +51 -19
- package/docs/snippets/dynamodb/deploying-table.mdx +145 -0
- package/docs/snippets/dynamodb/encryption-options.mdx +168 -0
- package/docs/snippets/dynamodb/gsi-config.mdx +38 -0
- package/docs/snippets/dynamodb/infrastructure.mdx +33 -0
- package/docs/snippets/dynamodb/local-dev-start.mdx +13 -0
- package/docs/snippets/dynamodb/local-dev-windows.mdx +15 -0
- package/docs/snippets/lambda-function/deploying-your-function.mdx +3 -3
- package/docs/snippets/mcp/architecture.mdx +1 -1
- package/docs/snippets/mcp/bedrock-deployment.mdx +9 -5
- package/docs/snippets/mcp/config.mdx +3 -2
- package/docs/snippets/mcp/shared-constructs.mdx +4 -5
- package/docs/snippets/pdk-migration/example/01-migrate-api.mdx +7 -5
- package/docs/snippets/pdk-migration/example/02-migrate-website.mdx +29 -10
- package/docs/snippets/pdk-migration/example/03-migrate-infra.mdx +4 -4
- package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +5 -111
- package/docs/snippets/prerequisites.mdx +1 -4
- package/docs/snippets/rdb/architecture.mdx +38 -0
- package/docs/snippets/rdb/cluster-instances.mdx +31 -0
- package/docs/snippets/rdb/deletion-protection.mdx +34 -0
- package/docs/snippets/rdb/deploying.mdx +187 -0
- package/docs/snippets/rdb/encryption-key-rotation.mdx +30 -0
- package/docs/snippets/rdb/engine-version.mdx +63 -0
- package/docs/snippets/rdb/infrastructure.mdx +35 -0
- package/docs/snippets/rdb/logging-mysql.mdx +5 -0
- package/docs/snippets/rdb/logging-postgres.mdx +5 -0
- package/docs/snippets/rdb/performance-insights.mdx +34 -0
- package/docs/snippets/rdb/rds-proxy.mdx +50 -0
- package/docs/snippets/rdb/removal-policy.mdx +57 -0
- package/docs/snippets/rdb/serverless-capacity.mdx +32 -0
- package/docs/snippets/recommended-prerequisites.mdx +10 -0
- package/docs/snippets/required-prerequisites.mdx +1 -4
- package/docs/snippets/runtime-config-app-id-note.mdx +8 -0
- package/docs/snippets/shared-constructs.mdx +1 -1
- package/docs/snippets/trivy-image-scan.mdx +37 -0
- package/generators.json +162 -10
- package/package.json +1 -1
- package/src/agentcore-gateway/agent-connection/schema.json +31 -0
- package/src/agentcore-gateway/gateway-connection/schema.json +31 -0
- package/src/agentcore-gateway/mcp-connection/schema.json +31 -0
- package/src/agentcore-gateway/react-connection/schema.json +31 -0
- package/src/agentcore-gateway/schema.json +72 -0
- package/src/agentcore-harness/schema.json +53 -0
- package/src/connection/schema.json +5 -0
- package/src/infra/app/schema.json +5 -0
- package/src/init/schema.json +35 -0
- package/src/internal/test-matrix/schema.json +21 -0
- package/src/license/schema.json +5 -0
- package/src/preset/schema.json +16 -5
- package/src/py/agent/a2a-connection/schema.json +5 -0
- package/src/py/agent/gateway-connection/schema.json +31 -0
- package/src/py/agent/mcp-connection/schema.json +5 -0
- package/src/py/agent/react-connection/schema.json +5 -0
- package/src/py/agent/schema.json +15 -1
- package/src/py/api/schema.json +5 -0
- package/src/py/dynamodb/agent-connection/schema.json +27 -0
- package/src/py/dynamodb/fast-api-connection/schema.json +23 -0
- package/src/py/dynamodb/mcp-server-connection/schema.json +27 -0
- package/src/py/dynamodb/schema.json +76 -0
- package/src/py/fast-api/react/schema.json +5 -0
- package/src/py/fast-api/schema.json +6 -0
- package/src/py/lambda-function/schema.json +6 -1
- package/src/py/mcp-server/schema.json +6 -0
- package/src/py/project/schema.json +6 -0
- package/src/py/rdb/agent-connection/schema.json +27 -0
- package/src/py/rdb/fast-api-connection/schema.json +23 -0
- package/src/py/rdb/mcp-server-connection/schema.json +27 -0
- package/src/py/rdb/schema.json +78 -0
- package/src/smithy/project/schema.json +28 -1
- package/src/smithy/react-connection/schema.json +5 -0
- package/src/smithy/ts/api/schema.json +6 -0
- package/src/terraform/project/schema.json +5 -0
- package/src/trpc/backend/schema.json +6 -0
- package/src/trpc/react/schema.json +5 -0
- package/src/ts/agent/a2a-connection/schema.json +5 -0
- package/src/ts/agent/gateway-connection/schema.json +31 -0
- package/src/ts/agent/mcp-connection/schema.json +5 -0
- package/src/ts/agent/react-connection/schema.json +5 -0
- package/src/ts/agent/schema.json +14 -0
- package/src/ts/api/schema.json +5 -0
- package/src/ts/astro-docs/schema.json +3 -3
- package/src/ts/dcr-proxy/schema.json +44 -0
- package/src/ts/docs/schema.json +3 -3
- package/src/ts/dynamodb/agent-connection/schema.json +5 -0
- package/src/ts/dynamodb/mcp-server-connection/schema.json +5 -0
- package/src/ts/dynamodb/schema.json +26 -2
- package/src/ts/dynamodb/smithy-connection/schema.json +5 -0
- package/src/ts/dynamodb/trpc-connection/schema.json +5 -0
- package/src/ts/lambda-function/schema.json +5 -0
- package/src/ts/lib/schema.json +5 -0
- package/src/ts/mcp-server/schema.json +6 -0
- package/src/ts/nx-generator/schema.json +5 -0
- package/src/ts/nx-migration/schema.json +63 -0
- package/src/ts/nx-plugin/schema.json +5 -0
- package/src/ts/rdb/agent-connection/schema.json +5 -0
- package/src/ts/rdb/mcp-server-connection/schema.json +5 -0
- package/src/ts/rdb/schema.json +7 -1
- package/src/ts/rdb/smithy-connection/schema.json +5 -0
- package/src/ts/rdb/trpc-connection/schema.json +5 -0
- package/src/ts/react-website/app/schema.json +12 -6
- package/src/ts/react-website/cognito-auth/schema.json +5 -0
- package/src/ts/react-website/runtime-config/schema.json +5 -0
- package/src/ts/website/app/schema.json +11 -6
- package/src/ts/website/auth/schema.json +5 -0
- /package/docs/snippets/connection/{lambda-rdb-ssl-requirements.mdx → ts-lambda-rdb-ssl-requirements.mdx} +0 -0
- /package/docs/snippets/connection/{mcp-server-rdb-ssl-requirements.mdx → ts-mcp-server-rdb-ssl-requirements.mdx} +0 -0
|
@@ -46,18 +46,14 @@ 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>-
|
|
49
|
+
Additionally, the agent's `<agent-name>-dev` target is updated to depend on the database's `dev` target.
|
|
50
50
|
|
|
51
|
-
##
|
|
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
|
-
import { getPrisma as getMyDb } from '
|
|
56
|
+
import { getPrisma as getMyDb } from '@my-scope/my-db';
|
|
61
57
|
|
|
62
58
|
export const getAgent = async () => {
|
|
63
59
|
const myDb = await getMyDb();
|
|
@@ -66,14 +62,13 @@ 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:
|
|
73
68
|
|
|
74
69
|
```ts title="packages/my-service/src/my-agent/agent.ts" {1,2,5,6}
|
|
75
|
-
import { getPrisma as getMyDb } from '
|
|
76
|
-
import { getPrisma as getOtherDb } from '
|
|
70
|
+
import { getPrisma as getMyDb } from '@my-scope/my-db';
|
|
71
|
+
import { getPrisma as getOtherDb } from '@my-scope/other-db';
|
|
77
72
|
|
|
78
73
|
export const getAgent = async () => {
|
|
79
74
|
const myDb = await getMyDb();
|
|
@@ -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"
|
|
94
|
-
import {
|
|
89
|
+
import { SecurityGroup } from 'aws-cdk-lib/aws-ec2';
|
|
90
|
+
import { RuntimeNetworkConfiguration } from 'aws-cdk-lib/aws-bedrockagentcore';
|
|
91
|
+
import { MyDatabase } from '@my-scope/common-constructs';
|
|
95
92
|
|
|
96
93
|
const db = new MyDatabase(this, 'Db', { vpc, ... });
|
|
97
|
-
|
|
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
|
-
|
|
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 =
|
|
114
|
-
database_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
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
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>-
|
|
184
|
+
<NxCommands commands={["<agent-name>-dev <project-name>"]} />
|
|
140
185
|
|
|
141
|
-
This starts the agent and all connected databases. The `
|
|
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
|
|
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,14 +35,14 @@ 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>-
|
|
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
|
|
|
42
42
|
Import entity factories from the DynamoDB package and use them inside `createServer`:
|
|
43
43
|
|
|
44
44
|
```ts title="packages/my-service/src/my-mcp/server.ts"
|
|
45
|
-
import { createExampleEntity } from '
|
|
45
|
+
import { createExampleEntity } from '@my-scope/my-table';
|
|
46
46
|
|
|
47
47
|
export const createServer = async () => {
|
|
48
48
|
const server = new McpServer({ name: 'my-service', version: '1.0.0' });
|
|
@@ -67,7 +67,7 @@ To allow the MCP server to access the DynamoDB table, grant the necessary permis
|
|
|
67
67
|
<Fragment slot="cdk">
|
|
68
68
|
|
|
69
69
|
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
70
|
-
import { MyTable } from '
|
|
70
|
+
import { MyTable } from '@my-scope/common-constructs';
|
|
71
71
|
|
|
72
72
|
const table = new MyTable(this, 'Table');
|
|
73
73
|
const myMcpServer = new MyMcpServer(this, 'MyMcpServer');
|
|
@@ -46,14 +46,14 @@ 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>-
|
|
49
|
+
Additionally, the `<mcp-server-name>-dev` target is updated to depend on the database's `dev` target.
|
|
50
50
|
|
|
51
|
-
##
|
|
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
|
|
|
55
55
|
```ts title="packages/my-service/src/my-mcp/server.ts" {1,4}
|
|
56
|
-
import { getPrisma as getMyDb } from '
|
|
56
|
+
import { getPrisma as getMyDb } from '@my-scope/my-db';
|
|
57
57
|
|
|
58
58
|
export const createServer = async () => {
|
|
59
59
|
const myDb = await getMyDb();
|
|
@@ -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 {
|
|
88
|
+
import { SecurityGroup } from 'aws-cdk-lib/aws-ec2';
|
|
89
|
+
import { RuntimeNetworkConfiguration } from 'aws-cdk-lib/aws-bedrockagentcore';
|
|
90
|
+
import { MyDatabase } from '@my-scope/common-constructs';
|
|
89
91
|
|
|
90
92
|
const db = new MyDatabase(this, 'Db', { vpc, ... });
|
|
91
|
-
|
|
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
|
-
|
|
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 =
|
|
108
|
-
database_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
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
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>-
|
|
183
|
+
<NxCommands commands={["<mcp-server-name>-dev <project-name>"]} />
|
|
134
184
|
|
|
135
|
-
This starts the MCP server and all connected databases. The `
|
|
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,25 @@ 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
|
+
:::tip[Sketch it visually]
|
|
15
|
+
Prefer to design your workspace first? The <Link path="get_started/graph-builder">Graph Builder</Link> lets you drag out projects and draw the connections between them, then gives you the commands to scaffold the lot.
|
|
16
|
+
:::
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Run the Generator
|
|
21
|
+
|
|
22
|
+
<RunGenerator generator="connection" />
|
|
23
|
+
|
|
24
|
+
### Options
|
|
25
|
+
|
|
26
|
+
<GeneratorParameters generator="connection" />
|
|
27
|
+
|
|
12
28
|
### Supported Connections
|
|
13
29
|
|
|
14
30
|
The Connection generator supports the following connections:
|
|
@@ -113,28 +129,55 @@ The Connection generator supports the following connections:
|
|
|
113
129
|
target="aurora"
|
|
114
130
|
/>
|
|
115
131
|
<ConnectionCard
|
|
116
|
-
title="MCP Server to Relational Database"
|
|
132
|
+
title="TypeScript MCP Server to Relational Database"
|
|
117
133
|
description="Connect a TypeScript MCP Server to an Aurora relational database"
|
|
118
134
|
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-mcp-server-rdb`}
|
|
119
135
|
source="mcp"
|
|
136
|
+
sourceBadge="typescript"
|
|
120
137
|
target="aurora"
|
|
121
138
|
/>
|
|
122
139
|
<ConnectionCard
|
|
123
|
-
title="
|
|
140
|
+
title="FastAPI to Python Relational Database"
|
|
141
|
+
description="Connect a FastAPI to a Python Aurora relational database"
|
|
142
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-fast-api-rdb`}
|
|
143
|
+
source="fastapi"
|
|
144
|
+
target="aurora"
|
|
145
|
+
targetBadge="python"
|
|
146
|
+
/>
|
|
147
|
+
<ConnectionCard
|
|
148
|
+
title="Python Agent to Python Relational Database"
|
|
149
|
+
description="Connect a Python Agent to a Python Aurora relational database"
|
|
150
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-agent-rdb`}
|
|
151
|
+
source="strands"
|
|
152
|
+
sourceBadge="python"
|
|
153
|
+
target="aurora"
|
|
154
|
+
targetBadge="python"
|
|
155
|
+
/>
|
|
156
|
+
<ConnectionCard
|
|
157
|
+
title="Python MCP Server to Python Relational Database"
|
|
158
|
+
description="Connect a Python MCP Server to a Python Aurora relational database"
|
|
159
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-mcp-server-rdb`}
|
|
160
|
+
source="mcp"
|
|
161
|
+
sourceBadge="python"
|
|
162
|
+
target="aurora"
|
|
163
|
+
targetBadge="python"
|
|
164
|
+
/>
|
|
165
|
+
<ConnectionCard
|
|
166
|
+
title="tRPC API to TypeScript DynamoDB"
|
|
124
167
|
description="Connect a tRPC API to a DynamoDB table"
|
|
125
168
|
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/trpc-dynamodb`}
|
|
126
169
|
source="trpc"
|
|
127
170
|
target="dynamodb"
|
|
128
171
|
/>
|
|
129
172
|
<ConnectionCard
|
|
130
|
-
title="Smithy API to DynamoDB"
|
|
173
|
+
title="Smithy API to TypeScript DynamoDB"
|
|
131
174
|
description="Connect a Smithy API to a DynamoDB table"
|
|
132
175
|
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/smithy-dynamodb`}
|
|
133
176
|
source="smithy"
|
|
134
177
|
target="dynamodb"
|
|
135
178
|
/>
|
|
136
179
|
<ConnectionCard
|
|
137
|
-
title="TypeScript Agent to DynamoDB"
|
|
180
|
+
title="TypeScript Agent to TypeScript DynamoDB"
|
|
138
181
|
description="Connect a TypeScript Agent to a DynamoDB table"
|
|
139
182
|
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-dynamodb`}
|
|
140
183
|
source="strands"
|
|
@@ -142,14 +185,88 @@ The Connection generator supports the following connections:
|
|
|
142
185
|
target="dynamodb"
|
|
143
186
|
/>
|
|
144
187
|
<ConnectionCard
|
|
145
|
-
title="MCP Server to DynamoDB"
|
|
188
|
+
title="MCP Server to TypeScript DynamoDB"
|
|
146
189
|
description="Connect a TypeScript MCP Server to a DynamoDB table"
|
|
147
190
|
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-mcp-server-dynamodb`}
|
|
148
191
|
source="mcp"
|
|
149
192
|
target="dynamodb"
|
|
150
193
|
/>
|
|
194
|
+
<ConnectionCard
|
|
195
|
+
title="FastAPI to Python DynamoDB"
|
|
196
|
+
description="Connect a FastAPI to a DynamoDB table"
|
|
197
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-fast-api-dynamodb`}
|
|
198
|
+
source="fastapi"
|
|
199
|
+
target="dynamodb"
|
|
200
|
+
targetBadge="python"
|
|
201
|
+
/>
|
|
202
|
+
<ConnectionCard
|
|
203
|
+
title="Python Agent to Python DynamoDB"
|
|
204
|
+
description="Connect a Python Agent to a DynamoDB table"
|
|
205
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-agent-dynamodb`}
|
|
206
|
+
source="strands"
|
|
207
|
+
sourceBadge="python"
|
|
208
|
+
target="dynamodb"
|
|
209
|
+
targetBadge="python"
|
|
210
|
+
/>
|
|
211
|
+
<ConnectionCard
|
|
212
|
+
title="Python MCP Server to Python DynamoDB"
|
|
213
|
+
description="Connect a Python MCP Server to a DynamoDB table"
|
|
214
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-mcp-server-dynamodb`}
|
|
215
|
+
source="mcp"
|
|
216
|
+
sourceBadge="python"
|
|
217
|
+
target="dynamodb"
|
|
218
|
+
targetBadge="python"
|
|
219
|
+
/>
|
|
220
|
+
<ConnectionCard
|
|
221
|
+
title="AgentCore Gateway to MCP Server"
|
|
222
|
+
description="Aggregate an MCP server behind an AgentCore Gateway"
|
|
223
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/agentcore-gateway-mcp`}
|
|
224
|
+
source="agentcore"
|
|
225
|
+
target="mcp"
|
|
226
|
+
/>
|
|
227
|
+
<ConnectionCard
|
|
228
|
+
title="AgentCore Gateway to AgentCore Gateway"
|
|
229
|
+
description="Aggregate an AgentCore Gateway behind another AgentCore Gateway"
|
|
230
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/agentcore-gateway-gateway`}
|
|
231
|
+
source="agentcore"
|
|
232
|
+
target="agentcore"
|
|
233
|
+
/>
|
|
234
|
+
<ConnectionCard
|
|
235
|
+
title="TypeScript Agent to AgentCore Gateway"
|
|
236
|
+
description="Connect a TypeScript Agent to an AgentCore Gateway"
|
|
237
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-gateway`}
|
|
238
|
+
source="strands"
|
|
239
|
+
sourceBadge="typescript"
|
|
240
|
+
target="agentcore"
|
|
241
|
+
/>
|
|
242
|
+
<ConnectionCard
|
|
243
|
+
title="Python Agent to AgentCore Gateway"
|
|
244
|
+
description="Connect a Python Agent to an AgentCore Gateway"
|
|
245
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-agent-gateway`}
|
|
246
|
+
source="strands"
|
|
247
|
+
sourceBadge="python"
|
|
248
|
+
target="agentcore"
|
|
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
|
+
/>
|
|
151
264
|
</CardGrid>
|
|
152
265
|
|
|
153
266
|
:::note[Runtime Configuration]
|
|
154
267
|
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
268
|
:::
|
|
269
|
+
|
|
270
|
+
:::tip[Local Development]
|
|
271
|
+
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.
|
|
272
|
+
:::
|