create-skybridge 0.0.0-dev.1b1d257 → 0.0.0-dev.1b2cb1b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/index.js +335 -212
  2. package/package.json +8 -8
  3. package/templates/blank/.dockerignore +4 -0
  4. package/templates/blank/Dockerfile +53 -0
  5. package/templates/blank/README.md +92 -0
  6. package/{template → templates/blank}/_gitignore +3 -1
  7. package/templates/blank/node_modules/.bin/alpic +21 -0
  8. package/templates/blank/node_modules/.bin/sb +21 -0
  9. package/templates/blank/node_modules/.bin/skybridge +21 -0
  10. package/{template → templates/blank}/node_modules/.bin/tsc +2 -2
  11. package/{template → templates/blank}/node_modules/.bin/tsserver +2 -2
  12. package/{template → templates/blank}/node_modules/.bin/tsx +2 -2
  13. package/templates/blank/node_modules/.bin/vite +21 -0
  14. package/templates/blank/package.json +29 -0
  15. package/templates/blank/src/helpers.ts +4 -0
  16. package/templates/blank/src/server.ts +16 -0
  17. package/templates/blank/tsconfig.json +5 -0
  18. package/templates/blank/vite.config.ts +6 -0
  19. package/templates/demo/.dockerignore +4 -0
  20. package/templates/demo/AGENTS.md +1 -0
  21. package/templates/demo/Dockerfile +53 -0
  22. package/templates/demo/README.md +95 -0
  23. package/templates/demo/_gitignore +7 -0
  24. package/templates/demo/alpic.json +3 -0
  25. package/templates/demo/node_modules/.bin/alpic +21 -0
  26. package/templates/demo/node_modules/.bin/sb +21 -0
  27. package/templates/demo/node_modules/.bin/skybridge +21 -0
  28. package/templates/demo/node_modules/.bin/tsc +21 -0
  29. package/templates/demo/node_modules/.bin/tsserver +21 -0
  30. package/templates/demo/node_modules/.bin/tsx +21 -0
  31. package/templates/demo/node_modules/.bin/vite +21 -0
  32. package/templates/demo/package.json +41 -0
  33. package/templates/demo/src/helpers.ts +4 -0
  34. package/templates/demo/src/index.css +59 -0
  35. package/templates/demo/src/server.ts +94 -0
  36. package/templates/demo/src/views/components/doc-link.tsx +22 -0
  37. package/templates/demo/src/views/components/doc.tsx +21 -0
  38. package/templates/demo/src/views/components/nav.tsx +31 -0
  39. package/templates/demo/src/views/components/progress.tsx +35 -0
  40. package/templates/demo/src/views/components/steps/outro.tsx +68 -0
  41. package/templates/demo/src/views/components/steps/state.tsx +47 -0
  42. package/templates/demo/src/views/components/steps/tool-call.tsx +53 -0
  43. package/templates/demo/src/views/components/steps/tool-output.tsx +40 -0
  44. package/templates/demo/src/views/images/mascot/beret.png +0 -0
  45. package/templates/demo/src/views/images/mascot/chapka.png +0 -0
  46. package/templates/demo/src/views/images/mascot/cowboy-hat.png +0 -0
  47. package/templates/demo/src/views/images/mascot/fez.png +0 -0
  48. package/templates/demo/src/views/images/mascot/jester-hat.png +0 -0
  49. package/templates/demo/src/views/images/mascot/mitre.png +0 -0
  50. package/templates/demo/src/views/images/mascot/non-la.png +0 -0
  51. package/templates/demo/src/views/images/mascot/original.png +0 -0
  52. package/templates/demo/src/views/images/mascot/propeller-beanie.png +0 -0
  53. package/templates/demo/src/views/images/mascot/ski-mask.png +0 -0
  54. package/templates/demo/src/views/images/mascot/sombrero.png +0 -0
  55. package/templates/demo/src/views/images/mascot/top-hat.png +0 -0
  56. package/templates/demo/src/views/images/mascot/viking-helmet.png +0 -0
  57. package/templates/demo/src/views/onboarding.tsx +63 -0
  58. package/templates/demo/src/views/use-mascot.ts +60 -0
  59. package/templates/demo/tsconfig.json +11 -0
  60. package/templates/demo/vite.config.ts +14 -0
  61. package/templates/ecom/.dockerignore +4 -0
  62. package/templates/ecom/.env.template +2 -0
  63. package/templates/ecom/AGENTS.md +2 -0
  64. package/templates/ecom/Dockerfile +53 -0
  65. package/templates/ecom/README.md +92 -0
  66. package/templates/ecom/_gitignore +8 -0
  67. package/templates/ecom/alpic.json +3 -0
  68. package/templates/ecom/node_modules/.bin/alpic +21 -0
  69. package/templates/ecom/node_modules/.bin/sb +21 -0
  70. package/templates/ecom/node_modules/.bin/skybridge +21 -0
  71. package/templates/ecom/node_modules/.bin/tsc +21 -0
  72. package/templates/ecom/node_modules/.bin/tsserver +21 -0
  73. package/templates/ecom/node_modules/.bin/tsx +21 -0
  74. package/templates/ecom/node_modules/.bin/vite +21 -0
  75. package/templates/ecom/package.json +29 -0
  76. package/templates/ecom/src/helpers.ts +4 -0
  77. package/templates/ecom/src/lib/format.ts +56 -0
  78. package/templates/ecom/src/server.ts +125 -0
  79. package/templates/ecom/tsconfig.json +5 -0
  80. package/templates/ecom/vite.config.ts +6 -0
  81. package/dist/index.test.d.ts +0 -1
  82. package/dist/index.test.js +0 -33
  83. package/template/README.md +0 -97
  84. package/template/node_modules/.bin/alpic +0 -21
  85. package/template/node_modules/.bin/sb +0 -21
  86. package/template/node_modules/.bin/skybridge +0 -21
  87. package/template/node_modules/.bin/vite +0 -21
  88. package/template/package.json +0 -34
  89. package/template/server/src/index.ts +0 -62
  90. package/template/tsconfig.json +0 -13
  91. package/template/web/src/helpers.ts +0 -4
  92. package/template/web/src/index.css +0 -152
  93. package/template/web/src/widgets/magic-8-ball.tsx +0 -27
  94. package/template/web/vite.config.ts +0 -15
  95. /package/{template → templates/blank}/AGENTS.md +0 -0
  96. /package/{template → templates/blank}/alpic.json +0 -0
@@ -0,0 +1,60 @@
1
+ import { useEffect } from "react";
2
+ import { useViewState } from "skybridge/web";
3
+ import beret from "./images/mascot/beret.png";
4
+ import chapka from "./images/mascot/chapka.png";
5
+ import cowboyHat from "./images/mascot/cowboy-hat.png";
6
+ import fez from "./images/mascot/fez.png";
7
+ import jesterHat from "./images/mascot/jester-hat.png";
8
+ import mitre from "./images/mascot/mitre.png";
9
+ import nonLa from "./images/mascot/non-la.png";
10
+ import original from "./images/mascot/original.png";
11
+ import propellerBeanie from "./images/mascot/propeller-beanie.png";
12
+ import skiMask from "./images/mascot/ski-mask.png";
13
+ import sombrero from "./images/mascot/sombrero.png";
14
+ import topHat from "./images/mascot/top-hat.png";
15
+ import vikingHelmet from "./images/mascot/viking-helmet.png";
16
+
17
+ const Hats = {
18
+ beret,
19
+ chapka,
20
+ "cowboy hat": cowboyHat,
21
+ fez,
22
+ "jester hat": jesterHat,
23
+ mitre,
24
+ "nón lá": nonLa,
25
+ "propeller beanie": propellerBeanie,
26
+ "ski mask": skiMask,
27
+ sombrero,
28
+ "top hat": topHat,
29
+ "viking helmet": vikingHelmet,
30
+ } as const;
31
+
32
+ type HatLabel = keyof typeof Hats;
33
+
34
+ const LABELS = Object.keys(Hats) as HatLabel[];
35
+
36
+ export function useMascot() {
37
+ // useViewState: persist UI state on the host and surface it to the model.
38
+ const [state, setState] = useViewState<{ hat?: HatLabel }>({});
39
+ const { hat } = state;
40
+ const img = hat ? Hats[hat] : original;
41
+
42
+ // Preload all hats once so swaps are instant.
43
+ useEffect(() => {
44
+ for (const src of Object.values(Hats)) {
45
+ new Image().src = src;
46
+ }
47
+ }, []);
48
+
49
+ return {
50
+ img,
51
+ hat,
52
+ changeHat: () => {
53
+ setState((prev) => {
54
+ const currentIndex = prev.hat ? LABELS.indexOf(prev.hat) : -1;
55
+ const next = LABELS[(currentIndex + 1) % LABELS.length];
56
+ return { ...prev, hat: next };
57
+ });
58
+ },
59
+ };
60
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "skybridge/tsconfig",
3
+
4
+ "compilerOptions": {
5
+ "paths": {
6
+ "@/*": ["./src/*"]
7
+ }
8
+ },
9
+
10
+ "include": ["src", ".skybridge/**/*.d.ts"]
11
+ }
@@ -0,0 +1,14 @@
1
+ import path from "node:path";
2
+ import tailwindcss from "@tailwindcss/vite";
3
+ import react from "@vitejs/plugin-react";
4
+ import { skybridge } from "skybridge/vite";
5
+ import { defineConfig } from "vite";
6
+
7
+ export default defineConfig({
8
+ plugins: [skybridge(), react(), tailwindcss()],
9
+ resolve: {
10
+ alias: {
11
+ "@": path.resolve(__dirname, "./src"),
12
+ },
13
+ },
14
+ });
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ .git
3
+ dist
4
+ .env*
@@ -0,0 +1,2 @@
1
+ # Copy to .env and fill in. Sourced by the server at startup.
2
+ API_KEY=
@@ -0,0 +1,2 @@
1
+ This is an MCP ecommerce app built with Skybridge.
2
+ ALWAYS use the `chatgpt-app-builder` skill when planning or updating the codebase: see its "ecommerce" reference.
@@ -0,0 +1,53 @@
1
+ # syntax=docker/dockerfile:1
2
+
3
+ # Dockerfile for a Skybridge MCP server.
4
+ #
5
+ # Detects npm, yarn, or pnpm from the lockfile in your project.
6
+ # (For bun or deno, adapt the install/build/prune commands below.)
7
+
8
+ # Build stage: install deps, compile the app, then prune dev deps.
9
+ FROM node:24.18.0-slim AS build
10
+ WORKDIR /app
11
+
12
+ COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
13
+ RUN --mount=type=cache,target=/root/.npm \
14
+ --mount=type=cache,target=/usr/local/share/.cache/yarn \
15
+ --mount=type=cache,target=/root/.local/share/pnpm/store \
16
+ if [ -f package-lock.json ]; then \
17
+ npm ci; \
18
+ elif [ -f yarn.lock ]; then \
19
+ corepack enable yarn && yarn install --frozen-lockfile; \
20
+ elif [ -f pnpm-lock.yaml ]; then \
21
+ corepack enable pnpm && pnpm install --frozen-lockfile; \
22
+ else \
23
+ echo "No lockfile found." && exit 1; \
24
+ fi
25
+
26
+ ENV NODE_ENV=production
27
+
28
+ COPY . .
29
+ RUN if [ -f package-lock.json ]; then \
30
+ npm run build && npm prune --omit=dev; \
31
+ elif [ -f yarn.lock ]; then \
32
+ corepack enable yarn && yarn build && yarn install --frozen-lockfile --production=true; \
33
+ elif [ -f pnpm-lock.yaml ]; then \
34
+ corepack enable pnpm && pnpm build && pnpm prune --prod; \
35
+ fi
36
+
37
+ # Runtime stage: copy built artifacts and prod deps, run as non-root.
38
+ FROM node:24.18.0-slim AS runtime
39
+ WORKDIR /app
40
+ ENV NODE_ENV=production
41
+
42
+ USER node
43
+
44
+ COPY --from=build --chown=node:node /app/node_modules ./node_modules
45
+ COPY --from=build --chown=node:node /app/dist ./dist
46
+ COPY --from=build --chown=node:node /app/package.json ./package.json
47
+
48
+ EXPOSE 3000
49
+
50
+ # Run the built server directly rather than via `npm start` / `skybridge start`.
51
+ # Each wrapper adds a process layer that can swallow SIGTERM, which makes
52
+ # graceful shutdowns time out on platforms like Cloud Run, Fly, and k8s.
53
+ CMD ["node", "dist/__entry.js"]
@@ -0,0 +1,92 @@
1
+ # Skybridge Boilerplate
2
+
3
+ A minimal TypeScript boilerplate for building MCP and ChatGPT Apps with the [Skybridge](https://docs.skybridge.tech) framework.
4
+
5
+ ## Getting Started
6
+
7
+ ### Prerequisites
8
+
9
+ - Node.js 24+
10
+
11
+ ### Local Development
12
+
13
+ #### 1. Install
14
+
15
+ ```bash
16
+ npm install
17
+ # or
18
+ pnpm install
19
+ # or
20
+ bun install
21
+ # or
22
+ deno install
23
+ # or
24
+ yarn install
25
+ ```
26
+
27
+ #### 2. Start your local server
28
+
29
+ Run the development server from the root directory:
30
+
31
+ ```bash
32
+ npm run dev
33
+ # or
34
+ pnpm dev
35
+ # or
36
+ bun dev
37
+ # or
38
+ deno task dev
39
+ # or
40
+ yarn dev
41
+ ```
42
+
43
+ This command starts:
44
+ - Your MCP server at `http://localhost:3000/mcp`.
45
+ - Skybridge DevTools UI at `http://localhost:3000`.
46
+
47
+ #### 3. Project structure
48
+
49
+ ```
50
+ ├── src/
51
+ │ ├── server.ts # Server entry point
52
+ │ └── helpers.ts # Shared utilities
53
+ ├── vite.config.ts
54
+ ├── alpic.json # Deployment config
55
+ └── package.json
56
+ ```
57
+
58
+ ### Create your first view
59
+
60
+ #### 1. Add a new view
61
+
62
+ - Register a tool in `src/server.ts` with a unique name (e.g., `my-view`) using [`registerTool`](https://docs.skybridge.tech/api-reference/register-tool) and a `view` config.
63
+ - Create a matching React component at `src/views/my-view.tsx`. **The file name must match the view name exactly**.
64
+
65
+ #### 2. Edit views with Hot Module Replacement (HMR)
66
+
67
+ Edit and save components in `src/views/` — changes will appear instantly inside your App.
68
+
69
+ #### 3. Edit server code
70
+
71
+ Modify files in `src/` and refresh the tool list with your MCP Client to see the changes.
72
+
73
+ ### Testing your App
74
+
75
+ You can test your app locally by using our DevTools UI on `http://localhost:3000` while running the `dev` command.
76
+
77
+ To connect your app with web clients like ChatGPT or Claude, expose your server on the internet by adding the `--tunnel` flag.
78
+ By enabling the tunnel, you'll also be able to access a playground to chat with your app and a real LLM. Learn more by reading the [test guide](https://docs.skybridge.tech/quickstart/test-your-app).
79
+
80
+
81
+ ## Deploy to Production
82
+
83
+ Skybridge is infrastructure vendor agnostic, and your app can be deployed on any cloud platform supporting MCP.
84
+
85
+ The simplest way to deploy your app is by running the `deploy` command, which will push your MCP server to the [Alpic](https://alpic.ai/) cloud for free.
86
+
87
+ ## Resources
88
+ - [Skybridge Documentation](https://docs.skybridge.tech/)
89
+ - [Apps SDK Documentation](https://developers.openai.com/apps-sdk)
90
+ - [MCP Apps Documentation](https://github.com/modelcontextprotocol/ext-apps/tree/main)
91
+ - [Model Context Protocol Documentation](https://modelcontextprotocol.io/)
92
+ - [Alpic Documentation](https://docs.alpic.ai/)
@@ -0,0 +1,8 @@
1
+ node_modules/
2
+ dist/
3
+ .env*
4
+ !.env.template
5
+ .DS_store
6
+ *.tsbuildinfo
7
+ .skybridge/
8
+ .vercel/
@@ -0,0 +1,3 @@
1
+ {
2
+ "$schema": "https://assets.alpic.ai/alpic.json"
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/alpic@1.148.1_@opentelemetry+api@1.9.1_@opentelemetry+core@2.8.0_@opentelemetry+api@1.9_dc7708ba103efafb508db02d69c9f925/node_modules/alpic/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/alpic@1.148.1_@opentelemetry+api@1.9.1_@opentelemetry+core@2.8.0_@opentelemetry+api@1.9_dc7708ba103efafb508db02d69c9f925/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/alpic@1.148.1_@opentelemetry+api@1.9.1_@opentelemetry+core@2.8.0_@opentelemetry+api@1.9_dc7708ba103efafb508db02d69c9f925/node_modules/alpic/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/alpic@1.148.1_@opentelemetry+api@1.9.1_@opentelemetry+core@2.8.0_@opentelemetry+api@1.9_dc7708ba103efafb508db02d69c9f925/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/../alpic/bin/run.js" "$@"
19
+ else
20
+ exec node "$basedir/../alpic/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/node_modules"
14
+ else
15
+ export NODE_PATH="/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/node_modules"
14
+ else
15
+ export NODE_PATH="/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/typescript@6.0.3/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.3/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/typescript@6.0.3/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.3/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/../typescript/bin/tsc" "$@"
19
+ else
20
+ exec node "$basedir/../typescript/bin/tsc" "$@"
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/typescript@6.0.3/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.3/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/typescript@6.0.3/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.3/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/../typescript/bin/tsserver" "$@"
19
+ else
20
+ exec node "$basedir/../typescript/bin/tsserver" "$@"
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/tsx@4.23.0/node_modules/tsx/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/tsx@4.23.0/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/tsx@4.23.0/node_modules/tsx/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/tsx@4.23.0/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/../tsx/dist/cli.mjs" "$@"
19
+ else
20
+ exec node "$basedir/../tsx/dist/cli.mjs" "$@"
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/vite@8.1.3_@types+node@24.13.2_esbuild@0.28.1_jiti@2.7.0_terser@5.44.1_tsx@4.23.0_yaml@2.8.2/node_modules/vite/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@8.1.3_@types+node@24.13.2_esbuild@0.28.1_jiti@2.7.0_terser@5.44.1_tsx@4.23.0_yaml@2.8.2/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/vite@8.1.3_@types+node@24.13.2_esbuild@0.28.1_jiti@2.7.0_terser@5.44.1_tsx@4.23.0_yaml@2.8.2/node_modules/vite/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@8.1.3_@types+node@24.13.2_esbuild@0.28.1_jiti@2.7.0_terser@5.44.1_tsx@4.23.0_yaml@2.8.2/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/../vite/bin/vite.js" "$@"
19
+ else
20
+ exec node "$basedir/../vite/bin/vite.js" "$@"
21
+ fi
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "skybridge-ecom",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "description": "Skybridge MCP ecommerce template",
6
+ "type": "module",
7
+ "scripts": {
8
+ "dev": "skybridge dev",
9
+ "dev:tunnel": "skybridge dev --tunnel",
10
+ "build": "skybridge build",
11
+ "start": "skybridge start",
12
+ "deploy": "alpic deploy"
13
+ },
14
+ "dependencies": {
15
+ "skybridge": "workspace:*",
16
+ "vite": "^8.1.3",
17
+ "zod": "^4.4.3"
18
+ },
19
+ "devDependencies": {
20
+ "@skybridge/devtools": "^1.2.4",
21
+ "@types/node": "^24.13.2",
22
+ "alpic": "^1.147.1",
23
+ "tsx": "^4.23.0",
24
+ "typescript": "^6.0.3"
25
+ },
26
+ "engines": {
27
+ "node": ">=24.18.0"
28
+ }
29
+ }
@@ -0,0 +1,4 @@
1
+ import { generateHelpers } from "skybridge/web";
2
+ import type { AppType } from "./server.js";
3
+
4
+ export const { useToolInfo, useCallTool } = generateHelpers<AppType>();
@@ -0,0 +1,56 @@
1
+ export type NarrateSearchResultsInput = {
2
+ keyword: string;
3
+ products: { id: string; properties: { name: string; value: string[] }[] }[];
4
+ pages?: { current: number; total: number };
5
+ totalHits?: number;
6
+ carouselMaxSize: number;
7
+ };
8
+
9
+ export function narrateSearchResults({
10
+ keyword,
11
+ pages,
12
+ products,
13
+ totalHits,
14
+ carouselMaxSize,
15
+ }: NarrateSearchResultsInput) {
16
+ const size = products.length;
17
+ if (size <= 0) {
18
+ return { content: "No product found." };
19
+ }
20
+
21
+ let header = `${size} product${size === 1 ? "" : "s"} found for ${keyword}.`;
22
+ if (pages) {
23
+ header += ` Page ${pages.current} of ${pages.total}.`;
24
+ }
25
+ if (totalHits) {
26
+ header += ` Total hits: ${totalHits}.`;
27
+ }
28
+
29
+ const body: string[] = [header];
30
+ for (const { id, properties } of products) {
31
+ const item = [`# ID: ${id}`];
32
+ for (const { name, value } of properties) {
33
+ item.push(`- ${name}: ${value.join(", ")}`);
34
+ }
35
+ body.push(item.join("\n"));
36
+ }
37
+
38
+ const footer =
39
+ size < carouselMaxSize
40
+ ? [
41
+ "",
42
+ "NEXT STEP: Only a few results found.",
43
+ "If the client asked for a specific product by name, these are fine: curate and call render-carousel with selected IDs.",
44
+ "Otherwise, search again with broader terms before rendering.",
45
+ ].join("\n")
46
+ : [
47
+ "",
48
+ "NEXT STEP:",
49
+ "1. Curate the best matches for the client's intent from the list above.",
50
+ "2. Write your recommendation mentioning the selected products.",
51
+ "3. Call render-carousel with the selected IDs.",
52
+ ].join("\n");
53
+
54
+ const content = [header, ...body, footer].join("\n\n");
55
+ return { content };
56
+ }
@@ -0,0 +1,125 @@
1
+ import { existsSync } from "node:fs";
2
+ import { McpServer } from "skybridge/server";
3
+ import { z } from "zod";
4
+ import {
5
+ type NarrateSearchResultsInput,
6
+ narrateSearchResults,
7
+ } from "./lib/format.js";
8
+
9
+ // Load .env into process.env when present (native to Node, no dependency).
10
+ if (existsSync(".env")) {
11
+ process.loadEnvFile();
12
+ }
13
+
14
+ // @todo: how many products the carousel curates toward. CAROUSEL_RANGE is
15
+ // interpolated into the prompts below so the model aims for the right amount.
16
+ const CAROUSEL_MAX_SIZE = 6;
17
+ const CAROUSEL_RANGE = `${Math.ceil(CAROUSEL_MAX_SIZE / 2)}-${CAROUSEL_MAX_SIZE}`;
18
+
19
+ // @todo: minimum number of searches the model runs before rendering. Feeds the
20
+ // prompts below to enforce multi-call exploration; raise for deeper results.
21
+ const MIN_SEARCH_ITERATIONS = 2;
22
+
23
+ const inputSchema = {
24
+ // @todo: tune this guidance to your catalog's vocabulary. The model reads
25
+ // it to turn conversational input into a good keyword.
26
+ keyword: z.string().describe(
27
+ `\
28
+ Short noun phrases extracted from conversational input. Never pass full sentences. \
29
+ ALWAYS use the singular form, not the plural. \
30
+ Include color, material, and style descriptors for accuracy. \
31
+ For vague gift or occasion queries without a clear product type, use broad category terms. \
32
+ Preserve the existing keyword across filter refinements; only replace when the user makes a completely different request.`,
33
+ ),
34
+
35
+ // @todo: set the sort options your backend supports (or remove).
36
+ sort: z.enum(["price-asc", "price-desc"]).optional().describe("Sort order."),
37
+
38
+ // @todo: declare the filters your catalog supports. Add one param per
39
+ // facet (category, color, size...), each optional so the model only sends
40
+ // what the user asked for. `priceRange` below is just an example, remove it.
41
+ priceRange: z
42
+ .string()
43
+ .optional()
44
+ .describe(
45
+ "Price range in dollars. Format: 'min-max' e.g. '0-500', '1000-2000'.",
46
+ ),
47
+ };
48
+
49
+ type SearchInput = z.infer<z.ZodObject<typeof inputSchema>>;
50
+
51
+ function search(input: SearchInput): NarrateSearchResultsInput {
52
+ // @todo: plug in your product API / DB. Query it with the input params and map
53
+ // each result into `products` below. `pages` and `totalHits` are optional.
54
+ return {
55
+ keyword: input.keyword,
56
+ products: [], // { id: string; properties: { name: string; value: string[] }[] }[]
57
+ pages: { current: 1, total: 1 },
58
+ totalHits: 0,
59
+ carouselMaxSize: CAROUSEL_MAX_SIZE,
60
+ };
61
+ }
62
+
63
+ const server = new McpServer(
64
+ {
65
+ // @todo: name and version your app.
66
+ name: "skybridge-ecom",
67
+ version: "0.0.1",
68
+ },
69
+ {
70
+ // @todo: adapt this server-wide prompt to your catalog.
71
+ instructions: `\
72
+ Two phases:
73
+
74
+ SEARCH: Call search_products ${MIN_SEARCH_ITERATIONS}+ times before presenting—never off one call. \
75
+ Vary the keyword, apply filters from a prior response, or page deeper. \
76
+ Stay silent while searching: emit NO text between calls. Speak only \
77
+ once the carousel renders. Never call a category unavailable before searching.`,
78
+ },
79
+ ).registerTool(
80
+ {
81
+ name: "search_products",
82
+ // @todo: describe YOUR catalog and how the agent should search and curate
83
+ // it. This is the model's main guide: be specific about your categories,
84
+ // the multi-call search loop, and when to render vs. keep searching.
85
+ description: `\
86
+ Search the product catalog. Handles any query: specific products, broad categories, gifts, occasions, or open discovery.
87
+ Never assume a category is unavailable: always search before responding.
88
+
89
+ The response is data only: a list of matching products (name, ID, price, description, and any product-specific attributes) plus pagination and the available filters. The raw results are for your eyes only: the client never sees them.
90
+
91
+ NEVER describe or characterize the raw results to the client: do not mention how many there are, what categories they fall into, or that they look off-topic. While searching, stay silent: do not narrate what you are doing, announce searches, or report progress between tool calls. Speak only once the carousel is rendered.
92
+
93
+ Act on the response as follows:
94
+
95
+ - FIRST SEARCH: use the keyword only (plus sort if needed). Read the available filters in the response; these are the only valid filter options for follow-ups.
96
+ - REFINEMENT: if the user's intent matches an available filter, apply it. If it doesn't match any filter, start a new keyword search.
97
+ - ITERATE: a single search is never enough. Run several searches (${MIN_SEARCH_ITERATIONS} minimum) before rendering: vary the keyword, apply a filter, or page deeper, and compare results across them. Quality comes from this multi-call exploration; one call then render gives shallow results.
98
+ - CURATION: read results and pick the best matches for the client's intent, grounding your choice in each product's description. If zero results, broaden the keyword or relax filters and search again: do NOT call render-carousel. If fewer than 3 results and the user didn't ask for a specific product, search again with broader terms. Only after exploring across several searches, call render-carousel with the selected IDs.
99
+ - PRESENT: Once you have ${CAROUSEL_RANGE} distinct, relevant products, call render-carousel with their IDs. Recommend ONLY AFTER the carousel displays, in carousel order.
100
+
101
+ The sweet spot is ${CAROUSEL_RANGE} products.
102
+ `,
103
+ annotations: {
104
+ readOnlyHint: true,
105
+ openWorldHint: false,
106
+ destructiveHint: false,
107
+ },
108
+ // @todo: customize the status messages shown in ChatGPT while the tool runs.
109
+ _meta: {
110
+ "openai/toolInvocation/invoking": "Searching",
111
+ "openai/toolInvocation/invoked": "Done searching",
112
+ },
113
+ inputSchema,
114
+ outputSchema: {},
115
+ },
116
+ (input) => {
117
+ const results = search(input);
118
+ const { content } = narrateSearchResults(results);
119
+ return { structuredContent: {}, content, isError: false };
120
+ },
121
+ );
122
+
123
+ export default await server.run();
124
+
125
+ export type AppType = typeof server;
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "skybridge/tsconfig",
3
+
4
+ "include": ["src", ".skybridge/**/*.d.ts"]
5
+ }
@@ -0,0 +1,6 @@
1
+ import { skybridge } from "skybridge/vite";
2
+ import { defineConfig } from "vite";
3
+
4
+ export default defineConfig({
5
+ plugins: [skybridge()],
6
+ });
@@ -1 +0,0 @@
1
- export {};