@aws/nx-plugin-mcp 0.120.0 → 1.0.0-rc.0
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 +74 -41
- package/docs/guides/astro-docs.mdx +144 -0
- package/docs/guides/connection/py-agent-a2a.mdx +105 -0
- package/docs/guides/connection/py-agent-mcp.mdx +147 -0
- package/docs/guides/connection/react-agui.mdx +240 -0
- package/docs/guides/connection/react-fastapi.mdx +1476 -0
- package/docs/guides/connection/react-py-agent.mdx +198 -0
- package/docs/guides/connection/react-smithy.mdx +1355 -0
- package/docs/guides/connection/react-trpc.mdx +447 -0
- package/docs/guides/connection/react-ts-agent.mdx +198 -0
- package/docs/guides/connection/smithy-rdb.mdx +161 -0
- package/docs/guides/connection/trpc-rdb.mdx +127 -0
- package/docs/guides/connection/ts-agent-a2a.mdx +106 -0
- package/docs/guides/connection/ts-agent-mcp.mdx +144 -0
- package/docs/guides/connection/ts-agent-rdb.mdx +141 -0
- package/docs/guides/connection/ts-mcp-server-rdb.mdx +135 -0
- package/docs/guides/connection.mdx +126 -0
- package/docs/guides/docker-bundling.mdx +403 -0
- package/docs/guides/docs.mdx +21 -0
- package/docs/guides/fastapi.mdx +511 -0
- package/docs/guides/license.mdx +293 -0
- package/docs/guides/nx-generator.mdx +588 -0
- package/docs/guides/py-agent.mdx +483 -0
- package/docs/guides/py-api.mdx +22 -0
- package/docs/guides/py-mcp-server.mdx +161 -0
- package/docs/guides/python-lambda-function.mdx +207 -0
- package/docs/guides/python-project.mdx +228 -0
- package/docs/guides/react-website-auth.mdx +216 -0
- package/docs/guides/react-website.mdx +424 -0
- package/docs/guides/runtime-config.mdx +312 -0
- package/docs/guides/terraform-project.mdx +317 -0
- package/docs/guides/trpc.mdx +818 -0
- package/docs/guides/ts-agent.mdx +436 -0
- package/docs/guides/ts-api.mdx +28 -0
- package/docs/guides/ts-lambda-function.mdx +218 -0
- package/docs/guides/ts-mcp-server.mdx +169 -0
- package/docs/guides/ts-nx-plugin.mdx +159 -0
- package/docs/guides/ts-rdb.mdx +759 -0
- package/docs/guides/ts-smithy-api.mdx +663 -0
- package/docs/guides/typescript-infrastructure.mdx +408 -0
- package/docs/guides/typescript-project.mdx +312 -0
- package/docs/guides/website.mdx +21 -0
- package/docs/guides/workspace.mdx +181 -0
- package/docs/snippets/agent/architecture.mdx +72 -0
- package/docs/snippets/agent/bedrock-deployment.mdx +172 -0
- package/docs/snippets/agent/runtime-arn.mdx +64 -0
- package/docs/snippets/api/api-architecture.mdx +93 -0
- package/docs/snippets/api/api-choice-note.mdx +6 -0
- package/docs/snippets/api/cors-configuration-cdk-note.mdx +25 -0
- package/docs/snippets/api/cors-configuration-terraform-note.mdx +28 -0
- package/docs/snippets/api/shared-constructs.mdx +38 -0
- package/docs/snippets/api/type-safe-api-integrations.mdx +643 -0
- package/docs/snippets/api/waf-configuration.mdx +37 -0
- package/docs/snippets/connection/a2a-infrastructure.mdx +63 -0
- package/docs/snippets/connection/lambda-rdb-ssl-requirements.mdx +40 -0
- package/docs/snippets/connection/mcp-server-rdb-ssl-requirements.mdx +35 -0
- package/docs/snippets/connection/rdb-api-infrastructure.mdx +72 -0
- package/docs/snippets/connection/react-agent-infrastructure.mdx +61 -0
- package/docs/snippets/connection/strands-agent-rdb-ssl-requirements.mdx +35 -0
- package/docs/snippets/lambda-function/architecture.mdx +36 -0
- package/docs/snippets/lambda-function/deploying-your-function.mdx +118 -0
- package/docs/snippets/mcp/architecture.mdx +58 -0
- package/docs/snippets/mcp/assistant-docs.mdx +10 -0
- package/docs/snippets/mcp/bedrock-deployment.mdx +167 -0
- package/docs/snippets/mcp/config.mdx +13 -0
- package/docs/snippets/mcp/configuration-py.mdx +42 -0
- package/docs/snippets/mcp/configuration-ts.mdx +53 -0
- package/docs/snippets/mcp/observability.mdx +8 -0
- package/docs/snippets/mcp/shared-constructs.mdx +32 -0
- package/docs/snippets/pdk-migration/example/01-migrate-api.mdx +602 -0
- package/docs/snippets/pdk-migration/example/02-migrate-website.mdx +915 -0
- package/docs/snippets/pdk-migration/example/03-migrate-infra.mdx +161 -0
- package/docs/snippets/pdk-migration/example/04-deploy.mdx +229 -0
- package/docs/snippets/pdk-migration/faq/aws-arch.mdx +17 -0
- package/docs/snippets/pdk-migration/faq/cdk-graph.mdx +29 -0
- package/docs/snippets/pdk-migration/faq/infrastructure-python-java.mdx +19 -0
- package/docs/snippets/pdk-migration/faq/pdk-nag.mdx +15 -0
- package/docs/snippets/pdk-migration/faq/pipeline.mdx +15 -0
- package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +310 -0
- package/docs/snippets/pdk-migration/faq/use-of-projen.mdx +15 -0
- package/docs/snippets/prerequisites.mdx +20 -0
- package/docs/snippets/required-prerequisites.mdx +12 -0
- package/docs/snippets/shared-constructs.mdx +40 -0
- package/docs/snippets/tools/acurl.mdx +73 -0
- package/docs/snippets/ts-bundle.mdx +14 -0
- package/generators.json +47 -6
- package/package.json +1 -1
- package/src/py/api/schema.json +100 -0
- package/src/ts/api/schema.json +105 -0
- package/src/ts/docs/schema.json +70 -0
- package/src/ts/website/app/schema.json +97 -0
- package/src/ts/website/auth/schema.json +46 -0
package/bin/aws-nx-mcp.js
CHANGED
|
@@ -19072,12 +19072,20 @@ var generators$1 = {
|
|
|
19072
19072
|
"metric": "g20",
|
|
19073
19073
|
"hidden": true
|
|
19074
19074
|
},
|
|
19075
|
+
"py#api": {
|
|
19076
|
+
"factory": "./src/py/api/generator",
|
|
19077
|
+
"schema": "./src/py/api/schema.json",
|
|
19078
|
+
"description": "Create a Python API",
|
|
19079
|
+
"metric": "g45",
|
|
19080
|
+
"guidePages": ["py-api", "fastapi"]
|
|
19081
|
+
},
|
|
19075
19082
|
"py#fast-api": {
|
|
19076
19083
|
"factory": "./src/py/fast-api/generator",
|
|
19077
19084
|
"schema": "./src/py/fast-api/schema.json",
|
|
19078
19085
|
"description": "Generates a FastAPI Python project",
|
|
19079
19086
|
"metric": "g3",
|
|
19080
|
-
"guidePages": ["fastapi"]
|
|
19087
|
+
"guidePages": ["fastapi"],
|
|
19088
|
+
"hidden": true
|
|
19081
19089
|
},
|
|
19082
19090
|
"py#fast-api#react-connection": {
|
|
19083
19091
|
"factory": "./src/py/fast-api/react/generator",
|
|
@@ -19147,12 +19155,20 @@ var generators$1 = {
|
|
|
19147
19155
|
"metric": "g23",
|
|
19148
19156
|
"guidePages": ["terraform-project"]
|
|
19149
19157
|
},
|
|
19158
|
+
"ts#docs": {
|
|
19159
|
+
"factory": "./src/ts/docs/generator",
|
|
19160
|
+
"schema": "./src/ts/docs/schema.json",
|
|
19161
|
+
"description": "Generates a documentation site",
|
|
19162
|
+
"metric": "g43",
|
|
19163
|
+
"guidePages": ["docs", "astro-docs"]
|
|
19164
|
+
},
|
|
19150
19165
|
"ts#astro-docs": {
|
|
19151
19166
|
"factory": "./src/ts/astro-docs/generator",
|
|
19152
19167
|
"schema": "./src/ts/astro-docs/schema.json",
|
|
19153
19168
|
"description": "Generates an Astro + Starlight documentation site with localisation, snippets, blog, and optional automated documentation translation",
|
|
19154
19169
|
"metric": "g37",
|
|
19155
|
-
"guidePages": ["astro-docs"]
|
|
19170
|
+
"guidePages": ["astro-docs"],
|
|
19171
|
+
"hidden": true
|
|
19156
19172
|
},
|
|
19157
19173
|
"ts#infra": {
|
|
19158
19174
|
"factory": "./src/infra/app/generator",
|
|
@@ -19193,19 +19209,35 @@ var generators$1 = {
|
|
|
19193
19209
|
"metric": "g1",
|
|
19194
19210
|
"guidePages": ["typescript-project"]
|
|
19195
19211
|
},
|
|
19212
|
+
"ts#website": {
|
|
19213
|
+
"factory": "./src/ts/website/app/generator",
|
|
19214
|
+
"schema": "./src/ts/website/app/schema.json",
|
|
19215
|
+
"description": "Generates a website application",
|
|
19216
|
+
"metric": "g43",
|
|
19217
|
+
"guidePages": ["website", "react-website"]
|
|
19218
|
+
},
|
|
19219
|
+
"ts#website#auth": {
|
|
19220
|
+
"factory": "./src/ts/website/auth/generator",
|
|
19221
|
+
"schema": "./src/ts/website/auth/schema.json",
|
|
19222
|
+
"description": "Adds auth to an existing website",
|
|
19223
|
+
"metric": "g44",
|
|
19224
|
+
"guidePages": ["react-website-auth"]
|
|
19225
|
+
},
|
|
19196
19226
|
"ts#react-website": {
|
|
19197
19227
|
"factory": "./src/ts/react-website/app/generator",
|
|
19198
19228
|
"schema": "./src/ts/react-website/app/schema.json",
|
|
19199
19229
|
"description": "Generates a React static website",
|
|
19200
19230
|
"metric": "g5",
|
|
19201
|
-
"guidePages": ["react-website"]
|
|
19231
|
+
"guidePages": ["react-website"],
|
|
19232
|
+
"hidden": true
|
|
19202
19233
|
},
|
|
19203
19234
|
"ts#react-website#auth": {
|
|
19204
19235
|
"factory": "./src/ts/react-website/cognito-auth/generator",
|
|
19205
19236
|
"schema": "./src/ts/react-website/cognito-auth/schema.json",
|
|
19206
19237
|
"description": "Adds auth to an existing React website",
|
|
19207
19238
|
"metric": "g6",
|
|
19208
|
-
"guidePages": ["react-website-auth"]
|
|
19239
|
+
"guidePages": ["react-website-auth"],
|
|
19240
|
+
"hidden": true
|
|
19209
19241
|
},
|
|
19210
19242
|
"ts#react-website#runtime-config": {
|
|
19211
19243
|
"factory": "./src/ts/react-website/runtime-config/generator",
|
|
@@ -19218,7 +19250,8 @@ var generators$1 = {
|
|
|
19218
19250
|
"factory": "./src/smithy/ts/api/generator",
|
|
19219
19251
|
"schema": "./src/smithy/ts/api/schema.json",
|
|
19220
19252
|
"description": "Create an API using Smithy and the Smithy TypeScript Server SDK",
|
|
19221
|
-
"metric": "g26"
|
|
19253
|
+
"metric": "g26",
|
|
19254
|
+
"hidden": true
|
|
19222
19255
|
},
|
|
19223
19256
|
"ts#agent": {
|
|
19224
19257
|
"factory": "./src/ts/agent/generator",
|
|
@@ -19261,12 +19294,24 @@ var generators$1 = {
|
|
|
19261
19294
|
"metric": "g29",
|
|
19262
19295
|
"hidden": true
|
|
19263
19296
|
},
|
|
19297
|
+
"ts#api": {
|
|
19298
|
+
"factory": "./src/ts/api/generator",
|
|
19299
|
+
"schema": "./src/ts/api/schema.json",
|
|
19300
|
+
"description": "Create a TypeScript API",
|
|
19301
|
+
"metric": "g46",
|
|
19302
|
+
"guidePages": [
|
|
19303
|
+
"ts-api",
|
|
19304
|
+
"trpc",
|
|
19305
|
+
"ts-smithy-api"
|
|
19306
|
+
]
|
|
19307
|
+
},
|
|
19264
19308
|
"ts#trpc-api": {
|
|
19265
19309
|
"factory": "./src/trpc/backend/generator",
|
|
19266
19310
|
"schema": "./src/trpc/backend/schema.json",
|
|
19267
19311
|
"description": "creates a trpc backend",
|
|
19268
19312
|
"metric": "g9",
|
|
19269
|
-
"guidePages": ["trpc"]
|
|
19313
|
+
"guidePages": ["trpc"],
|
|
19314
|
+
"hidden": true
|
|
19270
19315
|
},
|
|
19271
19316
|
"ts#trpc-api#react-connection": {
|
|
19272
19317
|
"factory": "./src/trpc/react/generator",
|
|
@@ -19408,10 +19453,10 @@ const buildInstallCommand = (pm, pkg, dev) => {
|
|
|
19408
19453
|
* The package manager is auto-detected by @aws/create-nx-workspace from the
|
|
19409
19454
|
* invoking command, so --pm is not needed.
|
|
19410
19455
|
*/
|
|
19411
|
-
const buildCreateNxWorkspaceCommand = (pm, workspace, iacProvider) => {
|
|
19456
|
+
const buildCreateNxWorkspaceCommand = (pm, workspace, iacProvider, tag) => {
|
|
19412
19457
|
return [
|
|
19413
19458
|
PACKAGE_MANAGER_COMMANDS[pm]?.create ?? `${pm} create`,
|
|
19414
|
-
"@aws/nx-workspace",
|
|
19459
|
+
tag ? `@aws/nx-workspace@${tag}` : "@aws/nx-workspace",
|
|
19415
19460
|
...pm === "npm" ? ["--"] : [],
|
|
19416
19461
|
workspace,
|
|
19417
19462
|
...iacProvider ? [`--iacProvider=${iacProvider}`] : []
|
|
@@ -52676,12 +52721,12 @@ const fetchGuideFrontmatters = async (info) => {
|
|
|
52676
52721
|
}));
|
|
52677
52722
|
};
|
|
52678
52723
|
/**
|
|
52679
|
-
* Read a guide's raw MDX
|
|
52724
|
+
* Read a guide's raw MDX from the local filesystem (bundled or monorepo).
|
|
52680
52725
|
*/
|
|
52681
52726
|
const fetchGuideRaw = async (page) => {
|
|
52682
52727
|
const local = fetchLocalGuide(page);
|
|
52683
52728
|
if (local !== void 0) return local;
|
|
52684
|
-
return
|
|
52729
|
+
return "";
|
|
52685
52730
|
};
|
|
52686
52731
|
/**
|
|
52687
52732
|
* Parse a guide's MDX once and return the body, the frontmatter, and the
|
|
@@ -52707,17 +52752,16 @@ const parseGuide = async (raw) => {
|
|
|
52707
52752
|
};
|
|
52708
52753
|
};
|
|
52709
52754
|
/**
|
|
52710
|
-
*
|
|
52711
|
-
*
|
|
52712
|
-
*
|
|
52713
|
-
*
|
|
52714
|
-
* instead of whatever is currently on `main`.
|
|
52715
|
-
*
|
|
52716
|
-
* When running as the published `@aws/nx-plugin-mcp` package, `__dirname`
|
|
52717
|
-
* resolves somewhere inside `node_modules/@aws/nx-plugin-mcp`, the local
|
|
52718
|
-
* probe misses, and we fall back to GitHub.
|
|
52755
|
+
* Probe paths for finding guide MDX files locally. Checked in order:
|
|
52756
|
+
* 1. Bundled docs in the published @aws/nx-plugin-mcp package
|
|
52757
|
+
* 2. Source checkout when running from the monorepo (dev/test)
|
|
52758
|
+
* 3. Rolldown-bundled binary in dist/ (monorepo layout)
|
|
52719
52759
|
*/
|
|
52720
|
-
const GUIDES_RELATIVE_PROBES = [
|
|
52760
|
+
const GUIDES_RELATIVE_PROBES = [
|
|
52761
|
+
"../docs/guides",
|
|
52762
|
+
"../../../docs/src/content/docs/en/guides",
|
|
52763
|
+
"../../../../docs/src/content/docs/en/guides"
|
|
52764
|
+
];
|
|
52721
52765
|
const fetchLocalGuide = (guide) => {
|
|
52722
52766
|
for (const rel of GUIDES_RELATIVE_PROBES) {
|
|
52723
52767
|
const candidate = path.default.resolve(__dirname, rel, `${guide}.mdx`);
|
|
@@ -52727,24 +52771,19 @@ const fetchLocalGuide = (guide) => {
|
|
|
52727
52771
|
}
|
|
52728
52772
|
};
|
|
52729
52773
|
/**
|
|
52730
|
-
* Fetch markdown guide pages
|
|
52731
|
-
* and falls back to fetching from the repo on `main` when no local copy
|
|
52732
|
-
* is available.
|
|
52774
|
+
* Fetch markdown guide pages from the local filesystem (bundled or monorepo).
|
|
52733
52775
|
*/
|
|
52734
52776
|
const fetchGuidePages = async (guidePages, generators, packageManager, snippetContentProvider, options) => {
|
|
52735
|
-
const
|
|
52736
|
-
|
|
52737
|
-
if (local !== void 0) return local;
|
|
52738
|
-
return await (await fetch(`https://raw.githubusercontent.com/awslabs/nx-plugin-for-aws/refs/heads/main/docs/src/content/docs/en/guides/${guide}.mdx`)).text();
|
|
52739
|
-
}))).filter((result) => result.status === "fulfilled");
|
|
52740
|
-
return (await Promise.all(fulfilled.map((result) => postProcessGuide(result.value, generators, packageManager, snippetContentProvider, options)))).join("\n\n");
|
|
52777
|
+
const guides = guidePages.map((guide) => fetchLocalGuide(guide)).filter((content) => content !== void 0);
|
|
52778
|
+
return (await Promise.all(guides.map((content) => postProcessGuide(content, generators, packageManager, snippetContentProvider, options)))).join("\n\n");
|
|
52741
52779
|
};
|
|
52742
|
-
const SNIPPETS_RELATIVE_PROBES = [
|
|
52743
|
-
|
|
52780
|
+
const SNIPPETS_RELATIVE_PROBES = [
|
|
52781
|
+
"../docs/snippets",
|
|
52782
|
+
"../../../docs/src/content/docs/en/snippets",
|
|
52783
|
+
"../../../../docs/src/content/docs/en/snippets"
|
|
52784
|
+
];
|
|
52744
52785
|
/**
|
|
52745
|
-
* Fetch a snippet's content
|
|
52746
|
-
* running under `mcp-inspect` or a linked test workspace) before falling
|
|
52747
|
-
* back to the copy on `main`.
|
|
52786
|
+
* Fetch a snippet's content from the local filesystem (bundled or monorepo).
|
|
52748
52787
|
*/
|
|
52749
52788
|
const fetchSnippet = async (snippetName) => {
|
|
52750
52789
|
for (const rel of SNIPPETS_RELATIVE_PROBES) {
|
|
@@ -52753,13 +52792,7 @@ const fetchSnippet = async (snippetName) => {
|
|
|
52753
52792
|
if (fs.default.existsSync(candidate)) return fs.default.readFileSync(candidate, "utf-8");
|
|
52754
52793
|
} catch {}
|
|
52755
52794
|
}
|
|
52756
|
-
|
|
52757
|
-
const response = await fetch(`${SNIPPET_BASE_URL}/${snippetName}.mdx`);
|
|
52758
|
-
if (!response.ok) return "";
|
|
52759
|
-
return await response.text();
|
|
52760
|
-
} catch {
|
|
52761
|
-
return "";
|
|
52762
|
-
}
|
|
52795
|
+
return "";
|
|
52763
52796
|
};
|
|
52764
52797
|
/**
|
|
52765
52798
|
* Post-process a guide page. Thin wrapper around the unified/remark-mdx
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Astro Docs
|
|
3
|
+
description: Reference documentation for an Astro + Starlight documentation site
|
|
4
|
+
when:
|
|
5
|
+
framework:
|
|
6
|
+
- astro
|
|
7
|
+
---
|
|
8
|
+
import { FileTree } from '@astrojs/starlight/components';
|
|
9
|
+
import RunGenerator from '@components/run-generator.astro';
|
|
10
|
+
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
11
|
+
import NxCommands from '@components/nx-commands.astro';
|
|
12
|
+
|
|
13
|
+
This generator scaffolds a documentation site powered by [Astro](https://astro.build/)
|
|
14
|
+
and the [Starlight](https://starlight.astro.build/) docs theme. It wires up
|
|
15
|
+
localisation, reusable content snippets, locale-aware internal links and a
|
|
16
|
+
[`starlight-blog`](https://starlight-blog-docs.vercel.app/) plugin by default.
|
|
17
|
+
|
|
18
|
+
By default it also scaffolds an automated translation pipeline powered by a
|
|
19
|
+
[Strands Agent](https://strandsagents.com/) on
|
|
20
|
+
[Amazon Bedrock](https://aws.amazon.com/bedrock/).
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Generate an Astro docs site
|
|
25
|
+
|
|
26
|
+
You can generate a new Astro docs site in two ways:
|
|
27
|
+
|
|
28
|
+
<RunGenerator generator="ts#docs" />
|
|
29
|
+
|
|
30
|
+
### Options
|
|
31
|
+
|
|
32
|
+
<GeneratorParameters generator="ts#docs" />
|
|
33
|
+
|
|
34
|
+
## Generator Output
|
|
35
|
+
|
|
36
|
+
By default the generator creates the following project structure at `docs/` in the
|
|
37
|
+
workspace root (configurable via the `name`, `directory` and `subDirectory` options):
|
|
38
|
+
|
|
39
|
+
<FileTree>
|
|
40
|
+
- astro.config.mjs Astro + Starlight configuration (locales, sidebar, blog plugin)
|
|
41
|
+
- tsconfig.json Extends astro/tsconfigs/strict with @components / @assets path aliases
|
|
42
|
+
- project.json Nx project with `build`, `start`, `preview` (and `translate` if enabled) targets
|
|
43
|
+
- scripts
|
|
44
|
+
- translate.ts Translation driver — a Strands agent with a scoped file-editor tool (omitted with `--noTranslation`)
|
|
45
|
+
- translate.config.json Source/target locales, glob patterns, model id, region (omitted with `--noTranslation`)
|
|
46
|
+
- src
|
|
47
|
+
- components
|
|
48
|
+
- link.astro Locale-aware link component (resolves paths against the current locale)
|
|
49
|
+
- snippet.astro Locale-aware snippet loader component
|
|
50
|
+
- content
|
|
51
|
+
- docs
|
|
52
|
+
- en
|
|
53
|
+
- index.mdx Landing page
|
|
54
|
+
- guides
|
|
55
|
+
- getting-started.mdx Sample guide referencing the link and snippet components
|
|
56
|
+
- blog
|
|
57
|
+
- welcome.mdx Sample blog post (omitted with `--noBlog`)
|
|
58
|
+
- snippets
|
|
59
|
+
- example.mdx Sample reusable snippet
|
|
60
|
+
- styles
|
|
61
|
+
- custom.css Starlight theme overrides
|
|
62
|
+
- README.md Project README
|
|
63
|
+
</FileTree>
|
|
64
|
+
|
|
65
|
+
### Localisation
|
|
66
|
+
|
|
67
|
+
The generator defaults to a single locale (`en`) and redirects the root URL to
|
|
68
|
+
it. To add more languages:
|
|
69
|
+
|
|
70
|
+
1. Add an entry under `locales` in `astro.config.mjs` (for example `ko: { label: '한국어' }`).
|
|
71
|
+
2. Create a matching directory under `src/content/docs/<locale>/`.
|
|
72
|
+
3. Populate it manually, or use the translation target described below.
|
|
73
|
+
|
|
74
|
+
## Translation
|
|
75
|
+
|
|
76
|
+
Unless you passed `--noTranslation`, the generator adds a `translate` target to
|
|
77
|
+
`project.json`, so you can run:
|
|
78
|
+
|
|
79
|
+
<NxCommands commands={[
|
|
80
|
+
'translate docs -- --all',
|
|
81
|
+
'translate docs -- --languages jp,ko',
|
|
82
|
+
'translate docs -- --dry-run',
|
|
83
|
+
]} />
|
|
84
|
+
|
|
85
|
+
When run without `--all`, the script only translates files that have changed
|
|
86
|
+
since the last translation commit on the current branch — meaning you can
|
|
87
|
+
safely re-run it on every docs PR without re-translating the whole site.
|
|
88
|
+
|
|
89
|
+
### Configuring translation
|
|
90
|
+
|
|
91
|
+
Edit `scripts/translate.config.json` to change:
|
|
92
|
+
|
|
93
|
+
| Field | Purpose |
|
|
94
|
+
| --- | --- |
|
|
95
|
+
| `sourceLanguage` | Locale to translate **from** (default `en`). |
|
|
96
|
+
| `targetLanguages` | Locales to translate **to**. Empty by default. For example `["fr", "de", "es", "ja", "ko"]`. |
|
|
97
|
+
| `docsDir` | Path to the docs content directory, relative to the project root. |
|
|
98
|
+
| `include` | Glob patterns (relative to `<docsDir>/<sourceLanguage>`) for files to translate. |
|
|
99
|
+
| `exclude` | Glob patterns to skip. |
|
|
100
|
+
| `modelId` | Bedrock model to use for translations. |
|
|
101
|
+
| `awsRegion` | AWS region the Bedrock client is configured with. Can also be set via `AWS_REGION`. |
|
|
102
|
+
| `concurrency` | Max number of concurrent agent invocations. |
|
|
103
|
+
| `translationCommitMessage` | Commit message marker for translation commits (default `docs: update translations`). |
|
|
104
|
+
|
|
105
|
+
### Locale-aware internal links
|
|
106
|
+
|
|
107
|
+
The generator ships a `Link` component that automatically resolves internal
|
|
108
|
+
docs paths against the current locale, so a single source of truth produces
|
|
109
|
+
the right URL in every language:
|
|
110
|
+
|
|
111
|
+
```mdx
|
|
112
|
+
import Link from '@components/link.astro';
|
|
113
|
+
|
|
114
|
+
<Link path="guides/getting-started">Read the getting-started guide</Link>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Snippets
|
|
118
|
+
|
|
119
|
+
Reusable content fragments live in `src/content/docs/<locale>/snippets/`. The
|
|
120
|
+
generated `Snippet` component loads the snippet that matches the current
|
|
121
|
+
locale:
|
|
122
|
+
|
|
123
|
+
```mdx
|
|
124
|
+
import Snippet from '@components/snippet.astro';
|
|
125
|
+
|
|
126
|
+
<Snippet name="example" />
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Wiring up CI
|
|
130
|
+
|
|
131
|
+
No CI workflow is generated out of the box — add one that:
|
|
132
|
+
|
|
133
|
+
1. Configures AWS credentials with permission to invoke Bedrock `InvokeModel` on
|
|
134
|
+
the configured model.
|
|
135
|
+
2. Runs the `translate` target on pull requests that touch your source-language
|
|
136
|
+
docs:
|
|
137
|
+
|
|
138
|
+
<NxCommands commands={['translate docs']} />
|
|
139
|
+
|
|
140
|
+
3. Commits the resulting translations back to the PR branch. The commit message
|
|
141
|
+
must match the `translationCommitMessage` value in
|
|
142
|
+
`scripts/translate.config.json` (default `docs: update translations`) so that
|
|
143
|
+
subsequent incremental runs can detect the baseline commit and only
|
|
144
|
+
re-translate the files that changed since.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Python Agent to A2A Agent
|
|
3
|
+
description: Connect a Python Agent to a remote A2A agent
|
|
4
|
+
when:
|
|
5
|
+
sourceType: py#agent
|
|
6
|
+
targetType:
|
|
7
|
+
- ts#agent
|
|
8
|
+
- py#agent
|
|
9
|
+
---
|
|
10
|
+
import { FileTree } from '@astrojs/starlight/components';
|
|
11
|
+
import Link from '@components/link.astro';
|
|
12
|
+
import RunGenerator from '@components/run-generator.astro';
|
|
13
|
+
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
14
|
+
import NxCommands from '@components/nx-commands.astro';
|
|
15
|
+
import Snippet from '@components/snippet.astro';
|
|
16
|
+
|
|
17
|
+
The `connection` generator can connect your <Link path="guides/py-agent">Python Agent</Link> to a remote [A2A](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-a2a.html) agent — either <Link path="guides/ts-agent">TypeScript</Link> or <Link path="guides/py-agent">Python</Link> — so your agent can delegate to another agent as a tool.
|
|
18
|
+
|
|
19
|
+
The generator sets up all the necessary wiring so your agent can discover and invoke the remote A2A agent, both when deployed to AWS (via Bedrock AgentCore) and when running locally.
|
|
20
|
+
|
|
21
|
+
## Prerequisites
|
|
22
|
+
|
|
23
|
+
Before using this generator, ensure you have:
|
|
24
|
+
|
|
25
|
+
1. A Python project with a <Link path="guides/py-agent">Strands Agent</Link> component (any 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
|
+
3. Both components created with `computeType: BedrockAgentCoreRuntime`
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Run the Generator
|
|
32
|
+
|
|
33
|
+
<RunGenerator generator="connection" />
|
|
34
|
+
|
|
35
|
+
Select your host agent project as the source and your A2A agent project as the target. If your projects contain multiple components, specify the `sourceComponent` and `targetComponent` options to disambiguate.
|
|
36
|
+
|
|
37
|
+
### Options
|
|
38
|
+
|
|
39
|
+
<GeneratorParameters generator="connection" />
|
|
40
|
+
|
|
41
|
+
## Generator Output
|
|
42
|
+
|
|
43
|
+
The generator creates a shared `agent_connection` Python project at `packages/common/agent_connection/` (if it doesn't already exist). Per-connection client modules are generated into this shared project:
|
|
44
|
+
|
|
45
|
+
<FileTree>
|
|
46
|
+
|
|
47
|
+
- packages/common/agent\_connection
|
|
48
|
+
- \<scope>\_agent\_connection
|
|
49
|
+
- \_\_init\_\_.py Re-exports per-connection clients
|
|
50
|
+
- core
|
|
51
|
+
- agentcore\_a2a\_client.py Core AgentCore A2A client with SigV4 authentication
|
|
52
|
+
- app
|
|
53
|
+
- \<target\_agent\_name>\_client.py Per-connection client for each A2A agent
|
|
54
|
+
|
|
55
|
+
</FileTree>
|
|
56
|
+
|
|
57
|
+
Additionally, the generator:
|
|
58
|
+
- Transforms your agent's `agent.py` to register the remote A2A agent as a tool using `@tool`
|
|
59
|
+
- Adds the `agent_connection` project as a workspace dependency of your agent project
|
|
60
|
+
- Updates the agent's `serve-local` target to depend on the target agent's `serve-local` target
|
|
61
|
+
|
|
62
|
+
## Using the Connected A2A Agent
|
|
63
|
+
|
|
64
|
+
The generator transforms your agent's `agent.py` to wrap the remote A2A agent as a tool:
|
|
65
|
+
|
|
66
|
+
```python title="packages/my-project/my_module/agent/agent.py" {4,9-15,21}
|
|
67
|
+
from contextlib import contextmanager
|
|
68
|
+
from strands import Agent, tool
|
|
69
|
+
|
|
70
|
+
from my_scope_agent_connection import RemoteAgentClient
|
|
71
|
+
|
|
72
|
+
@contextmanager
|
|
73
|
+
def get_agent(session_id: str):
|
|
74
|
+
remote_agent = RemoteAgentClient.create(session_id=session_id)
|
|
75
|
+
|
|
76
|
+
@tool
|
|
77
|
+
def ask_remote_agent(prompt: str) -> str:
|
|
78
|
+
"""Delegate a question to the remote RemoteAgent A2A agent and return its reply."""
|
|
79
|
+
return str(remote_agent(prompt))
|
|
80
|
+
|
|
81
|
+
yield Agent(
|
|
82
|
+
system_prompt="...",
|
|
83
|
+
tools=[ask_remote_agent],
|
|
84
|
+
)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The `session_id` parameter is plumbed through from the caller, ensuring consistency for [Bedrock AgentCore Observability](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability.html).
|
|
88
|
+
|
|
89
|
+
Under the hood, `RemoteAgentClient.create(session_id=...)` returns a Strands `A2AAgent` configured with an `httpx.AsyncClient` that signs requests with SigV4 when deployed to AWS, and a plain `http://localhost:<port>/` endpoint when `SERVE_LOCAL=true`.
|
|
90
|
+
|
|
91
|
+
## Infrastructure
|
|
92
|
+
|
|
93
|
+
<Snippet name="connection/a2a-infrastructure" parentHeading="Infrastructure" />
|
|
94
|
+
|
|
95
|
+
## Local Development
|
|
96
|
+
|
|
97
|
+
The generator configures the host agent's `serve-local` target to:
|
|
98
|
+
1. Start the connected A2A agent(s) automatically
|
|
99
|
+
2. Set `SERVE_LOCAL=true` so the generated client connects directly to `http://localhost:<port>/` instead of AgentCore
|
|
100
|
+
|
|
101
|
+
Run the agent locally with:
|
|
102
|
+
|
|
103
|
+
<NxCommands commands={["<agent-name>-serve-local <project-name>"]} />
|
|
104
|
+
|
|
105
|
+
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.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Python Agent to MCP
|
|
3
|
+
description: Connect a Python Agent to an MCP server
|
|
4
|
+
when:
|
|
5
|
+
sourceType: py#agent
|
|
6
|
+
targetType:
|
|
7
|
+
- ts#mcp-server
|
|
8
|
+
- py#mcp-server
|
|
9
|
+
---
|
|
10
|
+
import { FileTree } from '@astrojs/starlight/components';
|
|
11
|
+
import Link from '@components/link.astro';
|
|
12
|
+
import RunGenerator from '@components/run-generator.astro';
|
|
13
|
+
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
14
|
+
import NxCommands from '@components/nx-commands.astro';
|
|
15
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
16
|
+
|
|
17
|
+
The `connection` generator can connect your <Link path="guides/py-agent">Python Agent</Link> to an MCP server (either <Link path="guides/ts-mcp-server">TypeScript</Link> or <Link path="guides/py-mcp-server">Python</Link>).
|
|
18
|
+
|
|
19
|
+
The generator sets up all the necessary wiring so your agent can discover and invoke the MCP server's tools, both when deployed to AWS (via Bedrock AgentCore) and when running locally.
|
|
20
|
+
|
|
21
|
+
## Prerequisites
|
|
22
|
+
|
|
23
|
+
Before using this generator, ensure you have:
|
|
24
|
+
|
|
25
|
+
1. A Python project with a <Link path="guides/py-agent">Strands Agent</Link> component
|
|
26
|
+
2. A project with an MCP server component (either <Link path="guides/ts-mcp-server">`ts#mcp-server`</Link> or <Link path="guides/py-mcp-server">`py#mcp-server`</Link>)
|
|
27
|
+
3. Both components created with `computeType: BedrockAgentCoreRuntime`
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Run the Generator
|
|
32
|
+
|
|
33
|
+
<RunGenerator generator="connection" />
|
|
34
|
+
|
|
35
|
+
Select your agent project as the source and your MCP server project as the target. If your projects contain multiple components, specify the `sourceComponent` and `targetComponent` options to disambiguate.
|
|
36
|
+
|
|
37
|
+
### Options
|
|
38
|
+
|
|
39
|
+
<GeneratorParameters generator="connection" />
|
|
40
|
+
|
|
41
|
+
## Generator Output
|
|
42
|
+
|
|
43
|
+
The generator creates a shared `agent_connection` Python project at `packages/common/agent_connection/` (if it doesn't already exist). Per-connection client modules are generated into this shared project:
|
|
44
|
+
|
|
45
|
+
<FileTree>
|
|
46
|
+
|
|
47
|
+
- packages/common/agent\_connection
|
|
48
|
+
- \<scope>\_agent\_connection
|
|
49
|
+
- \_\_init\_\_.py Re-exports per-connection clients
|
|
50
|
+
- core
|
|
51
|
+
- agentcore\_mcp\_client.py Core AgentCore MCP client
|
|
52
|
+
- app
|
|
53
|
+
- \<mcp\_server\_name>\_client.py Per-connection client for each MCP server
|
|
54
|
+
|
|
55
|
+
</FileTree>
|
|
56
|
+
|
|
57
|
+
Additionally, the generator:
|
|
58
|
+
- Transforms your agent's `agent.py` to import and use the MCP server's tools via a class-based client
|
|
59
|
+
- Adds the `agent_connection` project as a workspace dependency of your agent project
|
|
60
|
+
- Updates the agent's `serve-local` target to depend on the MCP server's serve target
|
|
61
|
+
|
|
62
|
+
## Using the Connected MCP Server
|
|
63
|
+
|
|
64
|
+
The generator transforms your agent's `agent.py` to use the MCP server's tools:
|
|
65
|
+
|
|
66
|
+
```python title="packages/my-project/my_module/agent/agent.py" {4,10-14}
|
|
67
|
+
from contextlib import contextmanager
|
|
68
|
+
from strands import Agent
|
|
69
|
+
|
|
70
|
+
from my_scope_agent_connection import MyMcpServerClient
|
|
71
|
+
|
|
72
|
+
@contextmanager
|
|
73
|
+
def get_agent(session_id: str):
|
|
74
|
+
my_mcp_server = MyMcpServerClient.create(session_id=session_id)
|
|
75
|
+
with (
|
|
76
|
+
my_mcp_server,
|
|
77
|
+
):
|
|
78
|
+
yield Agent(
|
|
79
|
+
system_prompt="...",
|
|
80
|
+
tools=[*my_mcp_server.list_tools_sync()],
|
|
81
|
+
)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The `session_id` parameter is plumbed through from the caller, ensuring consistency for [Bedrock AgentCore Observability](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability.html).
|
|
85
|
+
|
|
86
|
+
## Infrastructure
|
|
87
|
+
|
|
88
|
+
<Infrastructure>
|
|
89
|
+
<Fragment slot="cdk">
|
|
90
|
+
After running the connection generator, you need to grant the agent permission to invoke the MCP server:
|
|
91
|
+
|
|
92
|
+
```ts title="packages/infra/src/stacks/application-stack.ts" {5}
|
|
93
|
+
const mcpServer = new MyMcpServer(this, 'MyMcpServer');
|
|
94
|
+
const myAgent = new MyAgent(this, 'MyAgent');
|
|
95
|
+
|
|
96
|
+
// Grant the agent permissions to invoke the MCP server
|
|
97
|
+
mcpServer.grantInvokeAccess(myAgent);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The MCP server's AgentCore runtime ARN is automatically registered in the `agentcore` namespace of <Link path="guides/runtime-config">Runtime Configuration</Link> by the generated CDK construct, so the agent can discover it at runtime.
|
|
101
|
+
</Fragment>
|
|
102
|
+
<Fragment slot="terraform">
|
|
103
|
+
After running the connection generator, you need to grant the agent permission to invoke the MCP server in your Terraform configuration:
|
|
104
|
+
|
|
105
|
+
```hcl title="packages/infra/src/main.tf" {12-24}
|
|
106
|
+
module "inventory_mcp_server" {
|
|
107
|
+
source = "../../common/terraform/src/app/mcp-servers/inventory-mcp"
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
module "story_agent" {
|
|
111
|
+
source = "../../common/terraform/src/app/agents/story-agent"
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
# Grant the agent permissions to invoke the MCP server
|
|
115
|
+
resource "aws_iam_policy" "agent_invoke_mcp" {
|
|
116
|
+
name = "AgentInvokeMcpPolicy"
|
|
117
|
+
policy = jsonencode({
|
|
118
|
+
Version = "2012-10-17"
|
|
119
|
+
Statement = [{
|
|
120
|
+
Effect = "Allow"
|
|
121
|
+
Action = "bedrock-agentcore:InvokeAgent"
|
|
122
|
+
Resource = module.inventory_mcp_server.agent_core_runtime_arn
|
|
123
|
+
}]
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
resource "aws_iam_role_policy_attachment" "agent_invoke_mcp" {
|
|
128
|
+
role = module.story_agent.agent_core_runtime_role_arn
|
|
129
|
+
policy_arn = aws_iam_policy.agent_invoke_mcp.arn
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The MCP server's AgentCore runtime ARN is automatically registered in the `agentcore` namespace of <Link path="guides/runtime-config">Runtime Configuration</Link> by the generated Terraform module, so the agent can discover it at runtime.
|
|
134
|
+
</Fragment>
|
|
135
|
+
</Infrastructure>
|
|
136
|
+
|
|
137
|
+
## Local Development
|
|
138
|
+
|
|
139
|
+
The generator configures the agent's `serve-local` target to:
|
|
140
|
+
1. Start the connected MCP server(s) automatically
|
|
141
|
+
2. Set `SERVE_LOCAL=true` so the generated client uses direct HTTP transport instead of AgentCore
|
|
142
|
+
|
|
143
|
+
Run the agent locally with:
|
|
144
|
+
|
|
145
|
+
<NxCommands commands={["<agent-name>-serve-local <project-name>"]} />
|
|
146
|
+
|
|
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.
|