skybridge 0.0.0-dev.bee74db → 0.0.0-dev.befb8f5
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/LICENSE +21 -674
- package/README.md +111 -14
- package/dist/src/server/devtoolsStaticServer.d.ts +15 -0
- package/dist/src/server/devtoolsStaticServer.js +38 -0
- package/dist/src/server/devtoolsStaticServer.js.map +1 -0
- package/dist/src/server/index.d.ts +3 -2
- package/dist/src/server/index.js +1 -0
- package/dist/src/server/index.js.map +1 -1
- package/dist/src/server/inferUtilityTypes.d.ts +10 -0
- package/dist/src/server/server.d.ts +19 -11
- package/dist/src/server/server.js +44 -33
- package/dist/src/server/server.js.map +1 -1
- package/dist/src/server/templateHelper.js +5 -4
- package/dist/src/server/templateHelper.js.map +1 -1
- package/dist/src/server/templates/development.hbs +2 -2
- package/dist/src/server/widgetsDevServer.js +3 -3
- package/dist/src/server/widgetsDevServer.js.map +1 -1
- package/dist/src/test/utils.d.ts +44 -9
- package/dist/src/test/utils.js +61 -3
- package/dist/src/test/utils.js.map +1 -1
- package/dist/src/test/widget.test.js +42 -20
- package/dist/src/test/widget.test.js.map +1 -1
- package/dist/src/web/create-store.d.ts +3 -0
- package/dist/src/web/create-store.js +25 -0
- package/dist/src/web/create-store.js.map +1 -0
- package/dist/src/web/create-store.test.d.ts +1 -0
- package/dist/src/web/create-store.test.js +70 -0
- package/dist/src/web/create-store.test.js.map +1 -0
- package/dist/src/web/data-llm.d.ts +1 -0
- package/dist/src/web/data-llm.js +4 -3
- package/dist/src/web/data-llm.js.map +1 -1
- package/dist/src/web/data-llm.test.js.map +1 -1
- package/dist/src/web/generate-helpers.d.ts +9 -7
- package/dist/src/web/generate-helpers.js +4 -2
- package/dist/src/web/generate-helpers.js.map +1 -1
- package/dist/src/web/generate-helpers.test-d.js +29 -2
- package/dist/src/web/generate-helpers.test-d.js.map +1 -1
- package/dist/src/web/generate-helpers.test.js +1 -1
- package/dist/src/web/generate-helpers.test.js.map +1 -1
- package/dist/src/web/helpers/state.d.ts +7 -0
- package/dist/src/web/helpers/state.js +40 -0
- package/dist/src/web/helpers/state.js.map +1 -0
- package/dist/src/web/helpers/state.test.d.ts +1 -0
- package/dist/src/web/helpers/state.test.js +53 -0
- package/dist/src/web/helpers/state.test.js.map +1 -0
- package/dist/src/web/hooks/index.d.ts +2 -2
- package/dist/src/web/hooks/index.js +1 -1
- package/dist/src/web/hooks/index.js.map +1 -1
- package/dist/src/web/hooks/use-call-tool.d.ts +1 -1
- package/dist/src/web/hooks/use-call-tool.js.map +1 -1
- package/dist/src/web/hooks/use-call-tool.test-d.js +1 -1
- package/dist/src/web/hooks/use-call-tool.test-d.js.map +1 -1
- package/dist/src/web/hooks/use-call-tool.test.js +9 -15
- package/dist/src/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/src/web/hooks/use-display-mode.js.map +1 -1
- package/dist/src/web/hooks/use-display-mode.test.js +2 -2
- package/dist/src/web/hooks/use-display-mode.test.js.map +1 -1
- package/dist/src/web/hooks/use-files.test.js +1 -1
- package/dist/src/web/hooks/use-files.test.js.map +1 -1
- package/dist/src/web/hooks/use-locale.js.map +1 -1
- package/dist/src/web/hooks/use-locale.test.js +2 -2
- package/dist/src/web/hooks/use-locale.test.js.map +1 -1
- package/dist/src/web/hooks/use-open-external.test.js +2 -2
- package/dist/src/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/src/web/hooks/use-openai-global.d.ts +1 -1
- package/dist/src/web/hooks/use-openai-global.js +7 -5
- package/dist/src/web/hooks/use-openai-global.js.map +1 -1
- package/dist/src/web/hooks/use-request-modal.test.js +2 -2
- package/dist/src/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/src/web/hooks/use-theme.js.map +1 -1
- package/dist/src/web/hooks/use-theme.test.js +2 -2
- package/dist/src/web/hooks/use-theme.test.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.d.ts +1 -1
- package/dist/src/web/hooks/use-tool-info.js +4 -6
- package/dist/src/web/hooks/use-tool-info.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.test-d.js +0 -1
- package/dist/src/web/hooks/use-tool-info.test-d.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.test.js +2 -2
- package/dist/src/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/src/web/hooks/use-user-agent.js.map +1 -1
- package/dist/src/web/hooks/use-user-agent.test.js +2 -2
- package/dist/src/web/hooks/use-user-agent.test.js.map +1 -1
- package/dist/src/web/hooks/use-widget-state.js +3 -25
- package/dist/src/web/hooks/use-widget-state.js.map +1 -1
- package/dist/src/web/hooks/use-widget-state.test.js +2 -2
- package/dist/src/web/hooks/use-widget-state.test.js.map +1 -1
- package/dist/src/web/index.d.ts +4 -3
- package/dist/src/web/index.js +4 -3
- package/dist/src/web/index.js.map +1 -1
- package/dist/src/web/plugin/plugin.js +10 -4
- package/dist/src/web/plugin/plugin.js.map +1 -1
- package/dist/src/web/proxy.js +1 -1
- package/dist/src/web/proxy.js.map +1 -1
- package/dist/src/web/types.d.ts +3 -3
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -1,28 +1,125 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
+
<img alt="Skybridge" src="docs/static/img/github-banner.png" width="100%">
|
|
4
|
+
|
|
5
|
+
<br />
|
|
6
|
+
|
|
3
7
|
# Skybridge
|
|
4
8
|
|
|
5
|
-
**
|
|
9
|
+
**Build ChatGPT Apps. The Modern TypeScript Way.**
|
|
10
|
+
|
|
11
|
+
The fullstack TypeScript framework for ChatGPT Apps.<br />
|
|
12
|
+
**Type-safe. React-powered. Zero config.**
|
|
13
|
+
|
|
14
|
+
<br />
|
|
15
|
+
|
|
16
|
+
[](https://www.npmjs.com/package/skybridge)
|
|
17
|
+
[](https://www.npmjs.com/package/skybridge)
|
|
18
|
+
[](https://github.com/alpic-ai/skybridge/blob/main/LICENSE)
|
|
19
|
+
|
|
20
|
+
<br />
|
|
21
|
+
|
|
22
|
+
[Documentation](https://skybridge.tech) · [Quick Start](https://github.com/new?template_name=apps-sdk-template&template_owner=alpic-ai) · [Examples](https://github.com/alpic-ai/apps-sdk-template)
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<br />
|
|
27
|
+
|
|
28
|
+
## ✨ Why Skybridge?
|
|
29
|
+
|
|
30
|
+
ChatGPT Apps let you embed **rich, interactive UIs** directly in conversations. But the raw SDK is low-level—no hooks, no type safety, no dev tools, and no HMR.
|
|
31
|
+
|
|
32
|
+
**Skybridge fixes that.**
|
|
33
|
+
|
|
34
|
+
| | |
|
|
35
|
+
|:--|:--|
|
|
36
|
+
| 👨💻 **Full Dev Environment** — HMR, debug traces, and local devtools. No more refresh loops. | ✅ **End-to-End Type Safety** — tRPC-style inference from server to widget. Autocomplete everywhere. |
|
|
37
|
+
| 🔄 **Widget-to-Model Sync** — Keep the model aware of UI state with `data-llm`. Dual surfaces, one source of truth. | ⚒️ **React Query-style Hooks** — `isPending`, `isError`, callbacks. State management you already know. |
|
|
38
|
+
|
|
39
|
+
<br />
|
|
40
|
+
|
|
41
|
+
## 🚀 Get Started
|
|
42
|
+
|
|
43
|
+
**Create a new ChatGPT app:**
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
gh repo create my-app --template alpic-ai/apps-sdk-template --clone
|
|
47
|
+
cd my-app && pnpm install
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Or add to an existing project:**
|
|
6
51
|
|
|
7
|
-
|
|
52
|
+
```bash
|
|
53
|
+
npm i skybridge
|
|
54
|
+
yarn add skybridge
|
|
55
|
+
pnpm add skybridge
|
|
56
|
+
bun add skybridge
|
|
57
|
+
deno add skybridge
|
|
58
|
+
```
|
|
8
59
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
60
|
+
<div align="center">
|
|
61
|
+
|
|
62
|
+
**👉 [Read the Docs](https://skybridge.tech) 👈**
|
|
12
63
|
|
|
13
64
|
</div>
|
|
14
65
|
|
|
15
|
-
|
|
66
|
+
<br />
|
|
67
|
+
|
|
68
|
+
## 📦 The Stack
|
|
69
|
+
|
|
70
|
+
- **`skybridge/server`** — Drop-in MCP SDK replacement with widget registration and type inference.
|
|
71
|
+
- **`skybridge/web`** — React hooks and components for ChatGPT's runtime.
|
|
72
|
+
|
|
73
|
+
### Server
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { McpServer } from "skybridge/server";
|
|
77
|
+
|
|
78
|
+
server.registerWidget("flights", {}, {
|
|
79
|
+
inputSchema: { destination: z.string() },
|
|
80
|
+
}, async ({ destination }) => {
|
|
81
|
+
const flights = await searchFlights(destination);
|
|
82
|
+
return { structuredContent: { flights } };
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Widget
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { useToolInfo } from "skybridge/web";
|
|
90
|
+
|
|
91
|
+
function FlightsWidget() {
|
|
92
|
+
const { output } = useToolInfo();
|
|
16
93
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
94
|
+
return output.structuredContent.flights.map(f =>
|
|
95
|
+
<FlightCard key={f.id} flight={f} />
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
20
99
|
|
|
21
|
-
|
|
100
|
+
<br />
|
|
22
101
|
|
|
23
|
-
##
|
|
102
|
+
## 🎯 Features at a Glance
|
|
103
|
+
|
|
104
|
+
- **Live Reload** — Vite HMR. See changes instantly without reinstalling.
|
|
105
|
+
- **Typed Hooks** — Full autocomplete for tools, inputs, outputs.
|
|
106
|
+
- **Widget → Tool Calls** — Trigger server actions from UI.
|
|
107
|
+
- **Dual Surface Sync** — Keep model aware of what users see with `data-llm`.
|
|
108
|
+
- **React Query-style API** — `isPending`, `isError`, callbacks.
|
|
109
|
+
- **MCP Compatible** — Extends the official SDK. Works with any MCP client.
|
|
110
|
+
|
|
111
|
+
<br />
|
|
112
|
+
|
|
113
|
+
<div align="center">
|
|
114
|
+
|
|
115
|
+
[](https://github.com/alpic-ai/skybridge/discussions)
|
|
116
|
+
[](https://github.com/alpic-ai/skybridge/issues)
|
|
117
|
+
[](https://discord.com/invite/gNAazGueab)
|
|
24
118
|
|
|
25
|
-
We welcome issues and pull requests!</br>
|
|
26
|
-
Participate in [GitHub discussions](https://github.com/alpic-ai/skybridge/discussions)</br>
|
|
27
|
-
Chat with the community on [Discord](https://discord.com/invite/gNAazGueab)</br>
|
|
28
119
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions
|
|
120
|
+
|
|
121
|
+
<br />
|
|
122
|
+
|
|
123
|
+
**[MIT License](LICENSE)** · Made with ❤️ by **[Alpic](https://alpic.ai)**
|
|
124
|
+
|
|
125
|
+
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type RequestHandler } from "express";
|
|
2
|
+
/**
|
|
3
|
+
* Serve the built devtools React app
|
|
4
|
+
* This router serves static files from the devtools's dist directory.
|
|
5
|
+
* It should be installed at the application root, like so:
|
|
6
|
+
*
|
|
7
|
+
* const app = express();
|
|
8
|
+
*
|
|
9
|
+
* if (env.NODE_ENV !== "production") {
|
|
10
|
+
* app.use(await devtoolsStaticServer(server));
|
|
11
|
+
* app.use(await widgetsDevServer());
|
|
12
|
+
* ^^^^^^^^ Make sure to install the devtoolsStaticServer before the widgetsDevServer
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
export declare const devtoolsStaticServer: () => Promise<RequestHandler>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import cors from "cors";
|
|
5
|
+
import express, {} from "express";
|
|
6
|
+
/**
|
|
7
|
+
* Serve the built devtools React app
|
|
8
|
+
* This router serves static files from the devtools's dist directory.
|
|
9
|
+
* It should be installed at the application root, like so:
|
|
10
|
+
*
|
|
11
|
+
* const app = express();
|
|
12
|
+
*
|
|
13
|
+
* if (env.NODE_ENV !== "production") {
|
|
14
|
+
* app.use(await devtoolsStaticServer(server));
|
|
15
|
+
* app.use(await widgetsDevServer());
|
|
16
|
+
* ^^^^^^^^ Make sure to install the devtoolsStaticServer before the widgetsDevServer
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
export const devtoolsStaticServer = async () => {
|
|
20
|
+
const router = express.Router();
|
|
21
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
const devtoolsPath = path.join(currentDir, "..", "devtools");
|
|
23
|
+
router.use(cors());
|
|
24
|
+
router.use(express.static(devtoolsPath));
|
|
25
|
+
router.get("/", (_req, res, next) => {
|
|
26
|
+
const indexHtmlPath = path.join(devtoolsPath, "index.html");
|
|
27
|
+
try {
|
|
28
|
+
const indexHtml = readFileSync(indexHtmlPath, "utf-8");
|
|
29
|
+
res.setHeader("Content-Type", "text/html");
|
|
30
|
+
res.send(indexHtml);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
next(error);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return router;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=devtoolsStaticServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devtoolsStaticServer.js","sourceRoot":"","sources":["../../../src/server/devtoolsStaticServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,EAAE,EAAuB,MAAM,SAAS,CAAC;AAEvD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,IAA6B,EAAE;IACtE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAChC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IAE7D,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAEnB,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAClC,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAC5D,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;YACvD,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;YAC3C,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
export { devtoolsStaticServer } from "./devtoolsStaticServer.js";
|
|
2
|
+
export type { AnyToolRegistry, InferTools, ToolInput, ToolNames, ToolOutput, ToolResponseMetadata, } from "./inferUtilityTypes.js";
|
|
3
|
+
export type { McpServerTypes, ToolDef } from "./server.js";
|
|
1
4
|
export { McpServer } from "./server.js";
|
|
2
5
|
export { widgetsDevServer } from "./widgetsDevServer.js";
|
|
3
|
-
export type { ToolDef, McpServerTypes } from "./server.js";
|
|
4
|
-
export type { InferTools, AnyToolRegistry, ToolNames, ToolInput, ToolOutput, } from "./inferUtilityTypes.js";
|
package/dist/src/server/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,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,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAUjE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -51,4 +51,14 @@ export type ToolInput<ServerType, ToolName extends ToolNames<ServerType>> = Extr
|
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
53
|
export type ToolOutput<ServerType, ToolName extends ToolNames<ServerType>> = ExtractTool<ServerType, ToolName>["output"];
|
|
54
|
+
/**
|
|
55
|
+
* Get the responseMetadata type for a specific tool (widget or regular tool).
|
|
56
|
+
* This is inferred from the `_meta` property of the tool callback's return value.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* type SearchMeta = ToolResponseMetadata<MyServer, "search">;
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export type ToolResponseMetadata<ServerType, ToolName extends ToolNames<ServerType>> = ExtractTool<ServerType, ToolName>["responseMetadata"];
|
|
54
64
|
export {};
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import { McpServer as McpServerBase } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import type {
|
|
3
|
-
import type { Resource, ToolAnnotations, CallToolResult, ServerRequest, ServerNotification } from "@modelcontextprotocol/sdk/types.js";
|
|
1
|
+
import { McpServer as McpServerBase, type RegisteredTool } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { AnySchema, SchemaOutput, ZodRawShapeCompat } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
4
3
|
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
5
|
-
import type {
|
|
6
|
-
export type ToolDef<TInput = unknown, TOutput = unknown> = {
|
|
4
|
+
import type { CallToolResult, Resource, ServerNotification, ServerRequest, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unknown> = {
|
|
7
6
|
input: TInput;
|
|
8
7
|
output: TOutput;
|
|
8
|
+
responseMetadata: TResponseMetadata;
|
|
9
9
|
};
|
|
10
10
|
type McpServerOriginalResourceConfig = Omit<Resource, "uri" | "name" | "mimeType">;
|
|
11
11
|
type McpServerOriginalToolConfig = Omit<Parameters<typeof McpServerBase.prototype.registerTool<ZodRawShapeCompat, ZodRawShapeCompat>>[1], "inputSchema" | "outputSchema">;
|
|
12
12
|
type ExtractStructuredContent<T> = T extends {
|
|
13
13
|
structuredContent: infer SC;
|
|
14
14
|
} ? SC : never;
|
|
15
|
+
type ExtractMeta<T> = Extract<T, {
|
|
16
|
+
_meta: unknown;
|
|
17
|
+
}> extends {
|
|
18
|
+
_meta: infer M;
|
|
19
|
+
} ? M : unknown;
|
|
15
20
|
/**
|
|
16
21
|
* Type-level marker interface for cross-package type inference.
|
|
17
22
|
* This enables TypeScript to infer tool types across package boundaries
|
|
@@ -21,7 +26,7 @@ type ExtractStructuredContent<T> = T extends {
|
|
|
21
26
|
*
|
|
22
27
|
* Inspired by tRPC's _def pattern and Hono's type markers.
|
|
23
28
|
*/
|
|
24
|
-
export interface McpServerTypes<TTools extends Record<string, ToolDef
|
|
29
|
+
export interface McpServerTypes<TTools extends Record<string, ToolDef>> {
|
|
25
30
|
readonly tools: TTools;
|
|
26
31
|
}
|
|
27
32
|
type Simplify<T> = {
|
|
@@ -32,8 +37,8 @@ type ShapeOutput<Shape extends ZodRawShapeCompat> = Simplify<{
|
|
|
32
37
|
} & {
|
|
33
38
|
[K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? K : never]?: SchemaOutput<Shape[K]>;
|
|
34
39
|
}>;
|
|
35
|
-
type AddTool<TTools, TName extends string, TInput extends ZodRawShapeCompat, TOutput> = McpServer<TTools & {
|
|
36
|
-
[K in TName]: ToolDef<ShapeOutput<TInput>, TOutput>;
|
|
40
|
+
type AddTool<TTools, TName extends string, TInput extends ZodRawShapeCompat, TOutput, TResponseMetadata = unknown> = McpServer<TTools & {
|
|
41
|
+
[K in TName]: ToolDef<ShapeOutput<TInput>, TOutput, TResponseMetadata>;
|
|
37
42
|
}>;
|
|
38
43
|
type ToolConfig<TInput extends ZodRawShapeCompat | AnySchema> = {
|
|
39
44
|
title?: string;
|
|
@@ -44,14 +49,17 @@ type ToolConfig<TInput extends ZodRawShapeCompat | AnySchema> = {
|
|
|
44
49
|
_meta?: Record<string, unknown>;
|
|
45
50
|
};
|
|
46
51
|
type ToolHandler<TInput extends ZodRawShapeCompat, TReturn extends CallToolResult = CallToolResult> = (args: ShapeOutput<TInput>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => TReturn | Promise<TReturn>;
|
|
47
|
-
export declare class McpServer<TTools extends Record<string, ToolDef> =
|
|
52
|
+
export declare class McpServer<TTools extends Record<string, ToolDef> = Record<never, ToolDef>> extends McpServerBase {
|
|
48
53
|
readonly $types: McpServerTypes<TTools>;
|
|
49
54
|
registerWidget<TName extends string, TInput extends ZodRawShapeCompat, TReturn extends CallToolResult>(name: TName, resourceConfig: McpServerOriginalResourceConfig, toolConfig: McpServerOriginalToolConfig & {
|
|
50
55
|
inputSchema?: TInput;
|
|
51
56
|
outputSchema?: ZodRawShapeCompat | AnySchema;
|
|
52
|
-
}, toolCallback: ToolHandler<TInput, TReturn>): AddTool<TTools, TName, TInput, ExtractStructuredContent<TReturn>>;
|
|
53
|
-
registerTool<TName extends string, InputArgs extends ZodRawShapeCompat, TReturn extends CallToolResult>(name: TName, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs, TReturn>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>>;
|
|
57
|
+
}, toolCallback: ToolHandler<TInput, TReturn>): AddTool<TTools, TName, TInput, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
|
|
58
|
+
registerTool<TName extends string, InputArgs extends ZodRawShapeCompat, TReturn extends CallToolResult>(name: TName, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs, TReturn>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
|
|
54
59
|
registerTool<InputArgs extends ZodRawShapeCompat>(name: string, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs>): RegisteredTool;
|
|
60
|
+
private registerWidgetResource;
|
|
55
61
|
private lookupDistFile;
|
|
62
|
+
private lookupDistFileWithIndexFallback;
|
|
63
|
+
private readManifest;
|
|
56
64
|
}
|
|
57
65
|
export {};
|
|
@@ -1,48 +1,35 @@
|
|
|
1
|
-
import { McpServer as McpServerBase } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { templateHelper } from "./templateHelper.js";
|
|
3
1
|
import { readFileSync } from "node:fs";
|
|
4
2
|
import path from "node:path";
|
|
3
|
+
import { McpServer as McpServerBase, } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import { templateHelper } from "./templateHelper.js";
|
|
5
5
|
export class McpServer extends McpServerBase {
|
|
6
6
|
registerWidget(name, resourceConfig, toolConfig, toolCallback) {
|
|
7
|
-
const uri = `ui://widgets/${name}.html`;
|
|
8
7
|
const resourceMetadata = {
|
|
9
8
|
...(resourceConfig._meta ?? {}),
|
|
10
9
|
};
|
|
11
10
|
if (toolConfig.description !== undefined) {
|
|
12
11
|
resourceMetadata["openai/widgetDescription"] = toolConfig.description;
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
serverUrl,
|
|
30
|
-
widgetName: name,
|
|
31
|
-
});
|
|
32
|
-
return {
|
|
33
|
-
contents: [
|
|
34
|
-
{
|
|
35
|
-
uri,
|
|
36
|
-
mimeType: "text/html+skybridge",
|
|
37
|
-
text: html,
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
};
|
|
13
|
+
const appsSdkUri = `ui://widgets/apps-sdk/${name}.html`;
|
|
14
|
+
this.registerWidgetResource({
|
|
15
|
+
name,
|
|
16
|
+
uri: appsSdkUri,
|
|
17
|
+
mimeType: "text/html+skybridge",
|
|
18
|
+
resourceConfig,
|
|
19
|
+
resourceMetadata,
|
|
20
|
+
});
|
|
21
|
+
const extAppsUri = `ui://widgets/ext-apps/${name}.html`;
|
|
22
|
+
this.registerWidgetResource({
|
|
23
|
+
name,
|
|
24
|
+
uri: extAppsUri,
|
|
25
|
+
mimeType: "text/html;profile=mcp-app",
|
|
26
|
+
resourceConfig,
|
|
27
|
+
resourceMetadata,
|
|
41
28
|
});
|
|
42
29
|
const toolMeta = {
|
|
43
30
|
...toolConfig._meta,
|
|
44
|
-
"openai/outputTemplate":
|
|
45
|
-
"ui/resourceUri":
|
|
31
|
+
"openai/outputTemplate": appsSdkUri,
|
|
32
|
+
"ui/resourceUri": extAppsUri,
|
|
46
33
|
};
|
|
47
34
|
this.registerTool(name, {
|
|
48
35
|
...toolConfig,
|
|
@@ -54,9 +41,33 @@ export class McpServer extends McpServerBase {
|
|
|
54
41
|
super.registerTool(name, config, cb);
|
|
55
42
|
return this;
|
|
56
43
|
}
|
|
44
|
+
registerWidgetResource({ name, uri, mimeType, resourceConfig, resourceMetadata, }) {
|
|
45
|
+
this.registerResource(name, uri, { ...resourceConfig, _meta: resourceMetadata }, async (_uri, extra) => {
|
|
46
|
+
const serverUrl = process.env.NODE_ENV === "production"
|
|
47
|
+
? `https://${extra?.requestInfo?.headers?.["x-forwarded-host"] ?? extra?.requestInfo?.headers?.host}`
|
|
48
|
+
: `http://localhost:3000`;
|
|
49
|
+
const html = process.env.NODE_ENV === "production"
|
|
50
|
+
? templateHelper.renderProduction({
|
|
51
|
+
serverUrl,
|
|
52
|
+
widgetFile: this.lookupDistFileWithIndexFallback(`src/widgets/${name}.tsx`),
|
|
53
|
+
styleFile: this.lookupDistFile("style.css"),
|
|
54
|
+
})
|
|
55
|
+
: templateHelper.renderDevelopment({ serverUrl, widgetName: name });
|
|
56
|
+
return { contents: [{ uri, mimeType, text: html }] };
|
|
57
|
+
});
|
|
58
|
+
}
|
|
57
59
|
lookupDistFile(key) {
|
|
58
|
-
const manifest =
|
|
60
|
+
const manifest = this.readManifest();
|
|
59
61
|
return manifest[key]?.file;
|
|
60
62
|
}
|
|
63
|
+
lookupDistFileWithIndexFallback(basePath) {
|
|
64
|
+
const manifest = this.readManifest();
|
|
65
|
+
const flatFileKey = `${basePath}.tsx`;
|
|
66
|
+
const indexFileKey = `${basePath}/index.tsx`;
|
|
67
|
+
return manifest[flatFileKey]?.file ?? manifest[indexFileKey]?.file;
|
|
68
|
+
}
|
|
69
|
+
readManifest() {
|
|
70
|
+
return JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
|
|
71
|
+
}
|
|
61
72
|
}
|
|
62
73
|
//# sourceMappingURL=server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI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G,IAAI,CAAC,YAAY,EAAE,CAAC;QAErC,MAAM,WAAW,GAAG,GAAG,QAAQ,MAAM,CAAC;QACtC,MAAM,YAAY,GAAG,GAAG,QAAQ,YAAY,CAAC;QAC7C,OAAO,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,IAAI,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC;IACrE,CAAC;IAEO,YAAY;QAClB,OAAO,IAAI,CAAC,KAAK,CACf,YAAY,CACV,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,CAAC,EACpE,OAAO,CACR,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import Handlebars from "handlebars";
|
|
2
1
|
import { readFileSync } from "node:fs";
|
|
3
|
-
import {
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
4
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
import Handlebars from "handlebars";
|
|
5
5
|
const __filename = fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = dirname(__filename);
|
|
7
7
|
class TemplateHelper {
|
|
8
8
|
templateCache = new Map();
|
|
9
9
|
loadTemplate(templateName) {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const cached = this.templateCache.get(templateName);
|
|
11
|
+
if (cached) {
|
|
12
|
+
return cached;
|
|
12
13
|
}
|
|
13
14
|
const templatePath = join(__dirname, "templates", `${templateName}.hbs`);
|
|
14
15
|
const templateSource = readFileSync(templatePath, "utf-8");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateHelper.js","sourceRoot":"","sources":["../../../src/server/templateHelper.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"templateHelper.js","sourceRoot":"","sources":["../../../src/server/templateHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,C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7,6 @@
|
|
|
7
7
|
</script>
|
|
8
8
|
<script type="module" src="{{serverUrl}}/@vite/client"></script>
|
|
9
9
|
<div id="root"></div>
|
|
10
|
-
<script type="module">
|
|
11
|
-
import('{{serverUrl}}/src/widgets/{{widgetName}}
|
|
10
|
+
<script type="module" id="dev-widget-entry">
|
|
11
|
+
import('{{serverUrl}}/src/widgets/{{widgetName}}');
|
|
12
12
|
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import express, {} from "express";
|
|
2
|
-
import cors from "cors";
|
|
3
1
|
import path from "node:path";
|
|
2
|
+
import cors from "cors";
|
|
3
|
+
import express, {} from "express";
|
|
4
4
|
/**
|
|
5
5
|
* Install Vite dev server
|
|
6
6
|
* This router MUST be installed at the application root, like so:
|
|
@@ -17,7 +17,7 @@ export const widgetsDevServer = async () => {
|
|
|
17
17
|
const workspaceRoot = searchForWorkspaceRoot(process.cwd());
|
|
18
18
|
const webAppRoot = path.join(workspaceRoot, "web");
|
|
19
19
|
const configResult = await loadConfigFromFile({ command: "serve", mode: "development" }, path.join(webAppRoot, "vite.config.ts"), webAppRoot);
|
|
20
|
-
// Remove build-specific options that don't apply to dev server
|
|
20
|
+
// biome-ignore lint/correctness/noUnusedVariables: Remove build-specific options that don't apply to dev server
|
|
21
21
|
const { build, preview, ...devConfig } = configResult?.config || {};
|
|
22
22
|
const vite = await createServer({
|
|
23
23
|
...devConfig,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widgetsDevServer.js","sourceRoot":"","sources":["../../../src/server/widgetsDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"widgetsDevServer.js","sourceRoot":"","sources":["../../../src/server/widgetsDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,EAAE,EAAuB,MAAM,SAAS,CAAC;AAEvD;;;;;;;;;G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5
|
*/
|
|
6
6
|
export declare function createMockMcpServer(): {
|
|
7
7
|
server: McpServer;
|
|
8
|
-
|
|
8
|
+
mockRegisterResource: MockInstance<McpServer["registerResource"]>;
|
|
9
9
|
mockRegisterTool: MockInstance<McpServer["registerTool"]>;
|
|
10
10
|
};
|
|
11
|
-
export declare function createTestServer(): McpServer<{
|
|
11
|
+
export declare function createTestServer(): McpServer<Record<never, import("../server/server.js").ToolDef<unknown, unknown, unknown>> & {
|
|
12
12
|
"search-voyage": import("../server/server.js").ToolDef<{
|
|
13
13
|
destination: string;
|
|
14
14
|
departureDate?: string | undefined;
|
|
@@ -20,7 +20,7 @@ export declare function createTestServer(): McpServer<{
|
|
|
20
20
|
price: number;
|
|
21
21
|
}[];
|
|
22
22
|
totalCount: number;
|
|
23
|
-
}>;
|
|
23
|
+
}, unknown>;
|
|
24
24
|
} & {
|
|
25
25
|
"get-trip-details": import("../server/server.js").ToolDef<{
|
|
26
26
|
tripId: string;
|
|
@@ -28,9 +28,9 @@ export declare function createTestServer(): McpServer<{
|
|
|
28
28
|
name: string;
|
|
29
29
|
description: string;
|
|
30
30
|
images: string[];
|
|
31
|
-
}>;
|
|
31
|
+
}, unknown>;
|
|
32
32
|
} & {
|
|
33
|
-
"no-input-widget": import("../server/server.js").ToolDef<{}, {}>;
|
|
33
|
+
"no-input-widget": import("../server/server.js").ToolDef<{}, {}, unknown>;
|
|
34
34
|
} & {
|
|
35
35
|
"inferred-output-widget": import("../server/server.js").ToolDef<{
|
|
36
36
|
query: string;
|
|
@@ -40,7 +40,7 @@ export declare function createTestServer(): McpServer<{
|
|
|
40
40
|
score: number;
|
|
41
41
|
}[];
|
|
42
42
|
inferredCount: number;
|
|
43
|
-
}>;
|
|
43
|
+
}, unknown>;
|
|
44
44
|
} & {
|
|
45
45
|
"calculate-price": import("../server/server.js").ToolDef<{
|
|
46
46
|
tripId: string;
|
|
@@ -48,7 +48,7 @@ export declare function createTestServer(): McpServer<{
|
|
|
48
48
|
}, {
|
|
49
49
|
totalPrice: number;
|
|
50
50
|
currency: string;
|
|
51
|
-
}>;
|
|
51
|
+
}, unknown>;
|
|
52
52
|
} & {
|
|
53
53
|
"inferred-tool": import("../server/server.js").ToolDef<{
|
|
54
54
|
itemId: string;
|
|
@@ -58,16 +58,51 @@ export declare function createTestServer(): McpServer<{
|
|
|
58
58
|
available: boolean;
|
|
59
59
|
};
|
|
60
60
|
fetchedAt: string;
|
|
61
|
+
}, unknown>;
|
|
62
|
+
} & {
|
|
63
|
+
"widget-with-metadata": import("../server/server.js").ToolDef<{
|
|
64
|
+
resourceId: string;
|
|
65
|
+
}, {
|
|
66
|
+
data: {
|
|
67
|
+
id: string;
|
|
68
|
+
loaded: boolean;
|
|
69
|
+
};
|
|
70
|
+
}, {
|
|
71
|
+
requestId: string;
|
|
72
|
+
timestamp: number;
|
|
73
|
+
cached: boolean;
|
|
74
|
+
}>;
|
|
75
|
+
} & {
|
|
76
|
+
"tool-with-metadata": import("../server/server.js").ToolDef<{
|
|
77
|
+
query: string;
|
|
78
|
+
}, {
|
|
79
|
+
results: string[];
|
|
80
|
+
}, {
|
|
81
|
+
executionTime: number;
|
|
82
|
+
source: string;
|
|
83
|
+
}>;
|
|
84
|
+
} & {
|
|
85
|
+
"widget-with-mixed-returns": import("../server/server.js").ToolDef<{
|
|
86
|
+
shouldSucceed: boolean;
|
|
87
|
+
}, {
|
|
88
|
+
error: string;
|
|
89
|
+
data?: undefined;
|
|
90
|
+
} | {
|
|
91
|
+
data: string;
|
|
92
|
+
error?: undefined;
|
|
93
|
+
}, {
|
|
94
|
+
processedAt: number;
|
|
95
|
+
region: string;
|
|
61
96
|
}>;
|
|
62
97
|
}>;
|
|
63
|
-
export declare function createMinimalTestServer(): McpServer<{
|
|
98
|
+
export declare function createMinimalTestServer(): McpServer<Record<never, import("../server/server.js").ToolDef<unknown, unknown, unknown>> & {
|
|
64
99
|
"search-voyage": import("../server/server.js").ToolDef<{
|
|
65
100
|
destination: string;
|
|
66
101
|
}, {
|
|
67
102
|
results: {
|
|
68
103
|
id: string;
|
|
69
104
|
}[];
|
|
70
|
-
}>;
|
|
105
|
+
}, unknown>;
|
|
71
106
|
}>;
|
|
72
107
|
/**
|
|
73
108
|
* Mock extra parameter for resource callback
|