skybridge 0.0.0-dev.e508ce2 → 0.0.0-dev.e54a5c4
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 +9 -5
- package/dist/commands/dev.d.ts +0 -1
- package/dist/commands/dev.js +0 -6
- package/dist/commands/dev.js.map +1 -1
- package/dist/server/express.d.ts +4 -2
- package/dist/server/express.js +3 -3
- package/dist/server/express.js.map +1 -1
- package/dist/server/express.test.js +17 -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/server.d.ts +13 -5
- package/dist/server/server.js +48 -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/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-tool-info.test.js +1 -1
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.test.js +1 -1
- package/dist/web/hooks/use-user.test.js.map +1 -1
- package/package.json +8 -8
- package/dist/server/const.d.ts +0 -1
- package/dist/server/const.js +0 -2
- package/dist/server/const.js.map +0 -1
package/README.md
CHANGED
|
@@ -120,11 +120,15 @@ Explore production-ready examples:
|
|
|
120
120
|
|
|
121
121
|
| Example | Description | Demo | Code |
|
|
122
122
|
|------------------------|----------------------------------------------------------------------------------|-----------------------------------------------------|-------------------------------------------------------------------------------------|
|
|
123
|
-
| **Capitals Explorer**
|
|
124
|
-
| **Ecommerce Carousel**
|
|
125
|
-
| **Everything**
|
|
126
|
-
| **
|
|
127
|
-
| **
|
|
123
|
+
| **Capitals Explorer** | Interactive world map with geolocation and Wikipedia integration | [Try Demo](https://capitals.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/capitals) |
|
|
124
|
+
| **Ecommerce Carousel** | Product carousel with cart, localization, and modals | [Try Demo](https://ecommerce.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/ecom-carousel) |
|
|
125
|
+
| **Everything** | Comprehensive playground showcasing all hooks and features | [Try Demo](https://everything.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/everything) |
|
|
126
|
+
| **Investigation Game** | Interactive murder mystery game with multi-screen gameplay and dynamic story progression | [Try Demo](https://investigation-game.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/investigation-game) |
|
|
127
|
+
| **Productivity** | Data visualization dashboard demonstrating Skybridge capabilities for MCP Apps | [Try Demo](https://productivity.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/productivity) |
|
|
128
|
+
| **Time's Up** | Word-guessing party game where the user gives hints and the AI tries to guess the secret word | [Try Demo](https://times-up.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/times-up) |
|
|
129
|
+
| **Auth — Clerk** | Full OAuth authentication with Clerk and personalized coffee shop search | — | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/auth-clerk) |
|
|
130
|
+
| **Auth — WorkOS AuthKit** | Full OAuth authentication with WorkOS AuthKit and personalized coffee shop search | — | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/auth-workos) |
|
|
131
|
+
| **Manifest Starter** | Starter app with Manifest UI agentic components out-of-the-box | [Try Demo](https://manifest-ui.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/manifest-ui) |
|
|
128
132
|
|
|
129
133
|
See all examples in the [Showcase](https://docs.skybridge.tech/showcase) or browse the [examples/](examples/) directory.
|
|
130
134
|
|
package/dist/commands/dev.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export default class Dev extends Command {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
port: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
-
"use-forwarded-host": import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
7
|
};
|
|
9
8
|
run(): Promise<void>;
|
|
10
9
|
}
|
package/dist/commands/dev.js
CHANGED
|
@@ -14,9 +14,6 @@ export default class Dev extends Command {
|
|
|
14
14
|
description: "Port to run the server on",
|
|
15
15
|
min: 1,
|
|
16
16
|
}),
|
|
17
|
-
"use-forwarded-host": Flags.boolean({
|
|
18
|
-
description: "Uses the forwarded host header to construct widget URLs instead of localhost, useful when accessing the dev server through a tunnel (e.g., ngrok)",
|
|
19
|
-
}),
|
|
20
17
|
};
|
|
21
18
|
async run() {
|
|
22
19
|
const { flags } = await this.parse(Dev);
|
|
@@ -27,9 +24,6 @@ export default class Dev extends Command {
|
|
|
27
24
|
const env = {
|
|
28
25
|
...process.env,
|
|
29
26
|
__PORT: String(port),
|
|
30
|
-
...(flags["use-forwarded-host"]
|
|
31
|
-
? { SKYBRIDGE_USE_FORWARDED_HOST: "true" }
|
|
32
|
-
: {}),
|
|
33
27
|
};
|
|
34
28
|
const App = () => {
|
|
35
29
|
const tsErrors = useTypeScriptCheck();
|
package/dist/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,OAAO;IACtC,MAAM,CAAU,WAAW,GAAG,0BAA0B,CAAC;IACzD,MAAM,CAAU,QAAQ,GAAG,CAAC,WAAW,CAAC,CAAC;IACzC,MAAM,CAAU,KAAK,GAAG;QACtB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC;YAClB,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,2BAA2B;YACxC,GAAG,EAAE,CAAC;SACP,CAAC;
|
|
1
|
+
{"version":3,"file":"dev.js","s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AC,CAAC,CAAC,CAC5B,8BACE,MAAC,IAAI,IAAC,KAAK,EAAC,OAAO,uBAAG,IAAI,IAAQ,EAClC,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,YAAE,OAAO,CAAC,IAAI,GAAQ,IACxC,CACJ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAC7B,KAAC,IAAI,IAAC,KAAK,EAAC,KAAK,YAAE,OAAO,CAAC,IAAI,GAAQ,CACxC,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,cAAE,OAAO,CAAC,IAAI,GAAQ,CAC5B,IAVO,OAAO,CAAC,EAAE,CAWd,CACP,CAAC,IACE,CACP,IACG,CACP,CAAC;QACJ,CAAC,CAAC;QAEF,MAAM,CAAC,KAAC,GAAG,KAAG,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC"}
|
package/dist/server/express.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type http from "node:http";
|
|
1
2
|
import express from "express";
|
|
2
3
|
import type { McpServer } from "./server";
|
|
3
|
-
export declare function
|
|
4
|
-
|
|
4
|
+
export declare function createApp({ mcpServer, httpServer, customMiddleware, }: {
|
|
5
|
+
mcpServer: McpServer;
|
|
6
|
+
httpServer: http.Server;
|
|
5
7
|
customMiddleware?: {
|
|
6
8
|
path?: string;
|
|
7
9
|
handlers: express.RequestHandler[];
|
package/dist/server/express.js
CHANGED
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
3
3
|
import cors from "cors";
|
|
4
4
|
import express from "express";
|
|
5
|
-
export async function
|
|
5
|
+
export async function createApp({ mcpServer, httpServer, customMiddleware = [], }) {
|
|
6
6
|
const app = express();
|
|
7
7
|
app.use(express.json());
|
|
8
8
|
const env = process.env.NODE_ENV || "development";
|
|
@@ -18,14 +18,14 @@ export async function createServer({ server, customMiddleware = [], }) {
|
|
|
18
18
|
const { devtoolsStaticServer } = await import("@skybridge/devtools");
|
|
19
19
|
app.use(await devtoolsStaticServer());
|
|
20
20
|
const { widgetsDevServer } = await import("./widgetsDevServer.js");
|
|
21
|
-
app.use(await widgetsDevServer());
|
|
21
|
+
app.use(await widgetsDevServer(httpServer));
|
|
22
22
|
}
|
|
23
23
|
if (env === "production") {
|
|
24
24
|
const assetsPath = path.join(process.cwd(), "dist", "assets");
|
|
25
25
|
app.use("/assets", cors());
|
|
26
26
|
app.use("/assets", express.static(assetsPath));
|
|
27
27
|
}
|
|
28
|
-
app.use("/mcp", mcpMiddleware(
|
|
28
|
+
app.use("/mcp", mcpMiddleware(mcpServer));
|
|
29
29
|
return app;
|
|
30
30
|
}
|
|
31
31
|
const mcpMiddleware = (server) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/server/express.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/server/express.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,EAC9B,SAAS,EACT,UAAU,EACV,gBAAgB,GAAG,EAAE,GAKtB;IACC,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACxB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,CAAC;IAElD,KAAK,MAAM,UAAU,IAAI,gBAAgB,EAAE,CAAC;QAC1C,IAAI,UAAU,CAAC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|
|
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,18 @@ async function postMcp(port) {
|
|
|
22
22
|
body: JSON.stringify({ jsonrpc: "2.0", method: "initialize", id: 1 }),
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
describe("
|
|
25
|
+
describe("createApp", () => {
|
|
26
26
|
it("runs global custom middleware before the /mcp handler", async () => {
|
|
27
|
-
const {
|
|
27
|
+
const { createApp } = await import("./express.js");
|
|
28
28
|
const calls = [];
|
|
29
29
|
const mw = (_req, _res, next) => {
|
|
30
30
|
calls.push("custom");
|
|
31
31
|
next();
|
|
32
32
|
};
|
|
33
|
-
const
|
|
34
|
-
|
|
33
|
+
const httpServer = http.createServer();
|
|
34
|
+
const app = await createApp({
|
|
35
|
+
mcpServer: fakeServer,
|
|
36
|
+
httpServer,
|
|
35
37
|
customMiddleware: [{ handlers: [mw] }],
|
|
36
38
|
});
|
|
37
39
|
const { port, server } = await listen(app);
|
|
@@ -40,14 +42,16 @@ describe("createServer", () => {
|
|
|
40
42
|
expect(calls).toEqual(["custom"]);
|
|
41
43
|
});
|
|
42
44
|
it("runs path-scoped middleware on /mcp", async () => {
|
|
43
|
-
const {
|
|
45
|
+
const { createApp } = await import("./express.js");
|
|
44
46
|
const calls = [];
|
|
45
47
|
const mw = (_req, _res, next) => {
|
|
46
48
|
calls.push("auth");
|
|
47
49
|
next();
|
|
48
50
|
};
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
+
const httpServer = http.createServer();
|
|
52
|
+
const app = await createApp({
|
|
53
|
+
mcpServer: fakeServer,
|
|
54
|
+
httpServer,
|
|
51
55
|
customMiddleware: [{ path: "/mcp", handlers: [mw] }],
|
|
52
56
|
});
|
|
53
57
|
const { port, server } = await listen(app);
|
|
@@ -56,12 +60,14 @@ describe("createServer", () => {
|
|
|
56
60
|
expect(calls).toEqual(["auth"]);
|
|
57
61
|
});
|
|
58
62
|
it("allows middleware to short-circuit with 401", async () => {
|
|
59
|
-
const {
|
|
63
|
+
const { createApp } = await import("./express.js");
|
|
60
64
|
const reject = (_req, res) => {
|
|
61
65
|
res.status(401).json({ error: "Unauthorized" });
|
|
62
66
|
};
|
|
63
|
-
const
|
|
64
|
-
|
|
67
|
+
const httpServer = http.createServer();
|
|
68
|
+
const app = await createApp({
|
|
69
|
+
mcpServer: fakeServer,
|
|
70
|
+
httpServer,
|
|
65
71
|
customMiddleware: [{ path: "/mcp", handlers: [reject] }],
|
|
66
72
|
});
|
|
67
73
|
const { port, server } = await listen(app);
|
|
@@ -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,
|
|
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,CAA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,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC;IAC9D,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,k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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;QAC5B,YAAY,CAAC,MAAM,CAAC,CAAC,aAAa,EAAgB,CAAC;QACnD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,uDAAuD,EAAE,GAAG,EAAE;IACjE,MAAM,CAAC,aAAa,CAAC,cAAc,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACnE,YAAY,CAAC,KAAK,CAAC,CAAC,aAAa,EAAa,CAA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1D,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,aAAa,EAA2B,CAAC;QACvE,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/server/server.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type { McpUiResourceMeta } from "@modelcontextprotocol/ext-apps";
|
|
|
2
2
|
import { McpServer as McpServerBase, type RegisteredTool } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import type { AnySchema, SchemaOutput, ZodRawShapeCompat } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
4
4
|
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
5
|
-
import type { CallToolResult, Resource, ServerNotification, ServerRequest, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
import type { CallToolResult, Resource, ServerNotification, ServerRequest, ServerResult, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
6
6
|
import type { RequestHandler } from "express";
|
|
7
|
-
import type { McpExtra, McpMethodString, McpMiddlewareFilter, McpMiddlewareFn, McpTypedMiddlewareFn } from "./middleware.js";
|
|
7
|
+
import type { McpExtra, McpExtraFor, McpMethodString, McpMiddlewareFilter, McpMiddlewareFn, McpResultFor, McpTypedMiddlewareFn, McpWildcard } from "./middleware.js";
|
|
8
8
|
export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unknown> = {
|
|
9
9
|
input: TInput;
|
|
10
10
|
output: TOutput;
|
|
@@ -99,19 +99,27 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
99
99
|
mcpMiddleware(filter: "request", handler: (request: {
|
|
100
100
|
method: string;
|
|
101
101
|
params: Record<string, unknown>;
|
|
102
|
-
}, extra: McpExtra, next: () => Promise<
|
|
102
|
+
}, extra: McpExtra, next: () => Promise<ServerResult>) => Promise<unknown> | unknown): this;
|
|
103
103
|
/**
|
|
104
104
|
* Register MCP protocol-level middleware for all notifications (`extra` is `undefined`).
|
|
105
105
|
*/
|
|
106
106
|
mcpMiddleware(filter: "notification", handler: (request: {
|
|
107
107
|
method: string;
|
|
108
108
|
params: Record<string, unknown>;
|
|
109
|
-
}, extra: undefined, next: () => Promise<
|
|
109
|
+
}, extra: undefined, next: () => Promise<undefined>) => Promise<unknown> | unknown): this;
|
|
110
110
|
/**
|
|
111
111
|
* Register MCP protocol-level middleware for an exact method.
|
|
112
|
-
* Narrows
|
|
112
|
+
* Narrows `params`, `extra`, and `next()` result based on the method string.
|
|
113
113
|
*/
|
|
114
114
|
mcpMiddleware<M extends McpMethodString>(filter: M, handler: McpTypedMiddlewareFn<M>): this;
|
|
115
|
+
/**
|
|
116
|
+
* Register MCP protocol-level middleware for a wildcard pattern (e.g. `"tools/*"`).
|
|
117
|
+
* `next()` returns the union of result types for matching methods.
|
|
118
|
+
*/
|
|
119
|
+
mcpMiddleware<W extends McpWildcard>(filter: W, handler: (request: {
|
|
120
|
+
method: string;
|
|
121
|
+
params: Record<string, unknown>;
|
|
122
|
+
}, extra: McpExtraFor<W>, next: () => Promise<McpResultFor<W>>) => Promise<unknown> | unknown): this;
|
|
115
123
|
/**
|
|
116
124
|
* Register MCP protocol-level middleware with a method filter.
|
|
117
125
|
* Filter can be an exact method (`"tools/call"`), wildcard (`"tools/*"`),
|
package/dist/server/server.js
CHANGED
|
@@ -4,8 +4,7 @@ import http from "node:http";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { McpServer as McpServerBase, } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
6
|
import { mergeWith, union } from "es-toolkit";
|
|
7
|
-
import {
|
|
8
|
-
import { createServer } from "./express.js";
|
|
7
|
+
import { createApp } from "./express.js";
|
|
9
8
|
import { buildMiddlewareChain, getHandlerMaps } from "./middleware.js";
|
|
10
9
|
import { templateHelper } from "./templateHelper.js";
|
|
11
10
|
const mergeWithUnion = (target, source) => {
|
|
@@ -85,21 +84,22 @@ export class McpServer extends McpServerBase {
|
|
|
85
84
|
}
|
|
86
85
|
async run() {
|
|
87
86
|
this.applyMcpMiddleware();
|
|
87
|
+
const httpServer = http.createServer();
|
|
88
88
|
if (!this.express) {
|
|
89
|
-
this.express = await
|
|
90
|
-
|
|
89
|
+
this.express = await createApp({
|
|
90
|
+
mcpServer: this,
|
|
91
|
+
httpServer,
|
|
91
92
|
customMiddleware: this.customMiddleware,
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
|
-
|
|
95
|
+
httpServer.on("request", this.express);
|
|
95
96
|
return new Promise((resolve, reject) => {
|
|
96
|
-
|
|
97
|
-
server.on("error", (error) => {
|
|
97
|
+
httpServer.on("error", (error) => {
|
|
98
98
|
console.error("Failed to start server:", error);
|
|
99
99
|
reject(error);
|
|
100
100
|
});
|
|
101
101
|
const port = parseInt(process.env.__PORT ?? "3000", 10);
|
|
102
|
-
|
|
102
|
+
httpServer.listen(port, () => {
|
|
103
103
|
resolve();
|
|
104
104
|
});
|
|
105
105
|
});
|
|
@@ -189,15 +189,33 @@ export class McpServer extends McpServerBase {
|
|
|
189
189
|
const { hostType, uri: widgetUri, mimeType, buildContentMeta, } = widgetConfig;
|
|
190
190
|
this.registerResource(name, widgetUri, { ...resourceConfig, _meta: resourceConfig._meta }, async (uri, extra) => {
|
|
191
191
|
const isProduction = process.env.NODE_ENV === "production";
|
|
192
|
-
const useForwardedHost = process.env.SKYBRIDGE_USE_FORWARDED_HOST === "true";
|
|
193
192
|
const isClaude = extra?.requestInfo?.headers?.["user-agent"] === "Claude-User";
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
193
|
+
const headers = extra?.requestInfo?.headers || {};
|
|
194
|
+
const header = (key) => {
|
|
195
|
+
const val = headers[key];
|
|
196
|
+
return Array.isArray(val) ? val[0] : val;
|
|
197
|
+
};
|
|
198
|
+
let serverUrl;
|
|
199
|
+
const forwardedHost = header("x-forwarded-host");
|
|
200
|
+
const origin = header("origin");
|
|
201
|
+
const host = header("host");
|
|
202
|
+
if (forwardedHost) {
|
|
203
|
+
const proto = header("x-forwarded-proto") || "https";
|
|
204
|
+
serverUrl = `${proto}://${forwardedHost}`;
|
|
205
|
+
}
|
|
206
|
+
else if (origin) {
|
|
207
|
+
serverUrl = origin;
|
|
208
|
+
}
|
|
209
|
+
else if (host) {
|
|
210
|
+
const proto = ["127.0.0.1:", "localhost:"].some((p) => host.startsWith(p))
|
|
211
|
+
? "http"
|
|
212
|
+
: "https";
|
|
213
|
+
serverUrl = `${proto}://${host}`;
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
const devPort = process.env.__PORT || "3000";
|
|
217
|
+
serverUrl = `http://localhost:${devPort}`;
|
|
218
|
+
}
|
|
201
219
|
const html = isProduction
|
|
202
220
|
? templateHelper.renderProduction({
|
|
203
221
|
hostType,
|
|
@@ -208,27 +226,25 @@ export class McpServer extends McpServerBase {
|
|
|
208
226
|
: templateHelper.renderDevelopment({
|
|
209
227
|
hostType,
|
|
210
228
|
serverUrl,
|
|
211
|
-
useLocalNetworkAccess: !useExternalHost,
|
|
212
229
|
widgetName: name,
|
|
213
230
|
});
|
|
214
231
|
const connectDomains = [serverUrl];
|
|
215
232
|
if (!isProduction) {
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
connectDomains.push(
|
|
233
|
+
const wsUrl = new URL(serverUrl);
|
|
234
|
+
wsUrl.protocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
235
|
+
connectDomains.push(wsUrl.origin);
|
|
236
|
+
}
|
|
237
|
+
let contentMetaOverrides = {};
|
|
238
|
+
if (isClaude) {
|
|
239
|
+
const pathname = extra?.requestInfo?.url?.pathname ?? "";
|
|
240
|
+
const url = `${serverUrl}${pathname}`;
|
|
241
|
+
const hash = crypto
|
|
242
|
+
.createHash("sha256")
|
|
243
|
+
.update(url)
|
|
244
|
+
.digest("hex")
|
|
245
|
+
.slice(0, 32);
|
|
246
|
+
contentMetaOverrides = { domain: `${hash}.claudemcpcontent.com` };
|
|
219
247
|
}
|
|
220
|
-
const pathname = extra?.requestInfo?.url?.pathname ?? "";
|
|
221
|
-
const url = `https://${hostFromHeaders}${pathname}`;
|
|
222
|
-
const hash = crypto
|
|
223
|
-
.createHash("sha256")
|
|
224
|
-
.update(url)
|
|
225
|
-
.digest("hex")
|
|
226
|
-
.slice(0, 32);
|
|
227
|
-
const contentMetaOverrides = isClaude
|
|
228
|
-
? {
|
|
229
|
-
domain: `${hash}.claudemcpcontent.com`,
|
|
230
|
-
}
|
|
231
|
-
: {};
|
|
232
248
|
const contentMeta = buildContentMeta({
|
|
233
249
|
resourceDomains: [serverUrl],
|
|
234
250
|
connectDomains,
|