@aws/nx-plugin-mcp 1.0.0-rc.79 → 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 +11 -1
- package/docs/get_started/tutorials/contribute-generator.mdx +2 -2
- package/docs/guides/connection/py-agent-gateway.mdx +6 -2
- package/docs/guides/connection/react-agui.mdx +1 -1
- package/docs/guides/connection/react-fastapi.mdx +1 -1
- package/docs/guides/connection/react-py-agent.mdx +1 -1
- package/docs/guides/connection/react-smithy.mdx +2 -2
- package/docs/guides/connection/react-trpc.mdx +1 -1
- package/docs/guides/connection/react-ts-agent.mdx +1 -1
- package/docs/guides/connection/smithy-dynamodb.mdx +1 -1
- package/docs/guides/connection/smithy-rdb.mdx +1 -1
- package/docs/guides/connection/ts-agent-gateway.mdx +6 -2
- package/docs/guides/fastapi.mdx +3 -6
- package/docs/guides/py-agent.mdx +8 -8
- package/docs/guides/react-website-auth.mdx +3 -1
- package/docs/guides/react-website.mdx +1 -1
- package/docs/guides/trpc.mdx +1 -1
- package/docs/guides/ts-agent.mdx +15 -13
- package/docs/guides/ts-mcp-server.mdx +9 -3
- package/docs/guides/ts-nx-plugin.mdx +1 -1
- package/docs/guides/ts-rdb.mdx +1 -1
- package/docs/guides/ts-smithy-api.mdx +1 -1
- package/docs/snippets/api/access-logging.mdx +9 -4
- package/docs/snippets/api/type-safe-api-integrations.mdx +37 -49
- package/docs/snippets/mcp/shared-constructs.mdx +4 -5
- package/generators.json +10 -0
- package/package.json +1 -1
- package/src/py/lambda-function/schema.json +1 -1
- package/src/py/project/schema.json +1 -0
- package/docs/get_started/tutorials/existing-project.mdx +0 -4
package/bin/aws-nx-mcp.js
CHANGED
|
@@ -54023,7 +54023,7 @@ When scaffolding several projects in one go, chain generators to avoid a slow de
|
|
|
54023
54023
|
- **Chain generators** with \`&&\` in a single command. Pass \`--prefer-install-dependencies=false\` on each generator except the last so dependencies install once at the end, for example:
|
|
54024
54024
|
|
|
54025
54025
|
${PACKAGE_MANAGERS.map((pm) => ` \`\`\`bash
|
|
54026
|
-
${buildNxCommand("g @aws/nx-plugin:ts#trpc-api --no-interactive --name=my-app-api --auth=
|
|
54026
|
+
${buildNxCommand("g @aws/nx-plugin:ts#trpc-api --no-interactive --name=my-app-api --auth=iam --prefer-install-dependencies=false", pm)} && \\
|
|
54027
54027
|
${buildNxCommand("g @aws/nx-plugin:ts#react-website --no-interactive --name=my-app-website --prefer-install-dependencies=false", pm)} && \\
|
|
54028
54028
|
${buildNxCommand("g @aws/nx-plugin:connection --no-interactive --sourceProject=@my-app/my-app-website --targetProject=@my-app/my-app-api --prefer-install-dependencies=false", pm)} && \\
|
|
54029
54029
|
${buildNxCommand("g @aws/nx-plugin:ts#infra --no-interactive --name=infra", pm)} && \\
|
|
@@ -54205,6 +54205,16 @@ var generators$1 = {
|
|
|
54205
54205
|
"connection/smithy-rdb",
|
|
54206
54206
|
"connection/ts-mcp-server-rdb",
|
|
54207
54207
|
"connection/ts-agent-rdb",
|
|
54208
|
+
"connection/trpc-dynamodb",
|
|
54209
|
+
"connection/smithy-dynamodb",
|
|
54210
|
+
"connection/ts-mcp-server-dynamodb",
|
|
54211
|
+
"connection/ts-agent-dynamodb",
|
|
54212
|
+
"connection/py-fast-api-rdb",
|
|
54213
|
+
"connection/py-agent-rdb",
|
|
54214
|
+
"connection/py-mcp-server-rdb",
|
|
54215
|
+
"connection/py-fast-api-dynamodb",
|
|
54216
|
+
"connection/py-agent-dynamodb",
|
|
54217
|
+
"connection/py-mcp-server-dynamodb",
|
|
54208
54218
|
"connection/ts-agent-gateway",
|
|
54209
54219
|
"connection/py-agent-gateway",
|
|
54210
54220
|
"connection/agentcore-gateway-mcp",
|
|
@@ -54,7 +54,7 @@ Let's create the new generator in `packages/nx-plugin/src/trpc/procedure`.
|
|
|
54
54
|
|
|
55
55
|
We provide a generator for creating new generators so you can quickly scaffold your new generator! You can run this generator as follows:
|
|
56
56
|
|
|
57
|
-
<RunGenerator generator="ts#nx-generator" requiredParameters={{
|
|
57
|
+
<RunGenerator generator="ts#nx-generator" requiredParameters={{ project: '@aws/nx-plugin', name: 'ts#trpc-api#procedure', directory: 'trpc/procedure', description: 'Adds a procedure to a tRPC API' }} />
|
|
58
58
|
|
|
59
59
|
You will notice the following files have been generated for you:
|
|
60
60
|
|
|
@@ -91,7 +91,7 @@ Let's update the schema to add the properties we'll need for the generator:
|
|
|
91
91
|
"description": "The name of the new procedure",
|
|
92
92
|
"type": "string",
|
|
93
93
|
"x-prompt": "What would you like to call your new procedure?",
|
|
94
|
-
"x-priority": "important"
|
|
94
|
+
"x-priority": "important"
|
|
95
95
|
},
|
|
96
96
|
"type": {
|
|
97
97
|
"description": "The type of procedure to generate",
|
|
@@ -21,9 +21,13 @@ The generator wires the agent so it authenticates to the Gateway with IAM SigV4
|
|
|
21
21
|
Before using this generator, ensure you have:
|
|
22
22
|
|
|
23
23
|
1. A Python project with a <Link path="guides/py-agent">Agent</Link> component (`infra: agentcore`)
|
|
24
|
-
2. A <Link path="guides/agentcore-gateway">`agentcore-gateway`</Link> project with `auth: iam`
|
|
24
|
+
2. A <Link path="guides/agentcore-gateway">`agentcore-gateway`</Link> project with `protocol: mcp` and `auth: iam`
|
|
25
25
|
|
|
26
|
-
The Gateway must use IAM authentication
|
|
26
|
+
The Gateway must serve the `mcp` protocol — the agent reaches it as an MCP client, so its targets are exposed as tools. The Gateway must also use IAM authentication: the agent signs its requests with SigV4 using its own execution role. The generator rejects Cognito-authenticated gateways.
|
|
27
|
+
|
|
28
|
+
:::note[One direction per Gateway]
|
|
29
|
+
A single Gateway cannot both be called by an agent and front one. Fronting agent runtimes needs `protocol: http` (see <Link path="guides/connection/agentcore-gateway-agent">Gateway to Agent</Link>), whereas being called by an agent needs `protocol: mcp`. Use a separate Gateway for each direction.
|
|
30
|
+
:::
|
|
27
31
|
|
|
28
32
|
## Usage
|
|
29
33
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
title: React to Smithy API
|
|
3
3
|
description: Connect a React website to a Smithy TypeScript API
|
|
4
4
|
when:
|
|
5
|
-
sourceType: react
|
|
6
|
-
targetType: smithy
|
|
5
|
+
sourceType: ts#react-website
|
|
6
|
+
targetType: ts#smithy-api
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
import { FileTree, Steps } from '@astrojs/starlight/components';
|
|
@@ -21,9 +21,13 @@ The generator wires the agent so it authenticates to the Gateway with IAM SigV4
|
|
|
21
21
|
Before using this generator, ensure you have:
|
|
22
22
|
|
|
23
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 with `auth: iam`
|
|
24
|
+
2. A <Link path="guides/agentcore-gateway">`agentcore-gateway`</Link> project with `protocol: mcp` and `auth: iam`
|
|
25
25
|
|
|
26
|
-
The Gateway must use IAM authentication
|
|
26
|
+
The Gateway must serve the `mcp` protocol — the agent reaches it as an MCP client, so its targets are exposed as tools. The Gateway must also use IAM authentication: the agent signs its requests with SigV4 using its own execution role. The generator rejects Cognito-authenticated gateways.
|
|
27
|
+
|
|
28
|
+
:::note[One direction per Gateway]
|
|
29
|
+
A single Gateway cannot both be called by an agent and front one. Fronting agent runtimes needs `protocol: http` (see <Link path="guides/connection/agentcore-gateway-agent">Gateway to Agent</Link>), whereas being called by an agent needs `protocol: mcp`. Use a separate Gateway for each direction.
|
|
30
|
+
:::
|
|
27
31
|
|
|
28
32
|
## Usage
|
|
29
33
|
|
package/docs/guides/fastapi.mdx
CHANGED
|
@@ -121,9 +121,7 @@ def read_item(item_id: int):
|
|
|
121
121
|
The logger automatically includes:
|
|
122
122
|
|
|
123
123
|
- Correlation IDs for request tracing
|
|
124
|
-
- Request path and method
|
|
125
|
-
- Lambda context information
|
|
126
|
-
- Cold start indicators
|
|
124
|
+
- Request path, matched route and method
|
|
127
125
|
|
|
128
126
|
#### Tracing
|
|
129
127
|
|
|
@@ -159,8 +157,7 @@ Default metrics include:
|
|
|
159
157
|
|
|
160
158
|
- Request counts
|
|
161
159
|
- Success/failure counts
|
|
162
|
-
-
|
|
163
|
-
- Per-route metrics
|
|
160
|
+
- Per-route metrics (via a `route` dimension of `<method> <path>`)
|
|
164
161
|
|
|
165
162
|
### Error Handling
|
|
166
163
|
|
|
@@ -648,7 +645,7 @@ If you are actively working on both your CDK infrastructure and FastAPI together
|
|
|
648
645
|
<NxCommands
|
|
649
646
|
commands={[
|
|
650
647
|
'watch --projects=<FastAPIProject> -- \\ ',
|
|
651
|
-
'run
|
|
648
|
+
'run @<scope>/common-constructs:"generate:<ApiName>-metadata"',
|
|
652
649
|
]}
|
|
653
650
|
/>
|
|
654
651
|
:::
|
package/docs/guides/py-agent.mdx
CHANGED
|
@@ -122,8 +122,8 @@ For deploying your Agent, the following files are generated:
|
|
|
122
122
|
- packages/common/constructs/src
|
|
123
123
|
- app
|
|
124
124
|
- agents
|
|
125
|
-
- \<
|
|
126
|
-
- \<
|
|
125
|
+
- \<agent-name>
|
|
126
|
+
- \<agent-name>.ts CDK construct for deploying your agent
|
|
127
127
|
</FileTree>
|
|
128
128
|
</Fragment>
|
|
129
129
|
<Fragment slot="terraform">
|
|
@@ -131,8 +131,8 @@ For deploying your Agent, the following files are generated:
|
|
|
131
131
|
- packages/common/terraform/src
|
|
132
132
|
- app
|
|
133
133
|
- agents
|
|
134
|
-
- \<
|
|
135
|
-
- \<
|
|
134
|
+
- \<agent-name>
|
|
135
|
+
- \<agent-name>.tf Module for deploying your agent
|
|
136
136
|
- core
|
|
137
137
|
- agent-core
|
|
138
138
|
- runtime.tf Generic module for deploying to Bedrock AgentCore Runtime
|
|
@@ -241,7 +241,7 @@ agent = create_agent(
|
|
|
241
241
|
|
|
242
242
|
<Tabs syncKey="agent-framework">
|
|
243
243
|
<TabItem label="Strands" _filter={{ framework: 'strands' }}>
|
|
244
|
-
By default, Strands agents use Claude 4
|
|
244
|
+
By default, Strands agents use Claude Sonnet 4.6 on Amazon Bedrock, but you can customize the model provider. See the [Strands documentation on model providers](https://strandsagents.com/docs/user-guide/concepts/model-providers/) for configuration options:
|
|
245
245
|
|
|
246
246
|
```python
|
|
247
247
|
from strands import Agent
|
|
@@ -317,10 +317,10 @@ The agent's invocation endpoint uses [Pydantic](https://docs.pydantic.dev/) mode
|
|
|
317
317
|
The default `InvokeInput` model accepts a prompt.
|
|
318
318
|
|
|
319
319
|
```python
|
|
320
|
-
from pydantic import BaseModel
|
|
320
|
+
from pydantic import BaseModel, Field
|
|
321
321
|
|
|
322
322
|
class InvokeInput(BaseModel):
|
|
323
|
-
prompt: str
|
|
323
|
+
prompt: str = Field(max_length=100000)
|
|
324
324
|
```
|
|
325
325
|
|
|
326
326
|
You can extend this model to include any additional fields your agent needs.
|
|
@@ -385,7 +385,7 @@ Since the generator vends CDK or Terraform infrastructure which manages deployin
|
|
|
385
385
|
<OptionFilter when={{ protocol: 'a2a' }} description="A2A server details">
|
|
386
386
|
## A2A Server (A2A protocol)
|
|
387
387
|
|
|
388
|
-
The generated `main.py` mounts an A2A server onto a parent FastAPI app that also exposes `/ping`. Strands agents use the Strands `A2AServer`; LangChain agents wrap the compiled graph in an [`a2a-sdk`](https://a2a-protocol.org/) `AgentExecutor`.
|
|
388
|
+
The generated `main.py` mounts an A2A server onto a parent FastAPI app that also exposes `/ping`. Strands agents use the Strands `A2AServer`; LangChain agents wrap the compiled graph in an [`a2a-sdk`](https://a2a-protocol.org/) `AgentExecutor`. The URL advertised in the agent card comes from the `AGENTCORE_RUNTIME_URL` environment variable, falling back to `http://localhost:<port>/` for local development.
|
|
389
389
|
|
|
390
390
|
Most users will not need to modify this file; edit `agent.py` to change tools or the system prompt. The A2A server populates the agent card (`/.well-known/agent-card.json`) from the agent's `name` and `description`.
|
|
391
391
|
</OptionFilter>
|
|
@@ -265,7 +265,9 @@ export class ApplicationStack extends Stack {
|
|
|
265
265
|
super(scope, id);
|
|
266
266
|
|
|
267
267
|
const identity = new UserIdentity(this, 'Identity');
|
|
268
|
-
const api = new MyApi(this, 'MyApi'
|
|
268
|
+
const api = new MyApi(this, 'MyApi', {
|
|
269
|
+
integrations: MyApi.defaultIntegrations(this).build(),
|
|
270
|
+
});
|
|
269
271
|
|
|
270
272
|
api.grantInvokeAccess(identity.identityPool.authenticatedRole);
|
|
271
273
|
|
|
@@ -497,7 +497,7 @@ You will also need to create DNS records (for example in Route 53) pointing your
|
|
|
497
497
|
|
|
498
498
|
## Runtime Configuration
|
|
499
499
|
|
|
500
|
-
Configuration from your infrastructure is provided to your website via <Link
|
|
500
|
+
Configuration from your infrastructure is provided to your website via <Link path="guides/runtime-config">Runtime Configuration</Link>. This allows your website to access details such as API URLs which are not known until your application is deployed.
|
|
501
501
|
|
|
502
502
|
### Infrastructure
|
|
503
503
|
|
package/docs/guides/trpc.mdx
CHANGED
|
@@ -466,7 +466,7 @@ export const createIdentityPlugin = () => {
|
|
|
466
466
|
</OptionFilter>
|
|
467
467
|
|
|
468
468
|
<OptionFilter when={{ auth: 'cognito' }} description="Identity middleware example for Cognito-authenticated APIs">
|
|
469
|
-
When you deploy with `auth: 'cognito'`, the API Gateway Cognito
|
|
469
|
+
When you deploy with `auth: 'cognito'`, the API Gateway Cognito authorizer verifies the JWT that the caller supplies in the `Authorization` header and places the verified claims on the Lambda event. Our middleware just reads those claims — no extra AWS SDK calls, no manual JWT verification.
|
|
470
470
|
|
|
471
471
|
First, we define what we'll add to the context:
|
|
472
472
|
|
package/docs/guides/ts-agent.mdx
CHANGED
|
@@ -118,8 +118,8 @@ For deploying your Agent, the following files are generated:
|
|
|
118
118
|
- packages/common/constructs/src
|
|
119
119
|
- app
|
|
120
120
|
- agents
|
|
121
|
-
- \<
|
|
122
|
-
- \<
|
|
121
|
+
- \<agent-name>
|
|
122
|
+
- \<agent-name>.ts CDK construct for deploying your agent
|
|
123
123
|
</FileTree>
|
|
124
124
|
</Fragment>
|
|
125
125
|
<Fragment slot="terraform">
|
|
@@ -127,8 +127,8 @@ For deploying your Agent, the following files are generated:
|
|
|
127
127
|
- packages/common/terraform/src
|
|
128
128
|
- app
|
|
129
129
|
- agents
|
|
130
|
-
- \<
|
|
131
|
-
- \<
|
|
130
|
+
- \<agent-name>
|
|
131
|
+
- \<agent-name>.tf Module for deploying your agent
|
|
132
132
|
- core
|
|
133
133
|
- agent-core
|
|
134
134
|
- runtime.tf Generic module for deploying to Bedrock AgentCore Runtime
|
|
@@ -203,7 +203,7 @@ The Strands framework automatically handles:
|
|
|
203
203
|
|
|
204
204
|
### Model Configuration
|
|
205
205
|
|
|
206
|
-
By default, Strands agents use Claude 4
|
|
206
|
+
By default, Strands agents use Claude Sonnet 4.6 on Amazon Bedrock, but you can easily switch between model providers:
|
|
207
207
|
|
|
208
208
|
```typescript
|
|
209
209
|
import { Agent } from '@strands-agents/sdk';
|
|
@@ -247,7 +247,7 @@ For a more in-depth guide to writing Strands agents, refer to the [Strands docum
|
|
|
247
247
|
<OptionFilter when={{ protocol: 'a2a' }} description="A2A Express server details">
|
|
248
248
|
## A2A Server (A2A protocol)
|
|
249
249
|
|
|
250
|
-
The generated `index.ts` mounts the [Strands A2A Express Server](https://strandsagents.com/docs/user-guide/concepts/multi-agent/agent-to-agent) onto an Express app so the generated agent exposes the A2A protocol endpoints alongside a `/ping` health check.
|
|
250
|
+
The generated `index.ts` mounts the [Strands A2A Express Server](https://strandsagents.com/docs/user-guide/concepts/multi-agent/agent-to-agent) onto an Express app so the generated agent exposes the A2A protocol endpoints alongside a `/ping` health check. The URL advertised in the agent card comes from the `AGENTCORE_RUNTIME_URL` environment variable, falling back to `http://localhost:<port>/` for local development.
|
|
251
251
|
|
|
252
252
|
Most users will not need to modify this file — edit `agent.ts` to change tools or the system prompt. A2A agents listen on port `9000` (vs `8080` for HTTP), which the generated Dockerfile and infrastructure are already configured for.
|
|
253
253
|
</OptionFilter>
|
|
@@ -255,7 +255,7 @@ Most users will not need to modify this file — edit `agent.ts` to change tools
|
|
|
255
255
|
<OptionFilter when={{ protocol: 'ag-ui' }} description="AG-UI server details">
|
|
256
256
|
## AG-UI Server (AG-UI protocol)
|
|
257
257
|
|
|
258
|
-
The generated `index.ts` wraps your Strands `Agent` in an [`@ag-ui/aws-strands`](https://www.npmjs.com/package/@ag-ui/aws-strands) `StrandsAgent` and
|
|
258
|
+
The generated `index.ts` wraps your Strands `Agent` in an [`@ag-ui/aws-strands`](https://www.npmjs.com/package/@ag-ui/aws-strands) `StrandsAgent` and builds an Express app. The resulting app exposes a single POST endpoint that streams [AG-UI](https://docs.ag-ui.com/) events over Server-Sent Events (SSE), as well as `/ping` for the AgentCore runtime health check.
|
|
259
259
|
|
|
260
260
|
AG-UI agents are designed to be consumed directly by a frontend. Use the <Link path="/guides/connection/react-agui">`connection` generator</Link> to wire your React website up to the agent with a [CopilotKit](https://docs.copilotkit.ai/aws-strands) provider and [AG-UI HttpAgent](https://docs.ag-ui.com/) client.
|
|
261
261
|
|
|
@@ -395,11 +395,13 @@ You can invoke a locally running agent using the `.local` factory method from th
|
|
|
395
395
|
|
|
396
396
|
You can, for example create a file named `scripts/test.ts` in your workspace which imports the client:
|
|
397
397
|
|
|
398
|
+
The client class is named after your agent, so an agent named `my-agent` exports `MyAgentClient`.
|
|
399
|
+
|
|
398
400
|
```typescript
|
|
399
401
|
// scripts/test.ts
|
|
400
|
-
import {
|
|
402
|
+
import { MyAgentClient } from '../packages/<project>/src/agent/client.js';
|
|
401
403
|
|
|
402
|
-
const client =
|
|
404
|
+
const client = MyAgentClient.local({ url: 'http://localhost:8081/ws' });
|
|
403
405
|
|
|
404
406
|
client.invoke.subscribe({ prompt: 'what is 1 plus 1?' }, { onData: console.log });
|
|
405
407
|
```
|
|
@@ -429,9 +431,9 @@ The client factory uses HTTP headers in the WebSocket handshake to authenticate
|
|
|
429
431
|
You can invoke your deployed agent by passing its ARN to the `withIamAuth` factory method:
|
|
430
432
|
|
|
431
433
|
```typescript
|
|
432
|
-
import {
|
|
434
|
+
import { MyAgentClient } from './agent/client.js';
|
|
433
435
|
|
|
434
|
-
const client =
|
|
436
|
+
const client = MyAgentClient.withIamAuth({
|
|
435
437
|
agentRuntimeArn: 'arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/my-agent',
|
|
436
438
|
});
|
|
437
439
|
|
|
@@ -453,7 +455,7 @@ This will use the default AWS credential provider chain to authenticate requests
|
|
|
453
455
|
Use the `withJwtAuth` factory method to authenticate with the JWT / Cognito access token.
|
|
454
456
|
|
|
455
457
|
```typescript
|
|
456
|
-
const client =
|
|
458
|
+
const client = MyAgentClient.withJwtAuth({
|
|
457
459
|
agentRuntimeArn: 'arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/my-agent',
|
|
458
460
|
accessTokenProvider: async () => `<access-token>`,
|
|
459
461
|
});
|
|
@@ -470,7 +472,7 @@ import { CognitoIdentityProvider } from "@aws-sdk/client-cognito-identity-provid
|
|
|
470
472
|
|
|
471
473
|
const cognito = new CognitoIdentityProvider();
|
|
472
474
|
|
|
473
|
-
const jwtClient =
|
|
475
|
+
const jwtClient = MyAgentClient.withJwtAuth({
|
|
474
476
|
agentRuntimeArn: 'arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/my-agent',
|
|
475
477
|
accessTokenProvider: async () => {
|
|
476
478
|
const response = await cognito.adminInitiateAuth({
|
|
@@ -100,12 +100,18 @@ export const registerMyTool = (server: McpServer) => {
|
|
|
100
100
|
};
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
-
Then register it in `server.ts`:
|
|
103
|
+
Then register it inside `createServer` in `server.ts`:
|
|
104
104
|
|
|
105
|
-
```typescript title="server.ts"
|
|
105
|
+
```typescript title="server.ts" {6}
|
|
106
106
|
import { registerMyTool } from './tools/my-tool.js';
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
export const createServer = async () => {
|
|
109
|
+
const server = new McpServer({ name: 'my-server', version: '1.0.0' });
|
|
110
|
+
|
|
111
|
+
registerMyTool(server);
|
|
112
|
+
|
|
113
|
+
return server;
|
|
114
|
+
};
|
|
109
115
|
```
|
|
110
116
|
|
|
111
117
|
### Adding Resources
|
|
@@ -57,7 +57,7 @@ The generator will create the following project structure:
|
|
|
57
57
|
|
|
58
58
|
Once you have your plugin project, you can add generators using the <Link path="/guides/nx-generator">`ts#nx-generator`</Link> generator:
|
|
59
59
|
|
|
60
|
-
<RunGenerator generator="ts#nx-generator" requiredParameters={{
|
|
60
|
+
<RunGenerator generator="ts#nx-generator" requiredParameters={{ project: 'your-plugin' }} />
|
|
61
61
|
|
|
62
62
|
This will add a new generator to your plugin.
|
|
63
63
|
|
package/docs/guides/ts-rdb.mdx
CHANGED
|
@@ -94,7 +94,7 @@ The generator automatically configures the `generate` target to create a type-sa
|
|
|
94
94
|
|
|
95
95
|
You can also manually generate the client at any time:
|
|
96
96
|
|
|
97
|
-
<NxCommands commands={['
|
|
97
|
+
<NxCommands commands={['run <your-db-project-name>:generate']} />
|
|
98
98
|
|
|
99
99
|
Use the `prisma` target to run Prisma CLI commands from the workspace root:
|
|
100
100
|
|
|
@@ -819,7 +819,7 @@ If you are actively working on both your CDK infrastructure and Smithy API toget
|
|
|
819
819
|
<NxCommands
|
|
820
820
|
commands={[
|
|
821
821
|
'watch --projects=<ModelProject> -- \\ ',
|
|
822
|
-
'run
|
|
822
|
+
'run @<scope>/common-constructs:"generate:<ApiName>-metadata"',
|
|
823
823
|
]}
|
|
824
824
|
/>
|
|
825
825
|
:::
|
|
@@ -14,16 +14,21 @@ API Gateway writes access logs using an account-level CloudWatch Logs role. This
|
|
|
14
14
|
<Fragment slot="cdk">
|
|
15
15
|
The account role is managed by the `ApiGatewayAccount` construct, a stack-scoped singleton resolved via `ApiGatewayAccount.ensure(scope)`. Each REST API's stage depends on it, and the role is configured by a Lambda-backed custom resource.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
The access log format is set by the `RestApi` construct your API extends. To customise it, pass `deployOptions` through to `super` in the generated `packages/common/constructs/src/app/apis/my-api.ts`, keeping the `tracingEnabled` the construct already sets:
|
|
18
18
|
|
|
19
|
-
```ts {
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
```ts {5-8} title="packages/common/constructs/src/app/apis/my-api.ts"
|
|
20
|
+
super(scope, id, {
|
|
21
|
+
apiName: 'MyApi',
|
|
22
|
+
// ...
|
|
22
23
|
deployOptions: {
|
|
24
|
+
tracingEnabled: true,
|
|
23
25
|
accessLogFormat: AccessLogFormat.clf(),
|
|
24
26
|
},
|
|
27
|
+
...props,
|
|
25
28
|
});
|
|
26
29
|
```
|
|
30
|
+
|
|
31
|
+
`AccessLogFormat` is imported from `aws-cdk-lib/aws-apigateway`. Anything you leave unset keeps the construct's default — a JSON format with the standard fields.
|
|
27
32
|
</Fragment>
|
|
28
33
|
<Fragment slot="terraform">
|
|
29
34
|
The account role is managed by the `core/api/api-gateway-account` module, which is instantiated by the generated API module. It configures the account idempotently and is never reset on `terraform destroy`.
|
|
@@ -125,36 +125,7 @@ new MyApi(this, 'MyApi', {
|
|
|
125
125
|
|
|
126
126
|
</Fragment>
|
|
127
127
|
<Fragment slot="terraform">
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
```hcl
|
|
131
|
-
# packages/common/terraform/src/app/apis/my-api/my-api.tf
|
|
132
|
-
# Add VPC variables
|
|
133
|
-
variable "vpc_subnet_ids" {
|
|
134
|
-
description = "List of VPC subnet IDs for Lambda function"
|
|
135
|
-
type = list(string)
|
|
136
|
-
default = []
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
variable "vpc_security_group_ids" {
|
|
140
|
-
description = "List of VPC security group IDs for Lambda function"
|
|
141
|
-
type = list(string)
|
|
142
|
-
default = []
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
# Update the Lambda function resource
|
|
146
|
-
resource "aws_lambda_function" "api_lambda" {
|
|
147
|
-
# ... existing configuration ...
|
|
148
|
-
|
|
149
|
-
# Add VPC configuration
|
|
150
|
-
vpc_config {
|
|
151
|
-
subnet_ids = var.vpc_subnet_ids
|
|
152
|
-
security_group_ids = var.vpc_security_group_ids
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
Then use the module with VPC configuration:
|
|
128
|
+
VPC configuration is already supported by the generated module — set `enable_vpc` along with `vpc_id` and `subnet_ids`, and the module deploys the Lambda function into your VPC behind a security group it creates for you:
|
|
158
129
|
|
|
159
130
|
```hcl
|
|
160
131
|
module "my_api" {
|
|
@@ -163,12 +134,15 @@ module "my_api" {
|
|
|
163
134
|
asset_bucket_name = module.asset_bucket.bucket_name
|
|
164
135
|
|
|
165
136
|
# VPC configuration
|
|
166
|
-
|
|
167
|
-
|
|
137
|
+
enable_vpc = true
|
|
138
|
+
vpc_id = aws_vpc.main.id
|
|
139
|
+
subnet_ids = [aws_subnet.private_a.id, aws_subnet.private_b.id]
|
|
168
140
|
|
|
169
141
|
tags = local.common_tags
|
|
170
142
|
}
|
|
171
143
|
```
|
|
144
|
+
|
|
145
|
+
For options the module does not expose, edit the `aws_lambda_function` resource in the generated Terraform module directly.
|
|
172
146
|
</Fragment>
|
|
173
147
|
</Infrastructure>
|
|
174
148
|
|
|
@@ -344,7 +318,9 @@ Edit `packages/common/terraform/src/app/apis/my-api/my-api.tf`:
|
|
|
344
318
|
|
|
345
319
|
# Remove the default single Lambda function
|
|
346
320
|
- resource "aws_lambda_function" "api_lambda" {
|
|
347
|
-
-
|
|
321
|
+
- s3_bucket = aws_s3_object.lambda_zip.bucket
|
|
322
|
+
- s3_key = aws_s3_object.lambda_zip.key
|
|
323
|
+
- s3_object_version = aws_s3_object.lambda_zip.version_id
|
|
348
324
|
- function_name = "MyApiHandler"
|
|
349
325
|
- role = aws_iam_role.lambda_execution_role.arn
|
|
350
326
|
- handler = "index.handler"
|
|
@@ -372,7 +348,9 @@ Edit `packages/common/terraform/src/app/apis/my-api/my-api.tf`:
|
|
|
372
348
|
|
|
373
349
|
# Add individual Lambda functions for each operation using the same bundle
|
|
374
350
|
+ resource "aws_lambda_function" "say_hello_handler" {
|
|
375
|
-
+
|
|
351
|
+
+ s3_bucket = aws_s3_object.lambda_zip.bucket
|
|
352
|
+
+ s3_key = aws_s3_object.lambda_zip.key
|
|
353
|
+
+ s3_object_version = aws_s3_object.lambda_zip.version_id
|
|
376
354
|
+ function_name = "MyApi-SayHello"
|
|
377
355
|
+ role = aws_iam_role.lambda_execution_role.arn
|
|
378
356
|
+ handler = "sayHello.handler" # Specific handler for this operation
|
|
@@ -392,7 +370,9 @@ Edit `packages/common/terraform/src/app/apis/my-api/my-api.tf`:
|
|
|
392
370
|
+ }
|
|
393
371
|
|
|
394
372
|
+ resource "aws_lambda_function" "get_documentation_handler" {
|
|
395
|
-
+
|
|
373
|
+
+ s3_bucket = aws_s3_object.lambda_zip.bucket
|
|
374
|
+
+ s3_key = aws_s3_object.lambda_zip.key
|
|
375
|
+
+ s3_object_version = aws_s3_object.lambda_zip.version_id
|
|
396
376
|
+ function_name = "MyApi-GetDocumentation"
|
|
397
377
|
+ role = aws_iam_role.lambda_execution_role.arn
|
|
398
378
|
+ handler = "getDocumentation.handler" # Specific handler for this operation
|
|
@@ -467,8 +447,10 @@ Edit `packages/common/terraform/src/app/apis/my-api/my-api.tf`:
|
|
|
467
447
|
|
|
468
448
|
# Remove the default single Lambda function
|
|
469
449
|
- resource "aws_lambda_function" "api_lambda" {
|
|
470
|
-
-
|
|
471
|
-
-
|
|
450
|
+
- s3_bucket = aws_s3_object.lambda_zip.bucket
|
|
451
|
+
- s3_key = aws_s3_object.lambda_zip.key
|
|
452
|
+
- s3_object_version = aws_s3_object.lambda_zip.version_id
|
|
453
|
+
- function_name = "MyApiHandler-${random_string.suffix.result}"
|
|
472
454
|
- role = aws_iam_role.lambda_execution_role.arn
|
|
473
455
|
- handler = "index.handler"
|
|
474
456
|
- runtime = "nodejs22.x"
|
|
@@ -477,25 +459,29 @@ Edit `packages/common/terraform/src/app/apis/my-api/my-api.tf`:
|
|
|
477
459
|
- }
|
|
478
460
|
|
|
479
461
|
# Remove the default proxy integration
|
|
480
|
-
- resource "
|
|
481
|
-
-
|
|
482
|
-
-
|
|
483
|
-
-
|
|
462
|
+
- resource "aws_api_gateway_integration" "lambda_integration" {
|
|
463
|
+
- rest_api_id = module.rest_api.api_id
|
|
464
|
+
- resource_id = aws_api_gateway_resource.proxy_resource.id
|
|
465
|
+
- http_method = aws_api_gateway_method.proxy_method.http_method
|
|
466
|
+
- integration_http_method = "POST"
|
|
467
|
+
- type = "AWS_PROXY"
|
|
468
|
+
- uri = aws_lambda_function.api_lambda.invoke_arn
|
|
484
469
|
- # ... rest of configuration
|
|
485
470
|
- }
|
|
486
471
|
|
|
487
|
-
# Remove the default proxy
|
|
488
|
-
- resource "
|
|
489
|
-
-
|
|
490
|
-
-
|
|
491
|
-
-
|
|
492
|
-
- target = "integrations/${aws_apigatewayv2_integration.lambda_integration.id}"
|
|
472
|
+
# Remove the default catch-all proxy method
|
|
473
|
+
- resource "aws_api_gateway_method" "proxy_method" {
|
|
474
|
+
- rest_api_id = module.rest_api.api_id
|
|
475
|
+
- resource_id = aws_api_gateway_resource.proxy_resource.id
|
|
476
|
+
- http_method = "ANY"
|
|
493
477
|
- # ... rest of configuration
|
|
494
478
|
- }
|
|
495
479
|
|
|
496
480
|
# Add individual Lambda functions for each operation using the same bundle
|
|
497
481
|
+ resource "aws_lambda_function" "say_hello_handler" {
|
|
498
|
-
+
|
|
482
|
+
+ s3_bucket = aws_s3_object.lambda_zip.bucket
|
|
483
|
+
+ s3_key = aws_s3_object.lambda_zip.key
|
|
484
|
+
+ s3_object_version = aws_s3_object.lambda_zip.version_id
|
|
499
485
|
+ function_name = "MyApi-SayHello"
|
|
500
486
|
+ role = aws_iam_role.lambda_execution_role.arn
|
|
501
487
|
+ handler = "sayHello.handler" # Specific handler for this operation
|
|
@@ -515,7 +501,9 @@ Edit `packages/common/terraform/src/app/apis/my-api/my-api.tf`:
|
|
|
515
501
|
+ }
|
|
516
502
|
|
|
517
503
|
+ resource "aws_lambda_function" "get_documentation_handler" {
|
|
518
|
-
+
|
|
504
|
+
+ s3_bucket = aws_s3_object.lambda_zip.bucket
|
|
505
|
+
+ s3_key = aws_s3_object.lambda_zip.key
|
|
506
|
+
+ s3_object_version = aws_s3_object.lambda_zip.version_id
|
|
519
507
|
+ function_name = "MyApi-GetDocumentation"
|
|
520
508
|
+ role = aws_iam_role.lambda_execution_role.arn
|
|
521
509
|
+ handler = "getDocumentation.handler" # Specific handler for this operation
|
|
@@ -12,9 +12,8 @@ For deploying your MCP Server, the following files are generated:
|
|
|
12
12
|
- packages/common/constructs/src
|
|
13
13
|
- app
|
|
14
14
|
- mcp-servers
|
|
15
|
-
- \<
|
|
16
|
-
- \<
|
|
17
|
-
- Dockerfile Passthrough docker file used by the CDK construct
|
|
15
|
+
- \<mcp-server-name>
|
|
16
|
+
- \<mcp-server-name>.ts CDK construct for deploying your MCP Server
|
|
18
17
|
</FileTree>
|
|
19
18
|
</Fragment>
|
|
20
19
|
<Fragment slot="terraform">
|
|
@@ -22,8 +21,8 @@ For deploying your MCP Server, the following files are generated:
|
|
|
22
21
|
- packages/common/terraform/src
|
|
23
22
|
- app
|
|
24
23
|
- mcp-servers
|
|
25
|
-
- \<
|
|
26
|
-
- \<
|
|
24
|
+
- \<mcp-server-name>
|
|
25
|
+
- \<mcp-server-name>.tf Module for deploying your MCP Server
|
|
27
26
|
- core
|
|
28
27
|
- agent-core
|
|
29
28
|
- runtime.tf Generic module for deploying to Bedrock AgentCore Runtime
|
package/generators.json
CHANGED
|
@@ -72,6 +72,16 @@
|
|
|
72
72
|
"connection/smithy-rdb",
|
|
73
73
|
"connection/ts-mcp-server-rdb",
|
|
74
74
|
"connection/ts-agent-rdb",
|
|
75
|
+
"connection/trpc-dynamodb",
|
|
76
|
+
"connection/smithy-dynamodb",
|
|
77
|
+
"connection/ts-mcp-server-dynamodb",
|
|
78
|
+
"connection/ts-agent-dynamodb",
|
|
79
|
+
"connection/py-fast-api-rdb",
|
|
80
|
+
"connection/py-agent-rdb",
|
|
81
|
+
"connection/py-mcp-server-rdb",
|
|
82
|
+
"connection/py-fast-api-dynamodb",
|
|
83
|
+
"connection/py-agent-dynamodb",
|
|
84
|
+
"connection/py-mcp-server-dynamodb",
|
|
75
85
|
"connection/ts-agent-gateway",
|
|
76
86
|
"connection/py-agent-gateway",
|
|
77
87
|
"connection/agentcore-gateway-mcp",
|
package/package.json
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"CloudFormationCustomResourceCreateModel",
|
|
46
46
|
"CloudFormationCustomResourceUpdateModel",
|
|
47
47
|
"CloudFormationCustomResourceDeleteModel",
|
|
48
|
-
"
|
|
48
|
+
"CloudWatchLogsModel",
|
|
49
49
|
"DynamoDBStreamModel",
|
|
50
50
|
"EventBridgeModel",
|
|
51
51
|
"IoTCoreThingEvent",
|