@_davideast/stitch-mcp 0.3.2 → 0.5.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.
Files changed (214) hide show
  1. package/README.md +54 -239
  2. package/dist/chunk-25wakzyb.js +137 -0
  3. package/dist/chunk-25wakzyb.js.map +10 -0
  4. package/dist/chunk-2cetsfw4.js +16531 -0
  5. package/dist/chunk-2cetsfw4.js.map +95 -0
  6. package/dist/chunk-2fcdwvrm.js +54 -0
  7. package/dist/chunk-2fcdwvrm.js.map +10 -0
  8. package/dist/chunk-2k7n0w2x.js +3980 -0
  9. package/dist/chunk-2k7n0w2x.js.map +16 -0
  10. package/dist/chunk-2kyqsrg2.js +403 -0
  11. package/dist/chunk-2kyqsrg2.js.map +10 -0
  12. package/dist/chunk-384jmtpy.js +11057 -0
  13. package/dist/chunk-384jmtpy.js.map +238 -0
  14. package/dist/chunk-3at4pjgn.js +22 -0
  15. package/dist/chunk-3at4pjgn.js.map +9 -0
  16. package/dist/chunk-3sfn889r.js +492 -0
  17. package/dist/chunk-3sfn889r.js.map +13 -0
  18. package/dist/chunk-45wx7tn7.js +94 -0
  19. package/dist/chunk-45wx7tn7.js.map +10 -0
  20. package/dist/chunk-48d17n29.js +10 -0
  21. package/dist/chunk-48d17n29.js.map +9 -0
  22. package/dist/chunk-4jwmvjb4.js +839 -0
  23. package/dist/chunk-4jwmvjb4.js.map +11 -0
  24. package/dist/chunk-4jygt4d6.js +14 -0
  25. package/dist/chunk-4jygt4d6.js.map +10 -0
  26. package/dist/chunk-4vxy1qce.js +68 -0
  27. package/dist/chunk-4vxy1qce.js.map +10 -0
  28. package/dist/chunk-7tx0wn04.js +11 -0
  29. package/dist/chunk-7tx0wn04.js.map +9 -0
  30. package/dist/chunk-7xh1y383.js +45188 -0
  31. package/dist/chunk-7xh1y383.js.map +258 -0
  32. package/dist/chunk-8yrtq2qs.js +18 -0
  33. package/dist/chunk-8yrtq2qs.js.map +9 -0
  34. package/dist/chunk-985f11w6.js +21 -0
  35. package/dist/chunk-985f11w6.js.map +9 -0
  36. package/dist/chunk-9tvppjaf.js +250 -0
  37. package/dist/chunk-9tvppjaf.js.map +14 -0
  38. package/dist/chunk-9wyra8hs.js +32 -0
  39. package/dist/chunk-9wyra8hs.js.map +9 -0
  40. package/dist/chunk-cwkb2wbe.js +733 -0
  41. package/dist/chunk-cwkb2wbe.js.map +16 -0
  42. package/dist/chunk-djhzzcgj.js +362 -0
  43. package/dist/chunk-djhzzcgj.js.map +13 -0
  44. package/dist/chunk-edp6faw2.js +7 -0
  45. package/dist/chunk-edp6faw2.js.map +9 -0
  46. package/dist/chunk-ezmw2j8c.js +14 -0
  47. package/dist/chunk-ezmw2j8c.js.map +9 -0
  48. package/dist/chunk-f2hq6bfv.js +22 -0
  49. package/dist/chunk-f2hq6bfv.js.map +10 -0
  50. package/dist/chunk-fwb4fnkp.js +31 -0
  51. package/dist/chunk-fwb4fnkp.js.map +10 -0
  52. package/dist/chunk-h18jrqed.js +9517 -0
  53. package/dist/chunk-h18jrqed.js.map +99 -0
  54. package/dist/chunk-hb3c6f6a.js +42 -0
  55. package/dist/chunk-hb3c6f6a.js.map +9 -0
  56. package/dist/chunk-jy2d17pr.js +252 -0
  57. package/dist/chunk-jy2d17pr.js.map +11 -0
  58. package/dist/chunk-kbtqrkwh.js +24 -0
  59. package/dist/chunk-kbtqrkwh.js.map +10 -0
  60. package/dist/chunk-knbnsf6s.js +92 -0
  61. package/dist/chunk-knbnsf6s.js.map +10 -0
  62. package/dist/chunk-mv9ssgmx.js +446 -0
  63. package/dist/chunk-mv9ssgmx.js.map +17 -0
  64. package/dist/chunk-nq68kghz.js +1647 -0
  65. package/dist/chunk-nq68kghz.js.map +10 -0
  66. package/dist/chunk-nthabjd9.js +3138 -0
  67. package/dist/chunk-nthabjd9.js.map +34 -0
  68. package/dist/chunk-nxpzt33t.js +278 -0
  69. package/dist/chunk-nxpzt33t.js.map +10 -0
  70. package/dist/chunk-pfyjtfex.js +172 -0
  71. package/dist/chunk-pfyjtfex.js.map +10 -0
  72. package/dist/chunk-q1nd6g0y.js +392 -0
  73. package/dist/chunk-q1nd6g0y.js.map +20 -0
  74. package/dist/chunk-q4js8r0z.js +4708 -0
  75. package/dist/chunk-q4js8r0z.js.map +29 -0
  76. package/dist/chunk-qv44tmn6.js +289 -0
  77. package/dist/chunk-qv44tmn6.js.map +13 -0
  78. package/dist/chunk-r2sg2nxa.js +20 -0
  79. package/dist/chunk-r2sg2nxa.js.map +9 -0
  80. package/dist/chunk-rp8wjzht.js +16959 -0
  81. package/dist/chunk-rp8wjzht.js.map +26 -0
  82. package/dist/chunk-rpxnm86e.js +372 -0
  83. package/dist/chunk-rpxnm86e.js.map +17 -0
  84. package/dist/chunk-sdp429xd.js +914 -0
  85. package/dist/chunk-sdp429xd.js.map +24 -0
  86. package/dist/chunk-t85nbjjb.js +113 -0
  87. package/dist/chunk-t85nbjjb.js.map +10 -0
  88. package/dist/chunk-tz7wnw4s.js +211 -0
  89. package/dist/chunk-tz7wnw4s.js.map +11 -0
  90. package/dist/chunk-v7117ywx.js +1477 -0
  91. package/dist/chunk-v7117ywx.js.map +23 -0
  92. package/dist/chunk-w8q7nsm7.js +2098 -0
  93. package/dist/chunk-w8q7nsm7.js.map +44 -0
  94. package/dist/chunk-wa64nz8b.js +47 -0
  95. package/dist/chunk-wa64nz8b.js.map +10 -0
  96. package/dist/chunk-wz8d5vzb.js +234 -0
  97. package/dist/chunk-wz8d5vzb.js.map +11 -0
  98. package/dist/chunk-ycfxp056.js +677 -0
  99. package/dist/chunk-ycfxp056.js.map +17 -0
  100. package/dist/chunk-z9d2xc83.js +3256 -0
  101. package/dist/chunk-z9d2xc83.js.map +84 -0
  102. package/dist/cli.js +111 -125552
  103. package/dist/cli.js.map +19 -0
  104. package/dist/commands/autoload.d.ts +2 -0
  105. package/dist/commands/doctor/command.d.ts +2 -1
  106. package/dist/commands/doctor/command.js +82 -0
  107. package/dist/commands/doctor/command.js.map +11 -0
  108. package/dist/commands/doctor/spec.d.ts +16 -8
  109. package/dist/commands/init/command.d.ts +2 -1
  110. package/dist/commands/init/command.js +98 -0
  111. package/dist/commands/init/command.js.map +11 -0
  112. package/dist/commands/init/spec.d.ts +29 -9
  113. package/dist/commands/logout/command.d.ts +2 -1
  114. package/dist/commands/logout/command.js +79 -0
  115. package/dist/commands/logout/command.js.map +11 -0
  116. package/dist/commands/logout/spec.d.ts +11 -0
  117. package/dist/commands/proxy/command.d.ts +2 -1
  118. package/dist/commands/proxy/command.js +56 -0
  119. package/dist/commands/proxy/command.js.map +11 -0
  120. package/dist/commands/proxy/spec.d.ts +15 -0
  121. package/dist/commands/screens/command.d.ts +2 -1
  122. package/dist/commands/screens/command.js +61 -0
  123. package/dist/commands/screens/command.js.map +11 -0
  124. package/dist/commands/screens/spec.d.ts +9 -0
  125. package/dist/commands/serve/command.d.ts +2 -1
  126. package/dist/commands/serve/command.js +65 -0
  127. package/dist/commands/serve/command.js.map +11 -0
  128. package/dist/commands/serve/spec.d.ts +9 -0
  129. package/dist/commands/site/command.d.ts +2 -1
  130. package/dist/commands/site/command.js +53 -0
  131. package/dist/commands/site/command.js.map +11 -0
  132. package/dist/commands/site/spec.d.ts +15 -0
  133. package/dist/commands/snapshot/command.d.ts +2 -1
  134. package/dist/commands/snapshot/command.js +59 -0
  135. package/dist/commands/snapshot/command.js.map +11 -0
  136. package/dist/commands/tool/command.d.ts +2 -1
  137. package/dist/commands/tool/command.js +79 -0
  138. package/dist/commands/tool/command.js.map +11 -0
  139. package/dist/commands/tool/handler.d.ts +17 -0
  140. package/dist/commands/tool/spec.d.ts +17 -0
  141. package/dist/commands/tool/steps/ValidateToolStep.d.ts +8 -0
  142. package/dist/commands/tool/virtual-tools/index.d.ts +1 -0
  143. package/dist/commands/tool/virtual-tools/list-tools.d.ts +2 -0
  144. package/dist/commands/view/command.d.ts +2 -1
  145. package/dist/commands/view/command.js +52 -0
  146. package/dist/commands/view/command.js.map +11 -0
  147. package/dist/commands/view/spec.d.ts +24 -0
  148. package/dist/framework/CommandDefinition.d.ts +2 -2
  149. package/dist/index.js +26 -21668
  150. package/dist/index.js.map +9 -0
  151. package/dist/lib/services/site/schemas.d.ts +8 -8
  152. package/dist/services/config/handler.d.ts +12 -0
  153. package/dist/services/config/spec.d.ts +82 -0
  154. package/dist/services/gcloud/auth.d.ts +28 -0
  155. package/dist/services/gcloud/core.d.ts +21 -0
  156. package/dist/services/gcloud/handler.d.ts +6 -18
  157. package/dist/services/gcloud/install.d.ts +23 -0
  158. package/dist/services/gcloud/projects.d.ts +15 -0
  159. package/dist/services/gcloud/spec.d.ts +32 -24
  160. package/dist/services/mcp-client/client.d.ts +0 -5
  161. package/dist/services/mcp-client/spec.d.ts +6 -6
  162. package/dist/services/mcp-config/spec.d.ts +12 -12
  163. package/dist/services/project/spec.d.ts +4 -4
  164. package/dist/services/proxy/spec.d.ts +3 -3
  165. package/dist/services/stitch/api.d.ts +10 -0
  166. package/dist/services/stitch/connection.d.ts +5 -0
  167. package/dist/services/stitch/handler.d.ts +5 -3
  168. package/dist/services/stitch/iam.d.ts +11 -0
  169. package/dist/services/stitch/spec.d.ts +6 -6
  170. package/dist/services/view/spec.d.ts +7 -7
  171. package/dist/src/cli.d.ts +1 -0
  172. package/dist/src/commands/doctor/handler.d.ts +9 -0
  173. package/dist/src/commands/doctor/handler.test.d.ts +1 -0
  174. package/dist/src/commands/doctor/spec.d.ts +130 -0
  175. package/dist/src/commands/doctor/spec.test.d.ts +1 -0
  176. package/dist/src/commands/init/handler.d.ts +17 -0
  177. package/dist/src/commands/init/handler.test.d.ts +1 -0
  178. package/dist/src/commands/init/spec.d.ts +88 -0
  179. package/dist/src/commands/init/spec.test.d.ts +1 -0
  180. package/dist/src/commands/proxy/handler.d.ts +7 -0
  181. package/dist/src/commands/proxy/handler.test.d.ts +1 -0
  182. package/dist/src/index.d.ts +13 -0
  183. package/dist/src/platform/detector.d.ts +29 -0
  184. package/dist/src/platform/paths.d.ts +20 -0
  185. package/dist/src/platform/shell.d.ts +26 -0
  186. package/dist/src/services/gcloud/handler.d.ts +48 -0
  187. package/dist/src/services/gcloud/handler.test.d.ts +1 -0
  188. package/dist/src/services/gcloud/spec.d.ts +405 -0
  189. package/dist/src/services/mcp-config/handler.d.ts +12 -0
  190. package/dist/src/services/mcp-config/handler.test.d.ts +1 -0
  191. package/dist/src/services/mcp-config/spec.d.ts +88 -0
  192. package/dist/src/services/mcp-config/spec.test.d.ts +1 -0
  193. package/dist/src/services/project/handler.d.ts +11 -0
  194. package/dist/src/services/project/handler.test.d.ts +1 -0
  195. package/dist/src/services/project/spec.d.ts +86 -0
  196. package/dist/src/services/project/spec.test.d.ts +1 -0
  197. package/dist/src/services/proxy/handler.d.ts +15 -0
  198. package/dist/src/services/proxy/handler.test.d.ts +1 -0
  199. package/dist/src/services/proxy/spec.d.ts +83 -0
  200. package/dist/src/services/proxy/spec.test.d.ts +1 -0
  201. package/dist/src/services/stitch/handler.d.ts +15 -0
  202. package/dist/src/services/stitch/handler.test.d.ts +1 -0
  203. package/dist/src/services/stitch/spec.d.ts +262 -0
  204. package/dist/src/services/stitch/spec.test.d.ts +1 -0
  205. package/dist/src/ui/spinner.d.ts +11 -0
  206. package/dist/src/ui/theme.d.ts +18 -0
  207. package/dist/src/ui/wizard.d.ts +24 -0
  208. package/dist/tests/mocks/shell.d.ts +2 -0
  209. package/dist/ui/JsonTree.d.ts +1 -1
  210. package/package.json +2 -2
  211. package/dist/commands/registry.d.ts +0 -2
  212. package/dist/ui/copy-behaviors/index.d.ts +0 -8
  213. package/dist/ui/serve-behaviors/index.d.ts +0 -7
  214. /package/dist/ui/navigation-behaviors/{index.d.ts → handler.d.ts} +0 -0
package/README.md CHANGED
@@ -21,16 +21,16 @@ npx @_davideast/stitch-mcp site -p <project-id>
21
21
 
22
22
  ## Features
23
23
 
24
- - **Local dev server** — `serve` runs a Vite server with all screens from a project
25
- - **Site generation** `site` builds an Astro project from screen-to-route mappings
26
- - **MCP proxy** — `proxy` bridges your IDE's coding agent to Stitch tools with automatic token refresh
27
- - **Virtual tools** — `build_site`, `get_screen_code`, `get_screen_image` give agents direct access to design HTML and screenshots
28
- - **Interactive browser** — `view` navigates projects and screens in the terminal
29
- - **Guided setup** — `init` handles gcloud, auth, and MCP client configuration
24
+ - **Preview designs locally** — serve all screens from a project on a Vite dev server
25
+ - **Build an Astro site from your designs** map screens to routes and generate a deployable project
26
+ - **Give your agent design context** — proxy Stitch tools to your IDE's coding agent with automatic token refresh
27
+ - **Explore your design data** — browse projects, screens, and metadata in the terminal or via CLI
28
+ - **Browse projects in your terminal** — navigate screens interactively with copy, preview, and open actions
29
+ - **Set up in one command** — guided wizard handles gcloud, auth, and MCP client configuration
30
30
 
31
31
  ## MCP integration
32
32
 
33
- Add this to your MCP client config to give coding agents access to Stitch tools and virtual tools:
33
+ Add this to your MCP client config to give coding agents access to Stitch tools:
34
34
 
35
35
  ```json
36
36
  {
@@ -45,161 +45,9 @@ Add this to your MCP client config to give coding agents access to Stitch tools
45
45
 
46
46
  Supported clients: VS Code, Cursor, Claude Code, Gemini CLI, Codex, OpenCode.
47
47
 
48
- ---
49
-
50
- ## Installation
51
-
52
- Run directly with `npx` (no install needed):
53
-
54
- ```bash
55
- npx @_davideast/stitch-mcp <command>
56
- ```
57
-
58
- Or install globally:
59
-
60
- ```bash
61
- npm install -g @_davideast/stitch-mcp
62
- stitch-mcp <command>
63
- ```
64
-
65
- ## Commands
66
-
67
- ### `init` — Set up authentication and MCP config
68
-
69
- ```bash
70
- npx @_davideast/stitch-mcp init [options]
71
- ```
72
-
73
- | Option | Description |
74
- |--------|-------------|
75
- | `--local` | Install gcloud locally to project directory instead of user home |
76
- | `-y, --yes` | Auto-approve verification prompts |
77
- | `--defaults` | Use default values for prompts |
78
- | `-c, --client <client>` | MCP client to configure (antigravity, vscode, cursor, claude-code, gemini-cli, codex, opencode) |
79
- | `-t, --transport <type>` | Transport type (`http` or `stdio`) |
80
-
81
- Walks through a setup wizard: MCP client selection, gcloud installation, OAuth login, application credentials, project selection, IAM permissions, Stitch API enablement, connection test, and config generation.
82
-
83
- ### `doctor` — Verify configuration health
84
-
85
- ```bash
86
- npx @_davideast/stitch-mcp doctor [options]
87
- ```
88
-
89
- | Option | Description |
90
- |--------|-------------|
91
- | `--verbose` | Show detailed error information |
92
-
93
- Checks that gcloud is installed, user is authenticated, Application Default Credentials exist, a GCP project is configured, and the Stitch API is reachable.
48
+ ### Virtual tools
94
49
 
95
- ### `serve` Local dev server for project screens
96
-
97
- ```bash
98
- npx @_davideast/stitch-mcp serve -p <project-id>
99
- ```
100
-
101
- | Option | Description |
102
- |--------|-------------|
103
- | `-p, --project <id>` | **Required.** Project ID |
104
-
105
- Fetches all screens from a Stitch project and serves them on a local Vite dev server. Each screen gets its own route for previewing rendered HTML in the browser.
106
-
107
- ### `screens` — Explore screens in a project
108
-
109
- ```bash
110
- npx @_davideast/stitch-mcp screens -p <project-id>
111
- ```
112
-
113
- | Option | Description |
114
- |--------|-------------|
115
- | `-p, --project <id>` | **Required.** Project ID |
116
-
117
- Opens an interactive terminal UI for browsing all screens in a project.
118
-
119
- ### `site` — Build an Astro site from screens
120
-
121
- ```bash
122
- npx @_davideast/stitch-mcp site -p <project-id> [options]
123
- ```
124
-
125
- | Option | Description |
126
- |--------|-------------|
127
- | `-p, --project <id>` | **Required.** Project ID |
128
- | `-o, --output <dir>` | Output directory (default: `.`) |
129
- | `-e, --export` | Export screen-to-route config as `build_site` JSON (no interactive UI) |
130
-
131
- Launches an interactive screen-to-route mapper, then generates an Astro project with the following structure:
132
-
133
- ```
134
- ├── package.json
135
- ├── astro.config.mjs
136
- └── src/
137
- ├── layouts/Layout.astro
138
- └── pages/
139
- ├── index.astro # screen mapped to "/"
140
- └── about.astro # screen mapped to "/about"
141
- ```
142
-
143
- External assets (fonts, images) are downloaded to `public/assets/` with URLs rewritten to local paths.
144
-
145
- Press `e` in the interactive builder to export the current screen-to-route config as JSON to stdout (useful for piping into `build_site`).
146
-
147
- ### `view` — Interactive resource browser
148
-
149
- ```bash
150
- npx @_davideast/stitch-mcp view [options]
151
- ```
152
-
153
- | Option | Description |
154
- |--------|-------------|
155
- | `--projects` | List all projects |
156
- | `--name <name>` | Resource name to view |
157
- | `--sourceScreen <name>` | Source screen resource name |
158
- | `--project <id>` | Project ID |
159
- | `--screen <id>` | Screen ID |
160
- | `--serve` | Serve the screen via local server |
161
-
162
- Browse Stitch resources in a navigable JSON tree. Supports drilling into nested objects and performing actions on selected nodes.
163
-
164
- **Keyboard shortcuts:**
165
-
166
- | Key | Action |
167
- |-----|--------|
168
- | `↑` / `↓` | Navigate up/down |
169
- | `Enter` | Expand/collapse or drill into nested object |
170
- | `Backspace` | Go back one level |
171
- | `c` | Copy selected value to clipboard |
172
- | `cc` | Extended copy (downloads content for URLs) |
173
- | `s` | Preview HTML — serves `htmlCode` in-memory and opens browser |
174
- | `o` | Open project in Stitch web app |
175
- | `q` | Quit viewer |
176
-
177
- ```bash
178
- # Browse all projects
179
- npx @_davideast/stitch-mcp view --projects
180
-
181
- # View a specific screen
182
- npx @_davideast/stitch-mcp view --project <project-id> --screen <screen-id>
183
- ```
184
-
185
- ### `tool` — Invoke MCP tools directly
186
-
187
- ```bash
188
- npx @_davideast/stitch-mcp tool [toolName] [options]
189
- ```
190
-
191
- | Option | Description |
192
- |--------|-------------|
193
- | `-s, --schema` | Show tool arguments and schema |
194
- | `-d, --data <json>` | JSON data (like `curl -d`) |
195
- | `-f, --data-file <path>` | Read JSON from file (like `curl -d @file`) |
196
- | `-o, --output <format>` | Output format: `json`, `pretty`, `raw` (default: `pretty`) |
197
-
198
- Calls any MCP tool (including virtual tools) from the command line. Run without a tool name to list available tools.
199
-
200
- **Virtual tools:**
201
-
202
- These tools are not part of the upstream Stitch MCP server. They are added by the proxy and combine multiple API calls into higher-level operations for coding agents.
50
+ The proxy exposes these tools alongside the upstream Stitch MCP tools. They combine multiple API calls into higher-level operations for coding agents:
203
51
 
204
52
  - **`build_site`** — Builds a site from a project by mapping screens to routes. Returns the design HTML for each page.
205
53
  - **`get_screen_code`** — Retrieves a screen and downloads its HTML code content.
@@ -231,72 +79,62 @@ npx @_davideast/stitch-mcp tool build_site -d '{
231
79
  }'
232
80
  ```
233
81
 
234
- ### `proxy` MCP proxy server
82
+ ## Explore your designs
83
+
84
+ Use `view` and `tool` to browse your design data and understand what's available before prompting agents.
235
85
 
236
86
  ```bash
237
- npx @_davideast/stitch-mcp proxy [options]
238
- ```
87
+ # Browse all projects
88
+ npx @_davideast/stitch-mcp view --projects
239
89
 
240
- | Option | Description |
241
- |--------|-------------|
242
- | `--transport <type>` | Transport type: `stdio` or `sse` (default: `stdio`) |
243
- | `--port <number>` | Port number (required for `sse`) |
244
- | `--debug` | Enable debug logging to `/tmp/stitch-proxy-debug.log` |
90
+ # Inspect a specific screen
91
+ npx @_davideast/stitch-mcp view --project <project-id> --screen <screen-id>
245
92
 
246
- Proxies requests between your MCP client and the Stitch MCP server. Handles automatic token refresh and exposes virtual tools alongside the upstream tools.
93
+ # Invoke any MCP tool from the CLI
94
+ npx @_davideast/stitch-mcp tool [toolName]
95
+ ```
247
96
 
248
- **STDIO config (default):**
97
+ Inside the `view` browser: `c` copies the selected value, `s` previews HTML in your browser, `o` opens the project in Stitch, and `q` quits. Use arrow keys to navigate and Enter to drill into nested data.
249
98
 
250
- ```json
251
- {
252
- "mcpServers": {
253
- "stitch": {
254
- "command": "npx",
255
- "args": ["@_davideast/stitch-mcp", "proxy"]
256
- }
257
- }
258
- }
259
- ```
99
+ Run `tool` without a name to list all available tools, or with `-s` to see a tool's schema.
260
100
 
261
- **SSE config:**
101
+ ---
262
102
 
263
- ```json
264
- {
265
- "mcpServers": {
266
- "stitch": {
267
- "command": "npx",
268
- "args": ["@_davideast/stitch-mcp", "proxy", "--transport", "sse", "--port", "3100"]
269
- }
270
- }
271
- }
272
- ```
103
+ ## Installation
273
104
 
274
- ### `logout` Revoke credentials
105
+ Run directly with `npx` (no install needed):
275
106
 
276
107
  ```bash
277
- npx @_davideast/stitch-mcp logout [options]
108
+ npx @_davideast/stitch-mcp <command>
278
109
  ```
279
110
 
280
- | Option | Description |
281
- |--------|-------------|
282
- | `--force` | Skip confirmation prompts |
283
- | `--clear-config` | Delete entire gcloud config directory |
284
-
285
- Revokes both user authentication and Application Default Credentials.
286
-
287
- ### `snapshot` — Create UI snapshots
111
+ Or install globally:
288
112
 
289
113
  ```bash
290
- npx @_davideast/stitch-mcp snapshot [options]
114
+ npm install -g @_davideast/stitch-mcp
115
+ stitch-mcp <command>
291
116
  ```
292
117
 
293
- | Option | Description |
294
- |--------|-------------|
295
- | `-c, --command <command>` | The command to snapshot (e.g. `init`) |
296
- | `-d, --data <file>` | Path to JSON data file |
297
- | `-s, --schema` | Print the data schema for the command |
118
+ ## Commands
298
119
 
299
- Creates UI snapshots of CLI commands given a data state. Useful for testing and documentation.
120
+ | Command | Description |
121
+ |---------|-------------|
122
+ | **Setup** | |
123
+ | `init` | Set up auth, gcloud, and MCP client config |
124
+ | `doctor` | Verify configuration health |
125
+ | `logout` | Revoke credentials |
126
+ | **Development** | |
127
+ | `serve -p <id>` | Preview project screens locally |
128
+ | `screens -p <id>` | Browse screens in terminal |
129
+ | `view` | Interactive resource browser |
130
+ | **Build** | |
131
+ | `site -p <id>` | Generate Astro project from screens |
132
+ | `snapshot` | Save screen state to file |
133
+ | **Integration** | |
134
+ | `tool [name]` | Invoke MCP tools from CLI |
135
+ | `proxy` | Run MCP proxy for agents |
136
+
137
+ Run any command with `--help` for full options.
300
138
 
301
139
  ## Authentication
302
140
 
@@ -351,23 +189,11 @@ Then use the proxy with `STITCH_USE_SYSTEM_GCLOUD=1`:
351
189
 
352
190
  ### "Permission Denied" errors
353
191
 
354
- Ensure:
355
- - You have Owner or Editor role on the GCP project
356
- - Billing is enabled on your project
357
- - Stitch API is enabled
358
-
359
- Run `doctor` to diagnose:
360
- ```bash
361
- npx @_davideast/stitch-mcp doctor --verbose
362
- ```
192
+ Ensure you have Owner or Editor role, billing is enabled, and the Stitch API is enabled. Run `doctor --verbose` to diagnose.
363
193
 
364
194
  ### Authentication URL not appearing
365
195
 
366
- The tool prints authentication URLs to the terminal with a 5-second timeout. If the URL doesn't appear:
367
-
368
- 1. Check your terminal output carefully
369
- 2. The URL starts with `https://accounts.google.com`
370
- 3. If using proxy with `--debug`, check `/tmp/stitch-proxy-debug.log`
196
+ The tool prints authentication URLs to the terminal with a 5-second timeout. Look for a URL starting with `https://accounts.google.com`. If using proxy with `--debug`, check `/tmp/stitch-proxy-debug.log`.
371
197
 
372
198
  ### Already authenticated but showing logged in
373
199
 
@@ -379,23 +205,12 @@ npx @_davideast/stitch-mcp logout --force --clear-config
379
205
 
380
206
  ### API connection fails after setup
381
207
 
382
- 1. Run the doctor command:
383
- ```bash
384
- npx @_davideast/stitch-mcp doctor --verbose
385
- ```
386
-
387
- 2. Verify your project has billing enabled
388
-
389
- 3. Check that Stitch API is enabled:
390
- ```bash
391
- gcloud services list --enabled | grep stitch
392
- ```
208
+ Run `doctor --verbose` to diagnose. Verify your project has billing and the Stitch API enabled. If issues persist, re-authenticate:
393
209
 
394
- 4. Try re-authenticating:
395
- ```bash
396
- npx @_davideast/stitch-mcp logout --force
397
- npx @_davideast/stitch-mcp init
398
- ```
210
+ ```bash
211
+ npx @_davideast/stitch-mcp logout --force
212
+ npx @_davideast/stitch-mcp init
213
+ ```
399
214
 
400
215
  ### WSL / SSH / Docker environments
401
216
 
@@ -0,0 +1,137 @@
1
+ import {
2
+ icons,
3
+ theme
4
+ } from "./chunk-kbtqrkwh.js";
5
+ import"./chunk-3sfn889r.js";
6
+ import {
7
+ __require
8
+ } from "./chunk-9wyra8hs.js";
9
+
10
+ // src/commands/view/handler.ts
11
+ class ViewCommandHandler {
12
+ async execute(options) {
13
+ if (options.serve) {
14
+ await this.executeServeMode(options);
15
+ } else {
16
+ await this.executeInteractiveMode(options);
17
+ }
18
+ }
19
+ async executeServeMode(options) {
20
+ if (!options.screen && !options.sourceScreen && !options.name) {
21
+ console.error(theme.red("Error: --serve requires a screen to be specified via --screen, --sourceScreen, or --name"));
22
+ process.exit(1);
23
+ }
24
+ const { ViewHandler } = await import("./chunk-t85nbjjb.js");
25
+ const handler = new ViewHandler;
26
+ const execOptions = { projects: false };
27
+ if (options.project)
28
+ execOptions.project = options.project;
29
+ if (options.screen)
30
+ execOptions.screen = options.screen;
31
+ if (options.sourceScreen)
32
+ execOptions.sourceScreen = options.sourceScreen;
33
+ if (options.name)
34
+ execOptions.name = options.name;
35
+ const res = await handler.execute(execOptions);
36
+ if (!res.success)
37
+ throw new Error(res.error.message);
38
+ const resource = res.data;
39
+ if (!resource) {
40
+ throw new Error("Could not find resource");
41
+ }
42
+ if (!resource.htmlCode || !resource.htmlCode.downloadUrl) {
43
+ console.error(theme.red("Error: The specified resource is not a screen or has no HTML code."));
44
+ process.exit(1);
45
+ }
46
+ const { StitchViteServer } = await import("./chunk-48d17n29.js");
47
+ const { downloadText } = await import("./chunk-3at4pjgn.js");
48
+ const server = new StitchViteServer;
49
+ const url = await server.start(0);
50
+ console.log(theme.green(`Starting server at ${url}`));
51
+ console.log("Downloading content...");
52
+ const html = await downloadText(resource.htmlCode.downloadUrl);
53
+ server.mount("/", html);
54
+ console.log(theme.green(`Serving screen "${resource.title || "Screen"}" at ${url}/`));
55
+ console.log("Press Ctrl+C to stop.");
56
+ await new Promise(() => {});
57
+ }
58
+ async executeInteractiveMode(options) {
59
+ const { render } = await import("./chunk-hb3c6f6a.js");
60
+ const React = await import("./chunk-edp6faw2.js");
61
+ const { InteractiveViewer } = await import("./chunk-ycfxp056.js");
62
+ const { ViewHandler } = await import("./chunk-t85nbjjb.js");
63
+ const handler = new ViewHandler;
64
+ const result = await handler.execute({
65
+ projects: options.projects,
66
+ name: options.name,
67
+ sourceScreen: options.sourceScreen,
68
+ project: options.project,
69
+ screen: options.screen
70
+ });
71
+ if (!result.success) {
72
+ console.error(theme.red(`
73
+ ${icons.error} View failed: ${result.error.message}`));
74
+ process.exit(1);
75
+ }
76
+ const createElement = React.createElement || React.default.createElement;
77
+ let rootLabel;
78
+ if (options.sourceScreen) {
79
+ rootLabel = "screen";
80
+ } else if (options.name) {
81
+ rootLabel = "resource";
82
+ }
83
+ const fetchResource = async (resourceName) => {
84
+ if (resourceName.includes("/screens/")) {
85
+ const navResult = await handler.execute({ projects: false, sourceScreen: resourceName });
86
+ if (!navResult.success)
87
+ throw new Error(navResult.error.message);
88
+ return navResult.data;
89
+ } else {
90
+ const navResult = await handler.execute({ projects: false, name: resourceName });
91
+ if (!navResult.success)
92
+ throw new Error(navResult.error.message);
93
+ return navResult.data;
94
+ }
95
+ };
96
+ const initialHistory = [];
97
+ if (options.sourceScreen) {
98
+ const projectMatch = options.sourceScreen.match(/^(projects\/\d+)/);
99
+ if (projectMatch) {
100
+ const projectName = projectMatch[1];
101
+ try {
102
+ const projectsResult = await handler.execute({ projects: true });
103
+ if (projectsResult.success) {
104
+ initialHistory.push({ data: projectsResult.data, rootLabel: undefined });
105
+ }
106
+ } catch (e) {}
107
+ try {
108
+ const projectResult = await handler.execute({ projects: false, name: projectName });
109
+ if (projectResult.success) {
110
+ initialHistory.push({ data: projectResult.data, rootLabel: "resource", resourcePath: projectName });
111
+ }
112
+ } catch (e) {}
113
+ }
114
+ }
115
+ if (options.name && !options.sourceScreen) {
116
+ try {
117
+ const projectsResult = await handler.execute({ projects: true });
118
+ if (projectsResult.success) {
119
+ initialHistory.push({ data: projectsResult.data, rootLabel: undefined });
120
+ }
121
+ } catch (e) {}
122
+ }
123
+ const instance = render(createElement(InteractiveViewer, {
124
+ initialData: result.data,
125
+ initialRootLabel: rootLabel,
126
+ initialHistory: initialHistory.length > 0 ? initialHistory : undefined,
127
+ onFetch: fetchResource
128
+ }));
129
+ await instance.waitUntilExit();
130
+ process.exit(0);
131
+ }
132
+ }
133
+ export {
134
+ ViewCommandHandler
135
+ };
136
+
137
+ //# debugId=FACA0134243A0F2764756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/commands/view/handler.ts"],
4
+ "sourcesContent": [
5
+ "import { theme, icons } from '../../ui/theme.js';\n\ninterface ViewOptions {\n projects: boolean;\n name?: string;\n sourceScreen?: string;\n project?: string;\n screen?: string;\n serve: boolean;\n}\n\nexport class ViewCommandHandler {\n async execute(options: ViewOptions): Promise<void> {\n if (options.serve) {\n await this.executeServeMode(options);\n } else {\n await this.executeInteractiveMode(options);\n }\n }\n\n private async executeServeMode(options: ViewOptions): Promise<void> {\n if (!options.screen && !options.sourceScreen && !options.name) {\n console.error(theme.red('Error: --serve requires a screen to be specified via --screen, --sourceScreen, or --name'));\n process.exit(1);\n }\n\n const { ViewHandler } = await import('../../services/view/handler.js');\n const handler = new ViewHandler();\n\n const execOptions: any = { projects: false };\n if (options.project) execOptions.project = options.project;\n if (options.screen) execOptions.screen = options.screen;\n if (options.sourceScreen) execOptions.sourceScreen = options.sourceScreen;\n if (options.name) execOptions.name = options.name;\n\n const res = await handler.execute(execOptions);\n if (!res.success) throw new Error(res.error.message);\n\n const resource = res.data;\n if (!resource) {\n throw new Error('Could not find resource');\n }\n\n if (!resource.htmlCode || !resource.htmlCode.downloadUrl) {\n console.error(theme.red('Error: The specified resource is not a screen or has no HTML code.'));\n process.exit(1);\n }\n\n const { StitchViteServer } = await import('../../lib/server/vite/StitchViteServer.js');\n const { downloadText } = await import('../../ui/copy-behaviors/clipboard.js');\n\n const server = new StitchViteServer();\n const url = await server.start(0);\n console.log(theme.green(`Starting server at ${url}`));\n\n console.log('Downloading content...');\n const html = await downloadText(resource.htmlCode.downloadUrl);\n server.mount('/', html);\n\n console.log(theme.green(`Serving screen \"${resource.title || 'Screen'}\" at ${url}/`));\n console.log('Press Ctrl+C to stop.');\n\n await new Promise(() => {});\n }\n\n private async executeInteractiveMode(options: ViewOptions): Promise<void> {\n const { render } = await import('ink');\n const React = await import('react');\n const { InteractiveViewer } = await import('../../ui/InteractiveViewer.js');\n const { ViewHandler } = await import('../../services/view/handler.js');\n\n const handler = new ViewHandler();\n const result = await handler.execute({\n projects: options.projects,\n name: options.name,\n sourceScreen: options.sourceScreen,\n project: options.project,\n screen: options.screen,\n });\n\n if (!result.success) {\n console.error(theme.red(`\\n${icons.error} View failed: ${result.error.message}`));\n process.exit(1);\n }\n\n const createElement = React.createElement || (React.default as any).createElement;\n\n let rootLabel: string | undefined;\n if (options.sourceScreen) {\n rootLabel = 'screen';\n } else if (options.name) {\n rootLabel = 'resource';\n }\n\n const fetchResource = async (resourceName: string): Promise<any> => {\n if (resourceName.includes('/screens/')) {\n const navResult = await handler.execute({ projects: false, sourceScreen: resourceName });\n if (!navResult.success) throw new Error(navResult.error.message);\n return navResult.data;\n } else {\n const navResult = await handler.execute({ projects: false, name: resourceName });\n if (!navResult.success) throw new Error(navResult.error.message);\n return navResult.data;\n }\n };\n\n const initialHistory: Array<{ data: any; rootLabel?: string; resourcePath?: string }> = [];\n\n if (options.sourceScreen) {\n const projectMatch = options.sourceScreen.match(/^(projects\\/\\d+)/);\n if (projectMatch) {\n const projectName = projectMatch[1];\n try {\n const projectsResult = await handler.execute({ projects: true });\n if (projectsResult.success) {\n initialHistory.push({ data: projectsResult.data, rootLabel: undefined });\n }\n } catch (e) {}\n\n try {\n const projectResult = await handler.execute({ projects: false, name: projectName });\n if (projectResult.success) {\n initialHistory.push({ data: projectResult.data, rootLabel: 'resource', resourcePath: projectName });\n }\n } catch (e) {}\n }\n }\n\n if (options.name && !options.sourceScreen) {\n try {\n const projectsResult = await handler.execute({ projects: true });\n if (projectsResult.success) {\n initialHistory.push({ data: projectsResult.data, rootLabel: undefined });\n }\n } catch (e) {}\n }\n\n const instance = render(createElement(InteractiveViewer, {\n initialData: result.data,\n initialRootLabel: rootLabel,\n initialHistory: initialHistory.length > 0 ? initialHistory : undefined,\n onFetch: fetchResource,\n }));\n await instance.waitUntilExit();\n process.exit(0);\n }\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;AAWO,MAAM,mBAAmB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