@aws/nx-plugin-mcp 1.0.0-rc.0 → 1.0.0-rc.2
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 +22 -17
- package/docs/guides/connection/py-agent-a2a.mdx +1 -1
- package/docs/guides/connection/py-agent-mcp.mdx +1 -1
- package/docs/guides/connection/react-agui.mdx +1 -1
- package/docs/guides/connection/react-py-agent.mdx +1 -1
- package/docs/guides/connection/react-trpc.mdx +1 -1
- package/docs/guides/connection/react-ts-agent.mdx +1 -1
- package/docs/guides/connection/ts-agent-a2a.mdx +1 -1
- package/docs/guides/connection/ts-agent-mcp.mdx +1 -1
- package/docs/guides/fastapi.mdx +8 -8
- package/docs/guides/py-agent.mdx +18 -18
- package/docs/guides/py-mcp-server.mdx +5 -5
- package/docs/guides/python-lambda-function.mdx +4 -4
- package/docs/guides/react-website.mdx +2 -2
- package/docs/guides/trpc.mdx +16 -15
- package/docs/guides/ts-agent.mdx +18 -18
- package/docs/guides/ts-lambda-function.mdx +4 -4
- package/docs/guides/ts-mcp-server.mdx +5 -5
- package/docs/guides/ts-rdb.mdx +3 -3
- package/docs/guides/ts-smithy-api.mdx +6 -5
- package/docs/guides/workspace.mdx +2 -2
- package/docs/snippets/agent/architecture.mdx +4 -4
- package/docs/snippets/agent/bedrock-deployment.mdx +1 -1
- package/docs/snippets/api/api-architecture.mdx +2 -2
- package/docs/snippets/api/type-safe-api-integrations.mdx +2 -2
- package/docs/snippets/lambda-function/deploying-your-function.mdx +2 -2
- package/docs/snippets/mcp/architecture.mdx +4 -4
- package/docs/snippets/mcp/bedrock-deployment.mdx +1 -1
- package/generators.json +10 -5
- package/package.json +1 -1
- package/src/infra/app/schema.json +1 -1
- package/src/preset/schema.json +4 -4
- package/src/py/agent/schema.json +18 -18
- package/src/py/api/schema.json +15 -15
- package/src/py/fast-api/schema.json +15 -15
- package/src/py/lambda-function/schema.json +15 -7
- package/src/py/mcp-server/schema.json +15 -15
- package/src/py/project/schema.json +2 -2
- package/src/smithy/ts/api/schema.json +15 -15
- package/src/trpc/backend/schema.json +15 -15
- package/src/ts/agent/schema.json +18 -18
- package/src/ts/api/schema.json +15 -15
- package/src/ts/lambda-function/schema.json +15 -7
- package/src/ts/mcp-server/schema.json +15 -15
- package/src/ts/rdb/schema.json +13 -13
- package/src/ts/react-website/app/schema.json +13 -13
- package/src/ts/react-website/cognito-auth/schema.json +4 -4
- package/src/ts/website/app/schema.json +21 -13
- package/src/ts/website/auth/schema.json +4 -4
package/docs/guides/trpc.mdx
CHANGED
|
@@ -4,6 +4,7 @@ description: Reference documentation for tRPC
|
|
|
4
4
|
generator: ts#trpc-api
|
|
5
5
|
when:
|
|
6
6
|
framework: [trpc]
|
|
7
|
+
infra: [rest-lambda, http-lambda]
|
|
7
8
|
---
|
|
8
9
|
import { FileTree, Tabs, TabItem } from '@astrojs/starlight/components';
|
|
9
10
|
import Link from '@components/link.astro';
|
|
@@ -33,7 +34,7 @@ You can generate a new tRPC API in two ways:
|
|
|
33
34
|
<Snippet name="api/api-choice-note" />
|
|
34
35
|
|
|
35
36
|
:::tip[API Type]
|
|
36
|
-
Select `
|
|
37
|
+
Select `rest-lambda` (default) as your `infra` if you would like to use [tRPC Subscriptions](https://trpc.io/docs/server/subscriptions) to stream responses.
|
|
37
38
|
:::
|
|
38
39
|
|
|
39
40
|
:::tip[Integration Pattern]
|
|
@@ -151,10 +152,10 @@ The use of `query` to define the implementation indicates that the operation is
|
|
|
151
152
|
|
|
152
153
|
If you add a new procedure, make sure you register it by adding it to the router in `src/router.ts`.
|
|
153
154
|
|
|
154
|
-
<OptionFilter when={{
|
|
155
|
+
<OptionFilter when={{ infra: 'rest-lambda' }} description="Streaming subscriptions — REST API only, uses SSE">
|
|
155
156
|
### Subscriptions (Streaming)
|
|
156
157
|
|
|
157
|
-
tRPC subscriptions allow you to stream data from the server to the client using [Server-Sent Events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). When you select `
|
|
158
|
+
tRPC subscriptions allow you to stream data from the server to the client using [Server-Sent Events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). When you select `rest-lambda` as your compute type, the generator automatically configures the infrastructure required for streaming, as well as a streaming Lambda handler and the `ZodAsyncIterable` schema helper.
|
|
158
159
|
|
|
159
160
|
To define a subscription procedure, use the `.subscription` method with an async generator function. Use the `ZodAsyncIterable` helper from `src/schema/z-async-iterable.ts` to define the output schema:
|
|
160
161
|
|
|
@@ -290,7 +291,7 @@ You can add additional values to the context provided to procedures by implement
|
|
|
290
291
|
|
|
291
292
|
As an example, let's implement some middlware to extract some details about the calling user from our API in `src/middleware/identity.ts`.
|
|
292
293
|
|
|
293
|
-
<OptionFilter when={{ auth: '
|
|
294
|
+
<OptionFilter when={{ auth: 'iam' }} description="Identity middleware example for IAM-authenticated APIs">
|
|
294
295
|
This example walks through identity middleware for `IAM` authentication. We look up the caller in Cognito using the sub extracted from the API Gateway event.
|
|
295
296
|
|
|
296
297
|
First, we define what we'll add to the context:
|
|
@@ -326,7 +327,7 @@ export const createIdentityPlugin = () => {
|
|
|
326
327
|
In our case, we want to extract details about the calling Cognito user. We'll do that by extracting the user's subject ID (or "sub") from the API Gateway event, and retrieving user details from Cognito. The implementation varies depending on whether the event was provided to our function by a REST API or an HTTP API:
|
|
327
328
|
|
|
328
329
|
<Tabs syncKey="http-rest">
|
|
329
|
-
<TabItem label="REST API" _filter={{
|
|
330
|
+
<TabItem label="REST API" _filter={{ infra: 'rest-lambda' }}>
|
|
330
331
|
```ts
|
|
331
332
|
import { CognitoIdentityProvider } from '@aws-sdk/client-cognito-identity-provider';
|
|
332
333
|
import { initTRPC, TRPCError } from '@trpc/server';
|
|
@@ -389,7 +390,7 @@ export const createIdentityPlugin = () => {
|
|
|
389
390
|
};
|
|
390
391
|
```
|
|
391
392
|
</TabItem>
|
|
392
|
-
<TabItem label="HTTP API" _filter={{
|
|
393
|
+
<TabItem label="HTTP API" _filter={{ infra: 'http-lambda' }}>
|
|
393
394
|
```ts
|
|
394
395
|
import { CognitoIdentityProvider } from '@aws-sdk/client-cognito-identity-provider';
|
|
395
396
|
import { initTRPC, TRPCError } from '@trpc/server';
|
|
@@ -461,8 +462,8 @@ export const createIdentityPlugin = () => {
|
|
|
461
462
|
</Tabs>
|
|
462
463
|
</OptionFilter>
|
|
463
464
|
|
|
464
|
-
<OptionFilter when={{ auth: '
|
|
465
|
-
When you deploy with `auth: '
|
|
465
|
+
<OptionFilter when={{ auth: 'cognito' }} description="Identity middleware example for Cognito-authenticated APIs">
|
|
466
|
+
When you deploy with `auth: 'cognito'`, the API Gateway Cognito User Pools authorizer verifies the JWT that the caller supplies in the `Authorization` header and places the verified claims on the Lambda event at `event.requestContext.authorizer.claims`. Our middleware just reads those claims — no extra AWS SDK calls, no manual JWT verification.
|
|
466
467
|
|
|
467
468
|
First, we define what we'll add to the context:
|
|
468
469
|
|
|
@@ -553,7 +554,7 @@ The tRPC API generator creates CDK or Terraform infrastructure as code based on
|
|
|
553
554
|
<Fragment slot="cdk">
|
|
554
555
|
The CDK construct for deploying your API lives in the `common/constructs` folder. You can consume this in a CDK application, for example:
|
|
555
556
|
|
|
556
|
-
<OptionFilter when={{ auth: ['
|
|
557
|
+
<OptionFilter when={{ auth: ['iam', 'custom'] }} description="CDK usage for IAM or Custom authentication">
|
|
557
558
|
```ts {6-8}
|
|
558
559
|
import { MyApi } from ':my-scope/common-constructs';
|
|
559
560
|
|
|
@@ -572,7 +573,7 @@ When using `Custom` auth, the construct creates a Lambda Authorizer internally f
|
|
|
572
573
|
:::
|
|
573
574
|
</OptionFilter>
|
|
574
575
|
|
|
575
|
-
<OptionFilter when={{ auth: '
|
|
576
|
+
<OptionFilter when={{ auth: 'cognito' }} description="CDK usage with Cognito authentication — pass the identity construct">
|
|
576
577
|
```ts {6,9}
|
|
577
578
|
import { MyApi, UserIdentity } from ':my-scope/common-constructs';
|
|
578
579
|
|
|
@@ -601,7 +602,7 @@ The Terraform modules for deploying your API are in the `common/terraform` folde
|
|
|
601
602
|
|
|
602
603
|
The API module stages its Lambda deployment zip in a shared S3 asset bucket — see the <Link path="/guides/terraform-project">Terraform infrastructure guide</Link> for details. Instantiate the `core/asset-bucket` module once per deployment and pass its `bucket_name` output into every API / Lambda module via the `asset_bucket_name` input:
|
|
603
604
|
|
|
604
|
-
<OptionFilter when={{ auth: ['
|
|
605
|
+
<OptionFilter when={{ auth: ['iam', 'custom'] }} description="Terraform usage for IAM or Custom authentication">
|
|
605
606
|
```hcl {1-3, 8}
|
|
606
607
|
module "asset_bucket" {
|
|
607
608
|
source = "../../common/terraform/src/core/asset-bucket"
|
|
@@ -628,7 +629,7 @@ module "my_api" {
|
|
|
628
629
|
```
|
|
629
630
|
</OptionFilter>
|
|
630
631
|
|
|
631
|
-
<OptionFilter when={{ auth: '
|
|
632
|
+
<OptionFilter when={{ auth: 'cognito' }} description="Terraform usage with Cognito authentication — supply user pool and client">
|
|
632
633
|
```hcl {1-3, 8-9}
|
|
633
634
|
module "asset_bucket" {
|
|
634
635
|
source = "../../common/terraform/src/core/asset-bucket"
|
|
@@ -711,7 +712,7 @@ module "my_api" {
|
|
|
711
712
|
}
|
|
712
713
|
```
|
|
713
714
|
|
|
714
|
-
<OptionFilter when={{ auth: '
|
|
715
|
+
<OptionFilter when={{ auth: 'custom' }} description="Custom Lambda Authorizer usage with Terraform">
|
|
715
716
|
:::caution[Custom Lambda Authorizer]
|
|
716
717
|
When using `Custom` auth, your API is protected by a Lambda Authorizer that **denies all requests by default**. You must implement your authorization logic in the generated `src/authorizer.ts` file before your API will accept any traffic.
|
|
717
718
|
:::
|
|
@@ -719,7 +720,7 @@ When using `Custom` auth, your API is protected by a Lambda Authorizer that **de
|
|
|
719
720
|
</Fragment>
|
|
720
721
|
</Infrastructure>
|
|
721
722
|
|
|
722
|
-
<OptionFilter when={{
|
|
723
|
+
<OptionFilter when={{ infra: 'rest-lambda' }} description="WAF — REST APIs get a WAF Web ACL by default">
|
|
723
724
|
### WAF
|
|
724
725
|
|
|
725
726
|
<Snippet name="api/waf-configuration" parentHeading="WAF" />
|
|
@@ -733,7 +734,7 @@ When using `Custom` auth, your API is protected by a Lambda Authorizer that **de
|
|
|
733
734
|
If you selected CDK for your `iacProvider`, when you add or remove a procedure in your tRPC API, these changes will be reflected immediately in the CDK construct without the need to rebuild.
|
|
734
735
|
:::
|
|
735
736
|
|
|
736
|
-
<OptionFilter when={{ auth: '
|
|
737
|
+
<OptionFilter when={{ auth: 'iam' }} description="Granting API invoke access — IAM-authenticated APIs only">
|
|
737
738
|
### Granting Access (IAM Only)
|
|
738
739
|
|
|
739
740
|
You can grant access to your API as follows:
|
package/docs/guides/ts-agent.mdx
CHANGED
|
@@ -47,7 +47,7 @@ First use the <Link path="/guides/typescript-project">`ts#project`</Link> genera
|
|
|
47
47
|
|
|
48
48
|
The generator will add the following files to your existing TypeScript project. The files generated depend on the chosen `protocol`:
|
|
49
49
|
|
|
50
|
-
<OptionFilter when={{ protocol: '
|
|
50
|
+
<OptionFilter when={{ protocol: 'http' }} description="tRPC-over-WebSocket layout">
|
|
51
51
|
### HTTP Protocol (default)
|
|
52
52
|
|
|
53
53
|
<FileTree>
|
|
@@ -60,13 +60,13 @@ The generator will add the following files to your existing TypeScript project.
|
|
|
60
60
|
- agent.ts Main agent definition with sample tools
|
|
61
61
|
- client.ts Vended client for invoking your agent
|
|
62
62
|
- agent-core-trpc-client.ts Client factory for connecting to agents on AgentCore Runtime
|
|
63
|
-
- Dockerfile Entry point for hosting your agent (excluded when `
|
|
63
|
+
- Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
|
|
64
64
|
- package.json Updated with Strands dependencies
|
|
65
65
|
- project.json Updated with agent serve targets
|
|
66
66
|
</FileTree>
|
|
67
67
|
</OptionFilter>
|
|
68
68
|
|
|
69
|
-
<OptionFilter when={{ protocol: '
|
|
69
|
+
<OptionFilter when={{ protocol: 'a2a' }} description="Strands A2A Express server layout">
|
|
70
70
|
### A2A Protocol
|
|
71
71
|
|
|
72
72
|
The entry point uses the [Strands A2A Express Server](https://strandsagents.com/docs/user-guide/concepts/multi-agent/agent-to-agent) instead of tRPC:
|
|
@@ -77,13 +77,13 @@ The entry point uses the [Strands A2A Express Server](https://strandsagents.com/
|
|
|
77
77
|
- agent/ (or custom name if specified)
|
|
78
78
|
- index.ts A2A Express server entry point
|
|
79
79
|
- agent.ts Main agent definition with sample tools
|
|
80
|
-
- Dockerfile Entry point for hosting your agent (excluded when `
|
|
80
|
+
- Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
|
|
81
81
|
- package.json Updated with Strands and Express dependencies
|
|
82
82
|
- project.json Updated with agent serve targets
|
|
83
83
|
</FileTree>
|
|
84
84
|
</OptionFilter>
|
|
85
85
|
|
|
86
|
-
<OptionFilter when={{ protocol: '
|
|
86
|
+
<OptionFilter when={{ protocol: 'ag-ui' }} description="AG-UI SSE-over-POST server layout">
|
|
87
87
|
### AG-UI Protocol
|
|
88
88
|
|
|
89
89
|
The entry point uses [`@ag-ui/aws-strands`](https://www.npmjs.com/package/@ag-ui/aws-strands) to expose the agent via the [AG-UI protocol](https://docs.ag-ui.com/) (SSE over POST), compatible with [CopilotKit](https://docs.copilotkit.ai/aws-strands):
|
|
@@ -94,7 +94,7 @@ The entry point uses [`@ag-ui/aws-strands`](https://www.npmjs.com/package/@ag-ui
|
|
|
94
94
|
- agent/ (or custom name if specified)
|
|
95
95
|
- index.ts AG-UI server entry point (Express + SSE)
|
|
96
96
|
- agent.ts Main agent definition with sample tools
|
|
97
|
-
- Dockerfile Entry point for hosting your agent (excluded when `
|
|
97
|
+
- Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
|
|
98
98
|
- package.json Updated with Strands and AG-UI dependencies
|
|
99
99
|
- project.json Updated with agent serve targets
|
|
100
100
|
</FileTree>
|
|
@@ -102,7 +102,7 @@ The entry point uses [`@ag-ui/aws-strands`](https://www.npmjs.com/package/@ag-ui
|
|
|
102
102
|
|
|
103
103
|
### Infrastructure
|
|
104
104
|
|
|
105
|
-
<OptionFilter when={{
|
|
105
|
+
<OptionFilter when={{ infra: 'agentcore' }} description="Bedrock AgentCore Runtime deployment">
|
|
106
106
|
<Snippet name="shared-constructs" />
|
|
107
107
|
|
|
108
108
|
For deploying your Agent, the following files are generated:
|
|
@@ -132,8 +132,8 @@ For deploying your Agent, the following files are generated:
|
|
|
132
132
|
</Infrastructure>
|
|
133
133
|
</OptionFilter>
|
|
134
134
|
|
|
135
|
-
<OptionFilter when={{
|
|
136
|
-
If you selected `
|
|
135
|
+
<OptionFilter when={{ infra: 'none' }} description="No infrastructure is vended for infra=none">
|
|
136
|
+
If you selected `none` for `infra`, no CDK constructs or Terraform modules are generated — the Agent can only be run locally. The `auth` option is ignored in this mode since there is no hosted endpoint to authenticate.
|
|
137
137
|
</OptionFilter>
|
|
138
138
|
|
|
139
139
|
#### Architecture
|
|
@@ -152,7 +152,7 @@ Your agent's server protocol determines how it communicates. You can choose betw
|
|
|
152
152
|
|
|
153
153
|
The protocol is set in the CDK/Terraform infrastructure, and the application code is generated accordingly.
|
|
154
154
|
|
|
155
|
-
<OptionFilter when={{ protocol: '
|
|
155
|
+
<OptionFilter when={{ protocol: 'http' }} description="tRPC over WebSocket details">
|
|
156
156
|
### tRPC over WebSocket (HTTP protocol)
|
|
157
157
|
|
|
158
158
|
The TypeScript Agent uses [tRPC](https://trpc.io/) over WebSocket, leveraging [AgentCore's bidirectional streaming support](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-get-started-websocket.html) to enable real-time, type-safe communication between clients and your agent.
|
|
@@ -239,7 +239,7 @@ For other MCP servers, please refer to the [Strands Documentation](https://stran
|
|
|
239
239
|
|
|
240
240
|
For a more in-depth guide to writing Strands agents, refer to the [Strands documentation](https://strandsagents.com/docs/user-guide/quickstart/overview/).
|
|
241
241
|
|
|
242
|
-
<OptionFilter when={{ protocol: '
|
|
242
|
+
<OptionFilter when={{ protocol: 'a2a' }} description="A2A Express server details">
|
|
243
243
|
## A2A Server (A2A protocol)
|
|
244
244
|
|
|
245
245
|
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. When deployed to AgentCore, the entry point resolves the runtime's public ARN from AppConfig and advertises it in the agent card.
|
|
@@ -247,7 +247,7 @@ The generated `index.ts` mounts the [Strands A2A Express Server](https://strands
|
|
|
247
247
|
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.
|
|
248
248
|
</OptionFilter>
|
|
249
249
|
|
|
250
|
-
<OptionFilter when={{ protocol: '
|
|
250
|
+
<OptionFilter when={{ protocol: 'ag-ui' }} description="AG-UI server details">
|
|
251
251
|
## AG-UI Server (AG-UI protocol)
|
|
252
252
|
|
|
253
253
|
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 creates an Express app via `createStrandsApp()`. 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.
|
|
@@ -275,7 +275,7 @@ The generator configures a `<your-agent-name>-chat` Nx target that depends on `<
|
|
|
275
275
|
|
|
276
276
|
For **HTTP** (tRPC over WebSocket) agents, the generator also emits a tiny `scripts/<your-agent-name>/chat.ts` that wraps the generated `<Agent>Client.local({ url })` so you can customize it as you evolve the agent's input shape.
|
|
277
277
|
|
|
278
|
-
<OptionFilter when={{
|
|
278
|
+
<OptionFilter when={{ infra: 'agentcore' }} description="Bedrock AgentCore Runtime deployment details">
|
|
279
279
|
## Deploying Your Agent to Bedrock AgentCore Runtime
|
|
280
280
|
|
|
281
281
|
<Snippet name="agent/bedrock-deployment" parentHeading="Deploying Your Agent to Bedrock AgentCore Runtime" />
|
|
@@ -305,7 +305,7 @@ For more details, refer to the [AgentCore documentation on observability](https:
|
|
|
305
305
|
|
|
306
306
|
Agent communication is transmitted via tRPC over WebSocket. As such, it's recommended to use the generated type-safe client factory in `client.ts`.
|
|
307
307
|
|
|
308
|
-
<OptionFilter when={{ protocol: '
|
|
308
|
+
<OptionFilter when={{ protocol: 'http' }} description="tRPC-over-WebSocket client factory invocation details">
|
|
309
309
|
### Invoke the Local Server
|
|
310
310
|
|
|
311
311
|
You can invoke a locally running agent using the `.local` factory method from the client factory.
|
|
@@ -340,7 +340,7 @@ The client factory uses HTTP headers in the WebSocket handshake to authenticate
|
|
|
340
340
|
:::
|
|
341
341
|
|
|
342
342
|
<Tabs syncKey="auth">
|
|
343
|
-
<TabItem label="IAM" _filter={{ auth: '
|
|
343
|
+
<TabItem label="IAM" _filter={{ auth: 'iam' }}>
|
|
344
344
|
##### IAM Authentication
|
|
345
345
|
|
|
346
346
|
You can invoke your deployed agent by passing its ARN to the `withIamAuth` factory method:
|
|
@@ -364,7 +364,7 @@ This will use the default AWS credential provider chain to authenticate requests
|
|
|
364
364
|
:::
|
|
365
365
|
</TabItem>
|
|
366
366
|
|
|
367
|
-
<TabItem label="Cognito" _filter={{ auth: '
|
|
367
|
+
<TabItem label="Cognito" _filter={{ auth: 'cognito' }}>
|
|
368
368
|
##### JWT / Cognito Authentication
|
|
369
369
|
|
|
370
370
|
Use the `withJwtAuth` factory method to authenticate with the JWT / Cognito access token.
|
|
@@ -415,7 +415,7 @@ For invoking your Agent from a React website, you can make use of the <Link path
|
|
|
415
415
|
Refer to the <Link path="/guides/connection/react-ts-agent">`connection` generator guide</Link> for details about how the connection is set up.
|
|
416
416
|
</OptionFilter>
|
|
417
417
|
|
|
418
|
-
<OptionFilter when={{ protocol: '
|
|
418
|
+
<OptionFilter when={{ protocol: 'a2a' }} description="A2A delegation details">
|
|
419
419
|
### Invoking an A2A Agent as a Tool
|
|
420
420
|
|
|
421
421
|
To delegate work from this agent to a remote A2A agent (either <Link path="/guides/ts-agent">TypeScript</Link> or <Link path="/guides/py-agent">Python</Link>), use the <Link path="/guides/connection/ts-agent-a2a">`connection` generator</Link>. It vends a SigV4-authenticated client for the target agent and AST-transforms this agent's `agent.ts` to register the remote A2A agent as a Strands `tool`.
|
|
@@ -425,7 +425,7 @@ To delegate work from this agent to a remote A2A agent (either <Link path="/guid
|
|
|
425
425
|
Refer to the <Link path="/guides/connection/ts-agent-a2a">`connection` generator guide</Link> for details about how the connection is set up.
|
|
426
426
|
</OptionFilter>
|
|
427
427
|
|
|
428
|
-
<OptionFilter when={{ protocol: '
|
|
428
|
+
<OptionFilter when={{ protocol: 'ag-ui' }} description="AG-UI / React connection details">
|
|
429
429
|
### Invoking an AG-UI Agent
|
|
430
430
|
|
|
431
431
|
To invoke your AG-UI agent from a React website, use the <Link path="/guides/connection/react-agui">`connection` generator</Link>, which wires up a [CopilotKit](https://docs.copilotkit.ai/aws-strands) client configured for your deployed agent with the correct authentication (IAM or Cognito).
|
|
@@ -179,8 +179,8 @@ export const handler = middy()
|
|
|
179
179
|
|
|
180
180
|
### Type Safety
|
|
181
181
|
|
|
182
|
-
<OptionFilter not when={{
|
|
183
|
-
If you chose an `
|
|
182
|
+
<OptionFilter not when={{ event: 'Any' }} description="event provides a typed Zod schema for the incoming event">
|
|
183
|
+
If you chose an `event` when generating your lambda function, your function is instrumented with the [`parser` middleware from AWS Lambda Powertools](https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/parser/). For example:
|
|
184
184
|
|
|
185
185
|
```typescript {4}
|
|
186
186
|
export const myFunction = async (
|
|
@@ -205,8 +205,8 @@ If you have custom data nested within an event, for example a DynamoDB stream or
|
|
|
205
205
|
:::
|
|
206
206
|
</OptionFilter>
|
|
207
207
|
|
|
208
|
-
<OptionFilter when={{
|
|
209
|
-
If you selected `Any` for your `
|
|
208
|
+
<OptionFilter when={{ event: 'Any' }} description="event=Any — no parser middleware, event is typed as `any`">
|
|
209
|
+
If you selected `Any` for your `event`, the `parser` middleware is not wired in and the `event` parameter is typed as `any`. Regenerate the function with a specific `event` if you want compile-time type safety and runtime validation.
|
|
210
210
|
</OptionFilter>
|
|
211
211
|
|
|
212
212
|
## Bundling
|
|
@@ -53,21 +53,21 @@ The generator will add the following files to your existing TypeScript project:
|
|
|
53
53
|
- divide.ts Sample tool
|
|
54
54
|
- resources/
|
|
55
55
|
- sample-guidance.ts Sample resource
|
|
56
|
-
- Dockerfile Entry point for hosting your MCP server (excluded when `
|
|
56
|
+
- Dockerfile Entry point for hosting your MCP server (excluded when `infra` is set to `None`)
|
|
57
57
|
- package.json Updated with bin entry and MCP dependencies
|
|
58
58
|
- project.json Updated with MCP server serve target
|
|
59
59
|
</FileTree>
|
|
60
60
|
|
|
61
61
|
### Infrastructure
|
|
62
62
|
|
|
63
|
-
<OptionFilter when={{
|
|
63
|
+
<OptionFilter when={{ infra: 'agentcore' }} description="Bedrock AgentCore Runtime deployment">
|
|
64
64
|
<Snippet name="shared-constructs" />
|
|
65
65
|
|
|
66
66
|
<Snippet name="mcp/shared-constructs" />
|
|
67
67
|
</OptionFilter>
|
|
68
68
|
|
|
69
|
-
<OptionFilter when={{
|
|
70
|
-
If you selected `
|
|
69
|
+
<OptionFilter when={{ infra: 'none' }} description="No infrastructure is vended for infra=none">
|
|
70
|
+
If you selected `none` for `infra`, no CDK constructs or Terraform modules are generated — the MCP server is configured for local STDIO / HTTP use only. The `auth` option is ignored in this mode since there is no hosted endpoint to authenticate.
|
|
71
71
|
</OptionFilter>
|
|
72
72
|
|
|
73
73
|
#### Architecture
|
|
@@ -146,7 +146,7 @@ If you would like to run your MCP server locally using [Streamable HTTP transpor
|
|
|
146
146
|
|
|
147
147
|
This command uses `tsx --watch` to automatically restart the server when files change.
|
|
148
148
|
|
|
149
|
-
<OptionFilter when={{
|
|
149
|
+
<OptionFilter when={{ infra: 'agentcore' }} description="Bedrock AgentCore Runtime deployment details">
|
|
150
150
|
## Deploying Your MCP Server to Bedrock AgentCore Runtime
|
|
151
151
|
|
|
152
152
|
<Snippet name="mcp/bedrock-deployment" parentHeading="Deploying Your MCP Server to Bedrock AgentCore Runtime" />
|
package/docs/guides/ts-rdb.mdx
CHANGED
|
@@ -528,7 +528,7 @@ By default, the generated local Docker database image matches the default Aurora
|
|
|
528
528
|
|
|
529
529
|
The local database image is configured in the generated database project's `serve-local` target in `project.json`. Update the image argument passed to `scripts/docker-start.ts` when you change engine versions.
|
|
530
530
|
|
|
531
|
-
<OptionFilter when={{ engine: '
|
|
531
|
+
<OptionFilter when={{ engine: 'postgres' }}>
|
|
532
532
|
<Infrastructure>
|
|
533
533
|
<Fragment slot="cdk">
|
|
534
534
|
|
|
@@ -554,7 +554,7 @@ module "my_database" {
|
|
|
554
554
|
</Infrastructure>
|
|
555
555
|
</OptionFilter>
|
|
556
556
|
|
|
557
|
-
<OptionFilter when={{ engine: '
|
|
557
|
+
<OptionFilter when={{ engine: 'mysql' }}>
|
|
558
558
|
<Infrastructure>
|
|
559
559
|
<Fragment slot="cdk">
|
|
560
560
|
|
|
@@ -689,7 +689,7 @@ module "my_database" {
|
|
|
689
689
|
|
|
690
690
|
## Limitations
|
|
691
691
|
|
|
692
|
-
<OptionFilter when={{ engine: '
|
|
692
|
+
<OptionFilter when={{ engine: 'mysql' }}>
|
|
693
693
|
|
|
694
694
|
### MySQL: API Gateway Streaming Mode
|
|
695
695
|
|
|
@@ -4,6 +4,7 @@ description: Reference documentation for Smithy TypeScript API
|
|
|
4
4
|
generator: ts#smithy-api
|
|
5
5
|
when:
|
|
6
6
|
framework: [smithy]
|
|
7
|
+
infra: [rest-lambda]
|
|
7
8
|
---
|
|
8
9
|
|
|
9
10
|
import { FileTree } from '@astrojs/starlight/components';
|
|
@@ -462,7 +463,7 @@ This sets up:
|
|
|
462
463
|
|
|
463
464
|
<Snippet name="api/cors-configuration-cdk-note" />
|
|
464
465
|
|
|
465
|
-
<OptionFilter when={{ auth: '
|
|
466
|
+
<OptionFilter when={{ auth: 'cognito' }} description="Cognito identity construct wiring">
|
|
466
467
|
:::note[Cognito Authentication]
|
|
467
468
|
If you selected `Cognito` authentication, you will need to supply the `identity` property to the API construct:
|
|
468
469
|
|
|
@@ -485,7 +486,7 @@ The `UserIdentity` construct can be generated using the <Link path="/guides/reac
|
|
|
485
486
|
:::
|
|
486
487
|
</OptionFilter>
|
|
487
488
|
|
|
488
|
-
<OptionFilter when={{ auth: '
|
|
489
|
+
<OptionFilter when={{ auth: 'custom' }} description="Custom Lambda Authorizer CDK usage">
|
|
489
490
|
:::caution[Custom Lambda Authorizer]
|
|
490
491
|
When using `Custom` auth, the construct creates a Lambda Authorizer internally from the generated `src/authorizer.ts` file, which **denies all requests by default**. You must implement your authorization logic in that file before your API will accept any traffic.
|
|
491
492
|
:::
|
|
@@ -532,7 +533,7 @@ This sets up:
|
|
|
532
533
|
|
|
533
534
|
<Snippet name="api/cors-configuration-terraform-note" />
|
|
534
535
|
|
|
535
|
-
<OptionFilter when={{ auth: '
|
|
536
|
+
<OptionFilter when={{ auth: 'cognito' }} description="Cognito module wiring">
|
|
536
537
|
:::note[Cognito Authentication]
|
|
537
538
|
If you selected `Cognito` authentication, you will need to supply the Cognito configuration:
|
|
538
539
|
|
|
@@ -556,7 +557,7 @@ module "my_api" {
|
|
|
556
557
|
:::
|
|
557
558
|
</OptionFilter>
|
|
558
559
|
|
|
559
|
-
<OptionFilter when={{ auth: '
|
|
560
|
+
<OptionFilter when={{ auth: 'custom' }} description="Custom Lambda Authorizer usage with Terraform">
|
|
560
561
|
:::caution[Custom Lambda Authorizer]
|
|
561
562
|
When using `Custom` auth, your API is protected by a Lambda Authorizer that **denies all requests by default**. You must implement your authorization logic in the generated `src/authorizer.ts` file before your API will accept any traffic.
|
|
562
563
|
:::
|
|
@@ -618,7 +619,7 @@ We do not support type-safe integrations for Terraform, and therefore no code ge
|
|
|
618
619
|
</Fragment>
|
|
619
620
|
</Infrastructure>
|
|
620
621
|
|
|
621
|
-
<OptionFilter when={{ auth: '
|
|
622
|
+
<OptionFilter when={{ auth: 'iam' }} description="IAM-authenticated APIs only">
|
|
622
623
|
### Granting Access (IAM Only)
|
|
623
624
|
|
|
624
625
|
If you selected `IAM` authentication, you can use the `grantInvokeAccess` method to grant access to your API:
|
|
@@ -167,7 +167,7 @@ import { AwsNxPluginConfig } from '@aws/nx-plugin';
|
|
|
167
167
|
|
|
168
168
|
export default {
|
|
169
169
|
iac: {
|
|
170
|
-
provider: '
|
|
170
|
+
provider: 'cdk', // or 'terraform'
|
|
171
171
|
},
|
|
172
172
|
containers: {
|
|
173
173
|
engine: 'docker', // or 'finch'
|
|
@@ -175,7 +175,7 @@ export default {
|
|
|
175
175
|
} satisfies AwsNxPluginConfig;
|
|
176
176
|
```
|
|
177
177
|
|
|
178
|
-
- **`iac.provider`** — the default infrastructure-as-code provider (`
|
|
178
|
+
- **`iac.provider`** — the default infrastructure-as-code provider (`cdk` or `terraform`) used by generators that emit infrastructure (e.g. `ts#infra`, `ts#trpc-api`, `py#fast-api`). Generators that accept an `--iac` flag default to `inherit`, which reads this value.
|
|
179
179
|
- **`containers.engine`** — the container CLI (`docker` or `finch`) baked into generated build/push/login commands. CDK image-asset builds also pick this up via the `CDK_DOCKER` environment variable. See the <Link path="guides/docker-bundling">Docker bundling guide</Link> for details.
|
|
180
180
|
|
|
181
181
|
You can edit either setting at any time — subsequent generator runs will pick up the new value.
|
|
@@ -3,8 +3,8 @@ title: Agent Architecture
|
|
|
3
3
|
---
|
|
4
4
|
import { Tabs, TabItem } from '@astrojs/starlight/components';
|
|
5
5
|
|
|
6
|
-
<Tabs syncKey="
|
|
7
|
-
<TabItem label="Bedrock AgentCore Runtime" _filter={{
|
|
6
|
+
<Tabs syncKey="infra">
|
|
7
|
+
<TabItem label="Bedrock AgentCore Runtime" _filter={{ infra: 'agentcore' }}>
|
|
8
8
|
|
|
9
9
|
When deployed to [Bedrock AgentCore Runtime](https://aws.amazon.com/bedrock/agentcore/), the agent is built into a container image, pushed to Amazon ECR and run in AgentCore Runtime. Clients invoke the AgentCore Runtime data plane endpoint, which forwards requests to your agent. The agent calls Amazon Bedrock for model inference and may invoke tools, MCP servers, or downstream APIs.
|
|
10
10
|
|
|
@@ -44,9 +44,9 @@ agentcore -> bedrock: InvokeModel
|
|
|
44
44
|
agentcore -> cw
|
|
45
45
|
```
|
|
46
46
|
</TabItem>
|
|
47
|
-
<TabItem label="None (local only)" _filter={{
|
|
47
|
+
<TabItem label="None (local only)" _filter={{ infra: 'none' }}>
|
|
48
48
|
|
|
49
|
-
With `
|
|
49
|
+
With `infra: none`, no AWS infrastructure is generated. The agent runs as a local process and calls Amazon Bedrock for model inference.
|
|
50
50
|
|
|
51
51
|
```d2 inline=true
|
|
52
52
|
direction: right
|
|
@@ -6,7 +6,7 @@ import Infrastructure from '@components/infrastructure.astro';
|
|
|
6
6
|
|
|
7
7
|
### Infrastructure as Code
|
|
8
8
|
|
|
9
|
-
If you selected `
|
|
9
|
+
If you selected `agentcore` for `infra`, the relevant CDK or Terraform infrastructure is generated which you can use to deploy your Agent to [Amazon Bedrock AgentCore Runtime](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agents-tools-runtime.html).
|
|
10
10
|
|
|
11
11
|
<Infrastructure>
|
|
12
12
|
<Fragment slot="cdk">
|
|
@@ -6,7 +6,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components';
|
|
|
6
6
|
The deployed application has the following architecture:
|
|
7
7
|
|
|
8
8
|
<Tabs syncKey="http-rest">
|
|
9
|
-
<TabItem label="REST API" _filter={{
|
|
9
|
+
<TabItem label="REST API" _filter={{ infra: 'rest-lambda' }}>
|
|
10
10
|
```d2 inline=true
|
|
11
11
|
direction: right
|
|
12
12
|
|
|
@@ -51,7 +51,7 @@ lambda -> xray
|
|
|
51
51
|
|
|
52
52
|
REST APIs include an [AWS WAFv2](https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html) Web ACL in front of the API Gateway stage with the AWS managed default ruleset enabled.
|
|
53
53
|
</TabItem>
|
|
54
|
-
<TabItem label="HTTP API" _filter={{
|
|
54
|
+
<TabItem label="HTTP API" _filter={{ infra: 'http-lambda' }}>
|
|
55
55
|
```d2 inline=true
|
|
56
56
|
direction: right
|
|
57
57
|
|
|
@@ -306,7 +306,7 @@ Edit `packages/common/terraform/src/app/apis/my-api/my-api.tf`:
|
|
|
306
306
|
3. **Create specific integrations and routes** for each operation, reusing the same ZIP bundle:
|
|
307
307
|
|
|
308
308
|
<Tabs syncKey="http-rest">
|
|
309
|
-
<TabItem label="HTTP API" _filter={{
|
|
309
|
+
<TabItem label="HTTP API" _filter={{ infra: 'http-lambda' }}>
|
|
310
310
|
|
|
311
311
|
```diff
|
|
312
312
|
# packages/common/terraform/src/app/apis/my-api/my-api.tf
|
|
@@ -429,7 +429,7 @@ Edit `packages/common/terraform/src/app/apis/my-api/my-api.tf`:
|
|
|
429
429
|
+ }
|
|
430
430
|
```
|
|
431
431
|
</TabItem>
|
|
432
|
-
<TabItem label="REST API" _filter={{
|
|
432
|
+
<TabItem label="REST API" _filter={{ infra: 'rest-lambda' }}>
|
|
433
433
|
|
|
434
434
|
```diff
|
|
435
435
|
# packages/common/terraform/src/app/apis/my-api/my-api.tf
|
|
@@ -30,7 +30,7 @@ This sets up:
|
|
|
30
30
|
This function can then be used as a target for any lambda [event source](https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/parser/):
|
|
31
31
|
|
|
32
32
|
:::note[Event Source Matching]
|
|
33
|
-
Ensure the event source matches the selected `
|
|
33
|
+
Ensure the event source matches the selected `event` option to ensure the event is properly handled within your handler function.
|
|
34
34
|
:::
|
|
35
35
|
|
|
36
36
|
The example below demonstrates the CDK code for invoking your lambda function on a schedule using EventBridge:
|
|
@@ -112,7 +112,7 @@ resource "aws_lambda_permission" "allow_eventbridge" {
|
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
:::note[Event Source Matching]
|
|
115
|
-
Ensure the event source matches the selected `
|
|
115
|
+
Ensure the event source matches the selected `event` option to ensure the event is properly handled within your handler function.
|
|
116
116
|
:::
|
|
117
117
|
</Fragment>
|
|
118
118
|
</Infrastructure>
|
|
@@ -3,8 +3,8 @@ title: MCP Server Architecture
|
|
|
3
3
|
---
|
|
4
4
|
import { Tabs, TabItem } from '@astrojs/starlight/components';
|
|
5
5
|
|
|
6
|
-
<Tabs syncKey="
|
|
7
|
-
<TabItem label="Bedrock AgentCore Runtime" _filter={{
|
|
6
|
+
<Tabs syncKey="infra">
|
|
7
|
+
<TabItem label="Bedrock AgentCore Runtime" _filter={{ infra: 'agentcore' }}>
|
|
8
8
|
|
|
9
9
|
When deployed to [Bedrock AgentCore Runtime](https://aws.amazon.com/bedrock/agentcore/), the MCP server is built into a container image, pushed to Amazon ECR, and run in AgentCore Runtime. AI assistants invoke the AgentCore Runtime data plane endpoint, which forwards `tools/*` and `resources/*` calls to your server over the [streamable HTTP transport](https://modelcontextprotocol.io/specification/draft/basic/transports#streamable-http).
|
|
10
10
|
|
|
@@ -36,9 +36,9 @@ ecr -> agentcore: Container\nimage
|
|
|
36
36
|
agentcore -> cw
|
|
37
37
|
```
|
|
38
38
|
</TabItem>
|
|
39
|
-
<TabItem label="None (local only)" _filter={{
|
|
39
|
+
<TabItem label="None (local only)" _filter={{ infra: 'none' }}>
|
|
40
40
|
|
|
41
|
-
With `
|
|
41
|
+
With `infra: none`, no AWS infrastructure is generated. The MCP server is configured for local STDIO and HTTP transports only, and is consumed by AI assistants running on the same machine.
|
|
42
42
|
|
|
43
43
|
```d2 inline=true
|
|
44
44
|
direction: right
|
|
@@ -6,7 +6,7 @@ import Infrastructure from '@components/infrastructure.astro';
|
|
|
6
6
|
|
|
7
7
|
### Infrastructure as Code
|
|
8
8
|
|
|
9
|
-
If you selected `
|
|
9
|
+
If you selected `agentcore` for `infra`, the relevant CDK or Terraform infrastructure is generated which you can use to deploy your MCP server to [Amazon Bedrock AgentCore Runtime](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agents-tools-runtime.html).
|
|
10
10
|
|
|
11
11
|
<Infrastructure>
|
|
12
12
|
<Fragment slot="cdk">
|
package/generators.json
CHANGED
|
@@ -100,7 +100,8 @@
|
|
|
100
100
|
"factory": "./src/py/mcp-server/generator",
|
|
101
101
|
"schema": "./src/py/mcp-server/schema.json",
|
|
102
102
|
"description": "Generate a Python Model Context Protocol (MCP) server for providing context to Large Language Models",
|
|
103
|
-
"metric": "g24"
|
|
103
|
+
"metric": "g24",
|
|
104
|
+
"guidePages": ["py-mcp-server"]
|
|
104
105
|
},
|
|
105
106
|
"py#project": {
|
|
106
107
|
"factory": "./src/py/project/generator",
|
|
@@ -113,7 +114,8 @@
|
|
|
113
114
|
"factory": "./src/py/agent/generator",
|
|
114
115
|
"schema": "./src/py/agent/schema.json",
|
|
115
116
|
"description": "Add an AI Agent to a Python project",
|
|
116
|
-
"metric": "g25"
|
|
117
|
+
"metric": "g25",
|
|
118
|
+
"guidePages": ["py-agent"]
|
|
117
119
|
},
|
|
118
120
|
"py#agent#mcp-connection": {
|
|
119
121
|
"factory": "./src/py/agent/mcp-connection/generator",
|
|
@@ -182,7 +184,8 @@
|
|
|
182
184
|
"factory": "./src/ts/mcp-server/generator",
|
|
183
185
|
"schema": "./src/ts/mcp-server/schema.json",
|
|
184
186
|
"description": "Generate a TypeScript Model Context Protocol (MCP) server for providing context to Large Language Models",
|
|
185
|
-
"metric": "g18"
|
|
187
|
+
"metric": "g18",
|
|
188
|
+
"guidePages": ["ts-mcp-server"]
|
|
186
189
|
},
|
|
187
190
|
"ts#nx-generator": {
|
|
188
191
|
"factory": "./src/ts/nx-generator/generator",
|
|
@@ -252,7 +255,8 @@
|
|
|
252
255
|
"factory": "./src/ts/agent/generator",
|
|
253
256
|
"schema": "./src/ts/agent/schema.json",
|
|
254
257
|
"description": "Add an AI Agent to a TypeScript project",
|
|
255
|
-
"metric": "g30"
|
|
258
|
+
"metric": "g30",
|
|
259
|
+
"guidePages": ["ts-agent"]
|
|
256
260
|
},
|
|
257
261
|
"ts#agent#mcp-connection": {
|
|
258
262
|
"factory": "./src/ts/agent/mcp-connection/generator",
|
|
@@ -315,7 +319,8 @@
|
|
|
315
319
|
"factory": "./src/ts/rdb/generator",
|
|
316
320
|
"schema": "./src/ts/rdb/schema.json",
|
|
317
321
|
"description": "Create a relational database project",
|
|
318
|
-
"metric": "g38"
|
|
322
|
+
"metric": "g38",
|
|
323
|
+
"guidePages": ["ts-rdb"]
|
|
319
324
|
},
|
|
320
325
|
"ts#rdb#smithy-connection": {
|
|
321
326
|
"factory": "./src/ts/rdb/smithy-connection/generator",
|