You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/a2ui-in-mcp-apps.md
+23-18Lines changed: 23 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -104,24 +104,29 @@ MCP Apps are typically delivered as a single HTML resource from the MCP Server.
104
104
2. Use a post-build script (like the [`inline.js`](https://github.com/google/A2UI/blob/main/samples/mcp/a2ui-in-mcpapps/server/apps/src/inline.js) script in the sample) to read the `index.html` and replace external `<script src="...">` and `<link rel="stylesheet" href="...">` tags with inline `<script>` and `<style>` tags containing the actual file contents.
105
105
3. This produces a self-contained HTML file that can be safely loaded via `srcdoc` in the restricted iframe.
106
106
107
-
!!! tip "Using Vite to inline "
108
-
If your project uses Vite (common for React, Vue, or Lit), you can achieve the same single-file output automatically using plugins like `vite-plugin-singlefile`. This eliminates the need for a custom post-build script by handling the inlining during the build process itself.
109
-
110
-
**How to use it:**
111
-
1. **Install the plugin**:
112
-
```bash
113
-
npm install -D vite-plugin-singlefile
114
-
```
115
-
2. **Configure Vite**: Add the plugin to your `vite.config.ts` (or `.js`):
116
-
```typescript
117
-
import { defineConfig } from 'vite'
118
-
import { viteSingleFile } from 'vite-plugin-singlefile'
119
-
120
-
export default defineConfig({
121
-
plugins: [viteSingleFile()],
122
-
})
123
-
```
124
-
This will ensure that all JS and CSS assets are inlined into the `index.html` file on build, making it ready to be served by your MCP server as a single resource.
107
+
> [!TIP]
108
+
> **Using Vite to inline**
109
+
>
110
+
> If your project uses Vite (common for React, Vue, or Lit), you can achieve the same single-file output automatically using plugins like `vite-plugin-singlefile`. This eliminates the need for a custom post-build script by handling the inlining during the build process itself.
111
+
>
112
+
> **How to use it:**
113
+
>
114
+
> 1.**Install the plugin**:
115
+
> ```bash
116
+
> npm install -D vite-plugin-singlefile
117
+
>```
118
+
> 2. **Configure Vite**: Add the plugin to your `vite.config.ts` (or `.js`):
119
+
>
120
+
>```typescript
121
+
> import {defineConfig} from 'vite';
122
+
> import {viteSingleFile} from 'vite-plugin-singlefile';
123
+
>
124
+
>export default defineConfig({
125
+
> plugins: [viteSingleFile()],
126
+
> });
127
+
>```
128
+
>
129
+
> This will ensure that all JS and CSS assets are inlined into the `index.html` file on build, making it ready to be served by your MCP server as a single resource.
- Command: `npm install && npm run dev` (requires building the Lit renderer first)
151
-
- URL: `http://localhost:5173/`
145
+
#### Step 1: Start the Agent
152
146
153
-
**What to expect**: A simple interface loading the MCP App, with a button to trigger an action handled by the agent.
154
-
155
-
### 2. MCP Apps (Calculator + Pong) (Angular)
156
-
157
-
#### Step 3: Open in Browser
158
-
159
-
Open your browser and navigate to `http://localhost:5173`. You should see the A2UI interface loading the MCP App.
160
-
161
-
**What to expect**: A page loading the MCP App in a sandboxed iframe. Clicking the "Call Agent Tool" button inside the iframe will trigger an action that is handled by the agent.
This sample verifies the sandbox with an Angular-based client, an MCP Proxy Agent, and a remote MCP Server. It requires **three** backend processes.
168
-
169
-
#### Step 1: Start the MCP Server (Calculator)
147
+
In a separate terminal, navigate to the agent directory and start the agent:
170
148
171
149
```bash
172
-
cd samples/mcp/mcp-apps-calculator/
173
-
uv run .
150
+
cd samples/agent/adk/mcp-apps-in-a2ui-sample
151
+
uv run agent.py
174
152
```
175
153
176
-
=======
154
+
The agent will run on `http://localhost:8000`.
155
+
156
+
#### Step 2: Start the Client
157
+
158
+
In a new terminal, navigate to the client directory and start the dev server (requires building the Lit renderer first):
177
159
178
160
```bash
179
161
cd samples/client/lit/mcp-apps-in-a2ui-sample
@@ -183,20 +165,9 @@ npm run dev
183
165
184
166
The client starts at `http://localhost:5173/`.
185
167
186
-
#### Step 2: Start the Agent
187
-
188
-
In a separate terminal, navigate to the agent directory and start the agent:
189
-
190
-
```bash
191
-
cd samples/agent/adk/mcp-apps-in-a2ui-sample
192
-
uv run agent.py
193
-
```
194
-
195
-
The agent will run on `http://localhost:8000`.
196
-
197
168
#### Step 3: Open in Browser
198
169
199
-
Open your browser and navigate to `http://localhost:5173`. You should see the A2UI interface loading the MCP App.
170
+
Open your browser and navigate to `http://localhost:5173/`. You should see the A2UI interface loading the MCP App.
200
171
201
172
**What to expect**: A page loading the MCP App in a sandboxed iframe. Clicking the "Call Agent Tool" button inside the iframe will trigger an action that is handled by the agent.
202
173
@@ -213,8 +184,6 @@ cd samples/mcp/mcp-apps-calculator/
0 commit comments