@amazon-devices/amazon-devices-buildertools-mcp 0.1.24 → 0.1.29

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/README.md CHANGED
@@ -12,15 +12,17 @@ A Model Context Protocol (MCP) server that provides context and tools for AI age
12
12
 
13
13
  The Amazon Devices Builder Tools MCP supports the following capabilities:
14
14
 
15
- | App Dev Area | Description | Example Prompts |
16
- |--------------|-------------|-----------------|
17
- | **Onboarding** | Onboard to Vega app development using AI agents with setup guidance and Q&A support | <ul><li>`Help me set up Vega app project and test my VPKG on Virtual Device?`</li><li>`Help me setup Vega SDK?`</li><li>`Build and run the app on Virtual device/Connected Device.`</li><li>`Can you tell me about vega app development?`</li><li>`What is the Vega CLI command for measuring cpu usage on a Vega device?`</li></ul> |
18
- | **Performance** | Debug and fix Time to First Frame (TTFF), Time to Fully Drawn (TTFD), and UI re-rendering issues | <ul><li>`Why is the TTFF higher for my Vega app?`</li><li>`Can you help me debug and fix Time to First Frame issue in my Vega app?`</li><li>`Why is the TTFD higher for my Vega app?`</li><li>`Can you help me minimize unnecessary re-renders in my app?`</li><li>`Find any re-rendering issues in my app.`</li></ul> |
19
- | **Performance Best Practices** | Analyze components and code to ensure they follow React Native Vega performance best practices | <ul><li>`Help me analyze if this component is following React Native Vega performance best practices`</li></ul> |
20
- | **Best Practices** | Validate manifest files and implement Vega components following best practices | <ul><li>`Can you help me upgrade my MovieCarousel.tsx from Carousel V1 to V2?`</li><li>`Can you help me implement Carousel?`</li><li>`Can you validate my manifest file and update as needed for my app?`</li></ul> |
21
- | **UI Development** | Create Vega app UI from screenshots and design mockups | <ul><li>`I have an image at {image_path}. Create a Vega app by creating a new folder using the sample template, update the sample test app to match the image, and confirm that the app can be built and run.`</li></ul> |
22
- | **Focus Management** | Implement D-Pad navigation and focus management for TV interfaces | <ul><li>`Can you create an app with 2 buttons to show case focus management?`</li></ul> |
23
- | **SDK & CLI** | Install/update SDK and efficiently run CLI tools via spec-driven CLI | <ul><li>`Install/update SDK from AI agents`</li><li>`Build my app`</li><li>`Run my app on virtual device`</li><li>`Run my app on physical device`</li><li>`Run KPI Visualizer and get performance results`</li></ul> |
15
+ | App Dev Area | Description | Example Prompts |
16
+ | ------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
17
+ | **Onboarding** | Onboard to Vega app development using AI agents with setup guidance and Q&A support | <ul><li>`Help me set up Vega app project and test my VPKG on Virtual Device?`</li><li>`Help me setup Vega SDK?`</li><li>`Build and run the app on Virtual device/Connected Device.`</li><li>`Can you tell me about vega app development?`</li><li>`What is the Vega CLI command for measuring cpu usage on a Vega device?`</li></ul> |
18
+ | **Performance** | Debug and fix Time to First Frame (TTFF), Time to Fully Drawn (TTFD), and UI re-rendering issues | <ul><li>`Why is the TTFF higher for my Vega app?`</li><li>`Can you help me debug and fix Time to First Frame issue in my Vega app?`</li><li>`Why is the TTFD higher for my Vega app?`</li><li>`Can you help me minimize unnecessary re-renders in my app?`</li><li>`Find any re-rendering issues in my app.`</li></ul> |
19
+ | **Performance Best Practices** | Analyze components and code to ensure they follow React Native Vega performance best practices | <ul><li>`Help me analyze if this component is following React Native Vega performance best practices`</li></ul> |
20
+ | **Best Practices** | Validate manifest files and implement Vega components following best practices | <ul><li>`Can you help me upgrade my MovieCarousel.tsx from Carousel V1 to V2?`</li><li>`Can you help me implement Carousel?`</li><li>`Can you validate my manifest file and update as needed for my app?`</li></ul> |
21
+ | **UI Development** | Create Vega app UI from screenshots and design mockups | <ul><li>`I have an image at {image_path}. Create a Vega app by creating a new folder using the sample template, update the sample test app to match the image, and confirm that the app can be built and run.`</li></ul> |
22
+ | **Focus Management** | Implement D-Pad navigation and focus management for TV interfaces | <ul><li>`Can you create an app with 2 buttons to show case focus management?`</li></ul> |
23
+ | **Give Feedback** | Provide feedback to Amazon about your experience with the MCP | <ul><li>`I want to provide feedback`</li><li>`How can I provide vega mcp feedback?`</li></ul> |
24
+ | **Crash Analysis** | Diagnose JavaScript, Native, LMK, and ANR crashes with automated ACR analysis | <ul><li>`Why did my app crash?`</li><li>`Help me analyze this ACR file /path/to/crash.acr`</li></ul> |
25
+ | **SDK & CLI** | Install/update SDK and efficiently run CLI tools via spec-driven CLI | <ul><li>`Install/update SDK from AI agents`</li><li>`Build my app`</li><li>`Run my app on virtual device`</li><li>`Run my app on physical device`</li><li>`Run KPI Visualizer and get performance results`</li></ul> |
24
26
 
25
27
  ## One-Click Installation
26
28
 
@@ -34,52 +36,96 @@ Some of the popular AI Agents support installing MCP servers with a single click
34
36
 
35
37
  [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=amazon-devices-buildertools-mcp&config=eyJjb21tYW5kIjoibnB4IC15IEBhbWF6b24tZGV2aWNlcy9hbWF6b24tZGV2aWNlcy1idWlsZGVydG9vbHMtbWNwQGxhdGVzdCJ9)
36
38
 
37
- ### Install MCP on VSCode
38
-
39
- [Add to VSCode](vscode:mcp/install?%7B%22name%22%3A%22amazon-devices-buildertools-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40amazon-devices%2Famazon-devices-buildertools-mcp%40latest%22%5D%7D)
40
-
41
-
42
39
  ## Installation with script
43
40
 
44
41
  Run the following command to **automatically** install Amazon Devices Builder Tools MCP in your AI Agent and add Vega-specific context document to your project to guide AI agents:
45
42
 
46
- > ℹ️ Important: It is important to run `npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest --init-context` to install the Vega-context document for your preferred AI agent in the project directory. This step is required even after one-click install of mcp.
43
+ > ℹ️ Important: It is important to run `npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest init-context` to install the Vega-context document for your preferred AI agent in the project directory. This step is required even after one-click install of mcp.
44
+
45
+ > ⚠️ **Deprecation Notice**: The `--init-context` flag is deprecated and will be removed in a future version. Please use the `init-context` subcommand instead.
47
46
 
48
47
  ```bash
48
+ # Recommended (new subcommand)
49
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest init-context
50
+
51
+ # Deprecated (will be removed)
49
52
  npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest --init-context
50
53
  ```
51
54
 
52
- This interactive command will:
55
+ This command supports both **interactive** and **non-interactive** modes:
56
+
57
+ **Interactive Mode (default):**
53
58
 
54
59
  1. **Display available AI agents** and their context file requirements
55
60
  2. **Let you select your preferred AI agent** from the supported list
56
- 3. **Update selected agent's MCP settings** to configure the Amazon Devices Builder Tools MCP server
61
+ 3. **Update selected agent's MCP settings** to configure the Amazon Devices Builder Tools MCP server
57
62
  4. **Ask for context installation directory** (defaults to current working directory)
58
63
  5. **Handle existing context files** by offering to merge or update content
59
64
  6. **Create the appropriate context file** in the correct location for your chosen AI agent
60
65
 
66
+ **Non-Interactive Mode:**
67
+ Use command-line options to skip prompts and automate the setup process.
68
+
69
+ ### Command Line Options
70
+
71
+ ```bash
72
+ init-context [options]
73
+
74
+ Options:
75
+ -a, --agent <type> Target AI agent (cursor, cline, kiro, claude-code-cli,
76
+ claude-code-desktop, github-copilot, amazon-q, other)
77
+ -p, --context-document-path Path to save context document
78
+ -d, --skip-context-document Skip context document installation (MCP config only)
79
+ -m, --skip-mcp-config Skip MCP configuration (context document only)
80
+ -f, --force Skip all confirmation prompts and force overwrite
81
+ -h, --help Show help for init-context command
82
+ ```
83
+
84
+ > ⚠️ **Note**: Command-line options are only supported with the `init-context` subcommand. The deprecated `--init-context` flag does not support these options.
85
+
61
86
  ### Example Usage
62
87
 
63
88
  ```bash
64
89
  # Navigate to your project directory
65
90
  cd my-vega-project
66
91
 
67
- # Initialize context for your AI agent
68
- npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest --init-context
92
+ # Interactive mode (default)
93
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest init-context
94
+
95
+ # Non-interactive with specific agent
96
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest init-context --agent cursor --force
97
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest init-context -a cursor -f
98
+
99
+ # MCP config only (skip context document)
100
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest init-context --agent cursor --skip-context-document
101
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest init-context -a cursor -d
102
+
103
+ # Context document only with custom path (skip MCP config)
104
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest init-context --agent kiro --context-document-path ./docs --skip-mcp-config
105
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest init-context -a kiro -p ./docs -m
106
+
107
+ # Show help
108
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest init-context --help
109
+ ```
110
+
111
+ ### Interactive Mode Prompts
112
+
113
+ When running in interactive mode, you'll be guided through:
114
+
115
+ # 1. Select your AI agent (e.g., "1" for Cursor, "6" for Kiro, "8" for Other/Custom)
69
116
 
70
- # Follow the interactive prompts:
71
- # 1. Select your AI agent (e.g., "5" for Kiro, "7" for Other/Custom)
72
117
  # 2. Enter y/n to automatically update Agent's MCP settings file
118
+
73
119
  # 3. Choose default context document installation path or enter custom path
120
+
74
121
  # 4. Choose action: merge, update or save file. Review the installed context document before proceeding.
75
- ```
76
122
 
77
123
  ### Using with Other AI Agents
78
124
 
79
125
  If your AI agent isn't in the supported list, select **"Other/Custom Agent"** which provides:
80
126
 
81
- - **View full content**: Display the complete context for manual copying
82
- - **Manual setup**: Copy the content to your agent's configuration directory
127
+ - **View full content**: Display the complete context for manual copying
128
+ - **Manual setup**: Copy the content to your agent's configuration directory
83
129
 
84
130
  > ℹ️ Important: Start the MCP Server from Agent's MCP config, if not already started - check your current running MCPs to ensure the amazon-devices-buildertools-mcp is listed as running/connected.
85
131
 
@@ -103,28 +149,73 @@ Below we list some popular AI agents and the link to how to install MCP servers.
103
149
  | --- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
104
150
  | 1 | Cursor | [Instructions](https://cursor.com/docs/context/mcp#using-mcpjson) |
105
151
  | 2 | Github Copilot | [Instructions](https://docs.github.com/en/copilot/how-tos/provide-context/use-mcp/extend-copilot-chat-with-mcp) then choose "Configuring MCP Servers Manually" |
106
- | 3 | Claude Code CLI | [Instructions](https://code.claude.com/docs/en/mcp#option-3%3A-add-a-local-stdio-server) |
107
- | 4 | Amazon Q IDE Extension | [Instructions](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/mcp-ide.html) |
108
- | 5 | Amazon Q CLI | [Instructions](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-mcp-config-CLI.html) |
109
- | 6 | Kiro | [Instructions](https://kiro.dev/docs/mcp/) |
110
- | 7 | Cline | [Instructions](https://docs.cline.bot/mcp/configuring-mcp-servers) |
152
+ | 3 | Claude Code | [Instructions](https://code.claude.com/docs/en/mcp#option-3%3A-add-a-local-stdio-server) |
153
+ | 4 | Claude Code Desktop | [Instructions](https://support.claude.com/en/articles/10949351-getting-started-with-local-mcp-servers-on-claude-desktop) |
154
+ | 5 | Amazon Q IDE Extension | [Instructions](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/mcp-ide.html) |
155
+ | 6 | Amazon Q CLI | [Instructions](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-mcp-config-CLI.html) |
156
+ | 7 | Kiro | [Instructions](https://kiro.dev/docs/mcp/) |
157
+ | 8 | Cline | [Instructions](https://docs.cline.bot/mcp/configuring-mcp-servers) |
111
158
 
112
159
  _If your agent is not listed, please ensure it supports MCP before continuing._
113
160
 
114
- > ℹ️ Important: Once configured, run `npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest --init-context` to install the Vega-context document for your preferred AI agent in the project directory
161
+ > ℹ️ Important: Once configured, run `npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest init-context` to install the Vega-context document for your preferred AI agent in the project directory
115
162
 
116
163
  ## Usage
117
164
 
118
165
  ### Command Line Options
119
166
 
120
167
  ```bash
121
- npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest --init-context # Install Amazon Devices Builder Tools MCP and initialize Vega context for AI agents
168
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest init-context # Install Amazon Devices Builder Tools MCP and initialize Vega context for AI agents
169
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest check-status # Check setup status of AI agents
122
170
  npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest --version # Show version information
123
171
  npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest -v # Show version information (alias)
124
172
  npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest --help # Show help message
125
173
  npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest -h # Show help message (alias)
126
174
  ```
127
175
 
176
+ ### Check Agent Setup Status
177
+
178
+ After installing the MCP server and context documents, you can verify your setup using the `check-status` command:
179
+
180
+ ```bash
181
+ # Check all agents
182
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest check-status
183
+
184
+ # Check specific agent
185
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest check-status --agent kiro
186
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest check-status -a cursor
187
+
188
+ # Show help
189
+ npx -y @amazon-devices/amazon-devices-buildertools-mcp@latest check-status --help
190
+ ```
191
+
192
+ **What it checks:**
193
+ - ✅ Context document installation status and version
194
+ - ✅ MCP configuration status
195
+ - ✅ Detection of legacy configurations
196
+ - ✅ Overall setup summary
197
+
198
+ **Example output:**
199
+
200
+ ```
201
+ ====================================================
202
+ 🔍 Checking Agent Setup Status
203
+ ====================================================
204
+
205
+ ─────────────────────────────────────────────────────────────────────────────
206
+ Agent │ Context Document │ MCP Configuration
207
+ ─────────────────────────────────────────────────────────────────────────────
208
+ Cursor │ ✅ v5.1 │ ✅ Configured
209
+ Kiro │ ✅ v5.1 │ ✅ Configured
210
+ ─────────────────────────────────────────────────────────────────────────────
211
+
212
+ 📊 Summary:
213
+ Total agents checked: 2
214
+ ✅ Fully configured: 2
215
+ ⚠️ Partially configured: 0
216
+ ❌ Not configured: 0
217
+ ```
218
+
128
219
  ### Verify Amazon Devices Builder Tools MCP is installed in your AI Agent
129
220
 
130
221
  In your AI Agent's chat interface, run the following prompt
@@ -136,8 +227,13 @@ List the tools provided by Amazon Devices Builder Tools MCP
136
227
  You should see a response that includes the following tools:
137
228
 
138
229
  - analyze_perfetto_traces
230
+ - get_app_hot_functions
139
231
  - read_document
140
232
  - list_documents
233
+ - search_documents
234
+ - execute_query
235
+ - get_database_schema
236
+ - read_asset
141
237
 
142
238
  ## MCP Tools
143
239
 
@@ -148,9 +244,11 @@ The Amazon Devices Builder Tools MCP provides the following tools to assist with
148
244
  Read documents related to App development for Amazon Vega OS. This tool provides access to comprehensive documentation about Vega app development and debugging topics.
149
245
 
150
246
  **Parameters:**
247
+
151
248
  - `document_name` (required): Name of the document to read (e.g., `react-native-for-vega-performance-best-practices.md`). Must be a markdown document with `.md` extension.
152
249
 
153
250
  **Example usage:**
251
+
154
252
  ```
155
253
  Read the document react-native-for-vega-performance-best-practices.md
156
254
  ```
@@ -160,13 +258,17 @@ Read the document react-native-for-vega-performance-best-practices.md
160
258
  List all available Vega documents related to App development for Amazon Vega OS. Returns name and description of available documents that can be retrieved using the `read_document` tool.
161
259
 
162
260
  **Parameters:**
261
+
163
262
  - `documentType` (optional): Filter documents by type. Valid values: `KB` (Knowledge Base), `PROMPT`, `STEERING`, `WORKFLOW`
164
263
 
165
264
  **Example usage:**
265
+
166
266
  ```
167
267
  List all available Vega documents
168
268
  ```
269
+
169
270
  or
271
+
170
272
  ```
171
273
  List documents of type KB
172
274
  ```
@@ -176,6 +278,7 @@ List documents of type KB
176
278
  Analyze Vega platform traces using Perfetto trace processor to extract KPI metrics and related performance data. This tool helps diagnose performance issues and analyze app launch times.
177
279
 
178
280
  **Parameters:**
281
+
179
282
  - `traceFilePath` (required): Path to the trace file to analyze. Usually found in Vega performance data output directories with names like `iter_*_vs_trace`
180
283
  - `queryType` (optional): Type of query to execute. Default: `kpi_analysis`
181
284
  - `kpiType` (optional): Specific KPI type to analyze. Options: `ttff` (Time to First Frame), `ttfd` (Time to First Display), `all`. Default: `all`
@@ -184,6 +287,7 @@ Analyze Vega platform traces using Perfetto trace processor to extract KPI metri
184
287
  - `appProcessName` (optional): Main application process name to analyze (will be auto-detected if not provided)
185
288
 
186
289
  **Example usage:**
290
+
187
291
  ```
188
292
  Analyze the trace file at /path/to/iter_1_vs_trace
189
293
  ```
@@ -193,6 +297,7 @@ Analyze the trace file at /path/to/iter_1_vs_trace
193
297
  Reads and analyzes CPU trace files to identify hot functions (CPU-intensive operations) contributing to performance bottlenecks. This tool helps pinpoint which functions in your application are consuming the most CPU time, enabling targeted performance optimization.
194
298
 
195
299
  **Parameters:**
300
+
196
301
  - `traceDataFilePath` (required): Path to the trace data file from the Activity Monitor. Usually found in Vega performance data output directories with names like `iter_<iteration>_trace<epoch>-converted.json` (e.g., `iter_2_trace1766067380670018106-converted.json`)
197
302
  - `limit` (optional): Maximum number of hot functions to return (default: 10)
198
303
  - `useSelfTime` (optional): Flag to indicate whether to use self CPU time or total CPU time for sorting (default: false)
@@ -201,15 +306,89 @@ Reads and analyzes CPU trace files to identify hot functions (CPU-intensive oper
201
306
  - `endOffsetSeconds` (optional): End time offset in seconds from trace beginning (e.g., 15.8 for analysis ending 15.8 seconds after trace start)
202
307
 
203
308
  **Example usage:**
309
+
204
310
  ```
205
311
  Analyze hot functions in the trace file at /path/to/iter_2_trace1766067380670018106-converted.json
206
312
  ```
207
313
 
208
314
  or with time window filtering:
315
+
209
316
  ```
210
317
  Analyze hot functions in /path/to/trace.json from 5 to 15 seconds with a limit of 20 functions
211
318
  ```
212
319
 
320
+ ### 5. `search_documents`
321
+
322
+ Search Vega development documentation using full-text search. Returns document IDs and relevant snippets matching the query. Use `read_document` with the returned ID to get full content.
323
+
324
+ **Parameters:**
325
+
326
+ - `query` (required): Search query string to find relevant documents
327
+ - `snippet_tokens` (optional): Maximum tokens in returned snippets (default: 32)
328
+
329
+ **Example usage:**
330
+
331
+ ```
332
+ Search for documents about "performance optimization"
333
+ ```
334
+
335
+ or with custom snippet length:
336
+
337
+ ```
338
+ Search for "React Native best practices" with 64 token snippets
339
+ ```
340
+
341
+ ### 6. `get_database_schema`
342
+
343
+ Get the schema for the Vega documentation database. Call this before using `execute_query` to understand available tables, columns, and FTS5 syntax.
344
+
345
+ **Parameters:** None
346
+
347
+ **Example usage:**
348
+
349
+ ```
350
+ Get the database schema for Vega documentation
351
+ ```
352
+
353
+ ### 7. `execute_query`
354
+
355
+ Execute a SQL query against the Vega documentation database. Use this tool for more complex queries when `search_documents` is insufficient. Use `get_database_schema` first to understand available tables and FTS5 syntax. The database is read-only.
356
+
357
+ **Parameters:**
358
+
359
+ - `sql_query` (required): SQL query to execute against the documentation database
360
+
361
+ **Example usage:**
362
+
363
+ ```
364
+ Execute query to search for "performance OR optimization" with custom snippets
365
+ ```
366
+
367
+ or with a specific SQL query:
368
+
369
+ ```
370
+ Execute query: SELECT dc.id, snippet(document_content_fts, 0, "<b>", "</b>", "...", 64) FROM document_content_fts JOIN document_content dc ON document_content_fts.rowid = dc.rowid WHERE document_content_fts MATCH "performance OR optimization" ORDER BY rank LIMIT 10
371
+ ```
372
+
373
+ ### 8. `read_asset`
374
+
375
+ Read assets referenced in Vega documentation. Assets are saved to a temporary location and the path is returned. Images can be viewed with
376
+ `fs_read` and scripts executed with the appropriate interpreter (e.g., `python3`)
377
+
378
+ **Parameters**
379
+ - `asset_id` (required): Path of the asset to read (e.g., `assets/scripts/example.py` or `assets/images/diagram.png`)
380
+
381
+ **Example usage:**
382
+ ```
383
+ Read the script assets/scripts/setup.sh and execute it
384
+ ```
385
+
386
+ or
387
+
388
+ ```
389
+ Read the image assets/images/architecture.png and describe what it shows
390
+ ```
391
+
213
392
  ## MCP Prompts
214
393
 
215
394
  > Check if your AI Agents supports MCP Prompts (`/prompts`) in https://modelcontextprotocol.io/clients
@@ -223,10 +402,12 @@ Amazon Devices Builder Tools MCP provides the following pre-defined prompt templ
223
402
  **Description:** Diagnose Vega application's Time to First Frame (TTFF) KPI
224
403
 
225
404
  **Parameters:**
405
+
226
406
  - `kpi_report_file_path` (required, string): Absolute path to the KPI report file
227
407
  - `kpi_to_diagnose` (required, string): Name of the KPI from KPI report to diagnose
228
408
 
229
409
  **Example usage:**
410
+
230
411
  ```
231
412
  > @diagnose_kpi_ttff /path/to/report.json ttff
232
413
  ```
@@ -236,10 +417,12 @@ Amazon Devices Builder Tools MCP provides the following pre-defined prompt templ
236
417
  **Description:** Diagnose Vega application's Time to Fully Drawn (TTFD) KPI
237
418
 
238
419
  **Parameters:**
420
+
239
421
  - `kpi_report_file_path` (required, string): Absolute path to the KPI report file
240
422
  - `kpi_to_diagnose` (required, string): Name of the KPI from KPI report to diagnose
241
423
 
242
424
  **Example usage:**
425
+
243
426
  ```
244
427
  > @diagnose_kpi_ttfd /path/to/report.json ttfd
245
428
  ```
@@ -249,9 +432,11 @@ Amazon Devices Builder Tools MCP provides the following pre-defined prompt templ
249
432
  **Description:** Diagnose and optimize React Native application performance issues including component rendering, memory management, navigation, network optimization, and state management.
250
433
 
251
434
  **Parameters:**
435
+
252
436
  - `app_source_path` (required, string): Path to the React Native application source code directory for analysis
253
437
 
254
438
  **Example usage:**
439
+
255
440
  ```
256
441
  > @apply_performance_best_practices /path/to/my-vega-app/src
257
442
  ```
@@ -261,9 +446,11 @@ Amazon Devices Builder Tools MCP provides the following pre-defined prompt templ
261
446
  **Description:** Diagnose and optimize Vega application UI fluidity performance issues caused by component re-rendering using React Native tools.
262
447
 
263
448
  **Parameters:**
449
+
264
450
  - `vega_app_package_path` (required, string): Absolute path to the Vega app package root directory
265
451
 
266
452
  **Example usage:**
453
+
267
454
  ```
268
455
  > @detect_component_re-renders /path/to/my-vega-app
269
456
  ```
@@ -273,11 +460,27 @@ Amazon Devices Builder Tools MCP provides the following pre-defined prompt templ
273
460
  **Description:** Assists in migrating to newer versions of the Carousel component in the Vega SDK.
274
461
 
275
462
  **Parameters:**
463
+
276
464
  - `current_implementation_file_path` (required, string): Absolute path to the file containing the V1 implementation of Carousel
277
465
  - `current_version` (required, string): The current version of Carousel, independent of package
278
466
  - `target_version` (required, string): The target version of Carousel, independent of package
279
467
 
280
468
  **Example usage:**
469
+
281
470
  ```
282
471
  > @upgrade_carousel_component /path/to/HomeScreen.tsx 1.0.6 2.0.0
283
472
  ```
473
+
474
+ ### 6. `diagnose_crash`
475
+
476
+ **Description:** Diagnose crashes in Vega applications including JavaScript, Native, LMK (Low Memory Killer), and ANR (Application Not Responding) crashes. Automatically discovers ACR files, symbolicates stack traces, and routes to the appropriate analysis workflow.
477
+
478
+ **Parameters:**
479
+
480
+ - `acr_file_path` (optional, string): Path to ACR file. If not provided, the tool will auto-discover ACR files from the device temp directory.
481
+
482
+ **Example usage:**
483
+
484
+ ```
485
+ > @diagnose_crash /path/to/crash.acr
486
+ ```
@@ -0,0 +1 @@
1
+ "use strict";exports.id=171,exports.ids=[171],exports.modules={5744:function(t,e,r){var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.UnauthorizedError=void 0,e.auth=async function(t,{serverUrl:e,authorizationCode:r}){const i=await c(e);let o=await Promise.resolve(t.clientInformation());if(!o){if(void 0!==r)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!t.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const n=await d(e,{metadata:i,clientMetadata:t.clientMetadata});await t.saveClientInformation(n),o=n}if(void 0!==r){const n=await t.codeVerifier(),s=await u(e,{metadata:i,clientInformation:o,authorizationCode:r,codeVerifier:n,redirectUri:t.redirectUrl});return await t.saveTokens(s),"AUTHORIZED"}const n=await t.tokens();if(null==n?void 0:n.refresh_token)try{const r=await h(e,{metadata:i,clientInformation:o,refreshToken:n.refresh_token});return await t.saveTokens(r),"AUTHORIZED"}catch(t){}const{authorizationUrl:s,codeVerifier:a}=await l(e,{metadata:i,clientInformation:o,redirectUrl:t.redirectUrl});return await t.saveCodeVerifier(a),await t.redirectToAuthorization(s),"REDIRECT"},e.discoverOAuthMetadata=c,e.startAuthorization=l,e.exchangeAuthorization=u,e.refreshAuthorization=h,e.registerClient=d;const o=i(r(70080)),n=r(72143),s=r(27570);class a extends Error{constructor(t){super(null!=t?t:"Unauthorized")}}async function c(t,e){var r;const i=new URL("/.well-known/oauth-authorization-server",t);let o;try{o=await fetch(i,{headers:{"MCP-Protocol-Version":null!==(r=null==e?void 0:e.protocolVersion)&&void 0!==r?r:n.LATEST_PROTOCOL_VERSION}})}catch(t){if(!(t instanceof TypeError))throw t;o=await fetch(i)}if(404!==o.status){if(!o.ok)throw new Error(`HTTP ${o.status} trying to load well-known OAuth metadata`);return s.OAuthMetadataSchema.parse(await o.json())}}async function l(t,{metadata:e,clientInformation:r,redirectUrl:i}){let n;if(e){if(n=new URL(e.authorization_endpoint),!e.response_types_supported.includes("code"))throw new Error("Incompatible auth server: does not support response type code");if(!e.code_challenge_methods_supported||!e.code_challenge_methods_supported.includes("S256"))throw new Error("Incompatible auth server: does not support code challenge method S256")}else n=new URL("/authorize",t);const s=await(0,o.default)(),a=s.code_verifier,c=s.code_challenge;return n.searchParams.set("response_type","code"),n.searchParams.set("client_id",r.client_id),n.searchParams.set("code_challenge",c),n.searchParams.set("code_challenge_method","S256"),n.searchParams.set("redirect_uri",String(i)),{authorizationUrl:n,codeVerifier:a}}async function u(t,{metadata:e,clientInformation:r,authorizationCode:i,codeVerifier:o,redirectUri:n}){const a="authorization_code";let c;if(e){if(c=new URL(e.token_endpoint),e.grant_types_supported&&!e.grant_types_supported.includes(a))throw new Error(`Incompatible auth server: does not support grant type ${a}`)}else c=new URL("/token",t);const l=new URLSearchParams({grant_type:a,client_id:r.client_id,code:i,code_verifier:o,redirect_uri:String(n)});r.client_secret&&l.set("client_secret",r.client_secret);const u=await fetch(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:l});if(!u.ok)throw new Error(`Token exchange failed: HTTP ${u.status}`);return s.OAuthTokensSchema.parse(await u.json())}async function h(t,{metadata:e,clientInformation:r,refreshToken:i}){let o;if(e){if(o=new URL(e.token_endpoint),e.grant_types_supported&&!e.grant_types_supported.includes("refresh_token"))throw new Error("Incompatible auth server: does not support grant type refresh_token")}else o=new URL("/token",t);const n=new URLSearchParams({grant_type:"refresh_token",client_id:r.client_id,refresh_token:i});r.client_secret&&n.set("client_secret",r.client_secret);const a=await fetch(o,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n});if(!a.ok)throw new Error(`Token refresh failed: HTTP ${a.status}`);return s.OAuthTokensSchema.parse(await a.json())}async function d(t,{metadata:e,clientMetadata:r}){let i;if(e){if(!e.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");i=new URL(e.registration_endpoint)}else i=new URL("/register",t);const o=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok)throw new Error(`Dynamic client registration failed: HTTP ${o.status}`);return s.OAuthClientInformationFullSchema.parse(await o.json())}e.UnauthorizedError=a},27570:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OAuthTokenRevocationRequestSchema=e.OAuthClientRegistrationErrorSchema=e.OAuthClientInformationFullSchema=e.OAuthClientInformationSchema=e.OAuthClientMetadataSchema=e.OAuthErrorResponseSchema=e.OAuthTokensSchema=e.OAuthMetadataSchema=void 0;const i=r(68547);e.OAuthMetadataSchema=i.z.object({issuer:i.z.string(),authorization_endpoint:i.z.string(),token_endpoint:i.z.string(),registration_endpoint:i.z.string().optional(),scopes_supported:i.z.array(i.z.string()).optional(),response_types_supported:i.z.array(i.z.string()),response_modes_supported:i.z.array(i.z.string()).optional(),grant_types_supported:i.z.array(i.z.string()).optional(),token_endpoint_auth_methods_supported:i.z.array(i.z.string()).optional(),token_endpoint_auth_signing_alg_values_supported:i.z.array(i.z.string()).optional(),service_documentation:i.z.string().optional(),revocation_endpoint:i.z.string().optional(),revocation_endpoint_auth_methods_supported:i.z.array(i.z.string()).optional(),revocation_endpoint_auth_signing_alg_values_supported:i.z.array(i.z.string()).optional(),introspection_endpoint:i.z.string().optional(),introspection_endpoint_auth_methods_supported:i.z.array(i.z.string()).optional(),introspection_endpoint_auth_signing_alg_values_supported:i.z.array(i.z.string()).optional(),code_challenge_methods_supported:i.z.array(i.z.string()).optional()}).passthrough(),e.OAuthTokensSchema=i.z.object({access_token:i.z.string(),token_type:i.z.string(),expires_in:i.z.number().optional(),scope:i.z.string().optional(),refresh_token:i.z.string().optional()}).strip(),e.OAuthErrorResponseSchema=i.z.object({error:i.z.string(),error_description:i.z.string().optional(),error_uri:i.z.string().optional()}),e.OAuthClientMetadataSchema=i.z.object({redirect_uris:i.z.array(i.z.string()).refine((t=>t.every((t=>URL.canParse(t)))),{message:"redirect_uris must contain valid URLs"}),token_endpoint_auth_method:i.z.string().optional(),grant_types:i.z.array(i.z.string()).optional(),response_types:i.z.array(i.z.string()).optional(),client_name:i.z.string().optional(),client_uri:i.z.string().optional(),logo_uri:i.z.string().optional(),scope:i.z.string().optional(),contacts:i.z.array(i.z.string()).optional(),tos_uri:i.z.string().optional(),policy_uri:i.z.string().optional(),jwks_uri:i.z.string().optional(),jwks:i.z.any().optional(),software_id:i.z.string().optional(),software_version:i.z.string().optional()}).strip(),e.OAuthClientInformationSchema=i.z.object({client_id:i.z.string(),client_secret:i.z.string().optional(),client_id_issued_at:i.z.number().optional(),client_secret_expires_at:i.z.number().optional()}).strip(),e.OAuthClientInformationFullSchema=e.OAuthClientMetadataSchema.merge(e.OAuthClientInformationSchema),e.OAuthClientRegistrationErrorSchema=i.z.object({error:i.z.string(),error_description:i.z.string().optional()}).strip(),e.OAuthTokenRevocationRequestSchema=i.z.object({token:i.z.string(),token_type_hint:i.z.string().optional()}).strip()},33205:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});var i=r(93119);class o extends TransformStream{constructor({onError:t,onRetry:e,onComment:r}={}){let o;super({start(n){o=i.createParser({onEvent:t=>{n.enqueue(t)},onError(e){"terminate"===t?n.error(e):"function"==typeof t&&t(e)},onRetry:e,onComment:r})},transform(t){o.feed(t)}})}}e.ParseError=i.ParseError,e.EventSourceParserStream=o},41268:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Client=void 0;const i=r(42312),o=r(72143);class n extends i.Protocol{constructor(t,e){var r;super(e),this._clientInfo=t,this._capabilities=null!==(r=null==e?void 0:e.capabilities)&&void 0!==r?r:{}}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=(0,i.mergeCapabilities)(this._capabilities,t)}assertCapability(t,e){var r;if(!(null===(r=this._serverCapabilities)||void 0===r?void 0:r[t]))throw new Error(`Server does not support ${t} (required for ${e})`)}async connect(t,e){if(await super.connect(t),void 0===t.sessionId)try{const t=await this.request({method:"initialize",params:{protocolVersion:o.LATEST_PROTOCOL_VERSION,capabilities:this._capabilities,clientInfo:this._clientInfo}},o.InitializeResultSchema,e);if(void 0===t)throw new Error(`Server sent invalid initialize result: ${t}`);if(!o.SUPPORTED_PROTOCOL_VERSIONS.includes(t.protocolVersion))throw new Error(`Server's protocol version is not supported: ${t.protocolVersion}`);this._serverCapabilities=t.capabilities,this._serverVersion=t.serverInfo,this._instructions=t.instructions,await this.notification({method:"notifications/initialized"})}catch(t){throw this.close(),t}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(t){var e,r,i,o,n;switch(t){case"logging/setLevel":if(!(null===(e=this._serverCapabilities)||void 0===e?void 0:e.logging))throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!(null===(r=this._serverCapabilities)||void 0===r?void 0:r.prompts))throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(null===(i=this._serverCapabilities)||void 0===i?void 0:i.resources))throw new Error(`Server does not support resources (required for ${t})`);if("resources/subscribe"===t&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${t})`);break;case"tools/call":case"tools/list":if(!(null===(o=this._serverCapabilities)||void 0===o?void 0:o.tools))throw new Error(`Server does not support tools (required for ${t})`);break;case"completion/complete":if(!(null===(n=this._serverCapabilities)||void 0===n?void 0:n.completions))throw new Error(`Server does not support completions (required for ${t})`)}}assertNotificationCapability(t){var e;if("notifications/roots/list_changed"===t&&!(null===(e=this._capabilities.roots)||void 0===e?void 0:e.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${t})`)}assertRequestHandlerCapability(t){switch(t){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${t})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${t})`)}}async ping(t){return this.request({method:"ping"},o.EmptyResultSchema,t)}async complete(t,e){return this.request({method:"completion/complete",params:t},o.CompleteResultSchema,e)}async setLoggingLevel(t,e){return this.request({method:"logging/setLevel",params:{level:t}},o.EmptyResultSchema,e)}async getPrompt(t,e){return this.request({method:"prompts/get",params:t},o.GetPromptResultSchema,e)}async listPrompts(t,e){return this.request({method:"prompts/list",params:t},o.ListPromptsResultSchema,e)}async listResources(t,e){return this.request({method:"resources/list",params:t},o.ListResourcesResultSchema,e)}async listResourceTemplates(t,e){return this.request({method:"resources/templates/list",params:t},o.ListResourceTemplatesResultSchema,e)}async readResource(t,e){return this.request({method:"resources/read",params:t},o.ReadResourceResultSchema,e)}async subscribeResource(t,e){return this.request({method:"resources/subscribe",params:t},o.EmptyResultSchema,e)}async unsubscribeResource(t,e){return this.request({method:"resources/unsubscribe",params:t},o.EmptyResultSchema,e)}async callTool(t,e=o.CallToolResultSchema,r){return this.request({method:"tools/call",params:t},e,r)}async listTools(t,e){return this.request({method:"tools/list",params:t},o.ListToolsResultSchema,e)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}e.Client=n},42171:(t,e,r)=>{e.MCPRemoteEndpointClient=void 0;const i=r(41268),o=r(60922),n=r(81747),s=r(22982);var a;!function(t){t.CLOSED="CLOSED",t.OPEN="OPEN",t.HALF_OPEN="HALF_OPEN"}(a||(a={}));e.MCPRemoteEndpointClient=class{constructor(t){this.circuitState=a.CLOSED,this.consecutiveFailures=0,this.circuitOpenedAt=0,this.activeRequests=0,this.requestQueue=[],this.endpointUrl=t.endpointUrl,this.onRetry=t.onRetry,this.onCircuitStateChange=t.onCircuitStateChange}async healthCheck(){try{const t=await this.getClient();await t.listTools(),(0,s.getLogger)().info("Remote endpoint health check passed",{url:this.endpointUrl})}catch(t){(0,s.getLogger)().warn("Remote endpoint health check failed, circuit breaker starting open",{url:this.endpointUrl,error:t instanceof Error?t.message:String(t)}),this.transitionCircuit(a.OPEN,"health_check_failure")}}async invoke(t){if(this.circuitState===a.OPEN){if(!(Date.now()-this.circuitOpenedAt>=n.CIRCUIT_BREAKER_COOLDOWN_MS))throw new n.RemoteEndpointError("Circuit breaker is open",this.endpointUrl,"circuit_open",0);this.transitionCircuit(a.HALF_OPEN,"cooldown_expired")}await this.acquireSlot();try{return await this.invokeWithRetry(t)}finally{this.releaseSlot()}}async dispose(){if(this.client){try{await this.client.close()}catch{}this.client=void 0,this.connecting=void 0}}async invokeWithRetry(t){var e;const r=Date.now()+n.TOTAL_TIMEOUT_MS;let i;for(let o=1;o<=n.MAX_RETRY_ATTEMPTS;o++){const a=r-Date.now();if(a<=0)break;const c=Date.now();try{const e=await this.getClient(),r=await Promise.race([e.callTool({name:t.operation,arguments:t.params}),this.timeoutPromise(a)]);return this.onSuccess(),{data:this.extractContent(r)}}catch(t){const a=Date.now()-c,l=this.classifyError(t);if(i=t instanceof Error?t:new Error(String(t)),"network"===l||"timeout"===l){const t=this.client;this.client=void 0,this.connecting=void 0,Promise.resolve(null==t?void 0:t.close()).catch((()=>{}))}if(null===(e=this.onRetry)||void 0===e||e.call(this,{attemptNumber:o,latencyMs:a,errorType:l,remainingBudgetMs:Math.max(0,r-Date.now())}),(0,s.getLogger)().debug("Remote endpoint retry",{attempt:o,errorType:l,latencyMs:a,remainingBudgetMs:Math.max(0,r-Date.now())}),o===n.MAX_RETRY_ATTEMPTS)break;const u=Math.min(200*Math.pow(2,o-1),Math.max(0,r-Date.now()));u>0&&await this.sleep(u)}}this.onFailure();const o=n.TOTAL_TIMEOUT_MS-Math.max(0,r-Date.now());throw new n.RemoteEndpointError(`Remote operation '${t.operation}' failed after ${n.MAX_RETRY_ATTEMPTS} attempts`,this.endpointUrl,this.classifyError(i),o,i)}async getClient(){if(this.client)return this.client;if(this.connecting)return this.connecting;this.connecting=this.createClient();try{return this.client=await this.connecting,this.client}catch(t){throw this.connecting=void 0,t}}async createClient(){const t=new o.StreamableHTTPClientTransport(new URL(this.endpointUrl)),e=new i.Client({name:"amazon-devices-buildertools-mcp",version:"0.1.0"});return await e.connect(t),e}extractContent(t){if(t&&"object"==typeof t&&"content"in t){const e=t.content;if(Array.isArray(e)&&e.length>0&&e[0].text)return e[0].text}return t}classifyError(t){if(!t)return"unknown";const e=t instanceof Error?t.message:String(t);return e.includes("timeout")||e.includes("TIMEOUT")?"timeout":e.includes("ECONNREFUSED")||e.includes("ENOTFOUND")||e.includes("fetch failed")?"network":e.includes("401")||e.includes("403")||e.includes("Unauthorized")||e.includes("Forbidden")?"auth":e.includes("429")||/\b[45]\d{2}\b/.test(e)?"http":"network"}timeoutPromise(t){return new Promise(((e,r)=>setTimeout((()=>r(new Error("timeout"))),t)))}sleep(t){return new Promise((e=>setTimeout(e,t)))}onSuccess(){this.consecutiveFailures=0,this.circuitState===a.HALF_OPEN&&this.transitionCircuit(a.CLOSED,"probe_success")}onFailure(){this.consecutiveFailures++,this.circuitState===a.HALF_OPEN?this.transitionCircuit(a.OPEN,"probe_failure"):this.consecutiveFailures>=n.CIRCUIT_BREAKER_THRESHOLD&&this.transitionCircuit(a.OPEN,`consecutive_failures_${this.consecutiveFailures}`)}transitionCircuit(t,e){var r;const i=this.circuitState;this.circuitState=t,t===a.OPEN&&(this.circuitOpenedAt=Date.now()),(0,s.getLogger)().warn("Circuit breaker state change",{previousState:i,newState:t,trigger:e}),null===(r=this.onCircuitStateChange)||void 0===r||r.call(this,{previousState:i,newState:t,trigger:e})}async acquireSlot(){if(!(this.activeRequests<n.MAX_CONCURRENT_REQUESTS))return new Promise((t=>{this.requestQueue.push({resolve:()=>{this.activeRequests++,t()}})}));this.activeRequests++}releaseSlot(){this.activeRequests--;const t=this.requestQueue.shift();t&&t.resolve()}}},60922:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StreamableHTTPClientTransport=e.StreamableHTTPError=void 0;const i=r(72143),o=r(5744),n=r(33205),s={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class a extends Error{constructor(t,e){super(`Streamable HTTP error: ${e}`),this.code=t}}e.StreamableHTTPError=a;e.StreamableHTTPClientTransport=class{constructor(t,e){var r;this._url=t,this._requestInit=null==e?void 0:e.requestInit,this._authProvider=null==e?void 0:e.authProvider,this._sessionId=null==e?void 0:e.sessionId,this._reconnectionOptions=null!==(r=null==e?void 0:e.reconnectionOptions)&&void 0!==r?r:s}async _authThenStart(){var t;if(!this._authProvider)throw new o.UnauthorizedError("No auth provider");let e;try{e=await(0,o.auth)(this._authProvider,{serverUrl:this._url})}catch(e){throw null===(t=this.onerror)||void 0===t||t.call(this,e),e}if("AUTHORIZED"!==e)throw new o.UnauthorizedError;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var t;const e={};if(this._authProvider){const t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}return this._sessionId&&(e["mcp-session-id"]=this._sessionId),new Headers({...e,...null===(t=this._requestInit)||void 0===t?void 0:t.headers})}async _startOrAuthSse(t){var e,r;const{resumptionToken:i}=t;try{const r=await this._commonHeaders();r.set("Accept","text/event-stream"),i&&r.set("last-event-id",i);const o=await fetch(this._url,{method:"GET",headers:r,signal:null===(e=this._abortController)||void 0===e?void 0:e.signal});if(!o.ok){if(401===o.status&&this._authProvider)return await this._authThenStart();if(405===o.status)return;throw new a(o.status,`Failed to open SSE stream: ${o.statusText}`)}this._handleSseStream(o.body,t)}catch(t){throw null===(r=this.onerror)||void 0===r||r.call(this,t),t}}_getNextReconnectionDelay(t){const e=this._reconnectionOptions.initialReconnectionDelay,r=this._reconnectionOptions.reconnectionDelayGrowFactor,i=this._reconnectionOptions.maxReconnectionDelay;return Math.min(e*Math.pow(r,t),i)}_scheduleReconnection(t,e=0){var r;const i=this._reconnectionOptions.maxRetries;if(i>0&&e>=i)return void(null===(r=this.onerror)||void 0===r||r.call(this,new Error(`Maximum reconnection attempts (${i}) exceeded.`)));const o=this._getNextReconnectionDelay(e);setTimeout((()=>{this._startOrAuthSse(t).catch((r=>{var i;null===(i=this.onerror)||void 0===i||i.call(this,new Error(`Failed to reconnect SSE stream: ${r instanceof Error?r.message:String(r)}`)),this._scheduleReconnection(t,e+1)}))}),o)}_handleSseStream(t,e){if(!t)return;const{onresumptiontoken:r,replayMessageId:o}=e;let s;(async()=>{var e,a,c,l;try{const c=t.pipeThrough(new TextDecoderStream).pipeThrough(new n.EventSourceParserStream).getReader();for(;;){const{value:t,done:n}=await c.read();if(n)break;if(t.id&&(s=t.id,null==r||r(t.id)),!t.event||"message"===t.event)try{const r=i.JSONRPCMessageSchema.parse(JSON.parse(t.data));void 0!==o&&(0,i.isJSONRPCResponse)(r)&&(r.id=o),null===(e=this.onmessage)||void 0===e||e.call(this,r)}catch(t){null===(a=this.onerror)||void 0===a||a.call(this,t)}}}catch(t){if(null===(c=this.onerror)||void 0===c||c.call(this,new Error(`SSE stream disconnected: ${t}`)),this._abortController&&!this._abortController.signal.aborted&&void 0!==s)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:o},0)}catch(t){null===(l=this.onerror)||void 0===l||l.call(this,new Error(`Failed to reconnect: ${t instanceof Error?t.message:String(t)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new o.UnauthorizedError("No auth provider");if("AUTHORIZED"!==await(0,o.auth)(this._authProvider,{serverUrl:this._url,authorizationCode:t}))throw new o.UnauthorizedError("Failed to authorize")}async close(){var t,e;null===(t=this._abortController)||void 0===t||t.abort(),null===(e=this.onclose)||void 0===e||e.call(this)}async send(t,e){var r,n,s;try{const{resumptionToken:s,onresumptiontoken:c}=e||{};if(s)return void this._startOrAuthSse({resumptionToken:s,replayMessageId:(0,i.isJSONRPCRequest)(t)?t.id:void 0}).catch((t=>{var e;return null===(e=this.onerror)||void 0===e?void 0:e.call(this,t)}));const l=await this._commonHeaders();l.set("content-type","application/json"),l.set("accept","application/json, text/event-stream");const u={...this._requestInit,method:"POST",headers:l,body:JSON.stringify(t),signal:null===(r=this._abortController)||void 0===r?void 0:r.signal},h=await fetch(this._url,u),d=h.headers.get("mcp-session-id");if(d&&(this._sessionId=d),!h.ok){if(401===h.status&&this._authProvider){if("AUTHORIZED"!==await(0,o.auth)(this._authProvider,{serverUrl:this._url}))throw new o.UnauthorizedError;return this.send(t)}const e=await h.text().catch((()=>null));throw new Error(`Error POSTing to endpoint (HTTP ${h.status}): ${e}`)}if(202===h.status)return void((0,i.isInitializedNotification)(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch((t=>{var e;return null===(e=this.onerror)||void 0===e?void 0:e.call(this,t)})));const p=(Array.isArray(t)?t:[t]).filter((t=>"method"in t&&"id"in t&&void 0!==t.id)).length>0,m=h.headers.get("content-type");if(p)if(null==m?void 0:m.includes("text/event-stream"))this._handleSseStream(h.body,{onresumptiontoken:c});else{if(!(null==m?void 0:m.includes("application/json")))throw new a(-1,`Unexpected content type: ${m}`);{const t=await h.json(),e=Array.isArray(t)?t.map((t=>i.JSONRPCMessageSchema.parse(t))):[i.JSONRPCMessageSchema.parse(t)];for(const t of e)null===(n=this.onmessage)||void 0===n||n.call(this,t)}}}catch(t){throw null===(s=this.onerror)||void 0===s||s.call(this,t),t}}get sessionId(){return this._sessionId}async terminateSession(){var t,e;if(this._sessionId)try{const e=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:e,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},i=await fetch(this._url,r);if(!i.ok&&405!==i.status)throw new a(i.status,`Failed to terminate session: ${i.statusText}`);this._sessionId=void 0}catch(t){throw null===(e=this.onerror)||void 0===e||e.call(this,t),t}}}},70080:(t,e,r)=>{let i;async function o(t){return(await i).getRandomValues(new Uint8Array(t))}async function n(t){const e=await(await i).subtle.digest("SHA-256",(new TextEncoder).encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}Object.defineProperty(e,"__esModule",{value:!0}),e.generateChallenge=n,e.default=async function(t){t||(t=43);if(t<43||t>128)throw`Expected a length between 43 and 128. Received ${t}.`;const e=await async function(t){return await async function(t){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%e.length;let i="";for(;i.length<t;){const n=await o(t-i.length);for(const t of n)t<r&&(i+=e[t%e.length])}return i}(t)}(t),r=await n(e);return{code_verifier:e,code_challenge:r}},e.verifyChallenge=async function(t,e){return await n(t)===e},i=globalThis.crypto?.webcrypto??globalThis.crypto??Promise.resolve().then(r.t.bind(r,77598,23)).then((t=>t.webcrypto))},93119:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=Object.defineProperty,i=(t,e,i)=>((t,e,i)=>e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i);class o extends Error{constructor(t,e){super(t),i(this,"type"),i(this,"field"),i(this,"value"),i(this,"line"),this.name="ParseError",this.type=e.type,this.field=e.field,this.value=e.value,this.line=e.line}}function n(t){}e.ParseError=o,e.createParser=function(t){const{onEvent:e=n,onError:r=n,onRetry:i=n,onComment:s}=t;let a,c="",l=!0,u="",h="";function d(t){if(""===t)return u.length>0&&e({id:a,event:h||void 0,data:u.endsWith("\n")?u.slice(0,-1):u}),a=void 0,u="",void(h="");if(t.startsWith(":"))return void(s&&s(t.slice(t.startsWith(": ")?2:1)));const r=t.indexOf(":");if(-1===r)p(t,"",t);else{const e=t.slice(0,r),i=" "===t[r+1]?2:1;p(e,t.slice(r+i),t)}}function p(t,e,n){switch(t){case"event":h=e;break;case"data":u=`${u}${e}\n`;break;case"id":a=e.includes("\0")?void 0:e;break;case"retry":/^\d+$/.test(e)?i(parseInt(e,10)):r(new o(`Invalid \`retry\` value: "${e}"`,{type:"invalid-retry",value:e,line:n}));break;default:r(new o(`Unknown field "${t.length>20?`${t.slice(0,20)}…`:t}"`,{type:"unknown-field",field:t,value:e,line:n}))}}return{feed:function(t){const e=l?t.replace(/^\xEF\xBB\xBF/,""):t,[r,i]=function(t){const e=[];let r="";const i=t.length;for(let o=0;o<i;o++){const i=t[o];"\r"===i&&"\n"===t[o+1]?(e.push(r),r="",o++):"\r"===i||"\n"===i?(e.push(r),r=""):r+=i}return[e,r]}(`${c}${e}`);for(const t of r)d(t);c=i,l=!1},reset:function(t={}){c&&t.consume&&d(c),a=void 0,u="",h="",c=""}}}}};