skybridge 0.0.0-dev.c2b2b14 → 0.0.0-dev.c306a75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -9
- package/dist/cli/types.d.ts +5 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/use-nodemon.d.ts +1 -6
- package/dist/cli/use-nodemon.js +7 -3
- package/dist/cli/use-nodemon.js.map +1 -1
- package/dist/cli/use-tunnel.d.ts +8 -0
- package/dist/cli/use-tunnel.js +101 -0
- package/dist/cli/use-tunnel.js.map +1 -0
- package/dist/commands/dev.d.ts +1 -1
- package/dist/commands/dev.js +9 -7
- package/dist/commands/dev.js.map +1 -1
- package/dist/server/express.d.ts +8 -2
- package/dist/server/express.js +24 -19
- package/dist/server/express.js.map +1 -1
- package/dist/server/express.test.js +189 -11
- package/dist/server/express.test.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/middleware.d.ts +32 -4
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/middleware.test-d.js +41 -18
- package/dist/server/middleware.test-d.js.map +1 -1
- package/dist/server/middleware.test.js +107 -0
- package/dist/server/middleware.test.js.map +1 -1
- package/dist/server/server.d.ts +17 -6
- package/dist/server/server.js +61 -32
- package/dist/server/server.js.map +1 -1
- package/dist/server/templateHelper.d.ts +0 -1
- package/dist/server/templateHelper.js.map +1 -1
- package/dist/server/templates/development.hbs +0 -55
- package/dist/server/widgetsDevServer.d.ts +2 -1
- package/dist/server/widgetsDevServer.js +2 -8
- package/dist/server/widgetsDevServer.js.map +1 -1
- package/dist/test/widget.test.js +17 -15
- package/dist/test/widget.test.js.map +1 -1
- package/dist/web/bridges/mcp-app/adaptor.d.ts +4 -2
- package/dist/web/bridges/mcp-app/adaptor.js +29 -35
- package/dist/web/bridges/mcp-app/adaptor.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.d.ts +13 -30
- package/dist/web/bridges/mcp-app/bridge.js +43 -201
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +5 -3
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +2 -2
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -41
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
- package/dist/web/bridges/types.d.ts +1 -0
- package/dist/web/components/modal-provider.js +1 -3
- package/dist/web/components/modal-provider.js.map +1 -1
- package/dist/web/create-store.test.js +3 -1
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.test.js +1 -0
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/hooks/test/utils.js +4 -0
- package/dist/web/hooks/test/utils.js.map +1 -1
- package/dist/web/hooks/use-layout.test.js +3 -3
- package/dist/web/hooks/use-layout.test.js.map +1 -1
- package/dist/web/hooks/use-open-external.test.js +15 -10
- package/dist/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/web/hooks/use-request-modal.test.js +5 -1
- package/dist/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js +1 -1
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.js +18 -2
- package/dist/web/hooks/use-user.js.map +1 -1
- package/dist/web/hooks/use-user.test.js +29 -1
- package/dist/web/hooks/use-user.test.js.map +1 -1
- package/package.json +14 -14
- package/tsconfig.base.json +3 -0
- package/dist/server/const.d.ts +0 -1
- package/dist/server/const.js +0 -2
- package/dist/server/const.js.map +0 -1
|
@@ -4,7 +4,7 @@ vi.mock("@skybridge/devtools", () => ({
|
|
|
4
4
|
devtoolsStaticServer: () => ((_req, _res, next) => next()),
|
|
5
5
|
}));
|
|
6
6
|
vi.mock("./widgetsDevServer.js", () => ({
|
|
7
|
-
widgetsDevServer: () => ((_req, _res, next) => next()),
|
|
7
|
+
widgetsDevServer: (_httpServer) => ((_req, _res, next) => next()),
|
|
8
8
|
}));
|
|
9
9
|
const fakeServer = {};
|
|
10
10
|
async function listen(app) {
|
|
@@ -22,16 +22,21 @@ async function postMcp(port) {
|
|
|
22
22
|
body: JSON.stringify({ jsonrpc: "2.0", method: "initialize", id: 1 }),
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
async function postApi(port) {
|
|
26
|
+
return fetch(`http://localhost:${port}/api/test`, { method: "POST" });
|
|
27
|
+
}
|
|
28
|
+
describe("createApp", () => {
|
|
26
29
|
it("runs global custom middleware before the /mcp handler", async () => {
|
|
27
|
-
const {
|
|
30
|
+
const { createApp } = await import("./express.js");
|
|
28
31
|
const calls = [];
|
|
29
32
|
const mw = (_req, _res, next) => {
|
|
30
33
|
calls.push("custom");
|
|
31
34
|
next();
|
|
32
35
|
};
|
|
33
|
-
const
|
|
34
|
-
|
|
36
|
+
const httpServer = http.createServer();
|
|
37
|
+
const app = await createApp({
|
|
38
|
+
mcpServer: fakeServer,
|
|
39
|
+
httpServer,
|
|
35
40
|
customMiddleware: [{ handlers: [mw] }],
|
|
36
41
|
});
|
|
37
42
|
const { port, server } = await listen(app);
|
|
@@ -40,14 +45,16 @@ describe("createServer", () => {
|
|
|
40
45
|
expect(calls).toEqual(["custom"]);
|
|
41
46
|
});
|
|
42
47
|
it("runs path-scoped middleware on /mcp", async () => {
|
|
43
|
-
const {
|
|
48
|
+
const { createApp } = await import("./express.js");
|
|
44
49
|
const calls = [];
|
|
45
50
|
const mw = (_req, _res, next) => {
|
|
46
51
|
calls.push("auth");
|
|
47
52
|
next();
|
|
48
53
|
};
|
|
49
|
-
const
|
|
50
|
-
|
|
54
|
+
const httpServer = http.createServer();
|
|
55
|
+
const app = await createApp({
|
|
56
|
+
mcpServer: fakeServer,
|
|
57
|
+
httpServer,
|
|
51
58
|
customMiddleware: [{ path: "/mcp", handlers: [mw] }],
|
|
52
59
|
});
|
|
53
60
|
const { port, server } = await listen(app);
|
|
@@ -56,19 +63,190 @@ describe("createServer", () => {
|
|
|
56
63
|
expect(calls).toEqual(["auth"]);
|
|
57
64
|
});
|
|
58
65
|
it("allows middleware to short-circuit with 401", async () => {
|
|
59
|
-
const {
|
|
66
|
+
const { createApp } = await import("./express.js");
|
|
67
|
+
const calls = [];
|
|
60
68
|
const reject = (_req, res) => {
|
|
69
|
+
calls.push("reject");
|
|
61
70
|
res.status(401).json({ error: "Unauthorized" });
|
|
62
71
|
};
|
|
63
|
-
const
|
|
64
|
-
|
|
72
|
+
const httpServer = http.createServer();
|
|
73
|
+
const app = await createApp({
|
|
74
|
+
mcpServer: fakeServer,
|
|
75
|
+
httpServer,
|
|
65
76
|
customMiddleware: [{ path: "/mcp", handlers: [reject] }],
|
|
66
77
|
});
|
|
67
78
|
const { port, server } = await listen(app);
|
|
68
79
|
openServer = server;
|
|
69
80
|
const res = await postMcp(port);
|
|
81
|
+
expect(calls).toEqual(["reject"]);
|
|
70
82
|
expect(res.status).toBe(401);
|
|
71
83
|
expect(await res.json()).toEqual({ error: "Unauthorized" });
|
|
72
84
|
});
|
|
85
|
+
it("runs multiple global middleware in registration order", async () => {
|
|
86
|
+
const { createApp } = await import("./express.js");
|
|
87
|
+
const calls = [];
|
|
88
|
+
const mwA = (_req, _res, next) => {
|
|
89
|
+
calls.push("A");
|
|
90
|
+
next();
|
|
91
|
+
};
|
|
92
|
+
const mwB = (_req, _res, next) => {
|
|
93
|
+
calls.push("B");
|
|
94
|
+
next();
|
|
95
|
+
};
|
|
96
|
+
const httpServer = http.createServer();
|
|
97
|
+
const app = await createApp({
|
|
98
|
+
mcpServer: fakeServer,
|
|
99
|
+
httpServer,
|
|
100
|
+
customMiddleware: [{ handlers: [mwA] }, { handlers: [mwB] }],
|
|
101
|
+
});
|
|
102
|
+
const { port, server } = await listen(app);
|
|
103
|
+
openServer = server;
|
|
104
|
+
await postMcp(port);
|
|
105
|
+
expect(calls).toEqual(["A", "B"]);
|
|
106
|
+
});
|
|
107
|
+
it("path-scoped middleware does not run on non-matching paths", async () => {
|
|
108
|
+
const { createApp } = await import("./express.js");
|
|
109
|
+
const calls = [];
|
|
110
|
+
const apiMw = (_req, _res, next) => {
|
|
111
|
+
calls.push("api");
|
|
112
|
+
next();
|
|
113
|
+
};
|
|
114
|
+
const httpServer = http.createServer();
|
|
115
|
+
const app = await createApp({
|
|
116
|
+
mcpServer: fakeServer,
|
|
117
|
+
httpServer,
|
|
118
|
+
customMiddleware: [{ path: "/api", handlers: [apiMw] }],
|
|
119
|
+
});
|
|
120
|
+
const { port, server } = await listen(app);
|
|
121
|
+
openServer = server;
|
|
122
|
+
// Hit /mcp — the /api middleware should NOT fire
|
|
123
|
+
await postMcp(port);
|
|
124
|
+
expect(calls).toEqual([]);
|
|
125
|
+
});
|
|
126
|
+
it("supports Express Router via custom middleware", async () => {
|
|
127
|
+
const { createApp } = await import("./express.js");
|
|
128
|
+
const { Router } = await import("express");
|
|
129
|
+
const router = Router();
|
|
130
|
+
router.get("/health", (_req, res) => {
|
|
131
|
+
res.json({ status: "ok" });
|
|
132
|
+
});
|
|
133
|
+
const httpServer = http.createServer();
|
|
134
|
+
const app = await createApp({
|
|
135
|
+
mcpServer: fakeServer,
|
|
136
|
+
httpServer,
|
|
137
|
+
customMiddleware: [{ handlers: [router] }],
|
|
138
|
+
});
|
|
139
|
+
const { port, server } = await listen(app);
|
|
140
|
+
openServer = server;
|
|
141
|
+
const res = await fetch(`http://localhost:${port}/health`);
|
|
142
|
+
expect(res.status).toBe(200);
|
|
143
|
+
expect(await res.json()).toEqual({ status: "ok" });
|
|
144
|
+
});
|
|
145
|
+
it("supports path-prefixed Router", async () => {
|
|
146
|
+
const { createApp } = await import("./express.js");
|
|
147
|
+
const { Router } = await import("express");
|
|
148
|
+
const router = Router();
|
|
149
|
+
router.get("/data", (_req, res) => {
|
|
150
|
+
res.json({ value: 42 });
|
|
151
|
+
});
|
|
152
|
+
const httpServer = http.createServer();
|
|
153
|
+
const app = await createApp({
|
|
154
|
+
mcpServer: fakeServer,
|
|
155
|
+
httpServer,
|
|
156
|
+
customMiddleware: [
|
|
157
|
+
{ path: "/api", handlers: [router] },
|
|
158
|
+
],
|
|
159
|
+
});
|
|
160
|
+
const { port, server } = await listen(app);
|
|
161
|
+
openServer = server;
|
|
162
|
+
const res = await fetch(`http://localhost:${port}/api/data`);
|
|
163
|
+
expect(res.status).toBe(200);
|
|
164
|
+
expect(await res.json()).toEqual({ value: 42 });
|
|
165
|
+
});
|
|
166
|
+
it("server survives middleware errors without crashing", async () => {
|
|
167
|
+
const { createApp } = await import("./express.js");
|
|
168
|
+
const throwing = () => {
|
|
169
|
+
throw new Error("boom");
|
|
170
|
+
};
|
|
171
|
+
const httpServer = http.createServer();
|
|
172
|
+
const app = await createApp({
|
|
173
|
+
mcpServer: fakeServer,
|
|
174
|
+
httpServer,
|
|
175
|
+
customMiddleware: [{ path: "/explode", handlers: [throwing] }],
|
|
176
|
+
});
|
|
177
|
+
const { port, server } = await listen(app);
|
|
178
|
+
openServer = server;
|
|
179
|
+
const res = await fetch(`http://localhost:${port}/explode`);
|
|
180
|
+
expect(res.status).toBe(500);
|
|
181
|
+
// Server process did not crash — it still accepts connections
|
|
182
|
+
const followUp = await fetch(`http://localhost:${port}/explode`);
|
|
183
|
+
expect(followUp.status).toBe(500);
|
|
184
|
+
});
|
|
185
|
+
it("returns 500 JSON-RPC error when the MCP handler throws and no error middleware is registered", async () => {
|
|
186
|
+
const { createApp } = await import("./express.js");
|
|
187
|
+
const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => { });
|
|
188
|
+
const httpServer = http.createServer();
|
|
189
|
+
const app = await createApp({ mcpServer: fakeServer, httpServer });
|
|
190
|
+
const { port, server } = await listen(app);
|
|
191
|
+
openServer = server;
|
|
192
|
+
const res = await postMcp(port);
|
|
193
|
+
expect(res.status).toBe(500);
|
|
194
|
+
expect(await res.json()).toEqual({
|
|
195
|
+
jsonrpc: "2.0",
|
|
196
|
+
error: { code: -32603, message: "Internal server error" },
|
|
197
|
+
id: null,
|
|
198
|
+
});
|
|
199
|
+
expect(consoleSpy).toHaveBeenCalledWith("Error handling MCP request:", expect.any(Error));
|
|
200
|
+
consoleSpy.mockRestore();
|
|
201
|
+
});
|
|
202
|
+
it("invokes a custom error handler when the MCP handler throws", async () => {
|
|
203
|
+
const { createApp } = await import("./express.js");
|
|
204
|
+
const calls = [];
|
|
205
|
+
const errorHandler = (_err, _req, res, _next) => {
|
|
206
|
+
calls.push("error-handler");
|
|
207
|
+
res.status(503).json({ custom: true });
|
|
208
|
+
};
|
|
209
|
+
const httpServer = http.createServer();
|
|
210
|
+
const app = await createApp({
|
|
211
|
+
mcpServer: fakeServer,
|
|
212
|
+
httpServer,
|
|
213
|
+
errorMiddleware: [{ handlers: [errorHandler] }],
|
|
214
|
+
});
|
|
215
|
+
const { port, server } = await listen(app);
|
|
216
|
+
openServer = server;
|
|
217
|
+
const res = await postMcp(port);
|
|
218
|
+
expect(calls).toEqual(["error-handler"]);
|
|
219
|
+
expect(res.status).toBe(503);
|
|
220
|
+
expect(await res.json()).toEqual({ custom: true });
|
|
221
|
+
});
|
|
222
|
+
it("invokes a path-scoped error handler only for matching routes", async () => {
|
|
223
|
+
const { createApp } = await import("./express.js");
|
|
224
|
+
const calls = [];
|
|
225
|
+
const mcpErrorHandler = (_err, _req, res, _next) => {
|
|
226
|
+
calls.push("mcp-error-handler");
|
|
227
|
+
res.status(503).json({ from: "mcp-error-handler" });
|
|
228
|
+
};
|
|
229
|
+
const throwingApiRoute = (_req, _res, next) => {
|
|
230
|
+
next(new Error("api error"));
|
|
231
|
+
};
|
|
232
|
+
const httpServer = http.createServer();
|
|
233
|
+
const app = await createApp({
|
|
234
|
+
mcpServer: fakeServer,
|
|
235
|
+
httpServer,
|
|
236
|
+
customMiddleware: [{ path: "/api/test", handlers: [throwingApiRoute] }],
|
|
237
|
+
errorMiddleware: [{ path: "/mcp", handlers: [mcpErrorHandler] }],
|
|
238
|
+
});
|
|
239
|
+
const { port, server } = await listen(app);
|
|
240
|
+
openServer = server;
|
|
241
|
+
const mcpRes = await postMcp(port);
|
|
242
|
+
expect(calls).toEqual(["mcp-error-handler"]);
|
|
243
|
+
expect(mcpRes.status).toBe(503);
|
|
244
|
+
expect(await mcpRes.json()).toEqual({ from: "mcp-error-handler" });
|
|
245
|
+
const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => { });
|
|
246
|
+
const apiRes = await postApi(port);
|
|
247
|
+
expect(calls).toEqual(["mcp-error-handler"]);
|
|
248
|
+
expect(apiRes.status).toBe(500);
|
|
249
|
+
consoleSpy.mockRestore();
|
|
250
|
+
});
|
|
73
251
|
});
|
|
74
252
|
//# 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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,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC,CAAC;QAEnE,MAAM,UAAU,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC3E,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QACnC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAC7C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChC,UAAU,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { AnyToolRegistry, InferTools, ToolInput, ToolNames, ToolOutput, ToolResponseMetadata, } from "./inferUtilityTypes.js";
|
|
2
|
-
export type { McpExtra, McpMethodString, McpMiddlewareFilter, McpMiddlewareFn, McpTypedMiddlewareFn, } from "./middleware.js";
|
|
2
|
+
export type { McpExtra, McpMethodString, McpMiddlewareFilter, McpMiddlewareFn, McpResultFor, McpTypedMiddlewareFn, McpWildcard, } from "./middleware.js";
|
|
3
3
|
export type { McpServerTypes, ToolDef, WidgetHostType } from "./server.js";
|
|
4
4
|
export { McpServer } from "./server.js";
|
|
5
5
|
export { widgetsDevServer } from "./widgetsDevServer.js";
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
2
|
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
3
|
-
import type { ClientNotification, ClientRequest, ServerNotification, ServerRequest } from "@modelcontextprotocol/sdk/types.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
4
|
/**
|
|
5
5
|
* The `extra` context object provided by the MCP SDK to request handlers.
|
|
6
6
|
*/
|
|
@@ -31,15 +31,43 @@ export type McpRequestParams<M extends string> = Extract<ClientRequest, {
|
|
|
31
31
|
} ? P : Record<string, unknown>;
|
|
32
32
|
/** Resolve extra type: McpExtra for requests, undefined for notifications. */
|
|
33
33
|
export type McpExtraFor<M extends string> = M extends ClientRequest["method"] ? McpExtra : M extends ClientNotification["method"] ? undefined : McpExtra | undefined;
|
|
34
|
-
/**
|
|
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. */
|
|
35
63
|
export type McpTypedMiddlewareFn<M extends string> = (request: {
|
|
36
64
|
method: M;
|
|
37
65
|
params: McpRequestParams<M>;
|
|
38
|
-
}, extra: McpExtraFor<M>, next: () => Promise<
|
|
66
|
+
}, extra: McpExtraFor<M>, next: () => Promise<McpResultFor<M>>) => Promise<unknown> | unknown;
|
|
39
67
|
/** Extracts `"prefix/*"` from `"prefix/anything"` — distributive over unions. */
|
|
40
68
|
type ToWildcard<T extends string> = T extends `${infer Prefix}/${string}` ? `${Prefix}/*` : never;
|
|
41
69
|
/** Wildcard prefixes derived from method strings (e.g. `"tools/*"` from `"tools/call"`). */
|
|
42
|
-
type McpWildcard = ToWildcard<McpMethodString>;
|
|
70
|
+
export type McpWildcard = ToWildcard<McpMethodString>;
|
|
43
71
|
/** Category keywords matching all requests or all notifications. */
|
|
44
72
|
type McpCategory = "request" | "notification";
|
|
45
73
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/server/middleware.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/server/middleware.ts"],"names":[],"mappings":"AAyJA;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,MAAM,GAAG,GAAW,MAAM,CAAC;IAE3B,IACE,CAAC,CAAC,kBAAkB,IAAI,GAAG,IAAI,GAAG,CAAC,gBAAgB,YAAY,GAAG,CAAC;QACnE,CAAC,CACC,uBAAuB,IAAI,GAAG,IAAI,GAAG,CAAC,qBAAqB,YAAY,GAAG,CAC3E,EACD,CAAC;QACD,MAAM,IAAI,KAAK,CACb,6FAA6F,CAC9F,CAAC;IACJ,CAAC;IAED,OAAO;QACL,eAAe,EAAE,GAAG,CAAC,gBAA8B;QACnD,oBAAoB,EAAE,GAAG,CAAC,qBAAmC;KAC9D,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAc,EACd,MAAc,EACd,cAAuB;IAEvB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,CAAC,cAAc,CAAC;IACzB,CAAC;IACD,IAAI,MAAM,KAAK,cAAc,EAAE,CAAC;QAC9B,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,uBAAuB;QAC3D,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,MAAM,KAAK,MAAM,CAAC;AAC3B,CAAC;AAED,SAAS,gBAAgB,CACvB,MAAc,EACd,MAAkC,EAClC,cAAuB;IAE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,GAAG,UAAU,CAAC,MAAM,CAAC;gBACxC,CAAC;gBACD,OAAO,eAAe,CAAC,GAAG,IAAI,CAAC,CAAC;YAClC,CAAC;YAED,IAAI,UAAU,GAAG,KAAK,CAAC;YAEvB,MAAM,IAAI,GAAG,GAAqB,EAAE;gBAClC,IAAI,UAAU,EAAE,CAAC;oBACf,MAAM,IAAI,KAAK,CACb,mDAAmD,MAAM,GAAG,CAC7D,CAAC;gBACJ,CAAC;gBACD,UAAU,GAAG,IAAI,CAAC;gBAClB,OAAO,YAAY,EAAE,CAAC;YACxB,CAAC,CAAC;YAEF,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC;QAEF,OAAO,YAAY,EAAE,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,46 +1,69 @@
|
|
|
1
1
|
import { expectTypeOf, test } from "vitest";
|
|
2
2
|
const server = null;
|
|
3
|
-
test("request category narrows extra
|
|
4
|
-
server.mcpMiddleware("request", (_request, extra, next) => {
|
|
3
|
+
test("request category narrows extra and next() result", () => {
|
|
4
|
+
server.mcpMiddleware("request", async (_request, extra, next) => {
|
|
5
5
|
expectTypeOf(extra).toEqualTypeOf();
|
|
6
6
|
extra.signal;
|
|
7
|
-
|
|
7
|
+
const result = await next();
|
|
8
|
+
expectTypeOf(result).toEqualTypeOf();
|
|
9
|
+
return result;
|
|
8
10
|
});
|
|
9
11
|
});
|
|
10
|
-
test("notification category narrows extra
|
|
11
|
-
server.mcpMiddleware("notification", (_request, extra, next) => {
|
|
12
|
+
test("notification category narrows extra and next() result", () => {
|
|
13
|
+
server.mcpMiddleware("notification", async (_request, extra, next) => {
|
|
12
14
|
expectTypeOf(extra).toEqualTypeOf();
|
|
13
15
|
// @ts-expect-error extra is undefined, cannot access .signal
|
|
14
16
|
extra.signal;
|
|
15
|
-
|
|
17
|
+
const result = await next();
|
|
18
|
+
expectTypeOf(result).toEqualTypeOf();
|
|
16
19
|
});
|
|
17
20
|
});
|
|
18
|
-
test("exact method tools/call narrows params and
|
|
19
|
-
server.mcpMiddleware("tools/call", (request, extra, next) => {
|
|
21
|
+
test("exact method tools/call narrows params, extra, and next() result", () => {
|
|
22
|
+
server.mcpMiddleware("tools/call", async (request, extra, next) => {
|
|
20
23
|
expectTypeOf(request.params.name).toBeString();
|
|
21
24
|
expectTypeOf(extra).toEqualTypeOf();
|
|
22
|
-
|
|
25
|
+
const result = await next();
|
|
26
|
+
expectTypeOf(result).toEqualTypeOf();
|
|
27
|
+
return result;
|
|
23
28
|
});
|
|
24
29
|
});
|
|
25
|
-
test("exact method tools/list narrows
|
|
26
|
-
server.mcpMiddleware("tools/list", (_request,
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
test("exact method tools/list narrows next() to ListToolsResult", () => {
|
|
31
|
+
server.mcpMiddleware("tools/list", async (_request, _extra, next) => {
|
|
32
|
+
const result = await next();
|
|
33
|
+
expectTypeOf(result).toEqualTypeOf();
|
|
34
|
+
return result;
|
|
29
35
|
});
|
|
30
36
|
});
|
|
31
|
-
test("exact notification method narrows extra
|
|
32
|
-
server.mcpMiddleware("notifications/initialized", (_request, extra, next) => {
|
|
37
|
+
test("exact notification method narrows extra and next() result", () => {
|
|
38
|
+
server.mcpMiddleware("notifications/initialized", async (_request, extra, next) => {
|
|
33
39
|
expectTypeOf(extra).toEqualTypeOf();
|
|
34
40
|
// @ts-expect-error extra is undefined
|
|
35
41
|
extra.signal;
|
|
36
|
-
|
|
42
|
+
const result = await next();
|
|
43
|
+
expectTypeOf(result).toEqualTypeOf();
|
|
37
44
|
});
|
|
38
45
|
});
|
|
39
|
-
test("McpTypedMiddlewareFn narrows params and
|
|
40
|
-
expectTypeOf().toBeFunction();
|
|
46
|
+
test("McpTypedMiddlewareFn narrows params, extra, and next() per method", () => {
|
|
41
47
|
expectTypeOf().toBeString();
|
|
42
48
|
expectTypeOf().toEqualTypeOf();
|
|
43
49
|
expectTypeOf().toEqualTypeOf();
|
|
50
|
+
expectTypeOf().toEqualTypeOf();
|
|
51
|
+
expectTypeOf().toEqualTypeOf();
|
|
52
|
+
});
|
|
53
|
+
test("McpResultFor maps methods to correct result types", () => {
|
|
54
|
+
expectTypeOf().toEqualTypeOf();
|
|
55
|
+
expectTypeOf().toEqualTypeOf();
|
|
56
|
+
expectTypeOf().toEqualTypeOf();
|
|
57
|
+
});
|
|
58
|
+
test("wildcard tools/* narrows next() to union of tools result types", () => {
|
|
59
|
+
server.mcpMiddleware("tools/*", async (_request, _extra, next) => {
|
|
60
|
+
const result = await next();
|
|
61
|
+
expectTypeOf(result).toEqualTypeOf();
|
|
62
|
+
return result;
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
test("McpResultFor resolves wildcards to union of matching result types", () => {
|
|
66
|
+
expectTypeOf().toEqualTypeOf();
|
|
44
67
|
});
|
|
45
68
|
test("catch-all middleware has no narrowing on extra or params", () => {
|
|
46
69
|
server.mcpMiddleware((_request, extra, next) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.test-d.js","sourceRoot":"","sources":["../../src/server/middleware.test-d.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"middleware.test-d.js","sourceRoot":"","sources":["../../src/server/middleware.test-d.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAQ5C,MAAM,MAAM,GAAG,IAA4B,CAAC;AAE5C,IAAI,CAAC,kDAAkD,EAAE,GAAG,EAAE;IAC5D,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC9D,YAAY,CAAC,KAAK,CAAC,CAAC,aAAa,EAAY,CAAC;QAC9C,KAAK,CAAC,MAAM,CAAC;QACb,MAAM,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC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AC;AACL,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,mEAAmE,EAAE,GAAG,EAAE;IAC7E,YAAY,EAA2B,CAAC,aAAa,EAElD,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,0DAA0D,EAAE,GAAG,EAAE;IACpE,MAAM,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC7C,YAAY,CAAC,KAAK,CAAC,CAAC,aAAa,EAAwB,CAAC;QAC1D,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,aAAa,EAA2B,CAAC;QACvE,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -330,6 +330,113 @@ describe("McpServer.mcpMiddleware()", () => {
|
|
|
330
330
|
await client.close();
|
|
331
331
|
await server.close();
|
|
332
332
|
});
|
|
333
|
+
it("wildcard filter intercepts matching methods only", async () => {
|
|
334
|
+
const matchedMethods = [];
|
|
335
|
+
const server = new McpServer({ name: "test", version: "1.0.0" });
|
|
336
|
+
server.registerTool("t1", { description: "t1" }, () => ({
|
|
337
|
+
content: [{ type: "text", text: "ok" }],
|
|
338
|
+
}));
|
|
339
|
+
server.mcpMiddleware("tools/*", async (request, _extra, next) => {
|
|
340
|
+
matchedMethods.push(request.method);
|
|
341
|
+
return next();
|
|
342
|
+
});
|
|
343
|
+
const client = createClient();
|
|
344
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
345
|
+
await server.connect(serverTransport);
|
|
346
|
+
await client.connect(clientTransport);
|
|
347
|
+
await client.listTools();
|
|
348
|
+
await client.callTool({ name: "t1" });
|
|
349
|
+
expect(matchedMethods).toContain("tools/list");
|
|
350
|
+
expect(matchedMethods).toContain("tools/call");
|
|
351
|
+
// Should not match initialize or notifications
|
|
352
|
+
expect(matchedMethods).not.toContain("initialize");
|
|
353
|
+
expect(matchedMethods).not.toContain("notifications/initialized");
|
|
354
|
+
await client.close();
|
|
355
|
+
await server.close();
|
|
356
|
+
});
|
|
357
|
+
it("middleware can modify tool result via McpServer integration", async () => {
|
|
358
|
+
const server = new McpServer({ name: "test", version: "1.0.0" });
|
|
359
|
+
server.registerTool("greet", {
|
|
360
|
+
description: "greet",
|
|
361
|
+
inputSchema: { name: z.string() },
|
|
362
|
+
}, (args) => ({
|
|
363
|
+
content: [{ type: "text", text: `hi ${args.name}` }],
|
|
364
|
+
}));
|
|
365
|
+
server.mcpMiddleware("tools/call", async (_req, _extra, next) => {
|
|
366
|
+
const result = (await next());
|
|
367
|
+
return {
|
|
368
|
+
...result,
|
|
369
|
+
content: [
|
|
370
|
+
...result.content,
|
|
371
|
+
{ type: "text", text: " (modified)" },
|
|
372
|
+
],
|
|
373
|
+
};
|
|
374
|
+
});
|
|
375
|
+
const client = createClient();
|
|
376
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
377
|
+
await server.connect(serverTransport);
|
|
378
|
+
await client.connect(clientTransport);
|
|
379
|
+
const result = await client.callTool({
|
|
380
|
+
name: "greet",
|
|
381
|
+
arguments: { name: "World" },
|
|
382
|
+
});
|
|
383
|
+
expect(result.content).toEqual([
|
|
384
|
+
{ type: "text", text: "hi World" },
|
|
385
|
+
{ type: "text", text: " (modified)" },
|
|
386
|
+
]);
|
|
387
|
+
await client.close();
|
|
388
|
+
await server.close();
|
|
389
|
+
});
|
|
390
|
+
it("middleware can short-circuit via McpServer integration", async () => {
|
|
391
|
+
const handlerCalled = vi.fn();
|
|
392
|
+
const server = new McpServer({ name: "test", version: "1.0.0" });
|
|
393
|
+
server.registerTool("t1", { description: "t1" }, () => {
|
|
394
|
+
handlerCalled();
|
|
395
|
+
return {
|
|
396
|
+
content: [{ type: "text", text: "original" }],
|
|
397
|
+
};
|
|
398
|
+
});
|
|
399
|
+
server.mcpMiddleware("tools/call", async () => ({
|
|
400
|
+
content: [{ type: "text", text: "short-circuited" }],
|
|
401
|
+
}));
|
|
402
|
+
const client = createClient();
|
|
403
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
404
|
+
await server.connect(serverTransport);
|
|
405
|
+
await client.connect(clientTransport);
|
|
406
|
+
const result = await client.callTool({ name: "t1" });
|
|
407
|
+
expect(result.content).toEqual([{ type: "text", text: "short-circuited" }]);
|
|
408
|
+
expect(handlerCalled).not.toHaveBeenCalled();
|
|
409
|
+
await client.close();
|
|
410
|
+
await server.close();
|
|
411
|
+
});
|
|
412
|
+
it("middleware can mutate tool call params via McpServer integration", async () => {
|
|
413
|
+
let receivedName = "";
|
|
414
|
+
const server = new McpServer({ name: "test", version: "1.0.0" });
|
|
415
|
+
server.registerTool("greet", {
|
|
416
|
+
description: "greet",
|
|
417
|
+
inputSchema: { name: z.string() },
|
|
418
|
+
}, (args) => {
|
|
419
|
+
receivedName = args.name;
|
|
420
|
+
return {
|
|
421
|
+
content: [{ type: "text", text: `hi ${args.name}` }],
|
|
422
|
+
};
|
|
423
|
+
});
|
|
424
|
+
server.mcpMiddleware("tools/call", async (request, _extra, next) => {
|
|
425
|
+
request.params.arguments = { name: "Overridden" };
|
|
426
|
+
return next();
|
|
427
|
+
});
|
|
428
|
+
const client = createClient();
|
|
429
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
430
|
+
await server.connect(serverTransport);
|
|
431
|
+
await client.connect(clientTransport);
|
|
432
|
+
await client.callTool({
|
|
433
|
+
name: "greet",
|
|
434
|
+
arguments: { name: "Original" },
|
|
435
|
+
});
|
|
436
|
+
expect(receivedName).toBe("Overridden");
|
|
437
|
+
await client.close();
|
|
438
|
+
await server.close();
|
|
439
|
+
});
|
|
333
440
|
it("category 'request' filter matches requests but not notifications", async () => {
|
|
334
441
|
const matchedMethods = [];
|
|
335
442
|
const server = new McpServer({ name: "test", version: "1.0.0" });
|