@aws/nx-plugin-mcp 1.0.0-rc.12 → 1.0.0-rc.14

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.
@@ -0,0 +1,116 @@
1
+ ---
2
+ title: Python Agent to DynamoDB
3
+ description: Connect a Python Agent to a Python DynamoDB project
4
+ when:
5
+ sourceType: py#agent
6
+ targetType: py#dynamodb
7
+ ---
8
+ import Link from '@components/link.astro';
9
+ import RunGenerator from '@components/run-generator.astro';
10
+ import GeneratorParameters from '@components/generator-parameters.astro';
11
+ import Infrastructure from '@components/infrastructure.astro';
12
+ import Snippet from '@components/snippet.astro';
13
+
14
+ The `connection` generator wires a <Link path="guides/py-agent">Python Agent</Link> to a <Link path="guides/py-dynamodb">Python DynamoDB</Link> project, configuring local development so both start together automatically.
15
+
16
+ ## Prerequisites
17
+
18
+ Before using this generator, ensure you have:
19
+
20
+ 1. A <Link path="guides/py-agent">`py#agent`</Link> project
21
+ 2. A <Link path="guides/py-dynamodb">`py#dynamodb`</Link> project
22
+
23
+ ## Usage
24
+
25
+ ### Run the Generator
26
+
27
+ <RunGenerator generator="connection" />
28
+
29
+ Select your Agent project as the source and your DynamoDB project as the target. If the project contains multiple agent components, specify `sourceComponent` to disambiguate.
30
+
31
+ ### Options
32
+
33
+ <GeneratorParameters generator="connection" />
34
+
35
+ ## Generator Output
36
+
37
+ The generator updates the agent's `<agent-name>-serve-local` target in `project.json` to depend on the DynamoDB project's `serve-local` target, and adds the DynamoDB package as a workspace dependency. No source files are modified.
38
+
39
+ ## Using DynamoDB in Agents
40
+
41
+ Import entity classes from the DynamoDB package and use them inside your agent tools:
42
+
43
+ ```python title="packages/my_project/my_project/my_agent/agent.py"
44
+ from my_scope.my_table.entities.example import ExampleModel
45
+ from strands import tool
46
+
47
+ @tool
48
+ def list_examples() -> list:
49
+ """List all example items."""
50
+ return [item.attribute_values for item in ExampleModel.scan()]
51
+ ```
52
+
53
+ ## Infrastructure
54
+
55
+ To allow the agent's Lambda function to access the DynamoDB table, grant the necessary permissions in your infrastructure.
56
+
57
+ <Infrastructure>
58
+ <Fragment slot="cdk">
59
+
60
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
61
+ import { MyTable } from ':my-scope/common-constructs';
62
+
63
+ const table = new MyTable(this, 'Table');
64
+ const myAgent = new MyAgent(this, 'MyAgent');
65
+
66
+ table.grantReadWriteData(myAgent);
67
+ ```
68
+
69
+ `grantReadWriteData` grants both the DynamoDB and KMS permissions to the agent's execution role.
70
+ </Fragment>
71
+ <Fragment slot="terraform">
72
+
73
+ ```hcl title="packages/infra/src/main.tf"
74
+ module "my_table" {
75
+ source = "../../common/terraform/src/app/dynamodb/my-table"
76
+ }
77
+
78
+ resource "aws_iam_role_policy" "dynamodb_access" {
79
+ role = module.my_agent.lambda_role_name
80
+
81
+ policy = jsonencode({
82
+ Version = "2012-10-17"
83
+ Statement = [
84
+ {
85
+ Effect = "Allow"
86
+ Action = [
87
+ "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem",
88
+ "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:Scan",
89
+ "dynamodb:BatchGetItem", "dynamodb:BatchWriteItem",
90
+ ]
91
+ Resource = [
92
+ module.my_table.table_arn,
93
+ "${module.my_table.table_arn}/index/*",
94
+ ]
95
+ },
96
+ {
97
+ Effect = "Allow"
98
+ Action = [
99
+ "kms:Encrypt",
100
+ "kms:Decrypt",
101
+ "kms:ReEncrypt*",
102
+ "kms:GenerateDataKey*",
103
+ "kms:DescribeKey"
104
+ ]
105
+ Resource = [module.my_table.kms_key_arn]
106
+ },
107
+ ]
108
+ })
109
+ }
110
+ ```
111
+ </Fragment>
112
+ </Infrastructure>
113
+
114
+ ## Local Development
115
+
116
+ <Snippet name="connection/py-dynamodb-local-development" />
@@ -0,0 +1,56 @@
1
+ ---
2
+ title: FastAPI to DynamoDB
3
+ description: Connect a FastAPI to a Python DynamoDB project
4
+ when:
5
+ sourceType: py#fast-api
6
+ targetType: py#dynamodb
7
+ ---
8
+ import Link from '@components/link.astro';
9
+ import RunGenerator from '@components/run-generator.astro';
10
+ import GeneratorParameters from '@components/generator-parameters.astro';
11
+ import Snippet from '@components/snippet.astro';
12
+
13
+ The `connection` generator wires a <Link path="guides/fastapi">FastAPI</Link> to a <Link path="guides/py-dynamodb">Python DynamoDB</Link> project, configuring local development so both start together automatically.
14
+
15
+ ## Prerequisites
16
+
17
+ Before using this generator, ensure you have:
18
+
19
+ 1. A <Link path="guides/fastapi">`py#fast-api`</Link> project
20
+ 2. A <Link path="guides/py-dynamodb">`py#dynamodb`</Link> project
21
+
22
+ ## Usage
23
+
24
+ ### Run the Generator
25
+
26
+ <RunGenerator generator="connection" />
27
+
28
+ Select your FastAPI project as the source and your DynamoDB project as the target.
29
+
30
+ ### Options
31
+
32
+ <GeneratorParameters generator="connection" />
33
+
34
+ ## Generator Output
35
+
36
+ The generator updates the FastAPI's `project.json` to add a dependency from its `serve-local` target to the DynamoDB project's `serve-local` target, and adds the DynamoDB package as a workspace dependency. No source files are modified.
37
+
38
+ ## Using DynamoDB in Route Handlers
39
+
40
+ Import entity classes from the DynamoDB package and use them inside your route handlers:
41
+
42
+ ```python title="packages/my_api/my_api/api.py"
43
+ from my_scope.my_table.entities.example import ExampleModel
44
+
45
+ @app.get("/examples")
46
+ def list_examples():
47
+ return list(ExampleModel.scan())
48
+ ```
49
+
50
+ ## Infrastructure
51
+
52
+ <Snippet name="connection/lambda-dynamodb-access" />
53
+
54
+ ## Local Development
55
+
56
+ <Snippet name="connection/py-dynamodb-local-development" />
@@ -0,0 +1,116 @@
1
+ ---
2
+ title: Python MCP Server to DynamoDB
3
+ description: Connect a Python MCP Server to a Python DynamoDB project
4
+ when:
5
+ sourceType: py#mcp-server
6
+ targetType: py#dynamodb
7
+ ---
8
+ import Link from '@components/link.astro';
9
+ import RunGenerator from '@components/run-generator.astro';
10
+ import GeneratorParameters from '@components/generator-parameters.astro';
11
+ import Infrastructure from '@components/infrastructure.astro';
12
+ import Snippet from '@components/snippet.astro';
13
+
14
+ The `connection` generator wires a <Link path="guides/py-mcp-server">Python MCP Server</Link> to a <Link path="guides/py-dynamodb">Python DynamoDB</Link> project, configuring local development so both start together automatically.
15
+
16
+ ## Prerequisites
17
+
18
+ Before using this generator, ensure you have:
19
+
20
+ 1. A <Link path="guides/py-mcp-server">`py#mcp-server`</Link> project
21
+ 2. A <Link path="guides/py-dynamodb">`py#dynamodb`</Link> project
22
+
23
+ ## Usage
24
+
25
+ ### Run the Generator
26
+
27
+ <RunGenerator generator="connection" />
28
+
29
+ Select your MCP server project as the source and your DynamoDB project as the target. If the project contains multiple MCP server components, specify `sourceComponent` to disambiguate.
30
+
31
+ ### Options
32
+
33
+ <GeneratorParameters generator="connection" />
34
+
35
+ ## Generator Output
36
+
37
+ 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, and adds the DynamoDB package as a workspace dependency. No source files are modified.
38
+
39
+ ## Using DynamoDB in Tools
40
+
41
+ Import entity classes from the DynamoDB package and use them inside your MCP server tools:
42
+
43
+ ```python title="packages/my_project/my_project/my_mcp_server/server.py"
44
+ from my_scope.my_table.entities.example import ExampleModel
45
+
46
+ @mcp.tool()
47
+ def list_examples() -> str:
48
+ """List all example items."""
49
+ items = list(ExampleModel.scan())
50
+ return str([item.attribute_values for item in items])
51
+ ```
52
+
53
+ ## Infrastructure
54
+
55
+ To allow the MCP server's Lambda function to access the DynamoDB table, grant the necessary permissions in your infrastructure.
56
+
57
+ <Infrastructure>
58
+ <Fragment slot="cdk">
59
+
60
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
61
+ import { MyTable } from ':my-scope/common-constructs';
62
+
63
+ const table = new MyTable(this, 'Table');
64
+ const myMcpServer = new MyMcpServer(this, 'MyMcpServer');
65
+
66
+ table.grantReadWriteData(myMcpServer);
67
+ ```
68
+
69
+ `grantReadWriteData` grants both the DynamoDB and KMS permissions to the MCP server's execution role.
70
+ </Fragment>
71
+ <Fragment slot="terraform">
72
+
73
+ ```hcl title="packages/infra/src/main.tf"
74
+ module "my_table" {
75
+ source = "../../common/terraform/src/app/dynamodb/my-table"
76
+ }
77
+
78
+ resource "aws_iam_role_policy" "dynamodb_access" {
79
+ role = module.my_mcp_server.lambda_role_name
80
+
81
+ policy = jsonencode({
82
+ Version = "2012-10-17"
83
+ Statement = [
84
+ {
85
+ Effect = "Allow"
86
+ Action = [
87
+ "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem",
88
+ "dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:Scan",
89
+ "dynamodb:BatchGetItem", "dynamodb:BatchWriteItem",
90
+ ]
91
+ Resource = [
92
+ module.my_table.table_arn,
93
+ "${module.my_table.table_arn}/index/*",
94
+ ]
95
+ },
96
+ {
97
+ Effect = "Allow"
98
+ Action = [
99
+ "kms:Encrypt",
100
+ "kms:Decrypt",
101
+ "kms:ReEncrypt*",
102
+ "kms:GenerateDataKey*",
103
+ "kms:DescribeKey"
104
+ ]
105
+ Resource = [module.my_table.kms_key_arn]
106
+ },
107
+ ]
108
+ })
109
+ }
110
+ ```
111
+ </Fragment>
112
+ </Infrastructure>
113
+
114
+ ## Local Development
115
+
116
+ <Snippet name="connection/py-dynamodb-local-development" />
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Smithy API to DynamoDB
3
- description: Connect a Smithy API to a DynamoDB table
3
+ description: Connect a Smithy API to a TypeScript DynamoDB project
4
4
  when:
5
5
  sourceType: smithy
6
6
  targetType: ts#dynamodb
@@ -12,7 +12,7 @@ import GeneratorParameters from '@components/generator-parameters.astro';
12
12
  import NxCommands from '@components/nx-commands.astro';
13
13
  import Snippet from '@components/snippet.astro';
14
14
 
15
- The `connection` generator wires a <Link path="guides/ts-smithy-api">Smithy API</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-smithy-api">Smithy API</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
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: tRPC API to DynamoDB
3
- description: Connect a tRPC API to a DynamoDB table
3
+ description: Connect a tRPC API to a TypeScript DynamoDB project
4
4
  when:
5
5
  sourceType: ts#trpc-api
6
6
  targetType: ts#dynamodb
@@ -12,7 +12,7 @@ import GeneratorParameters from '@components/generator-parameters.astro';
12
12
  import NxCommands from '@components/nx-commands.astro';
13
13
  import Snippet from '@components/snippet.astro';
14
14
 
15
- The `connection` generator wires a <Link path="guides/trpc">tRPC API</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/trpc">tRPC API</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
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: TypeScript Agent to DynamoDB
3
- description: Connect a TypeScript Agent to a DynamoDB table
3
+ description: Connect a TypeScript Agent to a TypeScript DynamoDB project
4
4
  when:
5
5
  sourceType: ts#agent
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-agent">TypeScript Agent</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-agent">TypeScript Agent</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
 
@@ -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
 
@@ -120,21 +120,21 @@ The Connection generator supports the following connections:
120
120
  target="aurora"
121
121
  />
122
122
  <ConnectionCard
123
- title="tRPC API to DynamoDB"
123
+ title="tRPC API to TypeScript DynamoDB"
124
124
  description="Connect a tRPC API to a DynamoDB table"
125
125
  href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/trpc-dynamodb`}
126
126
  source="trpc"
127
127
  target="dynamodb"
128
128
  />
129
129
  <ConnectionCard
130
- title="Smithy API to DynamoDB"
130
+ title="Smithy API to TypeScript DynamoDB"
131
131
  description="Connect a Smithy API to a DynamoDB table"
132
132
  href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/smithy-dynamodb`}
133
133
  source="smithy"
134
134
  target="dynamodb"
135
135
  />
136
136
  <ConnectionCard
137
- title="TypeScript Agent to DynamoDB"
137
+ title="TypeScript Agent to TypeScript DynamoDB"
138
138
  description="Connect a TypeScript Agent to a DynamoDB table"
139
139
  href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-dynamodb`}
140
140
  source="strands"
@@ -142,12 +142,38 @@ The Connection generator supports the following connections:
142
142
  target="dynamodb"
143
143
  />
144
144
  <ConnectionCard
145
- title="MCP Server to DynamoDB"
145
+ title="MCP Server to TypeScript DynamoDB"
146
146
  description="Connect a TypeScript MCP Server to a DynamoDB table"
147
147
  href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-mcp-server-dynamodb`}
148
148
  source="mcp"
149
149
  target="dynamodb"
150
150
  />
151
+ <ConnectionCard
152
+ title="FastAPI to Python DynamoDB"
153
+ description="Connect a FastAPI to a DynamoDB table"
154
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-fast-api-dynamodb`}
155
+ source="fastapi"
156
+ target="dynamodb"
157
+ targetBadge="python"
158
+ />
159
+ <ConnectionCard
160
+ title="Python Agent to Python DynamoDB"
161
+ description="Connect a Python Agent to a DynamoDB table"
162
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-agent-dynamodb`}
163
+ source="strands"
164
+ sourceBadge="python"
165
+ target="dynamodb"
166
+ targetBadge="python"
167
+ />
168
+ <ConnectionCard
169
+ title="Python MCP Server to Python DynamoDB"
170
+ description="Connect a Python MCP Server to a DynamoDB table"
171
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-mcp-server-dynamodb`}
172
+ source="mcp"
173
+ sourceBadge="python"
174
+ target="dynamodb"
175
+ targetBadge="python"
176
+ />
151
177
  <ConnectionCard
152
178
  title="AgentCore Gateway to MCP Server"
153
179
  description="Aggregate an MCP server behind an AgentCore Gateway"
@@ -351,19 +351,58 @@ This command uses `uv run` to execute your Agent using the [Bedrock AgentCore Py
351
351
 
352
352
  ### Chat with Your Agent
353
353
 
354
- The generator configures a `<your-agent-name>-chat` Nx target that depends on `<your-agent-name>-serve-local`. Running it starts the agent locally and drops you into an interactive terminal chat:
354
+ The generator configures a `<your-agent-name>-chat` Nx target that drops you into an interactive terminal chat with your agent.
355
+
356
+ The chat target runs standalone. By default it connects to your locally running agent, so start `<your-agent-name>-serve-local` first (in a separate terminal):
357
+
358
+ <NxCommands commands={['run your-project:agent-serve-local']} />
359
+
360
+ Then, in another terminal, start the chat:
355
361
 
356
362
  <NxCommands commands={['run your-project:agent-chat']} />
357
363
 
358
- For **HTTP** agents, the generator also emits:
364
+ The generator emits a `scripts/<your-agent-name>/chat.ts` for every protocol. It connects to the local agent by default, or to your deployed agent when `RUNTIME_CONFIG_APP_ID` is set (see [Chat with your deployed agent](#chat-with-your-deployed-agent) below).
365
+
366
+ For **HTTP** agents, the chat script uses a type-safe TypeScript client generated from the agent's OpenAPI spec. The generator also emits:
359
367
 
360
368
  - `scripts/<your-agent-name>_openapi.py` — a small script that exports the agent's OpenAPI spec
361
369
  - An `<your-agent-name>-openapi` Nx target that runs it
362
370
  - An `<your-agent-name>-generate-client` Nx target that produces a type-safe TypeScript client under `scripts/<your-agent-name>/generated/`
363
- - `scripts/<your-agent-name>/chat.ts` — a thin wrapper around the generated client
364
371
 
365
372
  When you customize the agent's input shape (e.g. add new fields to `InvokeInput`), update `chat.ts` to pass the new fields when invoking the agent and the rest works automatically.
366
373
 
374
+ <OptionFilter when={{ infra: 'agentcore' }} description="Deployed agent chat details">
375
+ #### Chat with your deployed agent
376
+
377
+ To chat with your agent deployed to Bedrock AgentCore, set the `RUNTIME_CONFIG_APP_ID` environment variable to the AppConfig application id of the deployment (output as `RuntimeConfigApplicationId` by the deployed stack). The chat script resolves your agent's runtime ARN from runtime configuration and connects to the deployed endpoint:
378
+
379
+ <Tabs syncKey="auth">
380
+ <TabItem label="IAM" _filter={{ auth: 'iam' }}>
381
+ For IAM-authenticated agents, requests are signed with [SigV4](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv.html) using your default AWS credentials. Ensure the environment has AWS credentials with permission to invoke the runtime:
382
+
383
+ <NxCommands commands={['run your-project:agent-chat']} env={{ RUNTIME_CONFIG_APP_ID: '<app-id>' }} />
384
+ </TabItem>
385
+
386
+ <TabItem label="Cognito" _filter={{ auth: 'cognito' }}>
387
+ For Cognito-authenticated agents, provide a Cognito access token via the `AGENT_ACCESS_TOKEN` environment variable, which is sent as a bearer token:
388
+
389
+ <NxCommands commands={['run your-project:agent-chat']} env={{ RUNTIME_CONFIG_APP_ID: '<app-id>', AGENT_ACCESS_TOKEN: '<access-token>' }} />
390
+
391
+ You can obtain an access token using the AWS CLI's `cognito-idp admin-initiate-auth` command, for example:
392
+
393
+ ```bash
394
+ aws cognito-idp admin-initiate-auth \
395
+ --user-pool-id <user-pool-id> \
396
+ --client-id <user-pool-client-id> \
397
+ --auth-flow ADMIN_NO_SRP_AUTH \
398
+ --auth-parameters USERNAME=<username>,PASSWORD=<password> \
399
+ --query 'AuthenticationResult.AccessToken' \
400
+ --output text
401
+ ```
402
+ </TabItem>
403
+ </Tabs>
404
+ </OptionFilter>
405
+
367
406
  <OptionFilter when={{ infra: 'agentcore' }} description="Bedrock AgentCore Runtime deployment details">
368
407
  ## Deploying Your Agent to Bedrock AgentCore Runtime
369
408