@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
title: React to TypeScript Agent
|
|
3
3
|
description: Connect a React website to a TypeScript Agent
|
|
4
4
|
when:
|
|
5
|
-
sourceType: react
|
|
5
|
+
sourceType: ts#react-website
|
|
6
6
|
targetType: ts#agent
|
|
7
7
|
protocol: http
|
|
8
8
|
---
|
|
@@ -64,13 +64,13 @@ Additionally, it installs the required dependencies:
|
|
|
64
64
|
The generated client connects to your Agent via tRPC over WebSocket. The agent exposes a tRPC router (including the `invoke` subscription for streaming agent responses) over a WebSocket endpoint.
|
|
65
65
|
|
|
66
66
|
- **Deployed**: The agent runtime ARN is loaded from <Link path="guides/runtime-config">Runtime Configuration</Link>. Running this connection generator also patches the agent's generated CDK/Terraform construct to publish its ARN to the website's `runtime-config.json` (under the `connection` namespace), so only agents you explicitly connect are exposed to the frontend. The ARN is converted to a WebSocket URL following the Bedrock AgentCore Runtime WebSocket protocol: `wss://bedrock-agentcore.<region>.amazonaws.com/runtimes/<encoded-arn>/ws`
|
|
67
|
-
- **Local development**: When running with `
|
|
67
|
+
- **Local development**: When running with `dev`, the runtime config override sets the value to a local `ws://` URL (e.g., `ws://localhost:8081/ws`), and the client connects directly
|
|
68
68
|
|
|
69
69
|
### Authentication
|
|
70
70
|
|
|
71
71
|
The generated code handles authentication depending on your agent's configuration:
|
|
72
72
|
|
|
73
|
-
- **IAM** (default): Uses AWS SigV4 presigned URLs to authenticate the WebSocket connection. Credentials are obtained from the Cognito Identity Pool configured with your website's auth. In `
|
|
73
|
+
- **IAM** (default): Uses AWS SigV4 presigned URLs to authenticate the WebSocket connection. Credentials are obtained from the Cognito Identity Pool configured with your website's auth. In `dev` mode, signing is automatically skipped when <Link path="guides/react-website#runtime-configuration">`runtime-config.json`</Link> is not present
|
|
74
74
|
- **Cognito**: Embeds the JWT access token in the `Sec-WebSocket-Protocol` header as a base64url-encoded bearer token, following the [AgentCore WebSocket auth protocol](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-get-started-websocket.html)
|
|
75
75
|
|
|
76
76
|
|
|
@@ -93,7 +93,7 @@ function ChatComponent() {
|
|
|
93
93
|
|
|
94
94
|
const subscription = useSubscription(
|
|
95
95
|
trpc.invoke.subscriptionOptions(
|
|
96
|
-
{
|
|
96
|
+
{ prompt: 'What can you help me with?' },
|
|
97
97
|
{
|
|
98
98
|
enabled: true,
|
|
99
99
|
onStarted: () => {
|
|
@@ -135,9 +135,9 @@ function ChatComponent() {
|
|
|
135
135
|
const client = useMyAgentAgentClient();
|
|
136
136
|
const [messages, setMessages] = useState<string[]>([]);
|
|
137
137
|
|
|
138
|
-
const sendMessage = (
|
|
138
|
+
const sendMessage = (prompt: string) => {
|
|
139
139
|
const subscription = client.invoke.subscribe(
|
|
140
|
-
{
|
|
140
|
+
{ prompt },
|
|
141
141
|
{
|
|
142
142
|
onData: (token) => {
|
|
143
143
|
setMessages((prev) => [...prev, token]);
|
|
@@ -174,11 +174,11 @@ For more details on the vanilla tRPC client, see the [tRPC Vanilla Client docume
|
|
|
174
174
|
|
|
175
175
|
## Local Development
|
|
176
176
|
|
|
177
|
-
The connection generator automatically configures `
|
|
177
|
+
The connection generator automatically configures `dev` integration for your react website:
|
|
178
178
|
|
|
179
|
-
1. Running `nx
|
|
179
|
+
1. Running `nx dev <website>` will also start the agent's local server
|
|
180
180
|
2. The runtime config is overridden to point to the local WebSocket URL (e.g., `ws://localhost:8081/ws`)
|
|
181
|
-
3. Like with connected APIs, authentication is skipped in `
|
|
181
|
+
3. Like with connected APIs, authentication is skipped in `dev` mode when <Link path="guides/react-website#runtime-configuration">`runtime-config.json`</Link> is not present
|
|
182
182
|
|
|
183
183
|
:::tip[Hot Reloading]
|
|
184
184
|
The website and connected agent will hot-reload, enabling you to quickly iterate on both together without deploying to AWS.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Smithy API to DynamoDB
|
|
3
|
-
description: Connect a Smithy API to a DynamoDB
|
|
3
|
+
description: Connect a Smithy API to a TypeScript DynamoDB project
|
|
4
4
|
when:
|
|
5
|
-
sourceType: smithy
|
|
5
|
+
sourceType: ts#smithy-api
|
|
6
6
|
targetType: ts#dynamodb
|
|
7
7
|
---
|
|
8
8
|
import { FileTree } from '@astrojs/starlight/components';
|
|
@@ -12,13 +12,13 @@ import GeneratorParameters from '@components/generator-parameters.astro';
|
|
|
12
12
|
import NxCommands from '@components/nx-commands.astro';
|
|
13
13
|
import Snippet from '@components/snippet.astro';
|
|
14
14
|
|
|
15
|
-
The `connection` generator wires a <Link path="guides/ts-smithy-api">Smithy API</Link> to a <Link path="guides/ts-dynamodb">DynamoDB</Link> project, configuring local development so both start together automatically.
|
|
15
|
+
The `connection` generator wires a <Link path="guides/ts-smithy-api">Smithy API</Link> to a <Link path="guides/ts-dynamodb">TypeScript DynamoDB</Link> project, configuring local development so both start together automatically.
|
|
16
16
|
|
|
17
17
|
## Prerequisites
|
|
18
18
|
|
|
19
19
|
Before using this generator, ensure you have:
|
|
20
20
|
|
|
21
|
-
1. A <Link path="guides/ts-smithy-api"
|
|
21
|
+
1. A <Link path="guides/ts-smithy-api">Smithy TypeScript API</Link> project (generated with `ts#api` using `--framework=smithy`)
|
|
22
22
|
2. A <Link path="guides/ts-dynamodb">`ts#dynamodb`</Link> project
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
@@ -35,14 +35,14 @@ Select your Smithy API backend project as the source and your DynamoDB project a
|
|
|
35
35
|
|
|
36
36
|
## Generator Output
|
|
37
37
|
|
|
38
|
-
The generator updates your Smithy API's `project.json` to add a dependency from its `
|
|
38
|
+
The generator updates your Smithy API's `project.json` to add a dependency from its `dev` target to the DynamoDB project's `dev` target. No source files are modified.
|
|
39
39
|
|
|
40
40
|
## Using DynamoDB in Operations
|
|
41
41
|
|
|
42
42
|
Import entity factories from the DynamoDB package and use them inside your operation implementations:
|
|
43
43
|
|
|
44
44
|
```ts title="packages/api/src/operations/list-examples.ts"
|
|
45
|
-
import { createExampleEntity } from '
|
|
45
|
+
import { createExampleEntity } from '@my-scope/my-table';
|
|
46
46
|
import {
|
|
47
47
|
ListExamplesOperationInput,
|
|
48
48
|
ListExamplesOperationOutput,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
title: Smithy API to Relational Database
|
|
3
3
|
description: Connect a Smithy API to a Relational Database
|
|
4
4
|
when:
|
|
5
|
-
sourceType: smithy
|
|
5
|
+
sourceType: ts#smithy-api
|
|
6
6
|
targetType: ts#rdb
|
|
7
7
|
---
|
|
8
8
|
import { FileTree } from '@astrojs/starlight/components';
|
|
@@ -18,7 +18,7 @@ The `connection` generator wires a <Link path="guides/ts-smithy-api">Smithy API<
|
|
|
18
18
|
|
|
19
19
|
Before using this generator, ensure you have:
|
|
20
20
|
|
|
21
|
-
1. A <Link path="guides/ts-smithy-api"
|
|
21
|
+
1. A <Link path="guides/ts-smithy-api">Smithy TypeScript API</Link> project (generated with `ts#api` using `--framework=smithy`)
|
|
22
22
|
2. A <Link path="guides/ts-rdb">`ts#rdb`</Link> project
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
@@ -46,7 +46,7 @@ The generator modifies three existing files in your Smithy API backend:
|
|
|
46
46
|
|
|
47
47
|
</FileTree>
|
|
48
48
|
|
|
49
|
-
Additionally, it updates the API's `
|
|
49
|
+
Additionally, it updates the API's `dev` target to start the database automatically.
|
|
50
50
|
|
|
51
51
|
## How It Works
|
|
52
52
|
|
|
@@ -55,7 +55,7 @@ Additionally, it updates the API's `serve-local` target to start the database au
|
|
|
55
55
|
The generator adds a typed `db` property to `ServiceContext` in `context.ts`:
|
|
56
56
|
|
|
57
57
|
```ts title="packages/api/src/context.ts" {1,7}
|
|
58
|
-
import { getPrisma as getMyDb } from '
|
|
58
|
+
import { getPrisma as getMyDb } from '@my-scope/my-db';
|
|
59
59
|
|
|
60
60
|
export interface ServiceContext {
|
|
61
61
|
tracer: Tracer;
|
|
@@ -69,8 +69,8 @@ export interface ServiceContext {
|
|
|
69
69
|
|
|
70
70
|
The Prisma client is instantiated inside `lambdaHandler` and passed through the service context:
|
|
71
71
|
|
|
72
|
-
```ts title="packages/api/src/handler.ts" {1,10}
|
|
73
|
-
import { getPrisma as getMyDb } from '
|
|
72
|
+
```ts title="packages/api/src/handler.ts" {1,5,10}
|
|
73
|
+
import { getPrisma as getMyDb } from '@my-scope/my-db';
|
|
74
74
|
|
|
75
75
|
export const lambdaHandler = async (event: APIGatewayProxyEvent) => {
|
|
76
76
|
const httpRequest = convertEvent(event);
|
|
@@ -134,14 +134,14 @@ const httpResponse = await serviceHandler.handle(httpRequest, {
|
|
|
134
134
|
|
|
135
135
|
### SSL Requirements When Connecting Without RDS Proxy
|
|
136
136
|
|
|
137
|
-
<Snippet name="connection/lambda-rdb-ssl-requirements" parentHeading="SSL Requirements When Connecting Without RDS Proxy" />
|
|
137
|
+
<Snippet name="connection/ts-lambda-rdb-ssl-requirements" parentHeading="SSL Requirements When Connecting Without RDS Proxy" />
|
|
138
138
|
|
|
139
139
|
## Local Development
|
|
140
140
|
|
|
141
141
|
The generator applies the same Prisma client injection inside the request handler in `local-server.ts`:
|
|
142
142
|
|
|
143
143
|
```ts title="packages/api/src/local-server.ts" {1,5,10}
|
|
144
|
-
import { getPrisma as getMyDb } from '
|
|
144
|
+
import { getPrisma as getMyDb } from '@my-scope/my-db';
|
|
145
145
|
|
|
146
146
|
const server = createServer(async function (req, res) {
|
|
147
147
|
const httpRequest = convertRequest(req);
|
|
@@ -156,6 +156,6 @@ const server = createServer(async function (req, res) {
|
|
|
156
156
|
});
|
|
157
157
|
```
|
|
158
158
|
|
|
159
|
-
<NxCommands commands={["
|
|
159
|
+
<NxCommands commands={["dev <api-project-name>"]} />
|
|
160
160
|
|
|
161
|
-
This starts both the API and the local database. The `
|
|
161
|
+
This starts both the API and the local database. The `LOCAL_DEV=true` environment variable is set automatically, so the Prisma client connects to the local Docker database instead of Aurora.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: tRPC API to DynamoDB
|
|
3
|
-
description: Connect a tRPC API to a DynamoDB
|
|
3
|
+
description: Connect a tRPC API to a TypeScript DynamoDB project
|
|
4
4
|
when:
|
|
5
5
|
sourceType: ts#trpc-api
|
|
6
6
|
targetType: ts#dynamodb
|
|
@@ -12,13 +12,13 @@ import GeneratorParameters from '@components/generator-parameters.astro';
|
|
|
12
12
|
import NxCommands from '@components/nx-commands.astro';
|
|
13
13
|
import Snippet from '@components/snippet.astro';
|
|
14
14
|
|
|
15
|
-
The `connection` generator wires a <Link path="guides/trpc">tRPC API</Link> to a <Link path="guides/ts-dynamodb">DynamoDB</Link> project, configuring local development so both start together automatically.
|
|
15
|
+
The `connection` generator wires a <Link path="guides/trpc">tRPC API</Link> to a <Link path="guides/ts-dynamodb">TypeScript DynamoDB</Link> project, configuring local development so both start together automatically.
|
|
16
16
|
|
|
17
17
|
## Prerequisites
|
|
18
18
|
|
|
19
19
|
Before using this generator, ensure you have:
|
|
20
20
|
|
|
21
|
-
1. A <Link path="guides/trpc"
|
|
21
|
+
1. A <Link path="guides/trpc">tRPC API</Link> project (generated with `ts#api`)
|
|
22
22
|
2. A <Link path="guides/ts-dynamodb">`ts#dynamodb`</Link> project
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
@@ -35,14 +35,14 @@ Select your tRPC API project as the source and your DynamoDB project as the targ
|
|
|
35
35
|
|
|
36
36
|
## Generator Output
|
|
37
37
|
|
|
38
|
-
The generator updates your tRPC API's `project.json` to add a dependency from its `
|
|
38
|
+
The generator updates your tRPC API's `project.json` to add a dependency from its `dev` target to the DynamoDB project's `dev` target. No source files are modified.
|
|
39
39
|
|
|
40
40
|
## Using DynamoDB in Procedures
|
|
41
41
|
|
|
42
42
|
Import entity factories from the DynamoDB package and use them inside your tRPC procedures:
|
|
43
43
|
|
|
44
44
|
```ts title="packages/api/src/procedures/example.ts"
|
|
45
|
-
import { createExampleEntity } from '
|
|
45
|
+
import { createExampleEntity } from '@my-scope/my-table';
|
|
46
46
|
import { publicProcedure } from '../init.js';
|
|
47
47
|
|
|
48
48
|
export const listExamples = publicProcedure
|
|
@@ -18,7 +18,7 @@ The `connection` generator wires a <Link path="guides/trpc">tRPC API</Link> to a
|
|
|
18
18
|
|
|
19
19
|
Before using this generator, ensure you have:
|
|
20
20
|
|
|
21
|
-
1. A <Link path="guides/trpc"
|
|
21
|
+
1. A <Link path="guides/trpc">tRPC API</Link> project (generated with `ts#api`)
|
|
22
22
|
2. A <Link path="guides/ts-rdb">`ts#rdb`</Link> project
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
@@ -45,7 +45,7 @@ The generator creates a middleware file in your tRPC API project:
|
|
|
45
45
|
|
|
46
46
|
</FileTree>
|
|
47
47
|
|
|
48
|
-
Additionally, it updates your tRPC API's `
|
|
48
|
+
Additionally, it updates your tRPC API's `dev` target to start the database automatically when running locally.
|
|
49
49
|
|
|
50
50
|
## Using the Middleware
|
|
51
51
|
|
|
@@ -65,7 +65,7 @@ export const authenticatedProcedure = t.procedure
|
|
|
65
65
|
|
|
66
66
|
The plugin merges `IMyDbContext` into your procedure context, making `myDb` available as an optional property:
|
|
67
67
|
|
|
68
|
-
```ts title="packages/api/src/procedures/users.ts" {8
|
|
68
|
+
```ts title="packages/api/src/procedures/users.ts" {7-8}
|
|
69
69
|
import { z } from 'zod';
|
|
70
70
|
import { authenticatedProcedure } from '../router.js';
|
|
71
71
|
|
|
@@ -116,12 +116,12 @@ export const dbProcedure = t.procedure
|
|
|
116
116
|
|
|
117
117
|
### SSL Requirements When Connecting Without RDS Proxy
|
|
118
118
|
|
|
119
|
-
<Snippet name="connection/lambda-rdb-ssl-requirements" parentHeading="SSL Requirements When Connecting Without RDS Proxy" />
|
|
119
|
+
<Snippet name="connection/ts-lambda-rdb-ssl-requirements" parentHeading="SSL Requirements When Connecting Without RDS Proxy" />
|
|
120
120
|
|
|
121
121
|
## Local Development
|
|
122
122
|
|
|
123
|
-
The generator configures your tRPC API's `
|
|
123
|
+
The generator configures your tRPC API's `dev` target to depend on the database's `dev` target, so running:
|
|
124
124
|
|
|
125
|
-
<NxCommands commands={["
|
|
125
|
+
<NxCommands commands={["dev <api-project-name>"]} />
|
|
126
126
|
|
|
127
127
|
will automatically start the local database alongside your API.
|
|
@@ -23,7 +23,7 @@ The generator sets up all the necessary wiring so your agent can discover and in
|
|
|
23
23
|
Before using this generator, ensure you have:
|
|
24
24
|
|
|
25
25
|
1. A TypeScript project with a <Link path="guides/ts-agent">Strands Agent</Link> component (any protocol)
|
|
26
|
-
2. A project with an Agent component generated with `--protocol=
|
|
26
|
+
2. A project with an Agent component generated with `--protocol=a2a` and `--auth=iam` (either <Link path="guides/ts-agent">`ts#agent`</Link> or <Link path="guides/py-agent">`py#agent`</Link>)
|
|
27
27
|
3. Both components created with `infra: agentcore`
|
|
28
28
|
|
|
29
29
|
## Usage
|
|
@@ -47,9 +47,12 @@ The generator creates a shared `agent-connection` package and modifies your agen
|
|
|
47
47
|
- packages/common/agent-connection
|
|
48
48
|
- src
|
|
49
49
|
- app
|
|
50
|
-
- \<target-agent-name>-client.ts High-level client for the connected A2A agent
|
|
50
|
+
- \<target-agent-name>-client-strands.ts High-level Strands client for the connected A2A agent
|
|
51
51
|
- core
|
|
52
|
-
- agentcore-
|
|
52
|
+
- agentcore-endpoints.ts Framework-agnostic ARN/URL resolution
|
|
53
|
+
- agentcore-fetch.ts Framework-agnostic SigV4 / JWT / session-forwarding fetch
|
|
54
|
+
- agentcore-a2a-client-config.ts Framework-agnostic A2A client config (signed `clientFactory`)
|
|
55
|
+
- agentcore-a2a-client-strands.ts Strands A2A client wrapping the config
|
|
53
56
|
- index.ts Exports all clients
|
|
54
57
|
- project.json
|
|
55
58
|
- tsconfig.json
|
|
@@ -58,20 +61,20 @@ The generator creates a shared `agent-connection` package and modifies your agen
|
|
|
58
61
|
|
|
59
62
|
Additionally, it:
|
|
60
63
|
- Transforms your agent's `agent.ts` to register the remote A2A agent as a Strands `tool`
|
|
61
|
-
- Updates the agent's `
|
|
64
|
+
- Updates the agent's `dev` target to depend on the target agent's `dev` target
|
|
62
65
|
- Installs required dependencies
|
|
63
66
|
|
|
64
67
|
## Using the Connected A2A Agent
|
|
65
68
|
|
|
66
69
|
The generator transforms your agent's `agent.ts` to wrap the remote A2A agent as a tool:
|
|
67
70
|
|
|
68
|
-
```ts title="packages/example/src/my-agent/agent.ts" {2,5-
|
|
71
|
+
```ts title="packages/example/src/my-agent/agent.ts" {2,5-12,15}
|
|
69
72
|
import { Agent, tool } from '@strands-agents/sdk';
|
|
70
|
-
import {
|
|
73
|
+
import { RemoteAgentClientStrands } from '@my-scope/agent-connection';
|
|
71
74
|
import { z } from 'zod';
|
|
72
75
|
|
|
73
76
|
export const getAgent = async (sessionId: string) => {
|
|
74
|
-
const remoteAgent = await
|
|
77
|
+
const remoteAgent = await RemoteAgentClientStrands.create(sessionId);
|
|
75
78
|
const remoteAgentTool = tool({
|
|
76
79
|
name: 'askRemoteAgent',
|
|
77
80
|
description: 'Delegate a question to the remote RemoteAgent A2A agent and return its reply.',
|
|
@@ -87,7 +90,7 @@ export const getAgent = async (sessionId: string) => {
|
|
|
87
90
|
|
|
88
91
|
The `sessionId` parameter is plumbed through from the caller, ensuring consistency for [Bedrock AgentCore Observability](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability.html).
|
|
89
92
|
|
|
90
|
-
Under the hood, `
|
|
93
|
+
Under the hood, `RemoteAgentClientStrands.create(sessionId)` returns a Strands `A2AAgent` configured with a SigV4-signing `clientFactory` when deployed to AWS, and a plain `http://localhost:<port>/` endpoint when `LOCAL_DEV=true`. The signing and endpoint resolution live in the framework-agnostic `agentcore-a2a-client-config.ts`; only the thin `agentcore-a2a-client-strands.ts` depends on Strands.
|
|
91
94
|
|
|
92
95
|
## Infrastructure
|
|
93
96
|
|
|
@@ -95,12 +98,12 @@ Under the hood, `RemoteAgentClient.create(sessionId)` returns a Strands `A2AAgen
|
|
|
95
98
|
|
|
96
99
|
## Local Development
|
|
97
100
|
|
|
98
|
-
The generator configures the host agent's `
|
|
101
|
+
The generator configures the host agent's `dev` target to:
|
|
99
102
|
1. Start the connected A2A agent(s) automatically
|
|
100
|
-
2. Set `
|
|
103
|
+
2. Set `LOCAL_DEV=true` so the generated client connects directly to `http://localhost:<port>/` instead of AgentCore
|
|
101
104
|
|
|
102
105
|
Run the agent locally with:
|
|
103
106
|
|
|
104
|
-
<NxCommands commands={["<agent-name>-
|
|
107
|
+
<NxCommands commands={["<agent-name>-dev <project-name>"]} />
|
|
105
108
|
|
|
106
109
|
This will start both the host agent and all connected A2A agents, with the host agent calling the remote agents over plain HTTP on their assigned local ports.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: TypeScript Agent to DynamoDB
|
|
3
|
-
description: Connect a TypeScript Agent to a DynamoDB
|
|
3
|
+
description: Connect a TypeScript Agent to a TypeScript DynamoDB project
|
|
4
4
|
when:
|
|
5
5
|
sourceType: ts#agent
|
|
6
6
|
targetType: ts#dynamodb
|
|
@@ -12,7 +12,7 @@ import NxCommands from '@components/nx-commands.astro';
|
|
|
12
12
|
import Infrastructure from '@components/infrastructure.astro';
|
|
13
13
|
import Snippet from '@components/snippet.astro';
|
|
14
14
|
|
|
15
|
-
The `connection` generator wires a <Link path="guides/ts-agent">TypeScript Agent</Link> to a <Link path="guides/ts-dynamodb">DynamoDB</Link> project, configuring local development so both start together automatically.
|
|
15
|
+
The `connection` generator wires a <Link path="guides/ts-agent">TypeScript Agent</Link> to a <Link path="guides/ts-dynamodb">TypeScript DynamoDB</Link> project, configuring local development so both start together automatically.
|
|
16
16
|
|
|
17
17
|
## Prerequisites
|
|
18
18
|
|
|
@@ -35,14 +35,14 @@ Select your Agent project as the source and your DynamoDB project as the target.
|
|
|
35
35
|
|
|
36
36
|
## Generator Output
|
|
37
37
|
|
|
38
|
-
The generator updates the agent's `<agent-name>-
|
|
38
|
+
The generator updates the agent's `<agent-name>-dev` target in `project.json` to depend on the DynamoDB project's `dev` target. No source files are modified.
|
|
39
39
|
|
|
40
40
|
## Using DynamoDB in Agents
|
|
41
41
|
|
|
42
42
|
Import entity factories from the DynamoDB package and use them inside your agent definition:
|
|
43
43
|
|
|
44
44
|
```ts title="packages/my-service/src/my-agent/agent.ts"
|
|
45
|
-
import { createExampleEntity } from '
|
|
45
|
+
import { createExampleEntity } from '@my-scope/my-table';
|
|
46
46
|
|
|
47
47
|
export const getAgent = async () => {
|
|
48
48
|
// ...
|
|
@@ -70,7 +70,7 @@ To allow the agent's Lambda function to access the DynamoDB table, grant the nec
|
|
|
70
70
|
<Fragment slot="cdk">
|
|
71
71
|
|
|
72
72
|
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
73
|
-
import { MyTable } from '
|
|
73
|
+
import { MyTable } from '@my-scope/common-constructs';
|
|
74
74
|
|
|
75
75
|
const table = new MyTable(this, 'Table');
|
|
76
76
|
const myAgent = new MyAgent(this, 'MyAgent');
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: TypeScript Agent to Gateway
|
|
3
|
+
description: Connect a TypeScript Agent to an AgentCore Gateway
|
|
4
|
+
when:
|
|
5
|
+
sourceType: ts#agent
|
|
6
|
+
targetType: agentcore-gateway
|
|
7
|
+
---
|
|
8
|
+
import { FileTree } from '@astrojs/starlight/components';
|
|
9
|
+
import Link from '@components/link.astro';
|
|
10
|
+
import RunGenerator from '@components/run-generator.astro';
|
|
11
|
+
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
12
|
+
import NxCommands from '@components/nx-commands.astro';
|
|
13
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
14
|
+
|
|
15
|
+
The `connection` generator can connect your <Link path="guides/ts-agent">TypeScript Agent</Link> to an <Link path="guides/agentcore-gateway">AgentCore Gateway</Link>.
|
|
16
|
+
|
|
17
|
+
The generator wires the agent so it authenticates to the Gateway with IAM SigV4 when deployed, and connects to the local gateway started by the Gateway project when running locally.
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
Before using this generator, ensure you have:
|
|
22
|
+
|
|
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 `protocol: mcp` and `auth: iam`
|
|
25
|
+
|
|
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
|
+
:::
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
### Run the Generator
|
|
35
|
+
|
|
36
|
+
<RunGenerator generator="connection" />
|
|
37
|
+
|
|
38
|
+
Select the agent project as the source and the Gateway project as the target.
|
|
39
|
+
|
|
40
|
+
### Options
|
|
41
|
+
|
|
42
|
+
<GeneratorParameters generator="connection" />
|
|
43
|
+
|
|
44
|
+
## Generator Output
|
|
45
|
+
|
|
46
|
+
The generator emits shared core client files into your `agent-connection` package, plus a per-Gateway wrapper, and modifies your agent:
|
|
47
|
+
|
|
48
|
+
<FileTree>
|
|
49
|
+
|
|
50
|
+
- packages/common/agent-connection
|
|
51
|
+
- src
|
|
52
|
+
- core/
|
|
53
|
+
- agentcore-endpoints.ts Framework-agnostic ARN/URL resolution
|
|
54
|
+
- agentcore-gateway-mcp-transport.ts Framework-agnostic Gateway MCP transport
|
|
55
|
+
- agentcore-gateway-mcp-client-strands.ts Strands MCP client for the deployed Gateway
|
|
56
|
+
- app/
|
|
57
|
+
- \<gateway-kebab>-client-strands.ts Per-Gateway Strands client wrapper
|
|
58
|
+
- index.ts Re-exports the Gateway client
|
|
59
|
+
|
|
60
|
+
</FileTree>
|
|
61
|
+
|
|
62
|
+
Additionally, the generator:
|
|
63
|
+
|
|
64
|
+
- Modifies your agent's `agent.ts` to import the Gateway client class, call `<Gateway>ClientStrands.create()`, and register the returned client in the `tools` array
|
|
65
|
+
- Wires the agent's `<agent>-dev` target to depend on the Gateway's `dev` target
|
|
66
|
+
- Installs the required SigV4 / MCP dependencies
|
|
67
|
+
|
|
68
|
+
## Using the connected Gateway
|
|
69
|
+
|
|
70
|
+
The generator transforms your agent's `agent.ts` to use the Gateway client:
|
|
71
|
+
|
|
72
|
+
```ts title="packages/example/src/my-agent/agent.ts" {2,5,8}
|
|
73
|
+
import { Agent } from '@strands-agents/sdk';
|
|
74
|
+
import { MyGatewayClientStrands } from '@my-scope/agent-connection';
|
|
75
|
+
|
|
76
|
+
export const getAgent = async () => {
|
|
77
|
+
const myGateway = await MyGatewayClientStrands.create();
|
|
78
|
+
return new Agent({
|
|
79
|
+
systemPrompt: '...',
|
|
80
|
+
tools: [myGateway],
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
When deployed (`LOCAL_DEV` unset), the client points at the Gateway's MCP endpoint and authenticates with SigV4. When `LOCAL_DEV=true`, it points at the local gateway started by the Gateway project's `dev` target, so the same `agent.ts` works uniformly in both modes.
|
|
86
|
+
|
|
87
|
+
The session ID is propagated to downstream MCP servers automatically via the `X-Amzn-Bedrock-AgentCore-Runtime-Session-Id` header.
|
|
88
|
+
|
|
89
|
+
## Infrastructure
|
|
90
|
+
|
|
91
|
+
After running the generator you must grant the agent permission to invoke the Gateway.
|
|
92
|
+
|
|
93
|
+
<Infrastructure>
|
|
94
|
+
<Fragment slot="cdk">
|
|
95
|
+
```ts title="packages/infra/src/stacks/application-stack.ts" {5}
|
|
96
|
+
const gateway = new MyGateway(this, 'MyGateway');
|
|
97
|
+
const myAgent = new MyAgent(this, 'MyAgent');
|
|
98
|
+
|
|
99
|
+
// Grant the agent permissions to invoke the Gateway
|
|
100
|
+
gateway.grantInvokeAccess(myAgent);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The Gateway URL is automatically registered in the `agentcore.gateways.<ClassName>` namespace of <Link path="guides/runtime-config">Runtime Configuration</Link> by the generated CDK construct, so the agent can discover it at runtime.
|
|
104
|
+
</Fragment>
|
|
105
|
+
<Fragment slot="terraform">
|
|
106
|
+
```hcl title="packages/infra/src/main.tf" {8-13}
|
|
107
|
+
module "my_gateway" {
|
|
108
|
+
source = "../../common/terraform/src/app/gateways/my-gateway"
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
module "my_agent" {
|
|
112
|
+
source = "../../common/terraform/src/app/agents/my-agent"
|
|
113
|
+
|
|
114
|
+
# Grant the agent permission to invoke the Gateway
|
|
115
|
+
additional_iam_policy_statements = [{
|
|
116
|
+
Effect = "Allow"
|
|
117
|
+
Action = ["bedrock-agentcore:InvokeGateway"]
|
|
118
|
+
Resource = [module.my_gateway.gateway_arn]
|
|
119
|
+
}]
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The Gateway URL is automatically registered in the `agentcore.gateways.<ClassName>` namespace of <Link path="guides/runtime-config">Runtime Configuration</Link> by the generated Terraform module, so the agent can discover it at runtime.
|
|
124
|
+
</Fragment>
|
|
125
|
+
</Infrastructure>
|
|
126
|
+
|
|
127
|
+
## Local Development
|
|
128
|
+
|
|
129
|
+
The generator configures the agent's `dev` target to:
|
|
130
|
+
|
|
131
|
+
1. Start the connected Gateway's local gateway and every attached MCP server
|
|
132
|
+
2. Set `LOCAL_DEV=true` so the generated client points at the local gateway instead of the deployed Gateway
|
|
133
|
+
|
|
134
|
+
Run the agent locally with:
|
|
135
|
+
|
|
136
|
+
<NxCommands commands={["<agent-name>-dev <project-name>"]} />
|
|
137
|
+
|
|
138
|
+
To run the agent locally **against the deployed Gateway** instead (for example, to exercise Cedar policies), use the agent's `serve` target. Without `LOCAL_DEV` set, the client resolves the deployed Gateway URL from runtime configuration and SigV4-signs requests with your local AWS credentials:
|
|
139
|
+
|
|
140
|
+
<NxCommands commands={["<agent-name>-serve <project-name>"]} />
|
|
141
|
+
|
|
142
|
+
### Local fidelity
|
|
143
|
+
|
|
144
|
+
The local gateway stands in for the deployed Gateway, so:
|
|
145
|
+
|
|
146
|
+
- **No Cedar policy evaluation.** Every tool is visible to the agent regardless of policies. Use the `serve` target to exercise policies against the deployed Gateway.
|
|
147
|
+
- **Tool-name prefixing is preserved.** Each local MCP server's tools are wrapped to expose names of the form `<target-name>___<tool-name>`, matching what the deployed Gateway emits. This keeps an agent's system prompt and the Cedar action names you reference consistent across local and deployed runs.
|
|
@@ -47,9 +47,12 @@ The generator creates a shared `agent-connection` package and modifies your agen
|
|
|
47
47
|
- packages/common/agent-connection
|
|
48
48
|
- src
|
|
49
49
|
- app
|
|
50
|
-
- \<mcp-server-name>-client.ts High-level client for the connected MCP server
|
|
50
|
+
- \<mcp-server-name>-client-strands.ts High-level Strands client for the connected MCP server
|
|
51
51
|
- core
|
|
52
|
-
- agentcore-
|
|
52
|
+
- agentcore-endpoints.ts Framework-agnostic ARN/URL resolution
|
|
53
|
+
- agentcore-fetch.ts Framework-agnostic SigV4 / JWT / session-forwarding fetch
|
|
54
|
+
- agentcore-mcp-transport.ts Framework-agnostic MCP transport
|
|
55
|
+
- agentcore-mcp-client-strands.ts Strands MCP client wrapping the transport
|
|
53
56
|
- index.ts Exports all clients
|
|
54
57
|
- project.json
|
|
55
58
|
- tsconfig.json
|
|
@@ -58,7 +61,7 @@ The generator creates a shared `agent-connection` package and modifies your agen
|
|
|
58
61
|
|
|
59
62
|
Additionally, it:
|
|
60
63
|
- Transforms your agent's `agent.ts` to import and use the MCP server's tools
|
|
61
|
-
- Updates the agent's `
|
|
64
|
+
- Updates the agent's `dev` target to depend on the MCP server's serve target
|
|
62
65
|
- Installs required dependencies
|
|
63
66
|
|
|
64
67
|
## Using the Connected MCP Server
|
|
@@ -67,10 +70,10 @@ The generator transforms your agent's `agent.ts` to use the MCP server's tools:
|
|
|
67
70
|
|
|
68
71
|
```ts title="packages/example/src/my-agent/agent.ts" {2,5,8}
|
|
69
72
|
import { Agent, tool } from '@strands-agents/sdk';
|
|
70
|
-
import {
|
|
73
|
+
import { MyMcpServerClientStrands } from '@my-scope/agent-connection';
|
|
71
74
|
|
|
72
75
|
export const getAgent = async (sessionId: string) => {
|
|
73
|
-
const myMcpServerClient = await
|
|
76
|
+
const myMcpServerClient = await MyMcpServerClientStrands.create(sessionId);
|
|
74
77
|
return new Agent({
|
|
75
78
|
systemPrompt: '...',
|
|
76
79
|
tools: [myMcpServerClient],
|
|
@@ -99,7 +102,7 @@ The MCP server's AgentCore runtime ARN is automatically registered in the `agent
|
|
|
99
102
|
<Fragment slot="terraform">
|
|
100
103
|
After running the connection generator, you need to grant the agent permission to invoke the MCP server in your Terraform configuration:
|
|
101
104
|
|
|
102
|
-
```hcl title="packages/infra/src/main.tf" {
|
|
105
|
+
```hcl title="packages/infra/src/main.tf" {9-25}
|
|
103
106
|
module "inventory_mcp_server" {
|
|
104
107
|
source = "../../common/terraform/src/app/mcp-servers/inventory-mcp"
|
|
105
108
|
}
|
|
@@ -133,12 +136,12 @@ The MCP server's AgentCore runtime ARN is automatically registered in the `agent
|
|
|
133
136
|
|
|
134
137
|
## Local Development
|
|
135
138
|
|
|
136
|
-
The generator configures the agent's `
|
|
139
|
+
The generator configures the agent's `dev` target to:
|
|
137
140
|
1. Start the connected MCP server(s) automatically
|
|
138
|
-
2. Set `
|
|
141
|
+
2. Set `LOCAL_DEV=true` so the generated client uses direct HTTP transport instead of AgentCore
|
|
139
142
|
|
|
140
143
|
Run the agent locally with:
|
|
141
144
|
|
|
142
|
-
<NxCommands commands={["<agent-name>-
|
|
145
|
+
<NxCommands commands={["<agent-name>-dev <project-name>"]} />
|
|
143
146
|
|
|
144
147
|
This will start both the agent and all connected MCP servers, with the agent connecting to the MCP servers directly via HTTP on their assigned local ports.
|