create-skybridge 0.0.0-dev.b0a1d24 → 0.0.0-dev.b138e06

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/dist/index.js CHANGED
@@ -5,10 +5,6 @@ import { fileURLToPath } from "node:url";
5
5
  import * as prompts from "@clack/prompts";
6
6
  import mri from "mri";
7
7
  const defaultProjectName = "skybridge-project";
8
- const templates = [
9
- { value: "default", label: "a minimal implementation" },
10
- { value: "ecom", label: "a functional ecommerce carousel" },
11
- ];
12
8
  // prettier-ignore
13
9
  const helpMessage = `\
14
10
  Usage: create-skybridge [OPTION]... [DIRECTORY]
@@ -19,10 +15,6 @@ Options:
19
15
  -h, --help show this help message
20
16
  --overwrite remove existing files in target directory
21
17
  --immediate install dependencies and start development server
22
- --template <template> use a specific template
23
-
24
- Available templates:
25
- ${templates.map((t) => ` ${t.value.padEnd(23)} ${t.label}`).join("\n")}
26
18
 
27
19
  Examples:
28
20
  create-skybridge my-app
@@ -31,14 +23,13 @@ Examples:
31
23
  export async function init(args = process.argv.slice(2)) {
32
24
  const argv = mri(args, {
33
25
  boolean: ["help", "overwrite", "immediate"],
34
- alias: { h: "help", t: "template" },
26
+ alias: { h: "help" },
35
27
  });
36
28
  const argTargetDir = argv._[0]
37
29
  ? sanitizeTargetDir(String(argv._[0]))
38
30
  : undefined;
39
31
  const argOverwrite = argv.overwrite;
40
32
  const argImmediate = argv.immediate;
41
- const argTemplate = argv.template;
42
33
  const help = argv.help;
43
34
  if (help) {
44
35
  console.log(helpMessage);
@@ -69,31 +60,7 @@ export async function init(args = process.argv.slice(2)) {
69
60
  targetDir = defaultProjectName;
70
61
  }
71
62
  }
72
- // 2. Select a template
73
- let templatePath = "../template";
74
- if (!argTemplate && interactive) {
75
- let message = "Please choose a template:";
76
- const hasInvalidTemplate = argTemplate && !templates.some((t) => t.value === argTemplate);
77
- if (hasInvalidTemplate) {
78
- message = `${argTemplate} is not a valid template. Please choose one of the following:`;
79
- }
80
- const template = await prompts.select({
81
- message,
82
- options: templates.map((t) => ({
83
- value: t.value,
84
- label: `${t.value}: ${t.label}`,
85
- })),
86
- });
87
- if (prompts.isCancel(template)) {
88
- return cancel();
89
- }
90
- switch (template) {
91
- case "ecom":
92
- templatePath = "../template-ecom";
93
- break;
94
- }
95
- }
96
- // 3. Handle directory if exist and not empty
63
+ // 2. Handle directory if exist and not empty
97
64
  if (fs.existsSync(targetDir) && !isEmpty(targetDir)) {
98
65
  let overwrite = argOverwrite ? "yes" : undefined;
99
66
  if (!overwrite) {
@@ -133,20 +100,17 @@ export async function init(args = process.argv.slice(2)) {
133
100
  }
134
101
  }
135
102
  const root = path.join(process.cwd(), targetDir);
136
- // 4. Copy the template
103
+ // 3. Copy the repository
137
104
  prompts.log.step(`Copying template...`);
138
105
  try {
139
- const templateDir = fileURLToPath(new URL(templatePath, import.meta.url));
106
+ const templateDir = fileURLToPath(new URL("../template", import.meta.url));
140
107
  // Copy template to target directory
141
108
  fs.cpSync(templateDir, root, {
142
109
  recursive: true,
143
110
  filter: (src) => [".npmrc"].every((file) => !src.endsWith(file)),
144
111
  });
145
- // Write .gitignore
146
- fs.writeFileSync(path.join(root, ".gitignore"), `node_modules/
147
- dist/
148
- .env*
149
- .DS_store`);
112
+ // Rename _gitignore to .gitignore
113
+ fs.renameSync(path.join(root, "_gitignore"), path.join(root, ".gitignore"));
150
114
  // Update project name in package.json
151
115
  const name = path.basename(root);
152
116
  const pkgPath = path.join(root, "package.json");
@@ -162,7 +126,7 @@ dist/
162
126
  }
163
127
  const userAgent = process.env.npm_config_user_agent;
164
128
  const pkgManager = userAgent?.split(" ")[0]?.split("/")[0] || "npm";
165
- // 5. Ask about immediate installation
129
+ // 4. Ask about immediate installation
166
130
  let immediate = argImmediate;
167
131
  if (immediate === undefined) {
168
132
  if (interactive) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-skybridge",
3
- "version": "0.0.0-dev.b0a1d24",
3
+ "version": "0.0.0-dev.b138e06",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Alpic",
@@ -14,8 +14,7 @@
14
14
  "files": [
15
15
  "index.js",
16
16
  "dist",
17
- "template",
18
- "template-ecom"
17
+ "template"
19
18
  ],
20
19
  "dependencies": {
21
20
  "@clack/prompts": "^0.11.0",
@@ -26,7 +25,7 @@
26
25
  "vitest": "^4.0.16"
27
26
  },
28
27
  "scripts": {
29
- "build": "tsc && node copyExamples.js",
28
+ "build": "tsc",
30
29
  "test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
31
30
  "test:unit": "vitest run",
32
31
  "test:type": "tsc --noEmit",
@@ -0,0 +1,5 @@
1
+ node_modules/
2
+ dist/
3
+ .env*
4
+ .DS_store
5
+ *.tsbuildinfo
@@ -1,4 +1,3 @@
1
1
  {
2
- "$schema": "https://assets.alpic.ai/alpic.json",
3
- "buildOutputDir": "server/dist"
2
+ "$schema": "https://assets.alpic.ai/alpic.json"
4
3
  }
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.20.0_@modelcontextprotocol+sdk@1.25.2_hono@4.11.3_zod@4.3.5__@types+node@25_aea5dc2b2511e98e2f9f50b3f1005e40/node_modules/skybridge/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.20.0_@modelcontextprotocol+sdk@1.25.2_hono@4.11.3_zod@4.3.5__@types+node@25_aea5dc2b2511e98e2f9f50b3f1005e40/node_modules/skybridge/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.20.0_@modelcontextprotocol+sdk@1.25.2_hono@4.11.3_zod@4.3.5__@types+node@25_aea5dc2b2511e98e2f9f50b3f1005e40/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.20.0_@modelcontextprotocol+sdk@1.25.2_hono@4.11.3_zod@4.3.5__@types+node@25_aea5dc2b2511e98e2f9f50b3f1005e40/node_modules/skybridge/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.20.0_@modelcontextprotocol+sdk@1.25.2_hono@4.11.3_zod@4.3.5__@types+node@25_aea5dc2b2511e98e2f9f50b3f1005e40/node_modules/skybridge/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.20.0_@modelcontextprotocol+sdk@1.25.2_hono@4.11.3_zod@4.3.5__@types+node@25_aea5dc2b2511e98e2f9f50b3f1005e40/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../skybridge/bin/run.js" "$@"
19
+ else
20
+ exec node "$basedir/../skybridge/bin/run.js" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.20.0_@modelcontextprotocol+sdk@1.25.2_hono@4.11.3_zod@4.3.5__@types+node@25_aea5dc2b2511e98e2f9f50b3f1005e40/node_modules/skybridge/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.20.0_@modelcontextprotocol+sdk@1.25.2_hono@4.11.3_zod@4.3.5__@types+node@25_aea5dc2b2511e98e2f9f50b3f1005e40/node_modules/skybridge/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.20.0_@modelcontextprotocol+sdk@1.25.2_hono@4.11.3_zod@4.3.5__@types+node@25_aea5dc2b2511e98e2f9f50b3f1005e40/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.20.0_@modelcontextprotocol+sdk@1.25.2_hono@4.11.3_zod@4.3.5__@types+node@25_aea5dc2b2511e98e2f9f50b3f1005e40/node_modules/skybridge/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.20.0_@modelcontextprotocol+sdk@1.25.2_hono@4.11.3_zod@4.3.5__@types+node@25_aea5dc2b2511e98e2f9f50b3f1005e40/node_modules/skybridge/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.20.0_@modelcontextprotocol+sdk@1.25.2_hono@4.11.3_zod@4.3.5__@types+node@25_aea5dc2b2511e98e2f9f50b3f1005e40/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../skybridge/bin/run.js" "$@"
19
+ else
20
+ exec node "$basedir/../skybridge/bin/run.js" "$@"
21
+ fi
@@ -10,9 +10,9 @@ case `uname` in
10
10
  esac
11
11
 
12
12
  if [ -z "$NODE_PATH" ]; then
13
- export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.0_@types+node@25.0.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules/vite/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.0_@types+node@25.0.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules/vite/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.0_@types+node@25.0.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
13
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.1_@types+node@25.0.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules/vite/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.1_@types+node@25.0.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules/vite/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.1_@types+node@25.0.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
14
14
  else
15
- export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.0_@types+node@25.0.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules/vite/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.0_@types+node@25.0.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules/vite/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.0_@types+node@25.0.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
15
+ export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.1_@types+node@25.0.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules/vite/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.1_@types+node@25.0.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules/vite/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.1_@types+node@25.0.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
16
16
  fi
17
17
  if [ -x "$basedir/node" ]; then
18
18
  exec "$basedir/node" "$basedir/../vite/bin/vite.js" "$@"
@@ -5,27 +5,29 @@
5
5
  "description": "Alpic MCP Server Template",
6
6
  "type": "module",
7
7
  "scripts": {
8
- "dev": "nodemon",
9
- "build": "vite build -c web/vite.config.ts && shx rm -rf server/dist && tsc -p tsconfig.server.json && shx cp -r web/dist server/dist/assets",
10
- "start": "node server/dist/index.js",
8
+ "dev": "skybridge",
9
+ "build": "skybridge build",
10
+ "start": "skybridge start",
11
11
  "inspector": "mcp-inspector http://localhost:3000/mcp",
12
12
  "server:build": "tsc -p tsconfig.server.json",
13
- "server:start": "node server/dist/index.js",
13
+ "server:start": "node dist/index.js",
14
14
  "web:build": "tsc -b web && vite build -c web/vite.config.ts",
15
15
  "web:preview": "vite preview -c web/vite.config.ts"
16
16
  },
17
17
  "dependencies": {
18
- "@modelcontextprotocol/sdk": "^1.25.1",
18
+ "@modelcontextprotocol/sdk": "^1.25.2",
19
+ "cors": "^2.8.5",
19
20
  "express": "^5.2.1",
20
21
  "react": "^19.2.3",
21
22
  "react-dom": "^19.2.3",
22
- "skybridge": ">=0.16.7 <1.0.0",
23
- "vite": "^7.3.0",
23
+ "skybridge": ">=0.20.0 <1.0.0",
24
+ "vite": "^7.3.1",
24
25
  "zod": "^4.3.5"
25
26
  },
26
27
  "devDependencies": {
27
28
  "@modelcontextprotocol/inspector": "^0.18.0",
28
- "@skybridge/devtools": ">=0.16.2 <1.0.0",
29
+ "@skybridge/devtools": ">=0.17.1 <1.0.0",
30
+ "@types/cors": "^2.8.19",
29
31
  "@types/express": "^5.0.6",
30
32
  "@types/react": "^19.2.7",
31
33
  "@types/react-dom": "^19.2.3",
@@ -35,8 +37,7 @@
35
37
  "tsx": "^4.21.0",
36
38
  "typescript": "^5.9.3"
37
39
  },
38
- "workspaces": [],
39
40
  "engines": {
40
- "node": ">=24.0.0"
41
+ "node": ">=24.12.0"
41
42
  }
42
43
  }
@@ -1,5 +1,8 @@
1
+ import path from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import cors from "cors";
1
4
  import express, { type Express } from "express";
2
- import { devtoolsStaticServer, widgetsDevServer } from "skybridge/server";
5
+ import { widgetsDevServer } from "skybridge/server";
3
6
  import type { ViteDevServer } from "vite";
4
7
  import { mcp } from "./middleware.js";
5
8
  import server from "./server.js";
@@ -13,10 +16,19 @@ app.use(mcp(server));
13
16
  const env = process.env.NODE_ENV || "development";
14
17
 
15
18
  if (env !== "production") {
19
+ const { devtoolsStaticServer } = await import("@skybridge/devtools");
16
20
  app.use(await devtoolsStaticServer());
17
21
  app.use(await widgetsDevServer());
18
22
  }
19
23
 
24
+ if (env === "production") {
25
+ const __filename = fileURLToPath(import.meta.url);
26
+ const __dirname = path.dirname(__filename);
27
+
28
+ app.use("/assets", cors());
29
+ app.use("/assets", express.static(path.join(__dirname, "assets")));
30
+ }
31
+
20
32
  app.listen(3000, (error) => {
21
33
  if (error) {
22
34
  console.error("Failed to start server:", error);
@@ -2,7 +2,7 @@
2
2
  "extends": "./tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "noEmit": false,
5
- "outDir": "server/dist",
5
+ "outDir": "dist",
6
6
  "sourceMap": true,
7
7
  "declaration": true
8
8
  },
@@ -1,86 +0,0 @@
1
- # Ecommerce Carousel Example
2
-
3
- ## What This Example Showcases
4
- This "Ecommerce Carousel" example demonstrates key Skybridge capabilities:
5
- - **Interactive Widget Rendering**: A React-based widget that displays an interactive product carousel directly in ChatGPT
6
- - **Tool Info Access**: Widgets access tool input, output, and metadata via `useToolInfo()` hook
7
- - **Theme Support**: Adapts to light/dark mode using the `useLayout()` hook
8
- - **Localization**: Translates UI based on user locale via `useUser()` hook
9
- - **External API Integration**: Demonstrates fetching data from REST APIs
10
- - **Hot Module Replacement**: Live reloading of widget components during development
11
-
12
- This example serves as a comprehensive reference for building sophisticated, interactive widgets that leverage Skybridge's full feature set.
13
-
14
- ## Getting Started
15
-
16
- ### Prerequisites
17
-
18
- - Node.js 22+
19
- - HTTP tunnel such as [ngrok](https://ngrok.com/download)
20
-
21
- ### Local Development
22
-
23
- #### 1. Install
24
-
25
- ```bash
26
- npm install
27
- # or
28
- yarn install
29
- # or
30
- pnpm install
31
- # or
32
- bun install
33
- ```
34
-
35
- #### 2. Start your local server
36
-
37
- Run the development server from the root directory:
38
-
39
- ```bash
40
- npm run dev
41
- # or
42
- yarn dev
43
- # or
44
- pnpm dev
45
- # or
46
- bun dev
47
- ```
48
-
49
- This command starts an Express server on port 3000. This server packages:
50
-
51
- - an MCP endpoint on `/mcp` (the app backend)
52
- - a React application on Vite HMR dev server (the UI elements to be displayed in ChatGPT)
53
-
54
- #### 3. Connect to ChatGPT
55
-
56
- - ChatGPT requires connectors to be publicly accessible. To expose your server on the Internet, run:
57
- ```bash
58
- ngrok http 3000
59
- ```
60
- - In ChatGPT, navigate to **Settings → Connectors → Create** and add the forwarding URL provided by ngrok suffixed with `/mcp` (e.g. `https://3785c5ddc4b6.ngrok-free.app/mcp`)
61
-
62
- ### Create your first widget
63
-
64
- #### 1. Add a new widget
65
-
66
- - Register a widget in `server/server.ts` with a unique name (e.g., `my-widget`)
67
- - Create a matching React component at `web/src/widgets/my-widget.tsx`. The file name must match the widget name exactly
68
-
69
- #### 2. Edit widgets with Hot Module Replacement (HMR)
70
-
71
- Edit and save components in `web/src/widgets/` — changes appear instantly in ChatGPT
72
-
73
- #### 3. Edit server code
74
-
75
- Modify files in `server/` and reload your ChatGPT connector in **Settings → Connectors → [Your connector] → Reload**
76
-
77
- ## Deploy to Production
78
-
79
- - Use [Alpic](https://alpic.ai/) to deploy your OpenAI App to production
80
- - In ChatGPT, navigate to **Settings → Connectors → Create** and add your MCP server URL (e.g., `https://your-app-name.alpic.live`)
81
-
82
- ## Resources
83
-
84
- - [Apps SDK Documentation](https://developers.openai.com/apps-sdk)
85
- - [Model Context Protocol Documentation](https://modelcontextprotocol.io/)
86
- - [Alpic Documentation](https://docs.alpic.ai/)
@@ -1,4 +0,0 @@
1
- {
2
- "$schema": "https://assets.alpic.ai/alpic.json",
3
- "buildOutputDir": "server/dist"
4
- }
@@ -1,5 +0,0 @@
1
- {
2
- "watch": ["server/src"],
3
- "ext": "ts,json",
4
- "exec": "tsx server/src/index.ts"
5
- }
@@ -1,40 +0,0 @@
1
- {
2
- "name": "ecom-carousel",
3
- "version": "0.0.1",
4
- "private": true,
5
- "description": "An e-commerce carousel example",
6
- "type": "module",
7
- "scripts": {
8
- "dev": "nodemon",
9
- "build": "vite build -c web/vite.config.ts && shx rm -rf server/dist && tsc -p tsconfig.server.json && shx cp -r web/dist server/dist/assets",
10
- "start": "node server/dist/index.js",
11
- "inspector": "mcp-inspector http://localhost:3000/mcp",
12
- "server:build": "tsc -p tsconfig.server.json",
13
- "server:start": "node server/dist/index.js",
14
- "web:build": "tsc -b web && vite build -c web/vite.config.ts",
15
- "web:preview": "vite preview -c web/vite.config.ts"
16
- },
17
- "dependencies": {
18
- "@modelcontextprotocol/sdk": "^1.25.1",
19
- "express": "^5.2.1",
20
- "react": "^19.2.3",
21
- "react-dom": "^19.2.3",
22
- "skybridge": ">=0.16.8 <1.0.0",
23
- "vite": "^7.3.0",
24
- "zod": "^4.3.5"
25
- },
26
- "devDependencies": {
27
- "@modelcontextprotocol/inspector": "^0.18.0",
28
- "@skybridge/devtools": "^0.16.2",
29
- "@types/express": "^5.0.6",
30
- "@types/node": "^22.19.3",
31
- "@types/react": "^19.2.7",
32
- "@types/react-dom": "^19.2.3",
33
- "@vitejs/plugin-react": "^5.1.2",
34
- "nodemon": "^3.1.11",
35
- "shx": "^0.4.0",
36
- "tsx": "^4.21.0",
37
- "typescript": "^5.9.3"
38
- },
39
- "workspaces": []
40
- }
@@ -1,39 +0,0 @@
1
- import express, { type Express } from "express";
2
- import { devtoolsStaticServer, widgetsDevServer } from "skybridge/server";
3
- import type { ViteDevServer } from "vite";
4
- import { mcp } from "./middleware.js";
5
- import server from "./server.js";
6
-
7
- const app = express() as Express & { vite: ViteDevServer };
8
-
9
- app.use(express.json());
10
-
11
- app.use(mcp(server));
12
-
13
- const env = process.env.NODE_ENV || "development";
14
-
15
- if (env !== "production") {
16
- app.use(await devtoolsStaticServer());
17
- app.use(await widgetsDevServer());
18
- }
19
-
20
- app.listen(3000, (error) => {
21
- if (error) {
22
- console.error("Failed to start server:", error);
23
- process.exit(1);
24
- }
25
-
26
- console.log(`Server listening on port 3000 - ${env}`);
27
- console.log(
28
- "Make your local server accessible with 'ngrok http 3000' and connect to ChatGPT with URL https://xxxxxx.ngrok-free.app/mcp",
29
- );
30
-
31
- if (env !== "production") {
32
- console.log("Devtools available at http://localhost:3000");
33
- }
34
- });
35
-
36
- process.on("SIGINT", async () => {
37
- console.log("Server shutdown complete");
38
- process.exit(0);
39
- });
@@ -1,54 +0,0 @@
1
- import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
2
- import type { NextFunction, Request, Response } from "express";
3
-
4
- import type { McpServer } from "skybridge/server";
5
-
6
- export const mcp =
7
- (server: McpServer) =>
8
- async (req: Request, res: Response, next: NextFunction) => {
9
- // Only handle requests to the /mcp path
10
- if (req.path !== "/mcp") {
11
- return next();
12
- }
13
-
14
- if (req.method === "POST") {
15
- try {
16
- const transport = new StreamableHTTPServerTransport({
17
- sessionIdGenerator: undefined,
18
- });
19
-
20
- res.on("close", () => {
21
- transport.close();
22
- });
23
-
24
- await server.connect(transport);
25
-
26
- await transport.handleRequest(req, res, req.body);
27
- } catch (error) {
28
- console.error("Error handling MCP request:", error);
29
- if (!res.headersSent) {
30
- res.status(500).json({
31
- jsonrpc: "2.0",
32
- error: {
33
- code: -32603,
34
- message: "Internal server error",
35
- },
36
- id: null,
37
- });
38
- }
39
- }
40
- } else if (req.method === "GET" || req.method === "DELETE") {
41
- res.writeHead(405).end(
42
- JSON.stringify({
43
- jsonrpc: "2.0",
44
- error: {
45
- code: -32000,
46
- message: "Method not allowed.",
47
- },
48
- id: null,
49
- }),
50
- );
51
- } else {
52
- next();
53
- }
54
- };
@@ -1,73 +0,0 @@
1
- import { McpServer } from "skybridge/server";
2
- import { z } from "zod";
3
-
4
- interface Product {
5
- id: number;
6
- title: string;
7
- price: number;
8
- description: string;
9
- category: string;
10
- image: string;
11
- rating: {
12
- rate: number;
13
- count: number;
14
- };
15
- }
16
-
17
- const server = new McpServer(
18
- {
19
- name: "ecom-carousel-app",
20
- version: "0.0.1",
21
- },
22
- { capabilities: {} },
23
- ).registerWidget(
24
- "ecom-carousel",
25
- {
26
- description: "E-commerce Product Carousel",
27
- },
28
- {
29
- description: "Display a carousel of products from the store.",
30
- inputSchema: {
31
- category: z
32
- .enum(["electronics", "jewelery", "men's clothing", "women's clothing"])
33
- .optional()
34
- .describe("Filter by product category"),
35
- maxPrice: z.number().optional().describe("Maximum price filter"),
36
- },
37
- },
38
- async ({ category, maxPrice }) => {
39
- try {
40
- const response = await fetch("https://fakestoreapi.com/products");
41
- if (!response.ok) {
42
- throw new Error(`API request failed: ${response.status}`);
43
- }
44
-
45
- const products: Product[] = await response.json();
46
- const filtered: Product[] = [];
47
-
48
- for (const product of products) {
49
- if (category && product.category !== category) {
50
- continue;
51
- }
52
- if (maxPrice !== undefined && product.price > maxPrice) {
53
- continue;
54
- }
55
- filtered.push(product);
56
- }
57
-
58
- return {
59
- structuredContent: { products: filtered },
60
- content: [{ type: "text", text: JSON.stringify(filtered) }],
61
- isError: false,
62
- };
63
- } catch (error) {
64
- return {
65
- content: [{ type: "text", text: `Error: ${error}` }],
66
- isError: true,
67
- };
68
- }
69
- },
70
- );
71
-
72
- export default server;
73
- export type AppType = typeof server;
@@ -1,23 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
- "jsx": "react-jsx",
8
-
9
- "strict": true,
10
- "skipLibCheck": true,
11
- "esModuleInterop": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "verbatimModuleSyntax": true,
14
-
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "noFallthroughCasesInSwitch": true,
18
-
19
- "noEmit": true
20
- },
21
- "include": ["server/src", "web/src", "web/vite.config.ts"],
22
- "exclude": ["dist", "node_modules"]
23
- }
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "noEmit": false,
5
- "outDir": "server/dist",
6
- "sourceMap": true,
7
- "declaration": true
8
- },
9
- "include": ["server/src"],
10
- "exclude": ["dist", "node_modules"]
11
- }
@@ -1,4 +0,0 @@
1
- import { generateHelpers } from "skybridge/web";
2
- import type { AppType } from "../../server/src/server";
3
-
4
- export const { useToolInfo } = generateHelpers<AppType>();
@@ -1,178 +0,0 @@
1
- .message {
2
- display: flex;
3
- justify-content: center;
4
- align-items: center;
5
- margin: 1rem;
6
- padding: 1rem;
7
- font-family: sans-serif;
8
- border-radius: 8px;
9
- }
10
-
11
- .message.light {
12
- color: #555;
13
- background: rgba(255, 255, 255, 0.9);
14
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
15
- }
16
-
17
- .message.dark {
18
- color: #ccc;
19
- background: rgba(40, 40, 40, 0.95);
20
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
21
- }
22
-
23
- .container {
24
- display: flex;
25
- flex-direction: column;
26
- height: auto;
27
- }
28
-
29
- .carousel {
30
- display: flex;
31
- gap: 1rem;
32
- overflow-x: auto;
33
- padding: 1rem;
34
- scroll-snap-type: x mandatory;
35
- margin-left: 1rem;
36
- }
37
-
38
- .product-card {
39
- flex: 0 0 150px;
40
- border: none;
41
- border-radius: 8px;
42
- overflow: hidden;
43
- scroll-snap-align: start;
44
- cursor: pointer;
45
- transition:
46
- transform 0.2s,
47
- box-shadow 0.2s;
48
- padding: 0;
49
- text-align: left;
50
- }
51
-
52
- .product-card.light {
53
- background: #fff;
54
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
55
- }
56
-
57
- .product-card.light:hover {
58
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
59
- }
60
-
61
- .product-card.dark {
62
- background: #2a2a2a;
63
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
64
- }
65
-
66
- .product-card.dark:hover {
67
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
68
- }
69
-
70
- .product-card:hover {
71
- transform: translateY(-2px);
72
- }
73
-
74
- .product-card.selected {
75
- border-bottom: 5px solid mediumseagreen;
76
- }
77
-
78
- .product-image {
79
- width: 100%;
80
- height: 120px;
81
- object-fit: contain;
82
- padding: 0.5rem;
83
- display: block;
84
- box-sizing: border-box;
85
- }
86
-
87
- .product-image.light {
88
- background: #f9f9f9;
89
- }
90
-
91
- .product-image.dark {
92
- background: #333;
93
- }
94
-
95
- .product-info {
96
- padding: 0.75rem;
97
- }
98
-
99
- .product-title {
100
- font-size: 0.75rem;
101
- font-family: sans-serif;
102
- overflow: hidden;
103
- text-overflow: ellipsis;
104
- white-space: nowrap;
105
- }
106
-
107
- .product-title.light {
108
- color: #333;
109
- }
110
-
111
- .product-title.dark {
112
- color: #eee;
113
- }
114
-
115
- .product-price {
116
- font-size: 0.875rem;
117
- font-family: sans-serif;
118
- font-weight: bold;
119
- color: mediumseagreen;
120
- margin-top: 0.25rem;
121
- }
122
-
123
- .product-detail {
124
- margin: 0 1rem 1rem;
125
- padding: 1rem;
126
- border-radius: 8px;
127
- font-family: sans-serif;
128
- }
129
-
130
- .product-detail.light {
131
- background: #fff;
132
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
133
- }
134
-
135
- .product-detail.dark {
136
- background: #2a2a2a;
137
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
138
- }
139
-
140
- .detail-title {
141
- font-size: 1rem;
142
- font-weight: bold;
143
- margin-bottom: 0.5rem;
144
- }
145
-
146
- .detail-title.light {
147
- color: #333;
148
- }
149
-
150
- .detail-title.dark {
151
- color: #eee;
152
- }
153
-
154
- .detail-rating {
155
- font-size: 0.875rem;
156
- margin-bottom: 0.5rem;
157
- }
158
-
159
- .detail-rating.light {
160
- color: #666;
161
- }
162
-
163
- .detail-rating.dark {
164
- color: #aaa;
165
- }
166
-
167
- .detail-description {
168
- font-size: 0.8rem;
169
- line-height: 1.4;
170
- }
171
-
172
- .detail-description.light {
173
- color: #555;
174
- }
175
-
176
- .detail-description.dark {
177
- color: #bbb;
178
- }
@@ -1,109 +0,0 @@
1
- import "@/index.css";
2
-
3
- import { useState } from "react";
4
- import { mountWidget, useLayout, useUser } from "skybridge/web";
5
- import { useToolInfo } from "../helpers.js";
6
-
7
- const translations: Record<string, Record<string, string>> = {
8
- en: {
9
- loading: "Loading products...",
10
- noProducts: "No product found",
11
- },
12
- fr: {
13
- loading: "Chargement des produits...",
14
- noProducts: "Aucun produit trouvé",
15
- },
16
- es: {
17
- loading: "Cargando productos...",
18
- noProducts: "No se encontraron productos",
19
- },
20
- de: {
21
- loading: "Produkte werden geladen...",
22
- noProducts: "Keine Produkte gefunden",
23
- },
24
- };
25
-
26
- function EcomCarousel() {
27
- const { theme } = useLayout();
28
- const { locale } = useUser();
29
-
30
- const lang = locale?.split("-")[0] ?? "en";
31
-
32
- function translate(key: string) {
33
- return translations[lang]?.[key] ?? translations.en[key];
34
- }
35
-
36
- const { output, isPending } = useToolInfo<"ecom-carousel">();
37
- type Product = NonNullable<typeof output>["products"][number];
38
- const [selected, setSelected] = useState<Product | null>(null);
39
-
40
- function cn(...classes: string[]) {
41
- return [theme, ...classes].filter(Boolean).join(" ");
42
- }
43
-
44
- if (isPending) {
45
- return (
46
- <div className={cn("container")}>
47
- <div className={cn("message")}>{translate("loading")}</div>
48
- </div>
49
- );
50
- }
51
-
52
- if (!output || output.products.length === 0) {
53
- return (
54
- <div className={cn("container")}>
55
- <div className={cn("message")}>{translate("noProducts")}</div>
56
- </div>
57
- );
58
- }
59
-
60
- const activeProduct = selected ?? output.products[0];
61
-
62
- return (
63
- <div className={cn("container")}>
64
- <div className={cn("carousel")}>
65
- {output.products.map((product) => (
66
- <button
67
- type="button"
68
- key={product.id}
69
- className={cn(
70
- "product-card",
71
- activeProduct?.id === product.id ? "selected" : "",
72
- )}
73
- onClick={() =>
74
- setSelected(selected?.id === product.id ? null : product)
75
- }
76
- >
77
- <img
78
- src={product.image}
79
- alt={product.title}
80
- className={cn("product-image")}
81
- />
82
- <div className={cn("product-info")}>
83
- <div className={cn("product-title")}>{product.title}</div>
84
- <div className={cn("product-price")}>
85
- ${product.price.toFixed(2)}
86
- </div>
87
- </div>
88
- </button>
89
- ))}
90
- </div>
91
- {activeProduct && (
92
- <div className={cn("product-detail")}>
93
- <div className={cn("detail-title")}>{activeProduct.title}</div>
94
- <div className={cn("detail-rating")}>
95
- ⭐ {activeProduct.rating.rate} ({activeProduct.rating.count}{" "}
96
- reviews)
97
- </div>
98
- <div className={cn("detail-description")}>
99
- {activeProduct.description}
100
- </div>
101
- </div>
102
- )}
103
- </div>
104
- );
105
- }
106
-
107
- export default EcomCarousel;
108
-
109
- mountWidget(<EcomCarousel />);
@@ -1,15 +0,0 @@
1
- import path from "node:path";
2
- import react from "@vitejs/plugin-react";
3
- import { skybridge } from "skybridge/web";
4
- import { defineConfig } from "vite";
5
-
6
- // https://vite.dev/config/
7
- export default defineConfig({
8
- plugins: [skybridge(), react()],
9
- root: __dirname,
10
- resolve: {
11
- alias: {
12
- "@": path.resolve(__dirname, "./src"),
13
- },
14
- },
15
- });