skybridge 0.0.0-dev.f953cb9 → 0.0.0-dev.f9ae1d8

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 (190) hide show
  1. package/README.md +24 -16
  2. package/dist/cli/header.js +1 -1
  3. package/dist/cli/header.js.map +1 -1
  4. package/dist/cli/types.d.ts +5 -0
  5. package/dist/cli/types.js +2 -0
  6. package/dist/cli/types.js.map +1 -0
  7. package/dist/cli/use-messages.d.ts +3 -0
  8. package/dist/cli/use-messages.js +11 -0
  9. package/dist/cli/use-messages.js.map +1 -0
  10. package/dist/cli/use-nodemon.d.ts +2 -6
  11. package/dist/cli/use-nodemon.js +8 -13
  12. package/dist/cli/use-nodemon.js.map +1 -1
  13. package/dist/cli/use-tunnel.d.ts +14 -0
  14. package/dist/cli/use-tunnel.js +97 -0
  15. package/dist/cli/use-tunnel.js.map +1 -0
  16. package/dist/commands/build.js +28 -7
  17. package/dist/commands/build.js.map +1 -1
  18. package/dist/commands/dev.d.ts +2 -1
  19. package/dist/commands/dev.js +14 -7
  20. package/dist/commands/dev.js.map +1 -1
  21. package/dist/commands/start.js +7 -10
  22. package/dist/commands/start.js.map +1 -1
  23. package/dist/server/asset-base-url-transform-plugin.d.ts +5 -6
  24. package/dist/server/asset-base-url-transform-plugin.js +8 -9
  25. package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
  26. package/dist/server/asset-base-url-transform-plugin.test.js +12 -13
  27. package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
  28. package/dist/server/content-helpers.d.ts +27 -0
  29. package/dist/server/content-helpers.js +46 -0
  30. package/dist/server/content-helpers.js.map +1 -0
  31. package/dist/server/content-helpers.test.js +70 -0
  32. package/dist/server/content-helpers.test.js.map +1 -0
  33. package/dist/server/express.d.ts +9 -3
  34. package/dist/server/express.js +26 -21
  35. package/dist/server/express.js.map +1 -1
  36. package/dist/server/express.test.js +227 -12
  37. package/dist/server/express.test.js.map +1 -1
  38. package/dist/server/index.d.ts +5 -3
  39. package/dist/server/index.js +3 -2
  40. package/dist/server/index.js.map +1 -1
  41. package/dist/server/inferUtilityTypes.d.ts +6 -6
  42. package/dist/server/metric.d.ts +14 -0
  43. package/dist/server/metric.js +62 -0
  44. package/dist/server/metric.js.map +1 -0
  45. package/dist/server/middleware.d.ts +124 -0
  46. package/dist/server/middleware.js +93 -0
  47. package/dist/server/middleware.js.map +1 -0
  48. package/dist/server/middleware.test-d.js +75 -0
  49. package/dist/server/middleware.test-d.js.map +1 -0
  50. package/dist/server/middleware.test.js +493 -0
  51. package/dist/server/middleware.test.js.map +1 -0
  52. package/dist/server/server.d.ts +132 -64
  53. package/dist/server/server.js +310 -92
  54. package/dist/server/server.js.map +1 -1
  55. package/dist/server/templateHelper.d.ts +5 -6
  56. package/dist/server/templateHelper.js.map +1 -1
  57. package/dist/server/templates/development.hbs +2 -57
  58. package/dist/server/templates/production.hbs +1 -1
  59. package/dist/server/viewsDevServer.d.ts +14 -0
  60. package/dist/server/viewsDevServer.js +45 -0
  61. package/dist/server/viewsDevServer.js.map +1 -0
  62. package/dist/test/utils.d.ts +13 -21
  63. package/dist/test/utils.js +42 -37
  64. package/dist/test/utils.js.map +1 -1
  65. package/dist/test/view.test.d.ts +1 -0
  66. package/dist/test/view.test.js +523 -0
  67. package/dist/test/view.test.js.map +1 -0
  68. package/dist/version.d.ts +1 -0
  69. package/dist/version.js +5 -0
  70. package/dist/version.js.map +1 -0
  71. package/dist/web/bridges/apps-sdk/adaptor.d.ts +5 -3
  72. package/dist/web/bridges/apps-sdk/adaptor.js +37 -15
  73. package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -1
  74. package/dist/web/bridges/apps-sdk/bridge.d.ts +1 -1
  75. package/dist/web/bridges/apps-sdk/index.d.ts +1 -1
  76. package/dist/web/bridges/apps-sdk/index.js.map +1 -1
  77. package/dist/web/bridges/apps-sdk/types.d.ts +14 -8
  78. package/dist/web/bridges/apps-sdk/types.js.map +1 -1
  79. package/dist/web/bridges/mcp-app/adaptor.d.ts +19 -7
  80. package/dist/web/bridges/mcp-app/adaptor.js +134 -56
  81. package/dist/web/bridges/mcp-app/adaptor.js.map +1 -1
  82. package/dist/web/bridges/mcp-app/bridge.d.ts +13 -30
  83. package/dist/web/bridges/mcp-app/bridge.js +43 -201
  84. package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
  85. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +5 -3
  86. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +2 -2
  87. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
  88. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -41
  89. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
  90. package/dist/web/bridges/types.d.ts +15 -8
  91. package/dist/web/components/modal-provider.js +3 -5
  92. package/dist/web/components/modal-provider.js.map +1 -1
  93. package/dist/web/create-store.js +17 -3
  94. package/dist/web/create-store.js.map +1 -1
  95. package/dist/web/create-store.test.js +21 -18
  96. package/dist/web/create-store.test.js.map +1 -1
  97. package/dist/web/data-llm.d.ts +1 -1
  98. package/dist/web/data-llm.js +3 -3
  99. package/dist/web/data-llm.js.map +1 -1
  100. package/dist/web/data-llm.test.js +24 -23
  101. package/dist/web/data-llm.test.js.map +1 -1
  102. package/dist/web/generate-helpers.d.ts +20 -18
  103. package/dist/web/generate-helpers.js +20 -18
  104. package/dist/web/generate-helpers.js.map +1 -1
  105. package/dist/web/generate-helpers.test-d.js +26 -26
  106. package/dist/web/generate-helpers.test-d.js.map +1 -1
  107. package/dist/web/helpers/state.d.ts +2 -2
  108. package/dist/web/helpers/state.js +11 -11
  109. package/dist/web/helpers/state.js.map +1 -1
  110. package/dist/web/helpers/state.test.js +9 -9
  111. package/dist/web/helpers/state.test.js.map +1 -1
  112. package/dist/web/hooks/index.d.ts +1 -1
  113. package/dist/web/hooks/index.js +1 -1
  114. package/dist/web/hooks/index.js.map +1 -1
  115. package/dist/web/hooks/test/utils.js +4 -0
  116. package/dist/web/hooks/test/utils.js.map +1 -1
  117. package/dist/web/hooks/use-files.d.ts +2 -1
  118. package/dist/web/hooks/use-files.js +1 -0
  119. package/dist/web/hooks/use-files.js.map +1 -1
  120. package/dist/web/hooks/use-files.test.js +22 -2
  121. package/dist/web/hooks/use-files.test.js.map +1 -1
  122. package/dist/web/hooks/use-layout.test.js +3 -3
  123. package/dist/web/hooks/use-layout.test.js.map +1 -1
  124. package/dist/web/hooks/use-open-external.test.js +15 -10
  125. package/dist/web/hooks/use-open-external.test.js.map +1 -1
  126. package/dist/web/hooks/use-request-modal.d.ts +1 -1
  127. package/dist/web/hooks/use-request-modal.js +4 -4
  128. package/dist/web/hooks/use-request-modal.js.map +1 -1
  129. package/dist/web/hooks/use-request-modal.test.js +5 -1
  130. package/dist/web/hooks/use-request-modal.test.js.map +1 -1
  131. package/dist/web/hooks/use-tool-info.test.js +1 -1
  132. package/dist/web/hooks/use-tool-info.test.js.map +1 -1
  133. package/dist/web/hooks/use-user.js +18 -2
  134. package/dist/web/hooks/use-user.js.map +1 -1
  135. package/dist/web/hooks/use-user.test.js +29 -1
  136. package/dist/web/hooks/use-user.test.js.map +1 -1
  137. package/dist/web/hooks/use-view-state.d.ts +4 -0
  138. package/dist/web/hooks/use-view-state.js +32 -0
  139. package/dist/web/hooks/use-view-state.js.map +1 -0
  140. package/dist/web/hooks/use-view-state.test.d.ts +1 -0
  141. package/dist/web/hooks/use-view-state.test.js +177 -0
  142. package/dist/web/hooks/use-view-state.test.js.map +1 -0
  143. package/dist/web/index.d.ts +1 -2
  144. package/dist/web/index.js +1 -2
  145. package/dist/web/index.js.map +1 -1
  146. package/dist/web/mount-view.d.ts +1 -0
  147. package/dist/web/{mount-widget.js → mount-view.js} +2 -2
  148. package/dist/web/mount-view.js.map +1 -0
  149. package/dist/web/plugin/plugin.d.ts +4 -1
  150. package/dist/web/plugin/plugin.js +112 -25
  151. package/dist/web/plugin/plugin.js.map +1 -1
  152. package/dist/web/plugin/scan-views.d.ts +8 -0
  153. package/dist/web/plugin/scan-views.js +70 -0
  154. package/dist/web/plugin/scan-views.js.map +1 -0
  155. package/dist/web/plugin/scan-views.test.d.ts +1 -0
  156. package/dist/web/plugin/scan-views.test.js +67 -0
  157. package/dist/web/plugin/scan-views.test.js.map +1 -0
  158. package/dist/web/plugin/transform-data-llm.js +1 -1
  159. package/dist/web/plugin/transform-data-llm.js.map +1 -1
  160. package/dist/web/plugin/validate-view.d.ts +1 -0
  161. package/dist/web/plugin/validate-view.js +9 -0
  162. package/dist/web/plugin/validate-view.js.map +1 -0
  163. package/dist/web/plugin/validate-view.test.d.ts +1 -0
  164. package/dist/web/plugin/validate-view.test.js +24 -0
  165. package/dist/web/plugin/validate-view.test.js.map +1 -0
  166. package/package.json +25 -17
  167. package/tsconfig.base.json +5 -0
  168. package/dist/server/const.d.ts +0 -1
  169. package/dist/server/const.js +0 -2
  170. package/dist/server/const.js.map +0 -1
  171. package/dist/server/widgetsDevServer.d.ts +0 -12
  172. package/dist/server/widgetsDevServer.js +0 -63
  173. package/dist/server/widgetsDevServer.js.map +0 -1
  174. package/dist/test/widget.test.js +0 -261
  175. package/dist/test/widget.test.js.map +0 -1
  176. package/dist/web/hooks/use-widget-state.d.ts +0 -4
  177. package/dist/web/hooks/use-widget-state.js +0 -32
  178. package/dist/web/hooks/use-widget-state.js.map +0 -1
  179. package/dist/web/hooks/use-widget-state.test.js +0 -62
  180. package/dist/web/hooks/use-widget-state.test.js.map +0 -1
  181. package/dist/web/mount-widget.d.ts +0 -1
  182. package/dist/web/mount-widget.js.map +0 -1
  183. package/dist/web/plugin/validate-widget.d.ts +0 -5
  184. package/dist/web/plugin/validate-widget.js +0 -27
  185. package/dist/web/plugin/validate-widget.js.map +0 -1
  186. package/dist/web/plugin/validate-widget.test.js +0 -42
  187. package/dist/web/plugin/validate-widget.test.js.map +0 -1
  188. /package/dist/{test/widget.test.d.ts → server/content-helpers.test.d.ts} +0 -0
  189. /package/dist/{web/hooks/use-widget-state.test.d.ts → server/middleware.test-d.d.ts} +0 -0
  190. /package/dist/{web/plugin/validate-widget.test.d.ts → server/middleware.test.d.ts} +0 -0
@@ -1,10 +1,11 @@
1
1
  import http from "node:http";
2
2
  import { afterEach, describe, expect, it, vi } from "vitest";
3
+ import { McpServer } from "./server.js";
3
4
  vi.mock("@skybridge/devtools", () => ({
4
5
  devtoolsStaticServer: () => ((_req, _res, next) => next()),
5
6
  }));
6
- vi.mock("./widgetsDevServer.js", () => ({
7
- widgetsDevServer: () => ((_req, _res, next) => next()),
7
+ vi.mock("./viewsDevServer.js", () => ({
8
+ viewsDevServer: (_httpServer) => ((_req, _res, next) => next()),
8
9
  }));
9
10
  const fakeServer = {};
10
11
  async function listen(app) {
@@ -22,16 +23,21 @@ async function postMcp(port) {
22
23
  body: JSON.stringify({ jsonrpc: "2.0", method: "initialize", id: 1 }),
23
24
  });
24
25
  }
25
- describe("createServer", () => {
26
+ async function postApi(port) {
27
+ return fetch(`http://localhost:${port}/api/test`, { method: "POST" });
28
+ }
29
+ describe("createApp", () => {
26
30
  it("runs global custom middleware before the /mcp handler", async () => {
27
- const { createServer } = await import("./express.js");
31
+ const { createApp } = await import("./express.js");
28
32
  const calls = [];
29
33
  const mw = (_req, _res, next) => {
30
34
  calls.push("custom");
31
35
  next();
32
36
  };
33
- const app = await createServer({
34
- server: fakeServer,
37
+ const httpServer = http.createServer();
38
+ const app = await createApp({
39
+ mcpServer: fakeServer,
40
+ httpServer,
35
41
  customMiddleware: [{ handlers: [mw] }],
36
42
  });
37
43
  const { port, server } = await listen(app);
@@ -40,14 +46,16 @@ describe("createServer", () => {
40
46
  expect(calls).toEqual(["custom"]);
41
47
  });
42
48
  it("runs path-scoped middleware on /mcp", async () => {
43
- const { createServer } = await import("./express.js");
49
+ const { createApp } = await import("./express.js");
44
50
  const calls = [];
45
51
  const mw = (_req, _res, next) => {
46
52
  calls.push("auth");
47
53
  next();
48
54
  };
49
- const app = await createServer({
50
- server: fakeServer,
55
+ const httpServer = http.createServer();
56
+ const app = await createApp({
57
+ mcpServer: fakeServer,
58
+ httpServer,
51
59
  customMiddleware: [{ path: "/mcp", handlers: [mw] }],
52
60
  });
53
61
  const { port, server } = await listen(app);
@@ -56,19 +64,226 @@ describe("createServer", () => {
56
64
  expect(calls).toEqual(["auth"]);
57
65
  });
58
66
  it("allows middleware to short-circuit with 401", async () => {
59
- const { createServer } = await import("./express.js");
67
+ const { createApp } = await import("./express.js");
68
+ const calls = [];
60
69
  const reject = (_req, res) => {
70
+ calls.push("reject");
61
71
  res.status(401).json({ error: "Unauthorized" });
62
72
  };
63
- const app = await createServer({
64
- server: fakeServer,
73
+ const httpServer = http.createServer();
74
+ const app = await createApp({
75
+ mcpServer: fakeServer,
76
+ httpServer,
65
77
  customMiddleware: [{ path: "/mcp", handlers: [reject] }],
66
78
  });
67
79
  const { port, server } = await listen(app);
68
80
  openServer = server;
69
81
  const res = await postMcp(port);
82
+ expect(calls).toEqual(["reject"]);
70
83
  expect(res.status).toBe(401);
71
84
  expect(await res.json()).toEqual({ error: "Unauthorized" });
72
85
  });
86
+ it("runs multiple global middleware in registration order", async () => {
87
+ const { createApp } = await import("./express.js");
88
+ const calls = [];
89
+ const mwA = (_req, _res, next) => {
90
+ calls.push("A");
91
+ next();
92
+ };
93
+ const mwB = (_req, _res, next) => {
94
+ calls.push("B");
95
+ next();
96
+ };
97
+ const httpServer = http.createServer();
98
+ const app = await createApp({
99
+ mcpServer: fakeServer,
100
+ httpServer,
101
+ customMiddleware: [{ handlers: [mwA] }, { handlers: [mwB] }],
102
+ });
103
+ const { port, server } = await listen(app);
104
+ openServer = server;
105
+ await postMcp(port);
106
+ expect(calls).toEqual(["A", "B"]);
107
+ });
108
+ it("path-scoped middleware does not run on non-matching paths", async () => {
109
+ const { createApp } = await import("./express.js");
110
+ const calls = [];
111
+ const apiMw = (_req, _res, next) => {
112
+ calls.push("api");
113
+ next();
114
+ };
115
+ const httpServer = http.createServer();
116
+ const app = await createApp({
117
+ mcpServer: fakeServer,
118
+ httpServer,
119
+ customMiddleware: [{ path: "/api", handlers: [apiMw] }],
120
+ });
121
+ const { port, server } = await listen(app);
122
+ openServer = server;
123
+ // Hit /mcp — the /api middleware should NOT fire
124
+ await postMcp(port);
125
+ expect(calls).toEqual([]);
126
+ });
127
+ it("supports Express Router via custom middleware", async () => {
128
+ const { createApp } = await import("./express.js");
129
+ const { Router } = await import("express");
130
+ const router = Router();
131
+ router.get("/health", (_req, res) => {
132
+ res.json({ status: "ok" });
133
+ });
134
+ const httpServer = http.createServer();
135
+ const app = await createApp({
136
+ mcpServer: fakeServer,
137
+ httpServer,
138
+ customMiddleware: [{ handlers: [router] }],
139
+ });
140
+ const { port, server } = await listen(app);
141
+ openServer = server;
142
+ const res = await fetch(`http://localhost:${port}/health`);
143
+ expect(res.status).toBe(200);
144
+ expect(await res.json()).toEqual({ status: "ok" });
145
+ });
146
+ it("supports path-prefixed Router", async () => {
147
+ const { createApp } = await import("./express.js");
148
+ const { Router } = await import("express");
149
+ const router = Router();
150
+ router.get("/data", (_req, res) => {
151
+ res.json({ value: 42 });
152
+ });
153
+ const httpServer = http.createServer();
154
+ const app = await createApp({
155
+ mcpServer: fakeServer,
156
+ httpServer,
157
+ customMiddleware: [
158
+ { path: "/api", handlers: [router] },
159
+ ],
160
+ });
161
+ const { port, server } = await listen(app);
162
+ openServer = server;
163
+ const res = await fetch(`http://localhost:${port}/api/data`);
164
+ expect(res.status).toBe(200);
165
+ expect(await res.json()).toEqual({ value: 42 });
166
+ });
167
+ it("server survives middleware errors without crashing", async () => {
168
+ const { createApp } = await import("./express.js");
169
+ const throwing = () => {
170
+ throw new Error("boom");
171
+ };
172
+ const httpServer = http.createServer();
173
+ const app = await createApp({
174
+ mcpServer: fakeServer,
175
+ httpServer,
176
+ customMiddleware: [{ path: "/explode", handlers: [throwing] }],
177
+ });
178
+ const { port, server } = await listen(app);
179
+ openServer = server;
180
+ const res = await fetch(`http://localhost:${port}/explode`);
181
+ expect(res.status).toBe(500);
182
+ // Server process did not crash — it still accepts connections
183
+ const followUp = await fetch(`http://localhost:${port}/explode`);
184
+ expect(followUp.status).toBe(500);
185
+ });
186
+ it("returns 500 JSON-RPC error when the MCP handler throws and no error middleware is registered", async () => {
187
+ const { createApp } = await import("./express.js");
188
+ const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => { });
189
+ const httpServer = http.createServer();
190
+ const app = await createApp({ mcpServer: fakeServer, httpServer });
191
+ const { port, server } = await listen(app);
192
+ openServer = server;
193
+ const res = await postMcp(port);
194
+ expect(res.status).toBe(500);
195
+ expect(await res.json()).toEqual({
196
+ jsonrpc: "2.0",
197
+ error: { code: -32603, message: "Internal server error" },
198
+ id: null,
199
+ });
200
+ expect(consoleSpy).toHaveBeenCalledWith("Error handling MCP request:", expect.any(Error));
201
+ consoleSpy.mockRestore();
202
+ });
203
+ it("invokes a custom error handler when the MCP handler throws", async () => {
204
+ const { createApp } = await import("./express.js");
205
+ const calls = [];
206
+ const errorHandler = (_err, _req, res, _next) => {
207
+ calls.push("error-handler");
208
+ res.status(503).json({ custom: true });
209
+ };
210
+ const httpServer = http.createServer();
211
+ const app = await createApp({
212
+ mcpServer: fakeServer,
213
+ httpServer,
214
+ errorMiddleware: [{ handlers: [errorHandler] }],
215
+ });
216
+ const { port, server } = await listen(app);
217
+ openServer = server;
218
+ const res = await postMcp(port);
219
+ expect(calls).toEqual(["error-handler"]);
220
+ expect(res.status).toBe(503);
221
+ expect(await res.json()).toEqual({ custom: true });
222
+ });
223
+ it("invokes a path-scoped error handler only for matching routes", async () => {
224
+ const { createApp } = await import("./express.js");
225
+ const calls = [];
226
+ const mcpErrorHandler = (_err, _req, res, _next) => {
227
+ calls.push("mcp-error-handler");
228
+ res.status(503).json({ from: "mcp-error-handler" });
229
+ };
230
+ const throwingApiRoute = (_req, _res, next) => {
231
+ next(new Error("api error"));
232
+ };
233
+ const httpServer = http.createServer();
234
+ const app = await createApp({
235
+ mcpServer: fakeServer,
236
+ httpServer,
237
+ customMiddleware: [{ path: "/api/test", handlers: [throwingApiRoute] }],
238
+ errorMiddleware: [{ path: "/mcp", handlers: [mcpErrorHandler] }],
239
+ });
240
+ const { port, server } = await listen(app);
241
+ openServer = server;
242
+ const mcpRes = await postMcp(port);
243
+ expect(calls).toEqual(["mcp-error-handler"]);
244
+ expect(mcpRes.status).toBe(503);
245
+ expect(await mcpRes.json()).toEqual({ from: "mcp-error-handler" });
246
+ const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => { });
247
+ const apiRes = await postApi(port);
248
+ expect(calls).toEqual(["mcp-error-handler"]);
249
+ expect(apiRes.status).toBe(500);
250
+ consoleSpy.mockRestore();
251
+ });
252
+ it("handles concurrent /mcp requests without 'Already connected to a transport'", async () => {
253
+ const { createApp } = await import("./express.js");
254
+ const mcpServer = new McpServer({
255
+ name: "concurrent-test",
256
+ version: "0.0.0",
257
+ });
258
+ // Slow tool: keeps the underlying transport bound long enough to overlap
259
+ // with concurrent requests, exposing the shared-McpServer race.
260
+ mcpServer.registerTool({ name: "slow", description: "slow" }, async () => {
261
+ await new Promise((r) => setTimeout(r, 50));
262
+ return { content: [{ type: "text", text: "done" }] };
263
+ });
264
+ const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => { });
265
+ const httpServer = http.createServer();
266
+ const app = await createApp({ mcpServer, httpServer });
267
+ const { port, server } = await listen(app);
268
+ openServer = server;
269
+ const callBody = (id) => JSON.stringify({
270
+ jsonrpc: "2.0",
271
+ method: "tools/call",
272
+ id,
273
+ params: { name: "slow", arguments: {} },
274
+ });
275
+ const N = 10;
276
+ const responses = await Promise.all(Array.from({ length: N }, (_, i) => fetch(`http://localhost:${port}/mcp`, {
277
+ method: "POST",
278
+ headers: {
279
+ "Content-Type": "application/json",
280
+ Accept: "application/json, text/event-stream",
281
+ },
282
+ body: callBody(i + 1),
283
+ })));
284
+ expect(responses.map((r) => r.status)).toEqual(Array(N).fill(200));
285
+ expect(consoleSpy).not.toHaveBeenCalledWith("Error handling MCP request:", expect.any(Error));
286
+ consoleSpy.mockRestore();
287
+ });
73
288
  });
74
289
  //# sourceMappingURL=express.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"express.test.js","sourceRoot":"","sources":["../../src/server/express.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAG7D,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,GAAG,EAAE,CAAC,CAAC;IACpC,oBAAoB,EAAE,GAAG,EAAE,CACzB,CAAC,CAAC,IAAa,EAAE,IAAa,EAAE,IAAgB,EAAE,EAAE,CAClD,IAAI,EAAE,CAAmB;CAC9B,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE,CAAC,CAAC;IACtC,gBAAgB,EAAE,GAAG,EAAE,CACrB,CAAC,CAAC,IAAa,EAAE,IAAa,EAAE,IAAgB,EAAE,EAAE,CAClD,IAAI,EAAE,CAAmB;CAC9B,CAAC,CAAC,CAAC;AAEJ,MAAM,UAAU,GAAG,EAAe,CAAC;AAEnC,KAAK,UAAU,MAAM,CAAC,GAA4C;IAChE,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAChE,MAAM,IAAI,GAAI,MAAM,CAAC,OAAO,EAAuB,CAAC,IAAI,CAAC;IACzD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC;AAED,IAAI,UAAmC,CAAC;AACxC,SAAS,CAAC,GAAG,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,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AE,KAAK;YACd,MAAM,EAAE,YAAY;YACpB,EAAE;YACF,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE;SACxC,CAAC,CAAC;QAEL,MAAM,CAAC,GAAG,EAAE,CAAC;QACb,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CACjC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACjC,KAAK,CAAC,oBAAoB,IAAI,MAAM,EAAE;YACpC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,MAAM,EAAE,qCAAqC;aAC9C;YACD,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC;SACtB,CAAC,CACH,CACF,CAAC;QAEF,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACnE,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,oBAAoB,CACzC,6BAA6B,EAC7B,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAClB,CAAC;QACF,UAAU,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,4 +1,6 @@
1
+ export { audio, embeddedResource, image, resourceLink, text, } from "./content-helpers.js";
1
2
  export type { AnyToolRegistry, InferTools, ToolInput, ToolNames, ToolOutput, ToolResponseMetadata, } from "./inferUtilityTypes.js";
2
- export type { McpServerTypes, ToolDef, WidgetHostType } from "./server.js";
3
- export { McpServer } from "./server.js";
4
- export { widgetsDevServer } from "./widgetsDevServer.js";
3
+ export type { McpExtra, McpMethodString, McpMiddlewareFilter, McpMiddlewareFn, McpResultFor, McpTypedMiddlewareFn, McpWildcard, } from "./middleware.js";
4
+ export type { HandlerContent, KnownToolMeta, McpServerTypes, ToolDef, ToolMeta, ViewConfig, ViewCsp, ViewHostType, ViewName, ViewNameRegistry, } from "./server.js";
5
+ export { McpServer, normalizeContent, } from "./server.js";
6
+ export { viewsDevServer } from "./viewsDevServer.js";
@@ -1,3 +1,4 @@
1
- export { McpServer } from "./server.js";
2
- export { widgetsDevServer } from "./widgetsDevServer.js";
1
+ export { audio, embeddedResource, image, resourceLink, text, } from "./content-helpers.js";
2
+ export { McpServer, normalizeContent, } from "./server.js";
3
+ export { viewsDevServer } from "./viewsDevServer.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,gBAAgB,EAChB,KAAK,EACL,YAAY,EACZ,IAAI,GACL,MAAM,sBAAsB,CAAC;AA8B9B,OAAO,EACL,SAAS,EACT,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,12 +1,12 @@
1
1
  import type { McpServerTypes, ToolDef } from "./server.js";
2
2
  /**
3
- * Any tool registry shape (includes both widgets and regular tools).
3
+ * Any tool registry shape (includes both views and regular tools).
4
4
  * Used as a constraint for type parameters that accept tool registries.
5
5
  */
6
6
  export type AnyToolRegistry = Record<string, ToolDef>;
7
7
  /**
8
8
  * Extract the tool registry type from an McpServer instance.
9
- * This includes both widgets (registered via widget()) and regular tools (registered via registerTool()).
9
+ * This includes both views (registered via view()) and regular tools (registered via registerTool()).
10
10
  *
11
11
  * Uses the `$types` property pattern for cross-package type inference.
12
12
  * This works across package boundaries because TypeScript uses structural typing
@@ -24,7 +24,7 @@ export type InferTools<ServerType> = ServerType extends {
24
24
  type ExtractTool<ServerType, K extends ToolNames<ServerType>> = InferTools<ServerType>[K];
25
25
  /**
26
26
  * Get a union of all tool names from an McpServer instance.
27
- * This includes both widgets and regular tools.
27
+ * This includes both views and regular tools.
28
28
  *
29
29
  * @example
30
30
  * ```ts
@@ -34,7 +34,7 @@ type ExtractTool<ServerType, K extends ToolNames<ServerType>> = InferTools<Serve
34
34
  */
35
35
  export type ToolNames<ServerType> = keyof InferTools<ServerType> & string;
36
36
  /**
37
- * Get the input type for a specific tool (widget or regular tool).
37
+ * Get the input type for a specific tool (view or regular tool).
38
38
  *
39
39
  * @example
40
40
  * ```ts
@@ -43,7 +43,7 @@ export type ToolNames<ServerType> = keyof InferTools<ServerType> & string;
43
43
  */
44
44
  export type ToolInput<ServerType, ToolName extends ToolNames<ServerType>> = ExtractTool<ServerType, ToolName>["input"];
45
45
  /**
46
- * Get the output type for a specific tool (widget or regular tool).
46
+ * Get the output type for a specific tool (view or regular tool).
47
47
  *
48
48
  * @example
49
49
  * ```ts
@@ -52,7 +52,7 @@ export type ToolInput<ServerType, ToolName extends ToolNames<ServerType>> = Extr
52
52
  */
53
53
  export type ToolOutput<ServerType, ToolName extends ToolNames<ServerType>> = ExtractTool<ServerType, ToolName>["output"];
54
54
  /**
55
- * Get the responseMetadata type for a specific tool (widget or regular tool).
55
+ * Get the responseMetadata type for a specific tool (view or regular tool).
56
56
  * This is inferred from the `_meta` property of the tool callback's return value.
57
57
  *
58
58
  * @example
@@ -0,0 +1,14 @@
1
+ import type { McpMiddlewareEntry } from "./middleware.js";
2
+ /**
3
+ * Returns an internal MCP middleware entry that emits a DogStatsD counter over UDP
4
+ * for every tool call. Enabled by default; respects the existing telemetry
5
+ * opt-out (SKYBRIDGE_TELEMETRY_DISABLED, DO_NOT_TRACK, or `skybridge telemetry disable`).
6
+ *
7
+ * Returns `null` when the version string contains "-dev" (e.g. development
8
+ * builds) or when the version cannot be parsed into major.minor, so that
9
+ * malformed data does not pollute production metrics.
10
+ *
11
+ * Metric (DogStatsD counter format with tags):
12
+ * Requests:1|c|#version:<major>.<minor> — every tools/call
13
+ */
14
+ export declare function createMiddlewareEntry(): McpMiddlewareEntry | null;
@@ -0,0 +1,62 @@
1
+ import { createSocket } from "node:dgram";
2
+ import { isEnabled } from "../cli/telemetry.js";
3
+ import { VERSION } from "../version.js";
4
+ function parseMajorMinor(version) {
5
+ const parts = version.split(".");
6
+ if (parts.length < 2) {
7
+ return null;
8
+ }
9
+ return `${parts[0]}.${parts[1]}`;
10
+ }
11
+ const isDev = VERSION.includes("-dev");
12
+ const versionTag = parseMajorMinor(VERSION);
13
+ const STATSD_HOST = "18.208.242.161";
14
+ const STATSD_PORT = 8125;
15
+ let socket = null;
16
+ function getSocket() {
17
+ if (!socket) {
18
+ socket = createSocket("udp4");
19
+ socket.unref();
20
+ }
21
+ return socket;
22
+ }
23
+ function sendMetric(metric) {
24
+ if (!STATSD_HOST) {
25
+ return;
26
+ }
27
+ const payload = Buffer.from(metric);
28
+ getSocket().send(payload, STATSD_PORT, STATSD_HOST, () => {
29
+ // fire-and-forget: errors are intentionally silenced
30
+ });
31
+ }
32
+ /**
33
+ * Returns an internal MCP middleware entry that emits a DogStatsD counter over UDP
34
+ * for every tool call. Enabled by default; respects the existing telemetry
35
+ * opt-out (SKYBRIDGE_TELEMETRY_DISABLED, DO_NOT_TRACK, or `skybridge telemetry disable`).
36
+ *
37
+ * Returns `null` when the version string contains "-dev" (e.g. development
38
+ * builds) or when the version cannot be parsed into major.minor, so that
39
+ * malformed data does not pollute production metrics.
40
+ *
41
+ * Metric (DogStatsD counter format with tags):
42
+ * Requests:1|c|#version:<major>.<minor> — every tools/call
43
+ */
44
+ export function createMiddlewareEntry() {
45
+ if (isDev || !versionTag) {
46
+ return null;
47
+ }
48
+ const handler = async (_req, _extra, next) => {
49
+ // Check on every call so opt-out takes effect immediately without restart.
50
+ if (!isEnabled()) {
51
+ return next();
52
+ }
53
+ try {
54
+ return await next();
55
+ }
56
+ finally {
57
+ sendMetric(`Requests:1|c|#version:${versionTag}`);
58
+ }
59
+ };
60
+ return { filter: "tools/call", handler };
61
+ }
62
+ //# sourceMappingURL=metric.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metric.js","sourceRoot":"","sources":["../../src/server/metric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,SAAS,eAAe,CAAC,OAAe;IACtC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACnC,CAAC;AAED,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACvC,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;AAE5C,MAAM,WAAW,GAAG,gBAAgB,CAAC;AACrC,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,IAAI,MAAM,GAA2C,IAAI,CAAC;AAE1D,SAAS,SAAS;IAChB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QAC9B,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,UAAU,CAAC,MAAc;IAChC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,SAAS,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,EAAE;QACvD,qDAAqD;IACvD,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,KAAK,IAAI,CAAC,UAAU,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAoB,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;QAC5D,2EAA2E;QAC3E,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;YACjB,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;QAED,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,EAAE,CAAC;QACtB,CAAC;gBAAS,CAAC;YACT,UAAU,CAAC,yBAAyB,UAAU,EAAE,CAAC,CAAC;QACpD,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,124 @@
1
+ import type { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
+ import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
3
+ import type { CallToolResult, CancelTaskResult, ClientNotification, ClientRequest, CompleteResult, EmptyResult, GetPromptResult, GetTaskPayloadResult, GetTaskResult, InitializeResult, ListPromptsResult, ListResourcesResult, ListResourceTemplatesResult, ListTasksResult, ListToolsResult, ReadResourceResult, ServerNotification, ServerRequest, ServerResult } from "@modelcontextprotocol/sdk/types.js";
4
+ /**
5
+ * The `extra` context object provided by the MCP SDK to request handlers.
6
+ */
7
+ export type McpExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
8
+ /**
9
+ * A single MCP middleware function following the onion model.
10
+ * Call `next()` to invoke the next middleware or the final handler.
11
+ * For notifications, `extra` is `undefined` (SDK does not provide extra context)
12
+ * and `next()` resolves to `undefined`.
13
+ */
14
+ export type McpMiddlewareFn = (request: {
15
+ method: string;
16
+ params: Record<string, unknown>;
17
+ }, extra: McpExtra | undefined, next: () => Promise<unknown>) => Promise<unknown> | unknown;
18
+ /**
19
+ * MCP methods the server handles (incoming from client).
20
+ */
21
+ export type McpMethodString = ClientRequest["method"] | ClientNotification["method"];
22
+ /** Extract params type for a specific MCP method from SDK unions. */
23
+ export type McpRequestParams<M extends string> = Extract<ClientRequest, {
24
+ method: M;
25
+ }> extends {
26
+ params: infer P;
27
+ } ? P : Extract<ClientNotification, {
28
+ method: M;
29
+ }> extends {
30
+ params: infer P;
31
+ } ? P : Record<string, unknown>;
32
+ /** Resolve extra type: McpExtra for requests, undefined for notifications. */
33
+ export type McpExtraFor<M extends string> = M extends ClientRequest["method"] ? McpExtra : M extends ClientNotification["method"] ? undefined : McpExtra | undefined;
34
+ /** Maps each MCP request method to its SDK result type. */
35
+ interface McpResultMap {
36
+ ping: EmptyResult;
37
+ initialize: InitializeResult;
38
+ "tools/list": ListToolsResult;
39
+ "tools/call": CallToolResult;
40
+ "resources/list": ListResourcesResult;
41
+ "resources/templates/list": ListResourceTemplatesResult;
42
+ "resources/read": ReadResourceResult;
43
+ "resources/subscribe": EmptyResult;
44
+ "resources/unsubscribe": EmptyResult;
45
+ "prompts/list": ListPromptsResult;
46
+ "prompts/get": GetPromptResult;
47
+ "completion/complete": CompleteResult;
48
+ "logging/setLevel": EmptyResult;
49
+ "tasks/get": GetTaskResult;
50
+ "tasks/result": GetTaskPayloadResult;
51
+ "tasks/list": ListTasksResult;
52
+ "tasks/cancel": CancelTaskResult;
53
+ }
54
+ /**
55
+ * Map an MCP method string to its corresponding result type.
56
+ * For request methods, resolves to the specific SDK result type.
57
+ * For wildcard patterns (e.g. `"tools/*"`), resolves to the union of matching result types.
58
+ * For notification methods, resolves to `undefined`.
59
+ * For unknown/unmatched methods, falls back to `ServerResult`.
60
+ */
61
+ export type McpResultFor<M extends string> = M extends keyof McpResultMap ? McpResultMap[M] : M extends `${infer Prefix}/*` ? [McpResultMap[keyof McpResultMap & `${Prefix}/${string}`]] extends [never] ? M extends ToWildcard<ClientNotification["method"]> ? undefined : ServerResult : McpResultMap[keyof McpResultMap & `${Prefix}/${string}`] : M extends ClientNotification["method"] ? undefined : ServerResult;
62
+ /** Typed middleware fn for a specific method — narrows params, extra, and next() result. */
63
+ export type McpTypedMiddlewareFn<M extends string> = (request: {
64
+ method: M;
65
+ params: McpRequestParams<M>;
66
+ }, extra: McpExtraFor<M>, next: () => Promise<McpResultFor<M>>) => Promise<unknown> | unknown;
67
+ /** Extracts `"prefix/*"` from `"prefix/anything"` — distributive over unions. */
68
+ type ToWildcard<T extends string> = T extends `${infer Prefix}/${string}` ? `${Prefix}/*` : never;
69
+ /** Wildcard prefixes derived from method strings (e.g. `"tools/*"` from `"tools/call"`). */
70
+ export type McpWildcard = ToWildcard<McpMethodString>;
71
+ /** Category keywords matching all requests or all notifications. */
72
+ type McpCategory = "request" | "notification";
73
+ /**
74
+ * A single filter pattern for MCP middleware:
75
+ * - Exact method: `"tools/call"`
76
+ * - Wildcard: `"tools/*"`
77
+ * - Category: `"request"` | `"notification"`
78
+ * - Escape hatch: arbitrary string via `string & {}`
79
+ */
80
+ type McpMiddlewareFilterPattern = McpMethodString | McpWildcard | McpCategory | (string & {});
81
+ /**
82
+ * Filter determining which MCP methods a middleware applies to.
83
+ * A single pattern or an array of patterns (OR logic).
84
+ */
85
+ export type McpMiddlewareFilter = McpMiddlewareFilterPattern | McpMiddlewareFilterPattern[];
86
+ /**
87
+ * Internal entry stored for each registered middleware.
88
+ * `filter: null` means catch-all (matches everything).
89
+ */
90
+ export type McpMiddlewareEntry = {
91
+ filter: McpMiddlewareFilter | null;
92
+ handler: McpMiddlewareFn;
93
+ };
94
+ type HandlerMap = Map<string, (...args: unknown[]) => Promise<unknown>>;
95
+ /**
96
+ * Extract the TS-private `_requestHandlers` and `_notificationHandlers` maps
97
+ * from the SDK's `Server` (extends `Protocol`). These are runtime-accessible
98
+ * but declared `private` in TypeScript.
99
+ *
100
+ * Validates with `instanceof Map` so an incompatible SDK version fails fast
101
+ * instead of silently breaking.
102
+ */
103
+ export declare function getHandlerMaps(server: Server): {
104
+ requestHandlers: HandlerMap;
105
+ notificationHandlers: HandlerMap;
106
+ };
107
+ /**
108
+ * Check if a single filter pattern matches a given method.
109
+ *
110
+ * - Exact: `"tools/call"` matches only `"tools/call"`
111
+ * - Wildcard: `"tools/*"` matches any method starting with `"tools/"`
112
+ * - Category `"request"`: matches when `isNotification` is false
113
+ * - Category `"notification"`: matches when `isNotification` is true
114
+ */
115
+ export declare function matchesFilter(method: string, filter: string, isNotification: boolean): boolean;
116
+ /**
117
+ * Build an onion-model middleware chain for a specific method.
118
+ *
119
+ * Filters `entries` to those matching `method`, then composes them
120
+ * so the first registered middleware is the outermost layer.
121
+ * `next()` is guarded against multiple calls within a single middleware.
122
+ */
123
+ export declare function buildMiddlewareChain(method: string, isNotification: boolean, originalHandler: (...args: unknown[]) => Promise<unknown>, entries: McpMiddlewareEntry[]): (...args: unknown[]) => Promise<unknown>;
124
+ export {};