@aws/nx-plugin-mcp 1.0.0-rc.8 → 1.0.0-rc.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/aws-nx-mcp.js +14210 -13550
- package/docs/get_started/building-with-ai.mdx +116 -0
- package/docs/get_started/concepts.mdx +67 -0
- package/docs/get_started/existing-project.mdx +180 -0
- package/docs/get_started/graph-builder.mdx +39 -0
- package/docs/get_started/quick-start.mdx +277 -0
- package/docs/get_started/tutorials/contribute-generator.mdx +408 -0
- package/docs/get_started/tutorials/dungeon-game/1.mdx +1578 -0
- package/docs/get_started/tutorials/dungeon-game/2.mdx +245 -0
- package/docs/get_started/tutorials/dungeon-game/3.mdx +66 -0
- package/docs/get_started/tutorials/dungeon-game/4.mdx +164 -0
- package/docs/get_started/tutorials/dungeon-game/overview.mdx +145 -0
- package/docs/get_started/tutorials/dungeon-game/wrap-up.mdx +41 -0
- package/docs/get_started/upgrading.mdx +147 -0
- package/docs/guides/agentcore-gateway.mdx +490 -0
- package/docs/guides/agentcore-harness.mdx +275 -0
- package/docs/guides/astro-docs.mdx +8 -0
- package/docs/guides/connection/agentcore-gateway-agent.mdx +222 -0
- package/docs/guides/connection/agentcore-gateway-gateway.mdx +154 -0
- package/docs/guides/connection/agentcore-gateway-mcp.mdx +134 -0
- package/docs/guides/connection/py-agent-a2a.mdx +48 -16
- package/docs/guides/connection/py-agent-dynamodb.mdx +116 -0
- package/docs/guides/connection/py-agent-gateway.mdx +182 -0
- package/docs/guides/connection/py-agent-mcp.mdx +43 -14
- package/docs/guides/connection/py-agent-rdb.mdx +178 -0
- package/docs/guides/connection/py-fast-api-dynamodb.mdx +56 -0
- package/docs/guides/connection/py-fast-api-rdb.mdx +184 -0
- package/docs/guides/connection/py-mcp-server-dynamodb.mdx +116 -0
- package/docs/guides/connection/py-mcp-server-rdb.mdx +187 -0
- package/docs/guides/connection/react-agentcore-gateway.mdx +112 -0
- package/docs/guides/connection/react-agui.mdx +33 -14
- package/docs/guides/connection/react-fastapi.mdx +39 -3
- package/docs/guides/connection/react-py-agent.mdx +10 -16
- package/docs/guides/connection/react-smithy.mdx +5 -5
- package/docs/guides/connection/react-trpc.mdx +2 -2
- package/docs/guides/connection/react-ts-agent.mdx +9 -9
- package/docs/guides/connection/smithy-dynamodb.mdx +6 -6
- package/docs/guides/connection/smithy-rdb.mdx +10 -10
- package/docs/guides/connection/trpc-dynamodb.mdx +5 -5
- package/docs/guides/connection/trpc-rdb.mdx +6 -6
- package/docs/guides/connection/ts-agent-a2a.mdx +14 -11
- package/docs/guides/connection/ts-agent-dynamodb.mdx +5 -5
- package/docs/guides/connection/ts-agent-gateway.mdx +147 -0
- package/docs/guides/connection/ts-agent-mcp.mdx +12 -9
- package/docs/guides/connection/ts-agent-rdb.mdx +70 -25
- package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +5 -5
- package/docs/guides/connection/ts-mcp-server-rdb.mdx +68 -18
- package/docs/guides/connection.mdx +122 -5
- package/docs/guides/docker-bundling.mdx +81 -12
- package/docs/guides/fastapi.mdx +252 -15
- package/docs/guides/local-development.mdx +87 -0
- package/docs/guides/nx-generator.mdx +4 -3
- package/docs/guides/nx-migration.mdx +165 -0
- package/docs/guides/py-agent.mdx +332 -55
- package/docs/guides/py-dynamodb.mdx +476 -0
- package/docs/guides/py-mcp-server.mdx +57 -2
- package/docs/guides/py-rdb.mdx +265 -0
- package/docs/guides/python-lambda-function.mdx +1 -1
- package/docs/guides/react-website-auth.mdx +104 -5
- package/docs/guides/react-website.mdx +413 -99
- package/docs/guides/runtime-config.mdx +1 -1
- package/docs/guides/security.mdx +75 -0
- package/docs/guides/smithy-project.mdx +167 -0
- package/docs/guides/terraform-project.mdx +2 -2
- package/docs/guides/trpc.mdx +54 -17
- package/docs/guides/ts-agent.mdx +207 -23
- package/docs/guides/ts-dcr-proxy.mdx +569 -0
- package/docs/guides/ts-dynamodb.mdx +66 -242
- package/docs/guides/ts-lambda-function.mdx +1 -1
- package/docs/guides/ts-mcp-server.mdx +111 -29
- package/docs/guides/ts-nx-plugin.mdx +4 -4
- package/docs/guides/ts-rdb.mdx +114 -468
- package/docs/guides/ts-smithy-api.mdx +259 -19
- package/docs/guides/typescript-infrastructure.mdx +46 -24
- package/docs/guides/typescript-project.mdx +134 -27
- package/docs/guides/workspace.mdx +10 -3
- package/docs/snippets/agent/architecture.mdx +1 -1
- package/docs/snippets/agent/bedrock-deployment.mdx +9 -5
- package/docs/snippets/agent/runtime-arn.mdx +23 -2
- package/docs/snippets/agent/securing-your-agent.mdx +39 -0
- package/docs/snippets/api/access-logging.mdx +38 -0
- package/docs/snippets/api/cors-configuration-cdk-note.mdx +1 -1
- package/docs/snippets/api/cors-configuration-terraform-note.mdx +1 -1
- package/docs/snippets/api/type-safe-api-integrations.mdx +69 -50
- package/docs/snippets/api/waf-configuration.mdx +3 -3
- package/docs/snippets/connection/a2a-infrastructure.mdx +1 -1
- package/docs/snippets/connection/dynamodb-local-development.mdx +2 -2
- package/docs/snippets/connection/lambda-dynamodb-access.mdx +1 -1
- package/docs/snippets/connection/py-dynamodb-local-development.mdx +7 -0
- package/docs/snippets/connection/py-lambda-rdb-ssl-requirements.mdx +7 -0
- package/docs/snippets/connection/rdb-api-infrastructure.mdx +51 -19
- package/docs/snippets/dynamodb/deploying-table.mdx +145 -0
- package/docs/snippets/dynamodb/encryption-options.mdx +168 -0
- package/docs/snippets/dynamodb/gsi-config.mdx +38 -0
- package/docs/snippets/dynamodb/infrastructure.mdx +33 -0
- package/docs/snippets/dynamodb/local-dev-start.mdx +13 -0
- package/docs/snippets/dynamodb/local-dev-windows.mdx +15 -0
- package/docs/snippets/lambda-function/deploying-your-function.mdx +3 -3
- package/docs/snippets/mcp/architecture.mdx +1 -1
- package/docs/snippets/mcp/bedrock-deployment.mdx +9 -5
- package/docs/snippets/mcp/config.mdx +3 -2
- package/docs/snippets/mcp/shared-constructs.mdx +4 -5
- package/docs/snippets/pdk-migration/example/01-migrate-api.mdx +7 -5
- package/docs/snippets/pdk-migration/example/02-migrate-website.mdx +29 -10
- package/docs/snippets/pdk-migration/example/03-migrate-infra.mdx +4 -4
- package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +5 -111
- package/docs/snippets/prerequisites.mdx +1 -4
- package/docs/snippets/rdb/architecture.mdx +38 -0
- package/docs/snippets/rdb/cluster-instances.mdx +31 -0
- package/docs/snippets/rdb/deletion-protection.mdx +34 -0
- package/docs/snippets/rdb/deploying.mdx +187 -0
- package/docs/snippets/rdb/encryption-key-rotation.mdx +30 -0
- package/docs/snippets/rdb/engine-version.mdx +63 -0
- package/docs/snippets/rdb/infrastructure.mdx +35 -0
- package/docs/snippets/rdb/logging-mysql.mdx +5 -0
- package/docs/snippets/rdb/logging-postgres.mdx +5 -0
- package/docs/snippets/rdb/performance-insights.mdx +34 -0
- package/docs/snippets/rdb/rds-proxy.mdx +50 -0
- package/docs/snippets/rdb/removal-policy.mdx +57 -0
- package/docs/snippets/rdb/serverless-capacity.mdx +32 -0
- package/docs/snippets/recommended-prerequisites.mdx +10 -0
- package/docs/snippets/required-prerequisites.mdx +1 -4
- package/docs/snippets/runtime-config-app-id-note.mdx +8 -0
- package/docs/snippets/shared-constructs.mdx +1 -1
- package/docs/snippets/trivy-image-scan.mdx +37 -0
- package/generators.json +162 -10
- package/package.json +1 -1
- package/src/agentcore-gateway/agent-connection/schema.json +31 -0
- package/src/agentcore-gateway/gateway-connection/schema.json +31 -0
- package/src/agentcore-gateway/mcp-connection/schema.json +31 -0
- package/src/agentcore-gateway/react-connection/schema.json +31 -0
- package/src/agentcore-gateway/schema.json +72 -0
- package/src/agentcore-harness/schema.json +53 -0
- package/src/connection/schema.json +5 -0
- package/src/infra/app/schema.json +5 -0
- package/src/init/schema.json +35 -0
- package/src/internal/test-matrix/schema.json +21 -0
- package/src/license/schema.json +5 -0
- package/src/preset/schema.json +16 -5
- package/src/py/agent/a2a-connection/schema.json +5 -0
- package/src/py/agent/gateway-connection/schema.json +31 -0
- package/src/py/agent/mcp-connection/schema.json +5 -0
- package/src/py/agent/react-connection/schema.json +5 -0
- package/src/py/agent/schema.json +15 -1
- package/src/py/api/schema.json +5 -0
- package/src/py/dynamodb/agent-connection/schema.json +27 -0
- package/src/py/dynamodb/fast-api-connection/schema.json +23 -0
- package/src/py/dynamodb/mcp-server-connection/schema.json +27 -0
- package/src/py/dynamodb/schema.json +76 -0
- package/src/py/fast-api/react/schema.json +5 -0
- package/src/py/fast-api/schema.json +6 -0
- package/src/py/lambda-function/schema.json +6 -1
- package/src/py/mcp-server/schema.json +6 -0
- package/src/py/project/schema.json +6 -0
- package/src/py/rdb/agent-connection/schema.json +27 -0
- package/src/py/rdb/fast-api-connection/schema.json +23 -0
- package/src/py/rdb/mcp-server-connection/schema.json +27 -0
- package/src/py/rdb/schema.json +78 -0
- package/src/smithy/project/schema.json +28 -1
- package/src/smithy/react-connection/schema.json +5 -0
- package/src/smithy/ts/api/schema.json +6 -0
- package/src/terraform/project/schema.json +5 -0
- package/src/trpc/backend/schema.json +6 -0
- package/src/trpc/react/schema.json +5 -0
- package/src/ts/agent/a2a-connection/schema.json +5 -0
- package/src/ts/agent/gateway-connection/schema.json +31 -0
- package/src/ts/agent/mcp-connection/schema.json +5 -0
- package/src/ts/agent/react-connection/schema.json +5 -0
- package/src/ts/agent/schema.json +14 -0
- package/src/ts/api/schema.json +5 -0
- package/src/ts/astro-docs/schema.json +3 -3
- package/src/ts/dcr-proxy/schema.json +44 -0
- package/src/ts/docs/schema.json +3 -3
- package/src/ts/dynamodb/agent-connection/schema.json +5 -0
- package/src/ts/dynamodb/mcp-server-connection/schema.json +5 -0
- package/src/ts/dynamodb/schema.json +26 -2
- package/src/ts/dynamodb/smithy-connection/schema.json +5 -0
- package/src/ts/dynamodb/trpc-connection/schema.json +5 -0
- package/src/ts/lambda-function/schema.json +5 -0
- package/src/ts/lib/schema.json +5 -0
- package/src/ts/mcp-server/schema.json +6 -0
- package/src/ts/nx-generator/schema.json +5 -0
- package/src/ts/nx-migration/schema.json +63 -0
- package/src/ts/nx-plugin/schema.json +5 -0
- package/src/ts/rdb/agent-connection/schema.json +5 -0
- package/src/ts/rdb/mcp-server-connection/schema.json +5 -0
- package/src/ts/rdb/schema.json +7 -1
- package/src/ts/rdb/smithy-connection/schema.json +5 -0
- package/src/ts/rdb/trpc-connection/schema.json +5 -0
- package/src/ts/react-website/app/schema.json +12 -6
- package/src/ts/react-website/cognito-auth/schema.json +5 -0
- package/src/ts/react-website/runtime-config/schema.json +5 -0
- package/src/ts/website/app/schema.json +11 -6
- package/src/ts/website/auth/schema.json +5 -0
- /package/docs/snippets/connection/{lambda-rdb-ssl-requirements.mdx → ts-lambda-rdb-ssl-requirements.mdx} +0 -0
- /package/docs/snippets/connection/{mcp-server-rdb-ssl-requirements.mdx → ts-mcp-server-rdb-ssl-requirements.mdx} +0 -0
package/docs/guides/ts-agent.mdx
CHANGED
|
@@ -4,7 +4,9 @@ description: Generate a TypeScript Agent for building AI agents with tools and d
|
|
|
4
4
|
generator: ts#agent
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
import { FileTree, Tabs, TabItem } from '@astrojs/starlight/components';
|
|
7
|
+
import { FileTree, Tabs, TabItem, CardGrid, Steps } from '@astrojs/starlight/components';
|
|
8
|
+
import Astro from '@astrojs/react';
|
|
9
|
+
import ConnectionCard from '@components/connection-card.astro';
|
|
8
10
|
import RunGenerator from '@components/run-generator.astro';
|
|
9
11
|
import NxCommands from '@components/nx-commands.astro';
|
|
10
12
|
import Link from '@components/link.astro';
|
|
@@ -58,6 +60,7 @@ The generator will add the following files to your existing TypeScript project.
|
|
|
58
60
|
- init.ts tRPC initialization
|
|
59
61
|
- router.ts tRPC router with agent procedures
|
|
60
62
|
- agent.ts Main agent definition with sample tools
|
|
63
|
+
- session.ts Resolves the SessionManager used to persist conversation state
|
|
61
64
|
- client.ts Vended client for invoking your agent
|
|
62
65
|
- agent-core-trpc-client.ts Client factory for connecting to agents on AgentCore Runtime
|
|
63
66
|
- Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
|
|
@@ -77,6 +80,7 @@ The entry point uses the [Strands A2A Express Server](https://strandsagents.com/
|
|
|
77
80
|
- agent/ (or custom name if specified)
|
|
78
81
|
- index.ts A2A Express server entry point
|
|
79
82
|
- agent.ts Main agent definition with sample tools
|
|
83
|
+
- session.ts Resolves the SessionManager used to persist conversation state
|
|
80
84
|
- Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
|
|
81
85
|
- package.json Updated with Strands and Express dependencies
|
|
82
86
|
- project.json Updated with agent serve targets
|
|
@@ -94,6 +98,7 @@ The entry point uses [`@ag-ui/aws-strands`](https://www.npmjs.com/package/@ag-ui
|
|
|
94
98
|
- agent/ (or custom name if specified)
|
|
95
99
|
- index.ts AG-UI server entry point (Express + SSE)
|
|
96
100
|
- agent.ts Main agent definition with sample tools
|
|
101
|
+
- session.ts Resolves the SessionManager used to persist conversation state
|
|
97
102
|
- Dockerfile Entry point for hosting your agent (excluded when `infra` is set to `None`)
|
|
98
103
|
- package.json Updated with Strands and AG-UI dependencies
|
|
99
104
|
- project.json Updated with agent serve targets
|
|
@@ -113,8 +118,8 @@ For deploying your Agent, the following files are generated:
|
|
|
113
118
|
- packages/common/constructs/src
|
|
114
119
|
- app
|
|
115
120
|
- agents
|
|
116
|
-
- \<
|
|
117
|
-
- \<
|
|
121
|
+
- \<agent-name>
|
|
122
|
+
- \<agent-name>.ts CDK construct for deploying your agent
|
|
118
123
|
</FileTree>
|
|
119
124
|
</Fragment>
|
|
120
125
|
<Fragment slot="terraform">
|
|
@@ -122,8 +127,8 @@ For deploying your Agent, the following files are generated:
|
|
|
122
127
|
- packages/common/terraform/src
|
|
123
128
|
- app
|
|
124
129
|
- agents
|
|
125
|
-
- \<
|
|
126
|
-
- \<
|
|
130
|
+
- \<agent-name>
|
|
131
|
+
- \<agent-name>.tf Module for deploying your agent
|
|
127
132
|
- core
|
|
128
133
|
- agent-core
|
|
129
134
|
- runtime.tf Generic module for deploying to Bedrock AgentCore Runtime
|
|
@@ -183,7 +188,7 @@ const letterCounter = tool({
|
|
|
183
188
|
});
|
|
184
189
|
|
|
185
190
|
// Add tools to your agent
|
|
186
|
-
export const getAgent = async (
|
|
191
|
+
export const getAgent = async () => {
|
|
187
192
|
return new Agent({
|
|
188
193
|
systemPrompt: 'You are a helpful assistant with access to various tools.',
|
|
189
194
|
tools: [letterCounter],
|
|
@@ -198,7 +203,7 @@ The Strands framework automatically handles:
|
|
|
198
203
|
|
|
199
204
|
### Model Configuration
|
|
200
205
|
|
|
201
|
-
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:
|
|
202
207
|
|
|
203
208
|
```typescript
|
|
204
209
|
import { Agent } from '@strands-agents/sdk';
|
|
@@ -242,7 +247,7 @@ For a more in-depth guide to writing Strands agents, refer to the [Strands docum
|
|
|
242
247
|
<OptionFilter when={{ protocol: 'a2a' }} description="A2A Express server details">
|
|
243
248
|
## A2A Server (A2A protocol)
|
|
244
249
|
|
|
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.
|
|
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.
|
|
246
251
|
|
|
247
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.
|
|
248
253
|
</OptionFilter>
|
|
@@ -250,7 +255,7 @@ Most users will not need to modify this file — edit `agent.ts` to change tools
|
|
|
250
255
|
<OptionFilter when={{ protocol: 'ag-ui' }} description="AG-UI server details">
|
|
251
256
|
## AG-UI Server (AG-UI protocol)
|
|
252
257
|
|
|
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
|
|
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.
|
|
254
259
|
|
|
255
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.
|
|
256
261
|
|
|
@@ -261,19 +266,61 @@ Most users will not need to modify `index.ts` — edit `agent.ts` to change tool
|
|
|
261
266
|
|
|
262
267
|
### Local Development
|
|
263
268
|
|
|
264
|
-
|
|
269
|
+
To run your Agent (and everything connected to it) locally, use the project's `dev` target:
|
|
265
270
|
|
|
266
|
-
<NxCommands commands={['
|
|
271
|
+
<NxCommands commands={['dev your-project']} />
|
|
267
272
|
|
|
268
|
-
|
|
273
|
+
If you have added multiple components to your project (agents, MCP servers, etc.), this starts them all. To run just this agent, target its `<your-agent-name>-dev` target:
|
|
274
|
+
|
|
275
|
+
<NxCommands commands={['agent-dev your-project']} />
|
|
276
|
+
|
|
277
|
+
This uses `tsx --watch` to automatically restart the server when files change. The agent will be available at `http://localhost:8081` (or the assigned port if you have multiple agents).
|
|
269
278
|
|
|
270
279
|
### Chat with Your Agent
|
|
271
280
|
|
|
272
|
-
The generator configures a `<your-agent-name>-chat` Nx target that
|
|
281
|
+
The generator configures a `<your-agent-name>-chat` Nx target that drops you into an interactive terminal chat with your agent.
|
|
282
|
+
|
|
283
|
+
The chat target runs standalone. By default it connects to your locally running agent, so start the agent's `<your-agent-name>-dev` target first (in a separate terminal):
|
|
284
|
+
|
|
285
|
+
<NxCommands commands={['agent-dev your-project']} />
|
|
286
|
+
|
|
287
|
+
Then, in another terminal, start the chat:
|
|
273
288
|
|
|
274
289
|
<NxCommands commands={['run your-project:agent-chat']} />
|
|
275
290
|
|
|
276
|
-
|
|
291
|
+
The generator emits a `scripts/<your-agent-name>/chat.ts` for every protocol. You can customize it as you evolve the agent's input shape. 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).
|
|
292
|
+
|
|
293
|
+
<OptionFilter when={{ infra: 'agentcore' }} description="Deployed agent chat details">
|
|
294
|
+
#### Chat with your deployed agent
|
|
295
|
+
|
|
296
|
+
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:
|
|
297
|
+
|
|
298
|
+
<Tabs syncKey="auth">
|
|
299
|
+
<TabItem label="IAM" _filter={{ auth: 'iam' }}>
|
|
300
|
+
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:
|
|
301
|
+
|
|
302
|
+
<NxCommands commands={['run your-project:agent-chat']} env={{ RUNTIME_CONFIG_APP_ID: '<app-id>' }} />
|
|
303
|
+
</TabItem>
|
|
304
|
+
|
|
305
|
+
<TabItem label="Cognito" _filter={{ auth: 'cognito' }}>
|
|
306
|
+
For Cognito-authenticated agents, provide a Cognito access token via the `AGENT_ACCESS_TOKEN` environment variable, which is sent as a bearer token:
|
|
307
|
+
|
|
308
|
+
<NxCommands commands={['run your-project:agent-chat']} env={{ RUNTIME_CONFIG_APP_ID: '<app-id>', AGENT_ACCESS_TOKEN: '<access-token>' }} />
|
|
309
|
+
|
|
310
|
+
You can obtain an access token using the AWS CLI's `cognito-idp admin-initiate-auth` command, for example:
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
aws cognito-idp admin-initiate-auth \
|
|
314
|
+
--user-pool-id <user-pool-id> \
|
|
315
|
+
--client-id <user-pool-client-id> \
|
|
316
|
+
--auth-flow ADMIN_NO_SRP_AUTH \
|
|
317
|
+
--auth-parameters USERNAME=<username>,PASSWORD=<password> \
|
|
318
|
+
--query 'AuthenticationResult.AccessToken' \
|
|
319
|
+
--output text
|
|
320
|
+
```
|
|
321
|
+
</TabItem>
|
|
322
|
+
</Tabs>
|
|
323
|
+
</OptionFilter>
|
|
277
324
|
|
|
278
325
|
<OptionFilter when={{ infra: 'agentcore' }} description="Bedrock AgentCore Runtime deployment details">
|
|
279
326
|
## Deploying Your Agent to Bedrock AgentCore Runtime
|
|
@@ -292,6 +339,10 @@ The generator configures a `<your-agent-name>-docker` target which copies the `D
|
|
|
292
339
|
|
|
293
340
|
A `docker` target is also generated which prepares the docker context for all agents if you have multiple defined.
|
|
294
341
|
|
|
342
|
+
### Image Scanning
|
|
343
|
+
|
|
344
|
+
<Snippet name="trivy-image-scan" parentHeading="Image Scanning" />
|
|
345
|
+
|
|
295
346
|
### Observability
|
|
296
347
|
|
|
297
348
|
Your agent is automatically configured with observability using the [AWS Distro for Open Telemetry](https://aws.amazon.com/otel/) (ADOT), by configuring auto-instrumentation in your `Dockerfile`.
|
|
@@ -299,6 +350,38 @@ Your agent is automatically configured with observability using the [AWS Distro
|
|
|
299
350
|
You can find traces in the CloudWatch AWS Console, by selecting "GenAI Observability" in the menu. Note that for traces to be populated you will need to enable [Transaction Search](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Transaction-Search.html).
|
|
300
351
|
|
|
301
352
|
For more details, refer to the [AgentCore documentation on observability](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability-configure.html).
|
|
353
|
+
|
|
354
|
+
### Session Management
|
|
355
|
+
|
|
356
|
+
The `session` option controls how your agent persists conversation state (message history, tool state, etc.) across invocations, using the Strands SDK's [SessionManager](https://strandsagents.com/docs/user-guide/concepts/agents/session-management/):
|
|
357
|
+
|
|
358
|
+
- **`s3`** (default): The CDK/Terraform infrastructure provisions a dedicated S3 bucket for session data, encrypted with a dedicated KMS key and with all public access blocked; server access logs are delivered to a CloudWatch Logs log group via the same key. The agent's IAM role is granted read/write/list/delete access to the bucket and decrypt/generate-data-key access to the key, and the bucket name is registered alongside the agent's ARN in AppConfig runtime configuration.
|
|
359
|
+
- **`in-memory`**: No bucket is provisioned. Conversation state is kept in memory only for the lifetime of the running process and does not survive restarts or scale-in.
|
|
360
|
+
|
|
361
|
+
This is implemented in the generated `session.ts`, which exports a `getSessionManager()` function resolving a `SessionManager` for the current session.
|
|
362
|
+
|
|
363
|
+
The session ID itself comes from the AgentCore Runtime session (propagated via the `x-amzn-bedrock-agentcore-runtime-session-id` header for A2A/AG-UI, or the WebSocket connection context for HTTP/tRPC) and is bound to an [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage)-based context so `getCurrentSessionId()` can resolve it anywhere in the request — including in any downstream MCP or A2A clients wired up via the <Link path="/guides/connection">`connection` generator</Link>, so the whole call chain shares a consistent session.
|
|
364
|
+
|
|
365
|
+
:::note[Local Development]
|
|
366
|
+
When running locally (`LOCAL_DEV=true`, set automatically by the `-dev` target), session data is always stored on disk under `tmp/agents/strands/<agent-name>` at the workspace root, regardless of the configured `session` option, for convenience.
|
|
367
|
+
:::
|
|
368
|
+
|
|
369
|
+
#### Restricting sessions to their owner
|
|
370
|
+
|
|
371
|
+
The session ID arrives from the caller, so on its own it identifies a conversation but not who the conversation belongs to. AgentCore Runtime authorizes an invocation against the agent runtime resource ARN rather than against an individual session, which leaves the agent free to decide what a session means to your application.
|
|
372
|
+
|
|
373
|
+
:::caution[The session also selects the microVM]
|
|
374
|
+
A session ID selects the [microVM](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-how-it-works.html) that serves the request, so its filesystem, `/tmp` and in-process caches are shared by every request resolving to that session. Two callers who send the same session ID share those resources even when their stored conversations are separate.
|
|
375
|
+
:::
|
|
376
|
+
|
|
377
|
+
To restrict each user to their own conversations:
|
|
378
|
+
|
|
379
|
+
<Steps>
|
|
380
|
+
1. Add an API to create a session, using <Link path="guides/trpc">tRPC</Link>, <Link path="guides/fastapi">FastAPI</Link> or <Link path="guides/ts-smithy-api">Smithy</Link>. Generate an opaque session ID (at least 33 characters) and store it alongside the calling user's ID — for example in a table created with the <Link path="guides/ts-dynamodb">`ts#dynamodb`</Link> generator. Each API guide shows how to retrieve the calling user's ID.
|
|
381
|
+
2. In your agent, look up the stored user ID for the session ID it was given, and reject the request when it does not match the caller. With `auth=cognito` the caller's JWT reaches your agent code, so its `sub` claim identifies them.
|
|
382
|
+
</Steps>
|
|
383
|
+
|
|
384
|
+
Generate the session ID rather than deriving it from user-supplied values such as a conversation name — anything a caller can predict, a caller can send.
|
|
302
385
|
</OptionFilter>
|
|
303
386
|
|
|
304
387
|
## Invoking your Agent
|
|
@@ -312,13 +395,15 @@ You can invoke a locally running agent using the `.local` factory method from th
|
|
|
312
395
|
|
|
313
396
|
You can, for example create a file named `scripts/test.ts` in your workspace which imports the client:
|
|
314
397
|
|
|
398
|
+
The client class is named after your agent, so an agent named `my-agent` exports `MyAgentClient`.
|
|
399
|
+
|
|
315
400
|
```typescript
|
|
316
401
|
// scripts/test.ts
|
|
317
|
-
import {
|
|
402
|
+
import { MyAgentClient } from '../packages/<project>/src/agent/client.js';
|
|
318
403
|
|
|
319
|
-
const client =
|
|
404
|
+
const client = MyAgentClient.local({ url: 'http://localhost:8081/ws' });
|
|
320
405
|
|
|
321
|
-
client.invoke.subscribe({
|
|
406
|
+
client.invoke.subscribe({ prompt: 'what is 1 plus 1?' }, { onData: console.log });
|
|
322
407
|
```
|
|
323
408
|
|
|
324
409
|
:::tip[Quick Testing]
|
|
@@ -346,13 +431,13 @@ The client factory uses HTTP headers in the WebSocket handshake to authenticate
|
|
|
346
431
|
You can invoke your deployed agent by passing its ARN to the `withIamAuth` factory method:
|
|
347
432
|
|
|
348
433
|
```typescript
|
|
349
|
-
import {
|
|
434
|
+
import { MyAgentClient } from './agent/client.js';
|
|
350
435
|
|
|
351
|
-
const client =
|
|
436
|
+
const client = MyAgentClient.withIamAuth({
|
|
352
437
|
agentRuntimeArn: 'arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/my-agent',
|
|
353
438
|
});
|
|
354
439
|
|
|
355
|
-
client.invoke.subscribe({
|
|
440
|
+
client.invoke.subscribe({ prompt: 'what is 1 plus 1?' }, {
|
|
356
441
|
onData: (message) => console.log(message),
|
|
357
442
|
onError: (error) => console.error(error),
|
|
358
443
|
onComplete: () => console.log('Done'),
|
|
@@ -370,12 +455,12 @@ This will use the default AWS credential provider chain to authenticate requests
|
|
|
370
455
|
Use the `withJwtAuth` factory method to authenticate with the JWT / Cognito access token.
|
|
371
456
|
|
|
372
457
|
```typescript
|
|
373
|
-
const client =
|
|
458
|
+
const client = MyAgentClient.withJwtAuth({
|
|
374
459
|
agentRuntimeArn: 'arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/my-agent',
|
|
375
460
|
accessTokenProvider: async () => `<access-token>`,
|
|
376
461
|
});
|
|
377
462
|
|
|
378
|
-
client.invoke.subscribe({
|
|
463
|
+
client.invoke.subscribe({ prompt: 'what is 1 plus 1?' }, {
|
|
379
464
|
onData: console.log,
|
|
380
465
|
});
|
|
381
466
|
```
|
|
@@ -387,7 +472,7 @@ import { CognitoIdentityProvider } from "@aws-sdk/client-cognito-identity-provid
|
|
|
387
472
|
|
|
388
473
|
const cognito = new CognitoIdentityProvider();
|
|
389
474
|
|
|
390
|
-
const jwtClient =
|
|
475
|
+
const jwtClient = MyAgentClient.withJwtAuth({
|
|
391
476
|
agentRuntimeArn: 'arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/my-agent',
|
|
392
477
|
accessTokenProvider: async () => {
|
|
393
478
|
const response = await cognito.adminInitiateAuth({
|
|
@@ -434,3 +519,102 @@ To invoke your AG-UI agent from a React website, use the <Link path="/guides/con
|
|
|
434
519
|
|
|
435
520
|
Refer to the <Link path="/guides/connection/react-agui">`connection` generator guide</Link> for details about how the connection is set up.
|
|
436
521
|
</OptionFilter>
|
|
522
|
+
|
|
523
|
+
## Securing your Agent
|
|
524
|
+
|
|
525
|
+
<Snippet name="agent/securing-your-agent" parentHeading="Securing your Agent" />
|
|
526
|
+
|
|
527
|
+
```typescript
|
|
528
|
+
// agent.ts
|
|
529
|
+
import { Agent } from '@strands-agents/sdk';
|
|
530
|
+
import { BedrockModel } from '@strands-agents/sdk/models/bedrock';
|
|
531
|
+
|
|
532
|
+
const model = new BedrockModel({
|
|
533
|
+
modelId: process.env.MODEL_ID,
|
|
534
|
+
guardrailConfig: {
|
|
535
|
+
guardrailIdentifier: process.env.GUARDRAIL_ID!,
|
|
536
|
+
guardrailVersion: process.env.GUARDRAIL_VERSION ?? 'DRAFT',
|
|
537
|
+
},
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
const agent = new Agent({ model, /* ... */ });
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
See the Strands [Guardrails](https://strandsagents.com/docs/user-guide/safety-security/guardrails/) guide for more detail.
|
|
544
|
+
|
|
545
|
+
## Connections
|
|
546
|
+
|
|
547
|
+
Use the <Link path="guides/connection">`connection`</Link> generator to integrate this project with others in your workspace. The following connections involve this project:
|
|
548
|
+
|
|
549
|
+
<CardGrid>
|
|
550
|
+
<ConnectionCard
|
|
551
|
+
title="React to TypeScript Agent"
|
|
552
|
+
description="Call a TypeScript Agent from a React website"
|
|
553
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-ts-agent`}
|
|
554
|
+
source="react"
|
|
555
|
+
target="strands"
|
|
556
|
+
targetBadge="typescript"
|
|
557
|
+
/>
|
|
558
|
+
<ConnectionCard
|
|
559
|
+
title="React to AG-UI Agent"
|
|
560
|
+
description="Call an Agent exposing the AG-UI protocol from a React website via CopilotKit"
|
|
561
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-agui`}
|
|
562
|
+
source="react"
|
|
563
|
+
target="copilotkit"
|
|
564
|
+
/>
|
|
565
|
+
<ConnectionCard
|
|
566
|
+
title="TypeScript Agent to MCP"
|
|
567
|
+
description="Connect a TypeScript Agent to an MCP server"
|
|
568
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-mcp`}
|
|
569
|
+
source="strands"
|
|
570
|
+
sourceBadge="typescript"
|
|
571
|
+
target="mcp"
|
|
572
|
+
/>
|
|
573
|
+
<ConnectionCard
|
|
574
|
+
title="TypeScript Agent to A2A Agent"
|
|
575
|
+
description="Connect a TypeScript Agent to a remote A2A agent"
|
|
576
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-a2a`}
|
|
577
|
+
source="strands"
|
|
578
|
+
sourceBadge="typescript"
|
|
579
|
+
target="a2a"
|
|
580
|
+
/>
|
|
581
|
+
<ConnectionCard
|
|
582
|
+
title="Python Agent to A2A Agent"
|
|
583
|
+
description="Connect a Python Agent to a remote A2A agent"
|
|
584
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-agent-a2a`}
|
|
585
|
+
source="strands"
|
|
586
|
+
sourceBadge="python"
|
|
587
|
+
target="a2a"
|
|
588
|
+
/>
|
|
589
|
+
<ConnectionCard
|
|
590
|
+
title="TypeScript Agent to Relational Database"
|
|
591
|
+
description="Connect a TypeScript Agent to an Aurora relational database"
|
|
592
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-rdb`}
|
|
593
|
+
source="strands"
|
|
594
|
+
sourceBadge="typescript"
|
|
595
|
+
target="aurora"
|
|
596
|
+
/>
|
|
597
|
+
<ConnectionCard
|
|
598
|
+
title="TypeScript Agent to TypeScript DynamoDB"
|
|
599
|
+
description="Connect a TypeScript Agent to a DynamoDB table"
|
|
600
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-dynamodb`}
|
|
601
|
+
source="strands"
|
|
602
|
+
sourceBadge="typescript"
|
|
603
|
+
target="dynamodb"
|
|
604
|
+
/>
|
|
605
|
+
<ConnectionCard
|
|
606
|
+
title="TypeScript Agent to AgentCore Gateway"
|
|
607
|
+
description="Connect a TypeScript Agent to an AgentCore Gateway"
|
|
608
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-gateway`}
|
|
609
|
+
source="strands"
|
|
610
|
+
sourceBadge="typescript"
|
|
611
|
+
target="agentcore"
|
|
612
|
+
/>
|
|
613
|
+
<ConnectionCard
|
|
614
|
+
title="AgentCore Gateway to Agent"
|
|
615
|
+
description="Front an agent with an AgentCore Gateway as a runtime target"
|
|
616
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/agentcore-gateway-agent`}
|
|
617
|
+
source="agentcore"
|
|
618
|
+
target="strands"
|
|
619
|
+
/>
|
|
620
|
+
</CardGrid>
|