@aws/nx-plugin-mcp 1.0.0-rc.10 → 1.0.0-rc.11
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.
|
@@ -153,3 +153,7 @@ The Connection generator supports the following connections:
|
|
|
153
153
|
:::note[Runtime Configuration]
|
|
154
154
|
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
155
|
:::
|
|
156
|
+
|
|
157
|
+
:::tip[Local Development]
|
|
158
|
+
Connected projects can be run on your machine with the `serve` and `serve-local` targets. See the <Link path="guides/local-development">Local Development</Link> guide for details.
|
|
159
|
+
:::
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Local Development
|
|
3
|
+
description: How local development works with the serve and serve-local targets
|
|
4
|
+
---
|
|
5
|
+
import Link from '@components/link.astro';
|
|
6
|
+
import NxCommands from '@components/nx-commands.astro';
|
|
7
|
+
import PackageManagerShortCommand from '@components/package-manager-short-command.astro';
|
|
8
|
+
|
|
9
|
+
Connected projects expose two targets for running them on your machine: `serve` and `serve-local`. The difference is one of **scope** — how much of your application runs locally versus pointing at deployed AWS infrastructure.
|
|
10
|
+
|
|
11
|
+
Consider a workspace with the following connections: a website that calls a tRPC `api`, and also calls an `agent` which in turn calls an `mcp` server.
|
|
12
|
+
|
|
13
|
+
## `serve`
|
|
14
|
+
|
|
15
|
+
The `serve` target runs **only the targeted project** locally. Every other project it connects to is expected to be **deployed**, and is reached at its real AWS URL.
|
|
16
|
+
|
|
17
|
+
<NxCommands commands={['serve website']} />
|
|
18
|
+
|
|
19
|
+
Because the targeted project talks to deployed resources, it needs to know where they are. For a website this is provided by its `runtime-config.json` (see <Link path="guides/react-website#local-runtime-config">Local Runtime Config</Link>), which you load from a deployed application. For server-side projects (APIs and agents) that read <Link path="guides/runtime-config">Runtime Configuration</Link>, set the `RUNTIME_CONFIG_APP_ID` environment variable to point at your deployed AppConfig application.
|
|
20
|
+
|
|
21
|
+
```d2
|
|
22
|
+
direction: right
|
|
23
|
+
|
|
24
|
+
local: Local {
|
|
25
|
+
style.stroke-dash: 3
|
|
26
|
+
website: website
|
|
27
|
+
}
|
|
28
|
+
deployed: Deployed {
|
|
29
|
+
style.stroke-dash: 3
|
|
30
|
+
api: api
|
|
31
|
+
agent: agent
|
|
32
|
+
mcp: mcp
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
local.website -> deployed.api
|
|
36
|
+
local.website -> deployed.agent
|
|
37
|
+
deployed.agent -> deployed.mcp
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Use `serve` when you want to iterate on a single project against the "real", deployed versions of everything it depends on.
|
|
41
|
+
|
|
42
|
+
## `serve-local`
|
|
43
|
+
|
|
44
|
+
The `serve-local` target runs the **targeted project** and **every project connected to it transitively**, all on your machine. The connection generator wires this up automatically — running `serve-local` on the website also starts local servers for the `api`, the `agent`, and the `mcp` server it reaches through the agent.
|
|
45
|
+
|
|
46
|
+
<NxCommands commands={['serve-local website']} />
|
|
47
|
+
|
|
48
|
+
When run this way, the website's `runtime-config.json` is automatically overridden (via [Vite's `MODE`](https://vite.dev/guide/env-and-mode), set to `serve-local`) so that it points at your locally running servers instead of deployed URLs.
|
|
49
|
+
|
|
50
|
+
```d2
|
|
51
|
+
direction: right
|
|
52
|
+
|
|
53
|
+
local: Local {
|
|
54
|
+
style.stroke-dash: 3
|
|
55
|
+
website: website
|
|
56
|
+
api: api
|
|
57
|
+
agent: agent
|
|
58
|
+
mcp: mcp
|
|
59
|
+
|
|
60
|
+
website -> api
|
|
61
|
+
website -> agent
|
|
62
|
+
agent -> mcp
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Every project runs locally, so there are no deployed dependencies.
|
|
67
|
+
|
|
68
|
+
Use `serve-local` when you are working across several connected projects at once and want to iterate quickly without deploying your infrastructure.
|
|
69
|
+
|
|
70
|
+
:::tip[`dev` shortcut]
|
|
71
|
+
A root `dev` script is added as a shortcut for the first website you generate in your workspace, so you can spin up the website and all connected components with:
|
|
72
|
+
|
|
73
|
+
<PackageManagerShortCommand commands={["dev"]} />
|
|
74
|
+
:::
|
|
75
|
+
|
|
76
|
+
For more detail on each project type's local development server, see the relevant guide — for example the <Link path="guides/react-website#local-development-server">React Website</Link> guide.
|
|
@@ -11,7 +11,6 @@ import GeneratorParameters from '@components/generator-parameters.astro';
|
|
|
11
11
|
import Infrastructure from '@components/infrastructure.astro';
|
|
12
12
|
import NxCommands from '@components/nx-commands.astro';
|
|
13
13
|
import Snippet from '@components/snippet.astro';
|
|
14
|
-
import OptionFilter from '@components/option-filter.astro';
|
|
15
14
|
|
|
16
15
|
This generator creates a new TypeScript project backed by [Amazon DynamoDB](https://aws.amazon.com/dynamodb/), using [ElectroDB](https://electrodb.dev/) for type-safe entity modelling. It generates the application code and infrastructure needed to provision and manage a DynamoDB table using AWS CDK or Terraform, with single-table design support and built-in local development via DynamoDB Local.
|
|
17
16
|
|
|
@@ -41,6 +40,7 @@ The generator creates the following project structure in the `<directory>/<name>
|
|
|
41
40
|
- entities
|
|
42
41
|
- example.ts Example ElectroDB entity definition
|
|
43
42
|
- index.ts Entity exports
|
|
43
|
+
- dynamodb.config.json GSI definitions for the table
|
|
44
44
|
- project.json Project configuration and build targets
|
|
45
45
|
</FileTree>
|
|
46
46
|
|
|
@@ -84,7 +84,7 @@ The generator configures a `serve-local` target that starts a [DynamoDB Local](h
|
|
|
84
84
|
This automatically:
|
|
85
85
|
1. Pulls the DynamoDB Local image (`pull-image` target)
|
|
86
86
|
2. Starts a container
|
|
87
|
-
3. Creates a local table with
|
|
87
|
+
3. Creates a local table with the indexes defined in `dynamodb.config.json`
|
|
88
88
|
|
|
89
89
|
### Data Modelling
|
|
90
90
|
|
|
@@ -165,11 +165,34 @@ Replace `<engine>` with your container engine (`docker` or `finch`) and `<scope>
|
|
|
165
165
|
|
|
166
166
|
## Adding/Removing Global Secondary Indexes
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
GSIs are defined in `dynamodb.config.json` at the project root. Add an entry to `globalSecondaryIndexes` for each GSI, following the [single-table design](https://electrodb.dev/en/core-concepts/single-table-relationships/) naming convention for GSI keys:
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
```json title="packages/my-table/dynamodb.config.json"
|
|
171
|
+
{
|
|
172
|
+
"globalSecondaryIndexes": [
|
|
173
|
+
{
|
|
174
|
+
"indexName": "gsi1pk-gsi1sk-index",
|
|
175
|
+
"partitionKey": "gsi1pk",
|
|
176
|
+
"sortKey": "gsi1sk"
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
The `sortKey` field is optional for hash-key-only GSIs.
|
|
183
|
+
|
|
184
|
+
This config file is read directly from the project root by all consumers:
|
|
185
|
+
- **Local development** — `serve-local` reads `dynamodb.config.json` and creates or updates the local table to match the GSI list
|
|
186
|
+
- **CDK** — the construct reads `dynamodb.config.json` at synth time, so GSI changes are reflected on the next `cdk deploy`
|
|
187
|
+
- **Terraform** — the module reads `dynamodb.config.json` at plan/apply time
|
|
188
|
+
|
|
189
|
+
### One GSI per Deployment
|
|
190
|
+
|
|
191
|
+
:::caution
|
|
192
|
+
DynamoDB [does not allow more than one GSI to be created or deleted in a single table update](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.OnlineOps.html).
|
|
193
|
+
|
|
194
|
+
Each deployment can add or remove **at most one GSI**. If you need to add or remove multiple GSIs, do so one at a time — update `dynamodb.config.json`, deploy the stack, then repeat for the next change.
|
|
195
|
+
:::
|
|
173
196
|
|
|
174
197
|
## Connecting to the Table
|
|
175
198
|
|
|
@@ -217,7 +240,7 @@ export class ApplicationStack extends Stack {
|
|
|
217
240
|
|
|
218
241
|
This provisions a DynamoDB table with:
|
|
219
242
|
- `pk` (partition key) and `sk` (sort key), both `String` type
|
|
220
|
-
-
|
|
243
|
+
- Global Secondary Indexes as defined in `dynamodb.config.json`
|
|
221
244
|
- On-demand (`PAY_PER_REQUEST`) billing
|
|
222
245
|
- Customer-managed KMS encryption with automatic key rotation
|
|
223
246
|
- Point-in-time recovery enabled
|
|
@@ -235,7 +258,7 @@ module "my_table" {
|
|
|
235
258
|
|
|
236
259
|
This provisions a DynamoDB table with:
|
|
237
260
|
- `pk` (partition key) and `sk` (sort key), both `String` type
|
|
238
|
-
-
|
|
261
|
+
- Global Secondary Indexes as defined in `dynamodb.config.json`
|
|
239
262
|
- On-demand (`PAY_PER_REQUEST`) billing
|
|
240
263
|
- Customer-managed KMS encryption with automatic key rotation
|
|
241
264
|
- Point-in-time recovery enabled
|