@aws/nx-plugin-mcp 0.119.0 → 0.121.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 +23 -35
- package/docs/guides/astro-docs.mdx +142 -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/fastapi.mdx +509 -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-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 +421 -0
- package/docs/guides/runtime-config.mdx +312 -0
- package/docs/guides/terraform-project.mdx +317 -0
- package/docs/guides/trpc.mdx +816 -0
- package/docs/guides/ts-agent.mdx +436 -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 +661 -0
- package/docs/guides/typescript-infrastructure.mdx +408 -0
- package/docs/guides/typescript-project.mdx +312 -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/package.json +1 -1
- package/src/py/agent/schema.json +1 -1
- package/src/py/fast-api/schema.json +2 -2
- package/src/py/mcp-server/schema.json +1 -1
- package/src/smithy/ts/api/schema.json +2 -2
- package/src/trpc/backend/schema.json +2 -2
- package/src/ts/agent/schema.json +1 -1
- package/src/ts/mcp-server/schema.json +1 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: React to AG-UI Agent
|
|
3
|
+
description: Connect a React website to an Agent via the AG-UI protocol using CopilotKit
|
|
4
|
+
when:
|
|
5
|
+
sourceType: react
|
|
6
|
+
targetType:
|
|
7
|
+
- ts#agent
|
|
8
|
+
- py#agent
|
|
9
|
+
protocol: AG-UI
|
|
10
|
+
---
|
|
11
|
+
import { FileTree } from '@astrojs/starlight/components';
|
|
12
|
+
import Link from '@components/link.astro';
|
|
13
|
+
import RunGenerator from '@components/run-generator.astro';
|
|
14
|
+
import NxCommands from '@components/nx-commands.astro';
|
|
15
|
+
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
16
|
+
import Snippet from '@components/snippet.astro';
|
|
17
|
+
|
|
18
|
+
Nx Plugin for AWS provides a generator to connect a React website to an Agent that exposes the [AG-UI protocol](https://docs.ag-ui.com/). It wires up [CopilotKit](https://docs.copilotkit.ai/aws-strands) with an [`@ag-ui/client`](https://docs.ag-ui.com/) `HttpAgent` on your website, with AWS IAM and Cognito authentication support.
|
|
19
|
+
|
|
20
|
+
## Prerequisites
|
|
21
|
+
|
|
22
|
+
Before using this generator, ensure you have:
|
|
23
|
+
|
|
24
|
+
1. A React website (generated using the <Link path="guides/react-website">`ts#react-website` generator</Link>)
|
|
25
|
+
2. A TypeScript or Python Agent with `protocol=AG-UI` (generated using the <Link path="guides/ts-agent">`ts#agent`</Link> or <Link path="guides/py-agent">`py#agent`</Link> generator)
|
|
26
|
+
3. For deployed agents, Cognito Auth added via the <Link path="/guides/react-website-auth">`ts#react-website-auth` generator</Link>
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
### Run the Generator
|
|
31
|
+
|
|
32
|
+
<RunGenerator generator="connection" />
|
|
33
|
+
|
|
34
|
+
You will be prompted to select your React website as the source project and the project containing your AG-UI Agent as the target project. If your target project contains multiple components (such as multiple agents or other component types), you will be prompted to specify a `targetComponent` to disambiguate.
|
|
35
|
+
|
|
36
|
+
### Options
|
|
37
|
+
|
|
38
|
+
<GeneratorParameters generator="connection" />
|
|
39
|
+
|
|
40
|
+
## Generator Output
|
|
41
|
+
|
|
42
|
+
The generator creates a **single shared** `AguiProvider` component, one hook per connected agent, and a themed wrapper for the CopilotKit chat components:
|
|
43
|
+
|
|
44
|
+
<FileTree>
|
|
45
|
+
|
|
46
|
+
- src
|
|
47
|
+
- components
|
|
48
|
+
- AguiProvider.tsx Single `CopilotKitProvider` for every AG-UI agent. Created on the first `connection` run and updated on subsequent runs to register each new agent.
|
|
49
|
+
- copilot
|
|
50
|
+
- index.tsx Re-exports `CopilotChat`, `CopilotSidebar` and `CopilotPopup` with slot defaults that match your website's `uxProvider` (Cloudscape, Shadcn, or no theme at all).
|
|
51
|
+
- *ThemeComponents*.tsx Per-slot theme components (e.g. `CloudscapeAssistantMessage.tsx`, `ShadcnChatInput.tsx`). Only vended when `uxProvider` is `Cloudscape` or `Shadcn`.
|
|
52
|
+
- hooks
|
|
53
|
+
- useAgui\<AgentName>.tsx Registers one AG-UI agent. One file per `connection` run.
|
|
54
|
+
- useSigV4.tsx SigV4 signing (IAM only)
|
|
55
|
+
|
|
56
|
+
</FileTree>
|
|
57
|
+
|
|
58
|
+
Running `connection` a second time for a different agent **adds a new `useAgui<AgentName>.tsx` hook** and updates `AguiProvider.tsx` to register both hooks — any custom edits you've made to the provider are preserved. `main.tsx` keeps its single `<AguiProvider>` wrapper — you never end up with nested providers.
|
|
59
|
+
|
|
60
|
+
The following dependencies are added to the root `package.json`:
|
|
61
|
+
|
|
62
|
+
- `@copilotkit/react-core` — ships `CopilotKitProvider` and chat components (`CopilotChat`, `CopilotSidebar`, `CopilotPopup`)
|
|
63
|
+
- `@ag-ui/client` — `HttpAgent` used by the generated hooks
|
|
64
|
+
- `aws4fetch`, `oidc-client-ts`, `react-oidc-context`, `@aws-sdk/credential-providers` — IAM auth only
|
|
65
|
+
- `react-oidc-context` — Cognito auth
|
|
66
|
+
|
|
67
|
+
## How It Works
|
|
68
|
+
|
|
69
|
+
### AG-UI Connection
|
|
70
|
+
|
|
71
|
+
Each `useAgui<AgentName>` hook reads its agent's runtime value from <Link path="guides/runtime-config">Runtime Configuration</Link> and instantiates an `@ag-ui/client` `HttpAgent`:
|
|
72
|
+
|
|
73
|
+
- **Deployed**: the runtime value is a Bedrock AgentCore Runtime ARN, which is converted to the AgentCore HTTPS endpoint: `https://bedrock-agentcore.<region>.amazonaws.com/runtimes/<encoded-arn>/invocations?qualifier=DEFAULT`
|
|
74
|
+
- **Local development**: `serve-local` overrides the value to the agent's local URL (e.g. `http://localhost:8081`)
|
|
75
|
+
|
|
76
|
+
The shared `AguiProvider` calls every generated hook and spreads each one into `selfManagedAgents` on a single `CopilotKitProvider`, which exposes them all to CopilotKit components.
|
|
77
|
+
|
|
78
|
+
### CopilotKit Integration
|
|
79
|
+
|
|
80
|
+
[CopilotKit](https://docs.copilotkit.ai/aws-strands) is the 1st-party reference React client for the AG-UI protocol and ships ready-made chat components:
|
|
81
|
+
|
|
82
|
+
- `<CopilotChat />` — full chat interface
|
|
83
|
+
- `<CopilotSidebar />` — fixed side panel chat
|
|
84
|
+
- `<CopilotPopup />` — floating chat popup
|
|
85
|
+
|
|
86
|
+
Place any of these anywhere inside the `<AguiProvider>` wrapper (already wired into `main.tsx` for you).
|
|
87
|
+
|
|
88
|
+
### Authentication
|
|
89
|
+
|
|
90
|
+
The generated code handles authentication depending on your agent's configuration:
|
|
91
|
+
|
|
92
|
+
- **IAM** (default): uses AWS SigV4-signed HTTP requests. Credentials are obtained from the Cognito Identity Pool configured with your website's auth.
|
|
93
|
+
- **Cognito**: embeds the JWT access token in the `Authorization` header as a Bearer token.
|
|
94
|
+
|
|
95
|
+
## Infrastructure
|
|
96
|
+
|
|
97
|
+
<Snippet name="connection/react-agent-infrastructure" parentHeading="Infrastructure" />
|
|
98
|
+
|
|
99
|
+
## Using the Generated Code
|
|
100
|
+
|
|
101
|
+
### Adding a Chat Interface
|
|
102
|
+
|
|
103
|
+
Instantiate CopilotKit components with `agentId` to select which agent to use. The id is the agent's name — the same one you chose when you ran the <Link path="guides/ts-agent">`ts#agent`</Link> or <Link path="guides/py-agent">`py#agent`</Link> generator — and you can also find it in the generated hook file (e.g. the key returned from `packages/web/src/hooks/useAgui<AgentName>.tsx`).
|
|
104
|
+
|
|
105
|
+
Import the chat components from the generated `./components/copilot` module so the theme that matches your website's `uxProvider` is applied automatically:
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
import { CopilotChat } from './components/copilot';
|
|
109
|
+
|
|
110
|
+
function ChatPage() {
|
|
111
|
+
return (
|
|
112
|
+
<CopilotChat
|
|
113
|
+
agentId="agent"
|
|
114
|
+
labels={{
|
|
115
|
+
welcomeMessageText: 'How can I help you today?',
|
|
116
|
+
chatInputPlaceholder: 'Ask me anything...',
|
|
117
|
+
}}
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Connecting Multiple AG-UI Agents
|
|
124
|
+
|
|
125
|
+
Run the `connection` generator once per agent. Every agent registered via the shared `AguiProvider` is visible from anywhere in the app — instantiate a CopilotKit component with a different `agentId` to route each chat to the agent you want:
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import { CopilotChat } from './components/copilot';
|
|
129
|
+
|
|
130
|
+
<CopilotChat agentId="story" /> {/* talks to StoryAgent */}
|
|
131
|
+
<CopilotChat agentId="research" /> {/* talks to ResearchAgent */}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Customising the Look and Feel
|
|
135
|
+
|
|
136
|
+
`<CopilotChat />` (and `<CopilotSidebar />`, `<CopilotPopup />`) use a recursive **slot system** — you can override any sub-component with either a Tailwind class string, a prop object, or a custom React component. See the [CopilotKit slots guide](https://docs.copilotkit.ai/aws-strands/custom-look-and-feel/slots) for the full slot tree.
|
|
137
|
+
|
|
138
|
+
### Built-in Themes
|
|
139
|
+
|
|
140
|
+
The generator reads `metadata.uxProvider` from your React website project and vends a themed wrapper module at `src/components/copilot/index.tsx` so the chat components match the rest of your UI without any extra configuration:
|
|
141
|
+
|
|
142
|
+
| `uxProvider` | Styling applied to `CopilotChat` / `CopilotSidebar` / `CopilotPopup` |
|
|
143
|
+
| ------------ | -------------------------------------------------------------------- |
|
|
144
|
+
| `Cloudscape` | Messages render inside Cloudscape `ChatBubble`s with gen-AI `Avatar`s (matching the [Cloudscape generative AI chat pattern](https://cloudscape.design/patterns/genai/generative-AI-chat/)); the typing indicator becomes a `LoadingBar` and the input is a `PromptInput`. Built from `@cloudscape-design/components` and `@cloudscape-design/chat-components`. |
|
|
145
|
+
| `Shadcn` | Assistant messages render in a `bg-muted` bubble with a `Sparkles` avatar; user messages render right-aligned in a `bg-primary` bubble with a `User` avatar. The input is a rounded `Textarea` + pill-shaped send/stop `Button` (Enter submits, Shift+Enter newlines). Uses shadcn primitives from the shared `common-shadcn` package. |
|
|
146
|
+
| `None` (or anything else) | No theme — the module just re-exports the default CopilotKit components. |
|
|
147
|
+
|
|
148
|
+
Import the themed components from the **local theme module** (not `@copilotkit/react-core/v2` directly) so the theme is applied automatically:
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import { CopilotChat } from './components/copilot';
|
|
152
|
+
|
|
153
|
+
<CopilotChat agentId="agent" />
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The theme is applied as slot defaults, so any slot you explicitly pass still wins — you keep full control whenever you need a one-off override.
|
|
157
|
+
|
|
158
|
+
### Customising the Theme
|
|
159
|
+
|
|
160
|
+
The generated theme lives entirely inside your project:
|
|
161
|
+
|
|
162
|
+
- `src/components/copilot/index.tsx` — exports the themed `CopilotChat` / `CopilotSidebar` / `CopilotPopup` and the `cloudscapeCopilotTheme` / `shadcnCopilotTheme` objects. Edit this file to change the default slot wiring for every chat in your app.
|
|
163
|
+
- `src/components/copilot/<ThemeComponent>.tsx` — per-slot theme components (e.g. `CloudscapeAssistantMessage`, `ShadcnChatInput`). Edit these to tweak the look of a single slot without re-wiring the theme.
|
|
164
|
+
|
|
165
|
+
For example, to drop in your own user-message renderer while keeping the rest of the theme, edit the relevant file in `src/components/copilot/` and re-export it from `index.tsx`.
|
|
166
|
+
|
|
167
|
+
### Tailwind styling via slots
|
|
168
|
+
|
|
169
|
+
Per-chat overrides still work alongside the theme — anything you pass as a slot prop overrides the themed default:
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
<CopilotChat
|
|
173
|
+
agentId="agent"
|
|
174
|
+
// style the input and its children
|
|
175
|
+
input={{
|
|
176
|
+
textArea: 'text-blue-600',
|
|
177
|
+
sendButton: 'bg-blue-600 hover:bg-blue-700',
|
|
178
|
+
}}
|
|
179
|
+
// style nested message slots
|
|
180
|
+
messageView={{
|
|
181
|
+
assistantMessage: 'bg-blue-50 rounded-xl p-2',
|
|
182
|
+
userMessage: 'bg-blue-100 rounded-xl',
|
|
183
|
+
}}
|
|
184
|
+
/>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Replacing a slot with a custom component
|
|
188
|
+
|
|
189
|
+
Any slot can take a React component instead of a className, so you can replace the default entirely:
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import { CopilotChat } from './components/copilot';
|
|
193
|
+
|
|
194
|
+
const MySendButton: React.FC<{ onClick: () => void }> = ({ onClick }) => (
|
|
195
|
+
<button onClick={onClick} className="my-send-btn">
|
|
196
|
+
Send
|
|
197
|
+
</button>
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
<CopilotChat
|
|
201
|
+
agentId="agent"
|
|
202
|
+
input={{ sendButton: MySendButton }}
|
|
203
|
+
/>;
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Deeper overrides follow the same shape — e.g. replace just the copy button on assistant messages:
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
<CopilotChat
|
|
210
|
+
agentId="agent"
|
|
211
|
+
messageView={{
|
|
212
|
+
assistantMessage: {
|
|
213
|
+
copyButton: ({ onClick }) => <button onClick={onClick}>Copy</button>,
|
|
214
|
+
},
|
|
215
|
+
}}
|
|
216
|
+
/>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Local Development
|
|
220
|
+
|
|
221
|
+
The connection generator automatically configures `serve-local` integration:
|
|
222
|
+
|
|
223
|
+
1. Running `nx serve-local <website>` will also start the agent's local server
|
|
224
|
+
2. The runtime config is overridden to point to the local AG-UI URL (e.g. `http://localhost:8081`)
|
|
225
|
+
3. Both the website and the agent hot-reload together
|
|
226
|
+
|
|
227
|
+
<NxCommands commands={['serve-local <WebsiteProject>']} />
|
|
228
|
+
|
|
229
|
+
:::tip[Hot Reloading]
|
|
230
|
+
The website and connected agent hot-reload together, enabling you to quickly iterate on both sides without deploying to AWS.
|
|
231
|
+
:::
|
|
232
|
+
|
|
233
|
+
## More Information
|
|
234
|
+
|
|
235
|
+
- <Link path="guides/ts-agent">TypeScript Agent Guide</Link>
|
|
236
|
+
- <Link path="guides/py-agent">Python Agent Guide</Link>
|
|
237
|
+
- [AG-UI Protocol Documentation](https://docs.ag-ui.com/)
|
|
238
|
+
- [CopilotKit + AWS Strands Documentation](https://docs.copilotkit.ai/aws-strands)
|
|
239
|
+
- [CopilotKit Custom Look & Feel](https://docs.copilotkit.ai/aws-strands/custom-look-and-feel/slots)
|
|
240
|
+
- [Bedrock AgentCore Runtime](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/)
|