@_davideast/stitch-mcp 0.5.2 → 0.5.3

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 (126) hide show
  1. package/dist/chunk-22bymmh9.js +137 -0
  2. package/dist/chunk-22bymmh9.js.map +10 -0
  3. package/dist/chunk-387yyye2.js +248 -0
  4. package/dist/chunk-387yyye2.js.map +14 -0
  5. package/dist/chunk-3ff2k44g.js +19 -0
  6. package/dist/chunk-3ff2k44g.js.map +9 -0
  7. package/dist/chunk-46cay1zp.js +273 -0
  8. package/dist/chunk-46cay1zp.js.map +10 -0
  9. package/dist/chunk-48e1jpm8.js +167 -0
  10. package/dist/chunk-48e1jpm8.js.map +10 -0
  11. package/dist/chunk-4arzkk1s.js +69 -0
  12. package/dist/chunk-4arzkk1s.js.map +10 -0
  13. package/dist/chunk-4js7vw6h.js +415 -0
  14. package/dist/chunk-4js7vw6h.js.map +20 -0
  15. package/dist/chunk-4p1wfk3t.js +736 -0
  16. package/dist/chunk-4p1wfk3t.js.map +16 -0
  17. package/dist/chunk-4zg969tc.js +370 -0
  18. package/dist/chunk-4zg969tc.js.map +16 -0
  19. package/dist/chunk-5jjt7tgw.js +247 -0
  20. package/dist/chunk-5jjt7tgw.js.map +14 -0
  21. package/dist/chunk-5t2h8z2n.js +273 -0
  22. package/dist/chunk-5t2h8z2n.js.map +10 -0
  23. package/dist/chunk-5zy3et1m.js +759 -0
  24. package/dist/chunk-5zy3et1m.js.map +19 -0
  25. package/dist/chunk-6wvst7z8.js +125 -0
  26. package/dist/chunk-6wvst7z8.js.map +12 -0
  27. package/dist/chunk-8mm08arm.js +256 -0
  28. package/dist/chunk-8mm08arm.js.map +11 -0
  29. package/dist/chunk-8nv4wwv0.js +19 -0
  30. package/dist/chunk-8nv4wwv0.js.map +9 -0
  31. package/dist/chunk-9cjny9z2.js +19 -0
  32. package/dist/chunk-9cjny9z2.js.map +9 -0
  33. package/dist/chunk-9ggfw78s.js +19 -0
  34. package/dist/chunk-9ggfw78s.js.map +9 -0
  35. package/dist/chunk-9nyyn1hn.js +125 -0
  36. package/dist/chunk-9nyyn1hn.js.map +12 -0
  37. package/dist/chunk-9nzbvp6r.js +19 -0
  38. package/dist/chunk-9nzbvp6r.js.map +9 -0
  39. package/dist/chunk-a0gmbh8e.js +415 -0
  40. package/dist/chunk-a0gmbh8e.js.map +20 -0
  41. package/dist/chunk-acv998mp.js +941 -0
  42. package/dist/chunk-acv998mp.js.map +27 -0
  43. package/dist/chunk-cpjsvven.js +10 -0
  44. package/dist/chunk-cpjsvven.js.map +9 -0
  45. package/dist/chunk-dmrahbs1.js +31467 -0
  46. package/dist/chunk-dmrahbs1.js.map +245 -0
  47. package/dist/chunk-dts6851a.js +137 -0
  48. package/dist/chunk-dts6851a.js.map +10 -0
  49. package/dist/chunk-efd0rm6g.js +69 -0
  50. package/dist/chunk-efd0rm6g.js.map +10 -0
  51. package/dist/chunk-f1kjn6cd.js +16554 -0
  52. package/dist/chunk-f1kjn6cd.js.map +98 -0
  53. package/dist/chunk-f5f6ekgp.js +109 -0
  54. package/dist/chunk-f5f6ekgp.js.map +10 -0
  55. package/dist/chunk-fmewhfh3.js +137 -0
  56. package/dist/chunk-fmewhfh3.js.map +10 -0
  57. package/dist/chunk-fmhrn6cg.js +6382 -0
  58. package/dist/chunk-fmhrn6cg.js.map +109 -0
  59. package/dist/chunk-gh7dzfhb.js +256 -0
  60. package/dist/chunk-gh7dzfhb.js.map +11 -0
  61. package/dist/chunk-gwhtc0fe.js +370 -0
  62. package/dist/chunk-gwhtc0fe.js.map +16 -0
  63. package/dist/chunk-hc7sdwmn.js +449 -0
  64. package/dist/chunk-hc7sdwmn.js.map +17 -0
  65. package/dist/chunk-k4xwb3wp.js +44184 -0
  66. package/dist/chunk-k4xwb3wp.js.map +237 -0
  67. package/dist/chunk-k751yfm6.js +736 -0
  68. package/dist/chunk-k751yfm6.js.map +16 -0
  69. package/dist/chunk-kkc2tvar.js +19 -0
  70. package/dist/chunk-kkc2tvar.js.map +9 -0
  71. package/dist/chunk-kva47mgc.js +10 -0
  72. package/dist/chunk-kva47mgc.js.map +9 -0
  73. package/dist/chunk-nv2j020p.js +45210 -0
  74. package/dist/chunk-nv2j020p.js.map +258 -0
  75. package/dist/chunk-pdj9s41r.js +683 -0
  76. package/dist/chunk-pdj9s41r.js.map +17 -0
  77. package/dist/chunk-ppphsy4t.js +273 -0
  78. package/dist/chunk-ppphsy4t.js.map +10 -0
  79. package/dist/chunk-psmw9zpa.js +941 -0
  80. package/dist/chunk-psmw9zpa.js.map +27 -0
  81. package/dist/chunk-pz31v3ma.js +24 -0
  82. package/dist/chunk-pz31v3ma.js.map +9 -0
  83. package/dist/chunk-qbt0906e.js +1495 -0
  84. package/dist/chunk-qbt0906e.js.map +23 -0
  85. package/dist/chunk-rh3k09h7.js +19 -0
  86. package/dist/chunk-rh3k09h7.js.map +9 -0
  87. package/dist/chunk-saznae7w.js +10 -0
  88. package/dist/chunk-saznae7w.js.map +9 -0
  89. package/dist/chunk-sscqdg1j.js +69 -0
  90. package/dist/chunk-sscqdg1j.js.map +10 -0
  91. package/dist/chunk-stgj6y85.js +835 -0
  92. package/dist/chunk-stgj6y85.js.map +19 -0
  93. package/dist/chunk-t3tqmxyj.js +42 -0
  94. package/dist/chunk-t3tqmxyj.js.map +9 -0
  95. package/dist/chunk-v8ak35zd.js +94 -0
  96. package/dist/chunk-v8ak35zd.js.map +10 -0
  97. package/dist/chunk-w9acw256.js +167 -0
  98. package/dist/chunk-w9acw256.js.map +10 -0
  99. package/dist/chunk-wq60thjn.js +167 -0
  100. package/dist/chunk-wq60thjn.js.map +10 -0
  101. package/dist/chunk-wzkdeb8a.js +736 -0
  102. package/dist/chunk-wzkdeb8a.js.map +16 -0
  103. package/dist/chunk-xxv6j815.js +256 -0
  104. package/dist/chunk-xxv6j815.js.map +11 -0
  105. package/dist/chunk-yjnj35q8.js +1495 -0
  106. package/dist/chunk-yjnj35q8.js.map +23 -0
  107. package/dist/chunk-yvzzrczy.js +45206 -0
  108. package/dist/chunk-yvzzrczy.js.map +258 -0
  109. package/dist/chunk-ywax1akt.js +370 -0
  110. package/dist/chunk-ywax1akt.js.map +16 -0
  111. package/dist/chunk-zakq9pc0.js +4989 -0
  112. package/dist/chunk-zakq9pc0.js.map +65 -0
  113. package/dist/commands/doctor/command.js +1 -1
  114. package/dist/commands/doctor/steps/AdcProjectCheckStep.d.ts +8 -0
  115. package/dist/commands/init/command.js +1 -1
  116. package/dist/commands/logout/command.js +1 -1
  117. package/dist/commands/proxy/command.js +1 -1
  118. package/dist/commands/screens/command.js +2 -2
  119. package/dist/commands/serve/command.js +3 -3
  120. package/dist/commands/site/command.js +1 -1
  121. package/dist/commands/snapshot/command.js +1 -1
  122. package/dist/commands/tool/command.js +1 -1
  123. package/dist/commands/view/command.js +1 -1
  124. package/dist/index.js +4 -4
  125. package/dist/lib/server/AssetGateway.d.ts +12 -0
  126. package/package.json +1 -1
@@ -0,0 +1,19 @@
1
+ import {
2
+ SiteBuilder
3
+ } from "./chunk-4p1wfk3t.js";
4
+ import"./chunk-krfqppg2.js";
5
+ import"./chunk-yvzzrczy.js";
6
+ import"./chunk-w8q7nsm7.js";
7
+ import"./chunk-f1kjn6cd.js";
8
+ import"./chunk-4jwmvjb4.js";
9
+ import"./chunk-6gw9apqb.js";
10
+ import"./chunk-a5xra9jn.js";
11
+ import"./chunk-nq68kghz.js";
12
+ import"./chunk-hc7sdwmn.js";
13
+ import"./chunk-3sfn889r.js";
14
+ import"./chunk-9wyra8hs.js";
15
+ export {
16
+ SiteBuilder
17
+ };
18
+
19
+ //# debugId=1C4BD3D870A3482964756E2164756E21
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [
5
+ ],
6
+ "mappings": "",
7
+ "debugId": "1C4BD3D870A3482964756E2164756E21",
8
+ "names": []
9
+ }
@@ -0,0 +1,125 @@
1
+ import {
2
+ JSONRPCMessageSchema,
3
+ StitchProxy
4
+ } from "./chunk-a1mk24q9.js";
5
+ import"./chunk-c6ge431q.js";
6
+ import"./chunk-9wyra8hs.js";
7
+
8
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
9
+ import process2 from "node:process";
10
+
11
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
12
+ class ReadBuffer {
13
+ append(chunk) {
14
+ this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
15
+ }
16
+ readMessage() {
17
+ if (!this._buffer) {
18
+ return null;
19
+ }
20
+ const index = this._buffer.indexOf(`
21
+ `);
22
+ if (index === -1) {
23
+ return null;
24
+ }
25
+ const line = this._buffer.toString("utf8", 0, index).replace(/\r$/, "");
26
+ this._buffer = this._buffer.subarray(index + 1);
27
+ return deserializeMessage(line);
28
+ }
29
+ clear() {
30
+ this._buffer = undefined;
31
+ }
32
+ }
33
+ function deserializeMessage(line) {
34
+ return JSONRPCMessageSchema.parse(JSON.parse(line));
35
+ }
36
+ function serializeMessage(message) {
37
+ return JSON.stringify(message) + `
38
+ `;
39
+ }
40
+
41
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
42
+ class StdioServerTransport {
43
+ constructor(_stdin = process2.stdin, _stdout = process2.stdout) {
44
+ this._stdin = _stdin;
45
+ this._stdout = _stdout;
46
+ this._readBuffer = new ReadBuffer;
47
+ this._started = false;
48
+ this._ondata = (chunk) => {
49
+ this._readBuffer.append(chunk);
50
+ this.processReadBuffer();
51
+ };
52
+ this._onerror = (error) => {
53
+ this.onerror?.(error);
54
+ };
55
+ }
56
+ async start() {
57
+ if (this._started) {
58
+ throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");
59
+ }
60
+ this._started = true;
61
+ this._stdin.on("data", this._ondata);
62
+ this._stdin.on("error", this._onerror);
63
+ }
64
+ processReadBuffer() {
65
+ while (true) {
66
+ try {
67
+ const message = this._readBuffer.readMessage();
68
+ if (message === null) {
69
+ break;
70
+ }
71
+ this.onmessage?.(message);
72
+ } catch (error) {
73
+ this.onerror?.(error);
74
+ }
75
+ }
76
+ }
77
+ async close() {
78
+ this._stdin.off("data", this._ondata);
79
+ this._stdin.off("error", this._onerror);
80
+ const remainingDataListeners = this._stdin.listenerCount("data");
81
+ if (remainingDataListeners === 0) {
82
+ this._stdin.pause();
83
+ }
84
+ this._readBuffer.clear();
85
+ this.onclose?.();
86
+ }
87
+ send(message) {
88
+ return new Promise((resolve) => {
89
+ const json = serializeMessage(message);
90
+ if (this._stdout.write(json)) {
91
+ resolve();
92
+ } else {
93
+ this._stdout.once("drain", resolve);
94
+ }
95
+ });
96
+ }
97
+ }
98
+
99
+ // src/commands/proxy/handler.ts
100
+ class ProxyCommandHandler {
101
+ createProxy;
102
+ createTransport;
103
+ constructor(deps) {
104
+ this.createProxy = deps?.createProxy ?? ((opts) => new StitchProxy(opts));
105
+ this.createTransport = deps?.createTransport ?? (() => new StdioServerTransport);
106
+ }
107
+ async execute(input) {
108
+ try {
109
+ const proxy = this.createProxy({
110
+ apiKey: process.env.STITCH_API_KEY
111
+ });
112
+ const transport = this.createTransport();
113
+ await proxy.start(transport);
114
+ await transport.onclose;
115
+ return { success: true, data: { status: "running" } };
116
+ } catch (e) {
117
+ return { success: false, error: { code: "PROXY_START_ERROR", message: e.message, recoverable: false } };
118
+ }
119
+ }
120
+ }
121
+ export {
122
+ ProxyCommandHandler
123
+ };
124
+
125
+ //# debugId=1A40EAFC14E573A564756E2164756E21
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js", "../node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js", "../src/commands/proxy/handler.ts"],
4
+ "sourcesContent": [
5
+ "import process from 'node:process';\nimport { ReadBuffer, serializeMessage } from '../shared/stdio.js';\n/**\n * Server transport for stdio: this communicates with an MCP client by reading from the current process' stdin and writing to stdout.\n *\n * This transport is only available in Node.js environments.\n */\nexport class StdioServerTransport {\n constructor(_stdin = process.stdin, _stdout = process.stdout) {\n this._stdin = _stdin;\n this._stdout = _stdout;\n this._readBuffer = new ReadBuffer();\n this._started = false;\n // Arrow functions to bind `this` properly, while maintaining function identity.\n this._ondata = (chunk) => {\n this._readBuffer.append(chunk);\n this.processReadBuffer();\n };\n this._onerror = (error) => {\n this.onerror?.(error);\n };\n }\n /**\n * Starts listening for messages on stdin.\n */\n async start() {\n if (this._started) {\n throw new Error('StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.');\n }\n this._started = true;\n this._stdin.on('data', this._ondata);\n this._stdin.on('error', this._onerror);\n }\n processReadBuffer() {\n while (true) {\n try {\n const message = this._readBuffer.readMessage();\n if (message === null) {\n break;\n }\n this.onmessage?.(message);\n }\n catch (error) {\n this.onerror?.(error);\n }\n }\n }\n async close() {\n // Remove our event listeners first\n this._stdin.off('data', this._ondata);\n this._stdin.off('error', this._onerror);\n // Check if we were the only data listener\n const remainingDataListeners = this._stdin.listenerCount('data');\n if (remainingDataListeners === 0) {\n // Only pause stdin if we were the only listener\n // This prevents interfering with other parts of the application that might be using stdin\n this._stdin.pause();\n }\n // Clear the buffer and notify closure\n this._readBuffer.clear();\n this.onclose?.();\n }\n send(message) {\n return new Promise(resolve => {\n const json = serializeMessage(message);\n if (this._stdout.write(json)) {\n resolve();\n }\n else {\n this._stdout.once('drain', resolve);\n }\n });\n }\n}\n//# sourceMappingURL=stdio.js.map",
6
+ "import { JSONRPCMessageSchema } from '../types.js';\n/**\n * Buffers a continuous stdio stream into discrete JSON-RPC messages.\n */\nexport class ReadBuffer {\n append(chunk) {\n this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;\n }\n readMessage() {\n if (!this._buffer) {\n return null;\n }\n const index = this._buffer.indexOf('\\n');\n if (index === -1) {\n return null;\n }\n const line = this._buffer.toString('utf8', 0, index).replace(/\\r$/, '');\n this._buffer = this._buffer.subarray(index + 1);\n return deserializeMessage(line);\n }\n clear() {\n this._buffer = undefined;\n }\n}\nexport function deserializeMessage(line) {\n return JSONRPCMessageSchema.parse(JSON.parse(line));\n}\nexport function serializeMessage(message) {\n return JSON.stringify(message) + '\\n';\n}\n//# sourceMappingURL=stdio.js.map",
7
+ "import { StitchProxy } from '@google/stitch-sdk';\nimport type { StitchProxy as StitchProxyType } from '@google/stitch-sdk';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\n\ninterface ProxyCommandInput {\n port?: number;\n debug?: boolean;\n}\n\ninterface ProxyCommandResult {\n success: boolean;\n data?: { status: string };\n error?: { code: string; message: string; recoverable: boolean };\n}\n\nexport class ProxyCommandHandler {\n private createProxy: (opts: { apiKey?: string }) => StitchProxyType;\n private createTransport: () => StdioServerTransport;\n\n constructor(deps?: {\n createProxy?: (opts: { apiKey?: string }) => StitchProxyType;\n createTransport?: () => StdioServerTransport;\n }) {\n this.createProxy = deps?.createProxy ?? ((opts) => new StitchProxy(opts));\n this.createTransport = deps?.createTransport ?? (() => new StdioServerTransport());\n }\n\n async execute(input: ProxyCommandInput): Promise<ProxyCommandResult> {\n try {\n const proxy = this.createProxy({\n apiKey: process.env.STITCH_API_KEY,\n });\n const transport = this.createTransport();\n await proxy.start(transport);\n await transport.onclose;\n return { success: true, data: { status: 'running' } };\n } catch (e: any) {\n return { success: false, error: { code: 'PROXY_START_ERROR', message: e.message, recoverable: false } };\n }\n }\n}\n"
8
+ ],
9
+ "mappings": ";;;;;;;;AAAA;;;ACIO,MAAM,WAAW;AAAA,EACpB,MAAM,CAAC,OAAO;AAAA,IACV,KAAK,UAAU,KAAK,UAAU,OAAO,OAAO,CAAC,KAAK,SAAS,KAAK,CAAC,IAAI;AAAA;AAAA,EAEzE,WAAW,GAAG;AAAA,IACV,IAAI,CAAC,KAAK,SAAS;AAAA,MACf,OAAO;AAAA,IACX;AAAA,IACA,MAAM,QAAQ,KAAK,QAAQ,QAAQ;AAAA,CAAI;AAAA,IACvC,IAAI,UAAU,IAAI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AAE,SAAS,OAAO,OAAO,EAAE,MAAM,qBAAqB,SAAS,EAAE,SAAS,aAAa,MAAM,EAAE;AAAA;AAAA;AAG5G;",
10
+ "debugId": "1A40EAFC14E573A564756E2164756E21",
11
+ "names": []
12
+ }
@@ -0,0 +1,19 @@
1
+ import {
2
+ DoctorHandler
3
+ } from "./chunk-5zy3et1m.js";
4
+ import"./chunk-psmw9zpa.js";
5
+ import"./chunk-zakq9pc0.js";
6
+ import"./chunk-nq68kghz.js";
7
+ import"./chunk-q6sv0243.js";
8
+ import"./chunk-f2hq6bfv.js";
9
+ import"./chunk-4jygt4d6.js";
10
+ import"./chunk-tz7wnw4s.js";
11
+ import"./chunk-kbtqrkwh.js";
12
+ import"./chunk-3sfn889r.js";
13
+ import"./chunk-c6ge431q.js";
14
+ import"./chunk-9wyra8hs.js";
15
+ export {
16
+ DoctorHandler
17
+ };
18
+
19
+ //# debugId=71BB7D9626616D6E64756E2164756E21
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [
5
+ ],
6
+ "mappings": "",
7
+ "debugId": "71BB7D9626616D6E64756E2164756E21",
8
+ "names": []
9
+ }
@@ -0,0 +1,415 @@
1
+ import {
2
+ downloadText
3
+ } from "./chunk-34w2wfyp.js";
4
+ import {
5
+ fetchWithRetry
6
+ } from "./chunk-6gw9apqb.js";
7
+ import"./chunk-akd997ec.js";
8
+ import {
9
+ StitchToolClient,
10
+ stitch
11
+ } from "./chunk-dmrahbs1.js";
12
+ import {
13
+ pLimit
14
+ } from "./chunk-a5xra9jn.js";
15
+ import {
16
+ runSteps
17
+ } from "./chunk-f2hq6bfv.js";
18
+ import"./chunk-4jygt4d6.js";
19
+ import"./chunk-tz7wnw4s.js";
20
+ import"./chunk-c6ge431q.js";
21
+ import"./chunk-9wyra8hs.js";
22
+
23
+ // src/commands/tool/virtual-tools/get-screen-code.ts
24
+ var getScreenCodeTool = {
25
+ name: "get_screen_code",
26
+ description: "(Virtual) Retrieves a screen and downloads its HTML code content.",
27
+ inputSchema: {
28
+ type: "object",
29
+ properties: {
30
+ projectId: {
31
+ type: "string",
32
+ description: "Required. The project ID of screen to retrieve."
33
+ },
34
+ screenId: {
35
+ type: "string",
36
+ description: "Required. The name of screen to retrieve."
37
+ }
38
+ },
39
+ required: ["projectId", "screenId"]
40
+ },
41
+ execute: async (client, args, stitch2) => {
42
+ if (!stitch2)
43
+ throw new Error("get_screen_code requires a Stitch instance");
44
+ const { projectId, screenId } = args;
45
+ const screen = await stitch2.project(projectId).getScreen(screenId);
46
+ let htmlContent = null;
47
+ try {
48
+ const htmlUrl = await screen.getHtml();
49
+ if (htmlUrl) {
50
+ htmlContent = await downloadText(htmlUrl);
51
+ }
52
+ } catch (e) {
53
+ console.error(`Error downloading HTML code: ${e}`);
54
+ }
55
+ return {
56
+ screenId: screen.screenId,
57
+ projectId: screen.projectId,
58
+ htmlContent
59
+ };
60
+ }
61
+ };
62
+ // src/commands/tool/virtual-tools/get-screen-image.ts
63
+ var getScreenImageTool = {
64
+ name: "get_screen_image",
65
+ description: "(Virtual) Retrieves a screen and downloads its screenshot image content.",
66
+ inputSchema: {
67
+ type: "object",
68
+ properties: {
69
+ projectId: {
70
+ type: "string",
71
+ description: "Required. The project ID of screen to retrieve."
72
+ },
73
+ screenId: {
74
+ type: "string",
75
+ description: "Required. The name of screen to retrieve."
76
+ }
77
+ },
78
+ required: ["projectId", "screenId"]
79
+ },
80
+ execute: async (client, args, stitch2) => {
81
+ if (!stitch2)
82
+ throw new Error("get_screen_image requires a Stitch instance");
83
+ const { projectId, screenId } = args;
84
+ const screen = await stitch2.project(projectId).getScreen(screenId);
85
+ let imageContent = null;
86
+ try {
87
+ const imageUrl = await screen.getImage();
88
+ if (imageUrl) {
89
+ const response = await fetch(imageUrl);
90
+ const arrayBuffer = await response.arrayBuffer();
91
+ const buffer = Buffer.from(arrayBuffer);
92
+ imageContent = buffer.toString("base64");
93
+ }
94
+ } catch (e) {
95
+ console.error(`Error downloading screenshot: ${e}`);
96
+ }
97
+ return {
98
+ screenId: screen.screenId,
99
+ projectId: screen.projectId,
100
+ imageContent
101
+ };
102
+ }
103
+ };
104
+ // src/commands/tool/virtual-tools/build-site.ts
105
+ var buildSiteTool = {
106
+ name: "build_site",
107
+ description: "(Virtual) Builds a site from a Stitch project by mapping screens to routes. Returns the design HTML for each page to use as context for code generation.",
108
+ inputSchema: {
109
+ type: "object",
110
+ properties: {
111
+ projectId: {
112
+ type: "string",
113
+ description: "Required. The project ID to build a site from."
114
+ },
115
+ routes: {
116
+ type: "array",
117
+ description: "Required. Array of screen-to-route mappings.",
118
+ items: {
119
+ type: "object",
120
+ properties: {
121
+ screenId: {
122
+ type: "string",
123
+ description: "The screen ID to use for this route."
124
+ },
125
+ route: {
126
+ type: "string",
127
+ description: 'The route path (e.g. "/" or "/about").'
128
+ }
129
+ },
130
+ required: ["screenId", "route"]
131
+ }
132
+ }
133
+ },
134
+ required: ["projectId", "routes"]
135
+ },
136
+ execute: async (client, args, stitch2) => {
137
+ if (!stitch2)
138
+ throw new Error("build_site requires a Stitch instance");
139
+ const { projectId, routes } = args;
140
+ if (!Array.isArray(routes)) {
141
+ throw new Error("routes must be an array");
142
+ }
143
+ if (routes.length === 0) {
144
+ throw new Error("routes must be a non-empty array");
145
+ }
146
+ for (const entry of routes) {
147
+ if (!entry.screenId || typeof entry.screenId !== "string") {
148
+ throw new Error('Each route entry must have a "screenId" string');
149
+ }
150
+ if (!entry.route || typeof entry.route !== "string") {
151
+ throw new Error('Each route entry must have a "route" string');
152
+ }
153
+ }
154
+ const routePaths = routes.map((r) => r.route);
155
+ const uniqueRoutes = new Set(routePaths);
156
+ if (uniqueRoutes.size !== routePaths.length) {
157
+ const duplicates = routePaths.filter((r, i) => routePaths.indexOf(r) !== i);
158
+ throw new Error(`Duplicate route paths found: ${[...new Set(duplicates)].join(", ")}`);
159
+ }
160
+ const project = stitch2.project(projectId);
161
+ const sdkScreens = await project.screens();
162
+ const screenMap = new Map(sdkScreens.map((s) => [s.screenId, s]));
163
+ const missingIds = routes.map((r) => r.screenId).filter((id) => !screenMap.has(id));
164
+ if (missingIds.length > 0) {
165
+ throw new Error(`Screen IDs not found in project: ${missingIds.join(", ")}`);
166
+ }
167
+ const limit = pLimit(3);
168
+ const htmlContent = new Map;
169
+ const errors = [];
170
+ await Promise.all(routes.map((r) => limit(async () => {
171
+ const screen = screenMap.get(r.screenId);
172
+ try {
173
+ const htmlUrl = await screen.getHtml();
174
+ if (htmlUrl) {
175
+ const html = await fetchWithRetry(htmlUrl);
176
+ htmlContent.set(r.screenId, html);
177
+ } else {
178
+ htmlContent.set(r.screenId, "");
179
+ }
180
+ } catch (e) {
181
+ errors.push(`${r.screenId}: ${e.message}`);
182
+ }
183
+ })));
184
+ if (errors.length > 0) {
185
+ throw new Error(`Failed to fetch HTML for screens: ${errors.join("; ")}`);
186
+ }
187
+ const pages = routes.map((r) => ({
188
+ screenId: r.screenId,
189
+ route: r.route,
190
+ title: screenMap.get(r.screenId).title ?? r.screenId,
191
+ html: htmlContent.get(r.screenId)
192
+ }));
193
+ return {
194
+ success: true,
195
+ pages,
196
+ message: `Built ${pages.length} page(s) with design HTML`
197
+ };
198
+ }
199
+ };
200
+ // src/commands/tool/virtual-tools/list-tools.ts
201
+ var listToolsTool = {
202
+ name: "list_tools",
203
+ description: "List all available tools with their descriptions and schemas.",
204
+ inputSchema: {
205
+ type: "object",
206
+ properties: {}
207
+ },
208
+ execute: async (client, _args) => {
209
+ const result = await client.listTools();
210
+ return result.tools || [];
211
+ }
212
+ };
213
+ // src/commands/tool/virtual-tools/index.ts
214
+ var virtualTools = [
215
+ getScreenCodeTool,
216
+ getScreenImageTool,
217
+ buildSiteTool,
218
+ listToolsTool
219
+ ];
220
+
221
+ // src/commands/tool/steps/ListToolsStep.ts
222
+ class ListToolsStep {
223
+ id = "list-tools";
224
+ name = "List available tools";
225
+ async shouldRun(context) {
226
+ const name = context.input.toolName?.toLowerCase();
227
+ return !name || name === "list" || name === "listtools" || name === "list_tools";
228
+ }
229
+ async run(context) {
230
+ const result = await context.client.listTools();
231
+ const serverTools = result.tools || [];
232
+ const tools = [
233
+ ...context.virtualTools.map((t) => ({ name: t.name, description: t.description, inputSchema: t.inputSchema, virtual: true })),
234
+ ...serverTools.map((t) => ({ ...t, virtual: false }))
235
+ ];
236
+ context.result = { success: true, data: tools };
237
+ return { success: true };
238
+ }
239
+ }
240
+
241
+ // src/commands/tool/steps/ShowSchemaStep.ts
242
+ class ShowSchemaStep {
243
+ id = "show-schema";
244
+ name = "Show tool schema";
245
+ async shouldRun(context) {
246
+ return !!context.input.toolName && context.input.toolName !== "list" && context.input.showSchema;
247
+ }
248
+ async run(context) {
249
+ const toolName = context.input.toolName;
250
+ const result = await context.client.listTools();
251
+ const serverTools = result.tools || [];
252
+ const allTools = [...context.virtualTools, ...serverTools];
253
+ const tool = allTools.find((t) => t.name === toolName);
254
+ if (!tool) {
255
+ context.result = { success: false, error: `Tool not found: ${toolName}` };
256
+ return { success: false, error: new Error(`Tool not found: ${toolName}`) };
257
+ }
258
+ context.result = { success: true, data: this.formatSchema(tool) };
259
+ return { success: true };
260
+ }
261
+ formatSchema(tool) {
262
+ const schema = tool.inputSchema;
263
+ const args = {};
264
+ if (schema?.properties) {
265
+ for (const [key, prop] of Object.entries(schema.properties)) {
266
+ const required = schema.required?.includes(key) ? "(required)" : "(optional)";
267
+ args[key] = `${prop.type} ${required}${prop.description ? " - " + prop.description : ""}`;
268
+ }
269
+ }
270
+ return {
271
+ name: tool.name,
272
+ description: tool.description,
273
+ virtual: tool.virtual ?? false,
274
+ arguments: args,
275
+ example: this.generateExample(tool)
276
+ };
277
+ }
278
+ generateExample(tool) {
279
+ const exampleArgs = {};
280
+ if (tool.inputSchema?.properties) {
281
+ for (const [key, prop] of Object.entries(tool.inputSchema.properties)) {
282
+ exampleArgs[key] = prop.type === "string" ? `<${key}>` : `<${prop.type}>`;
283
+ }
284
+ }
285
+ return `stitch-mcp tool ${tool.name} -d '${JSON.stringify(exampleArgs)}'`;
286
+ }
287
+ }
288
+
289
+ // src/commands/tool/steps/ParseArgsStep.ts
290
+ class ParseArgsStep {
291
+ id = "parse-args";
292
+ name = "Parse tool arguments";
293
+ async shouldRun(context) {
294
+ return !!context.input.toolName && context.input.toolName !== "list" && !context.input.showSchema;
295
+ }
296
+ async run(context) {
297
+ let args = {};
298
+ if (context.input.data) {
299
+ args = JSON.parse(context.input.data);
300
+ } else if (context.input.dataFile) {
301
+ const content = await Bun.file(context.input.dataFile.replace("@", "")).text();
302
+ args = JSON.parse(content);
303
+ }
304
+ context.parsedArgs = args;
305
+ return { success: true };
306
+ }
307
+ }
308
+
309
+ // src/commands/tool/steps/ValidateToolStep.ts
310
+ class ValidateToolStep {
311
+ id = "validate-tool";
312
+ name = "Validate tool exists";
313
+ async shouldRun(context) {
314
+ return !!context.input.toolName && context.input.toolName !== "list" && !context.input.showSchema && context.parsedArgs !== undefined;
315
+ }
316
+ async run(context) {
317
+ const toolName = context.input.toolName;
318
+ const result = await context.client.listTools();
319
+ const serverTools = result.tools || [];
320
+ const allTools = [...context.virtualTools, ...serverTools];
321
+ const found = allTools.find((t) => t.name === toolName);
322
+ if (!found) {
323
+ const availableNames = allTools.map((t) => t.name).sort();
324
+ context.result = {
325
+ success: false,
326
+ error: `Tool not found: "${toolName}". Use "list_tools" to see available tools.`,
327
+ data: {
328
+ requestedTool: toolName,
329
+ availableTools: availableNames,
330
+ hint: 'Call "list_tools" to see all available tools with descriptions and schemas.'
331
+ }
332
+ };
333
+ return { success: false, error: new Error(`Tool not found: ${toolName}`) };
334
+ }
335
+ return { success: true };
336
+ }
337
+ }
338
+
339
+ // src/commands/tool/steps/ExecuteToolStep.ts
340
+ class ExecuteToolStep {
341
+ id = "execute-tool";
342
+ name = "Execute tool";
343
+ async shouldRun(context) {
344
+ return context.parsedArgs !== undefined;
345
+ }
346
+ async run(context) {
347
+ const toolName = context.input.toolName;
348
+ const args = context.parsedArgs;
349
+ const virtualTool = context.virtualTools.find((t) => t.name === toolName);
350
+ if (virtualTool) {
351
+ try {
352
+ const result2 = await virtualTool.execute(context.client, args, context.stitch);
353
+ context.result = { success: true, data: result2 };
354
+ return { success: true };
355
+ } catch (e) {
356
+ context.result = { success: false, error: `Virtual tool execution failed: ${e.message || String(e)}` };
357
+ return { success: false, error: e };
358
+ }
359
+ }
360
+ const result = await context.client.callTool(toolName, args);
361
+ context.result = { success: true, data: result };
362
+ return { success: true };
363
+ }
364
+ }
365
+
366
+ // src/commands/tool/handler.ts
367
+ var deps = {
368
+ runSteps,
369
+ ListToolsStep,
370
+ ShowSchemaStep,
371
+ ParseArgsStep,
372
+ ValidateToolStep,
373
+ ExecuteToolStep
374
+ };
375
+
376
+ class ToolCommandHandler {
377
+ client;
378
+ stitchInstance;
379
+ tools;
380
+ steps;
381
+ constructor(client, tools, stitchInstance) {
382
+ this.client = client || new StitchToolClient;
383
+ this.stitchInstance = stitchInstance || stitch;
384
+ this.tools = tools || virtualTools;
385
+ this.steps = [
386
+ new deps.ListToolsStep,
387
+ new deps.ShowSchemaStep,
388
+ new deps.ParseArgsStep,
389
+ new deps.ValidateToolStep,
390
+ new deps.ExecuteToolStep
391
+ ];
392
+ }
393
+ async execute(input) {
394
+ const context = {
395
+ input,
396
+ client: this.client,
397
+ stitch: this.stitchInstance,
398
+ virtualTools: this.tools
399
+ };
400
+ try {
401
+ await deps.runSteps(this.steps, context, {
402
+ onAfterStep: (_step, _result, ctx) => ctx.result !== undefined
403
+ });
404
+ } finally {
405
+ await this.client.close();
406
+ }
407
+ return context.result ?? { success: false, error: "No step produced a result" };
408
+ }
409
+ }
410
+ export {
411
+ deps,
412
+ ToolCommandHandler
413
+ };
414
+
415
+ //# debugId=7A003C51AFD3BD2C64756E2164756E21