create-skybridge 0.0.0-dev.32f382f → 0.0.0-dev.3300e72
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 +46 -24
- package/package.json +2 -2
- package/templates/blank/package.json +2 -2
- package/templates/demo/package.json +3 -3
- package/templates/ecom/.dockerignore +4 -0
- package/templates/ecom/.env.template +2 -0
- package/templates/ecom/AGENTS.md +2 -0
- package/templates/ecom/Dockerfile +53 -0
- package/templates/ecom/README.md +92 -0
- package/templates/ecom/_gitignore +8 -0
- package/templates/ecom/alpic.json +3 -0
- package/templates/ecom/node_modules/.bin/alpic +21 -0
- package/templates/ecom/node_modules/.bin/sb +21 -0
- package/templates/ecom/node_modules/.bin/skybridge +21 -0
- package/templates/ecom/node_modules/.bin/tsc +21 -0
- package/templates/ecom/node_modules/.bin/tsserver +21 -0
- package/templates/ecom/node_modules/.bin/tsx +21 -0
- package/templates/ecom/node_modules/.bin/vite +21 -0
- package/templates/ecom/package.json +29 -0
- package/templates/ecom/src/config.ts +10 -0
- package/templates/ecom/src/helpers.ts +4 -0
- package/templates/ecom/src/server.ts +36 -0
- package/templates/ecom/src/tools/search-products.ts +185 -0
- package/templates/ecom/tsconfig.json +5 -0
- package/templates/ecom/vite.config.ts +6 -0
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import mri from "mri";
|
|
|
7
7
|
const OUTPUT_TAIL_LINES = 10;
|
|
8
8
|
const DEFAULT_PROJECT_NAME = "skybridge-project";
|
|
9
9
|
const PACKAGE_MANAGERS = ["bun", "deno", "npm", "pnpm", "yarn"];
|
|
10
|
-
const TEMPLATES = ["demo", "blank"];
|
|
10
|
+
const TEMPLATES = ["demo", "blank", "ecom"];
|
|
11
11
|
const pkg = JSON.parse(fs.readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf-8"));
|
|
12
12
|
const version = pkg.version;
|
|
13
13
|
const HELP_MESSAGE = `Usage: skybridge create [path] [options]
|
|
@@ -19,6 +19,7 @@ Arguments:
|
|
|
19
19
|
|
|
20
20
|
Options:
|
|
21
21
|
--blank scaffold a minimal project without demo tools and views
|
|
22
|
+
--ecom scaffold the ecommerce template (search products, render carousel)
|
|
22
23
|
--overwrite remove existing files if target directory is not empty
|
|
23
24
|
--pm <choice> package manager to use (choices: ${PACKAGE_MANAGERS.join(", ")}. default to npm when none is provided or infered)
|
|
24
25
|
--skip-skills skip installing coding agent skills
|
|
@@ -60,7 +61,15 @@ const Spinner = {
|
|
|
60
61
|
};
|
|
61
62
|
export async function init(args = process.argv.slice(2)) {
|
|
62
63
|
const argv = mri(args, {
|
|
63
|
-
boolean: [
|
|
64
|
+
boolean: [
|
|
65
|
+
"help",
|
|
66
|
+
"blank",
|
|
67
|
+
"ecom",
|
|
68
|
+
"overwrite",
|
|
69
|
+
"skip-skills",
|
|
70
|
+
"start",
|
|
71
|
+
"yes",
|
|
72
|
+
],
|
|
64
73
|
string: ["pm"],
|
|
65
74
|
alias: { h: "help" },
|
|
66
75
|
});
|
|
@@ -121,30 +130,43 @@ export async function init(args = process.argv.slice(2)) {
|
|
|
121
130
|
if (argv.blank) {
|
|
122
131
|
template = "blank";
|
|
123
132
|
}
|
|
124
|
-
|
|
125
|
-
template
|
|
133
|
+
if (argv.ecom) {
|
|
134
|
+
if (template) {
|
|
135
|
+
abort("Cannot specify both --blank and --ecom.");
|
|
136
|
+
}
|
|
137
|
+
template = "ecom";
|
|
126
138
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
if (!template) {
|
|
140
|
+
if (yes) {
|
|
141
|
+
template = "demo";
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
const choice = await prompts.select({
|
|
145
|
+
message: "Choose a template:",
|
|
146
|
+
options: [
|
|
147
|
+
{
|
|
148
|
+
value: "demo",
|
|
149
|
+
label: "demo",
|
|
150
|
+
hint: "starter code with tools and UI",
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
value: "blank",
|
|
154
|
+
label: "blank",
|
|
155
|
+
hint: "minimal boilerplate without tools",
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
value: "ecom",
|
|
159
|
+
label: "ecom",
|
|
160
|
+
hint: "ecommerce template with product search tool and carousel view",
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
initialValue: "demo",
|
|
164
|
+
});
|
|
165
|
+
if (prompts.isCancel(choice)) {
|
|
166
|
+
return cancel();
|
|
167
|
+
}
|
|
168
|
+
template = choice;
|
|
146
169
|
}
|
|
147
|
-
template = choice;
|
|
148
170
|
}
|
|
149
171
|
// 4. Copy template
|
|
150
172
|
const root = path.resolve(targetDir);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-skybridge",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.3300e72",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Alpic",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/cross-spawn": "^6.0.6",
|
|
26
26
|
"typescript": "^6.0.3",
|
|
27
|
-
"vitest": "^4.1.
|
|
27
|
+
"vitest": "^4.1.9"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsc",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
16
|
-
"skybridge": "^0.0.0-dev.
|
|
16
|
+
"skybridge": "^0.0.0-dev.3300e72",
|
|
17
17
|
"vite": "^8.1.3"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@skybridge/devtools": "^1.2.4",
|
|
21
21
|
"@types/node": "^24.13.2",
|
|
22
|
-
"alpic": "^1.
|
|
22
|
+
"alpic": "^1.147.1",
|
|
23
23
|
"tsx": "^4.23.0",
|
|
24
24
|
"typescript": "^6.0.3"
|
|
25
25
|
},
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"deploy": "alpic deploy"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@alpic-ai/ui": "^1.
|
|
15
|
+
"@alpic-ai/ui": "^1.147.1",
|
|
16
16
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
17
17
|
"lucide-react": "^1.23.0",
|
|
18
18
|
"react": "^19.2.7",
|
|
19
19
|
"react-dom": "^19.2.7",
|
|
20
|
-
"skybridge": "^0.0.0-dev.
|
|
20
|
+
"skybridge": "^0.0.0-dev.3300e72",
|
|
21
21
|
"sonner": "^2.0.7",
|
|
22
22
|
"tw-animate-css": "^1.4.0",
|
|
23
23
|
"vite": "^8.1.3",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@types/react": "^19.2.17",
|
|
31
31
|
"@types/react-dom": "^19.2.3",
|
|
32
32
|
"@vitejs/plugin-react": "^6.0.3",
|
|
33
|
-
"alpic": "^1.
|
|
33
|
+
"alpic": "^1.147.1",
|
|
34
34
|
"tailwindcss": "^4.3.2",
|
|
35
35
|
"tsx": "^4.23.0",
|
|
36
36
|
"typescript": "^6.0.3"
|
|
@@ -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,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,10 @@
|
|
|
1
|
+
// App-wide tuning knobs, shared by the server prompt and the tools.
|
|
2
|
+
|
|
3
|
+
// @todo: minimum number of searches the model runs before rendering. Feeds the
|
|
4
|
+
// prompts to enforce multi-call exploration; raise for deeper results.
|
|
5
|
+
export const MIN_SEARCH_ITERATIONS = 2;
|
|
6
|
+
|
|
7
|
+
// @todo: how many products the carousel curates toward. CAROUSEL_RANGE is
|
|
8
|
+
// interpolated into the prompts so the model aims for the right amount.
|
|
9
|
+
export const CAROUSEL_MAX_SIZE = 6;
|
|
10
|
+
export const CAROUSEL_RANGE = `${Math.ceil(CAROUSEL_MAX_SIZE / 2)}-${CAROUSEL_MAX_SIZE}`;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { McpServer } from "skybridge/server";
|
|
3
|
+
import { MIN_SEARCH_ITERATIONS } from "./config.js";
|
|
4
|
+
import {
|
|
5
|
+
searchProductsDefinition,
|
|
6
|
+
searchProductsHandler,
|
|
7
|
+
} from "./tools/search-products.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
|
+
const server = new McpServer(
|
|
15
|
+
{
|
|
16
|
+
// @todo: name and version your app.
|
|
17
|
+
name: "skybridge-ecom",
|
|
18
|
+
version: "0.0.1",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
// @todo: adapt this server-wide prompt to your catalog.
|
|
22
|
+
instructions: `\
|
|
23
|
+
Two phases:
|
|
24
|
+
|
|
25
|
+
SEARCH: Call search-products ${MIN_SEARCH_ITERATIONS}+ times before presenting—never off one call. \
|
|
26
|
+
Vary the keyword, apply filters from a prior response, or page deeper. \
|
|
27
|
+
Stay silent while searching: emit NO text between calls. Speak only \
|
|
28
|
+
once the carousel renders. Never call a category unavailable before searching.
|
|
29
|
+
|
|
30
|
+
RENDER: not implemented yet`,
|
|
31
|
+
},
|
|
32
|
+
).registerTool(searchProductsDefinition, searchProductsHandler);
|
|
33
|
+
|
|
34
|
+
export default await server.run();
|
|
35
|
+
|
|
36
|
+
export type AppType = typeof server;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
CAROUSEL_MAX_SIZE,
|
|
4
|
+
CAROUSEL_RANGE,
|
|
5
|
+
MIN_SEARCH_ITERATIONS,
|
|
6
|
+
} from "../config.js";
|
|
7
|
+
|
|
8
|
+
// The `search-products` tool: keyword + filters in, matching products out as
|
|
9
|
+
// structured output for the model. It has NO view — include only what the model
|
|
10
|
+
// needs to curate (ids + properties), never presentational data (images, media);
|
|
11
|
+
// render-carousel handles that. Everything this tool needs lives in this file.
|
|
12
|
+
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Input
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
const inputSchema = {
|
|
18
|
+
// @todo: tune this guidance to your catalog's vocabulary. The model reads
|
|
19
|
+
// it to turn conversational input into a good keyword.
|
|
20
|
+
keyword: z.string().describe(
|
|
21
|
+
`\
|
|
22
|
+
Short noun phrases extracted from conversational input. Never pass full sentences. \
|
|
23
|
+
ALWAYS use the singular form, not the plural. \
|
|
24
|
+
Include color, material, and style descriptors for accuracy. \
|
|
25
|
+
For vague gift or occasion queries without a clear product type, use broad category terms. \
|
|
26
|
+
Preserve the existing keyword across filter refinements; only replace when the user makes a completely different request.`,
|
|
27
|
+
),
|
|
28
|
+
|
|
29
|
+
// @todo: set the sort options your backend supports (or remove).
|
|
30
|
+
sort: z.enum(["price-asc", "price-desc"]).optional().describe("Sort order."),
|
|
31
|
+
|
|
32
|
+
// @todo: declare the filters your catalog supports. Add one param per
|
|
33
|
+
// facet (category, color, size...), each optional so the model only sends
|
|
34
|
+
// what the user asked for. `priceRange` below is just an example, remove it.
|
|
35
|
+
priceRange: z
|
|
36
|
+
.string()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe(
|
|
39
|
+
"Price range in dollars. Format: 'min-max' e.g. '0-500', '1000-2000'.",
|
|
40
|
+
),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type SearchInput = z.infer<z.ZodObject<typeof inputSchema>>;
|
|
44
|
+
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// Output — model-facing grounding, returned in structuredContent.
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
// The property names the model curates on (grounding only, no presentational data).
|
|
50
|
+
// @todo: replace with your catalog's property names.
|
|
51
|
+
const propertyName = z.enum(["name", "price", "description"]);
|
|
52
|
+
|
|
53
|
+
const outputSchema = {
|
|
54
|
+
products: z
|
|
55
|
+
.array(
|
|
56
|
+
z.object({
|
|
57
|
+
id: z.string().describe("Stable product ID; pass to render-carousel."),
|
|
58
|
+
properties: z
|
|
59
|
+
.array(
|
|
60
|
+
z.object({
|
|
61
|
+
name: propertyName.describe("Which property this is."),
|
|
62
|
+
value: z.array(z.string()).describe("The property's value(s)."),
|
|
63
|
+
}),
|
|
64
|
+
)
|
|
65
|
+
.describe("Product properties to curate on."),
|
|
66
|
+
}),
|
|
67
|
+
)
|
|
68
|
+
.describe("Matching products, sorted."),
|
|
69
|
+
pages: z
|
|
70
|
+
.object({
|
|
71
|
+
current: z.number(),
|
|
72
|
+
total: z.number(),
|
|
73
|
+
})
|
|
74
|
+
.optional()
|
|
75
|
+
.describe("Pagination: current page and total page count."),
|
|
76
|
+
totalHits: z
|
|
77
|
+
.number()
|
|
78
|
+
.optional()
|
|
79
|
+
.describe("Total matching products across all pages."),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
type SearchResults = z.infer<z.ZodObject<typeof outputSchema>>;
|
|
83
|
+
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
// Data access
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
|
|
88
|
+
function search(input: SearchInput): SearchResults {
|
|
89
|
+
// @todo: plug in your product API / DB. Query it with the input params and map
|
|
90
|
+
// each result into `products` below. `pages` and `totalHits` are optional.
|
|
91
|
+
return {
|
|
92
|
+
products: [], // { id: string; properties: { name: PropertyName; value: string[] }[] }[]
|
|
93
|
+
pages: { current: 1, total: 1 },
|
|
94
|
+
totalHits: 0,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
// Narration — framing + next-step instructions for the model. The products
|
|
100
|
+
// themselves ride in structuredContent; this text carries NO result data.
|
|
101
|
+
// @todo: customize the NEXT STEPS guidance below for your flow (keep searching
|
|
102
|
+
// vs. curate and render). Remind the model to ground claims in the structured
|
|
103
|
+
// results and never invent attributes.
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
|
|
106
|
+
function narrate({ products }: SearchResults): string {
|
|
107
|
+
const size = products.length;
|
|
108
|
+
|
|
109
|
+
if (size === 0) {
|
|
110
|
+
return `\
|
|
111
|
+
No products found.
|
|
112
|
+
|
|
113
|
+
NEXT STEP: Broaden the keyword or relax filters, then search again.`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (size < CAROUSEL_MAX_SIZE) {
|
|
117
|
+
return `\
|
|
118
|
+
Only a few results.
|
|
119
|
+
|
|
120
|
+
NEXT STEPS:
|
|
121
|
+
1. If the client asked for a specific product by name, these are fine: curate and call render-carousel with the selected IDs.
|
|
122
|
+
2. Otherwise, search again with broader terms before rendering.`;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return `\
|
|
126
|
+
Enough results to present.
|
|
127
|
+
|
|
128
|
+
NEXT STEPS:
|
|
129
|
+
1. Curate the best matches for the client's intent from the structured results.
|
|
130
|
+
2. Write your recommendation mentioning the selected products.
|
|
131
|
+
3. Call render-carousel with the selected IDs.`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ---------------------------------------------------------------------------
|
|
135
|
+
// Tool (registered from server.ts to keep the typed tool chain intact)
|
|
136
|
+
// ---------------------------------------------------------------------------
|
|
137
|
+
|
|
138
|
+
export const searchProductsDefinition = {
|
|
139
|
+
name: "search-products" as const,
|
|
140
|
+
|
|
141
|
+
// @todo: describe YOUR catalog and how the agent should search and curate
|
|
142
|
+
// it. This is the model's main guide: be specific about your categories,
|
|
143
|
+
// the multi-call search loop, and when to render vs. keep searching.
|
|
144
|
+
description: `\
|
|
145
|
+
Search the product catalog. Handles any query: specific products, broad categories, gifts, occasions, or open discovery.
|
|
146
|
+
Never assume a category is unavailable: always search before responding.
|
|
147
|
+
|
|
148
|
+
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.
|
|
149
|
+
|
|
150
|
+
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.
|
|
151
|
+
|
|
152
|
+
Act on the response as follows:
|
|
153
|
+
|
|
154
|
+
- 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.
|
|
155
|
+
- REFINEMENT: if the user's intent matches an available filter, apply it. If it doesn't match any filter, start a new keyword search.
|
|
156
|
+
- 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.
|
|
157
|
+
- 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.
|
|
158
|
+
- PRESENT: Once you have ${CAROUSEL_RANGE} distinct, relevant products, call render-carousel with their IDs. Recommend ONLY AFTER the carousel displays, in carousel order.
|
|
159
|
+
|
|
160
|
+
The sweet spot is ${CAROUSEL_RANGE} products.
|
|
161
|
+
`,
|
|
162
|
+
annotations: {
|
|
163
|
+
readOnlyHint: true,
|
|
164
|
+
openWorldHint: false,
|
|
165
|
+
destructiveHint: false,
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
// @todo: customize the status messages shown in ChatGPT while the tool runs.
|
|
169
|
+
_meta: {
|
|
170
|
+
"openai/toolInvocation/invoking": "Searching",
|
|
171
|
+
"openai/toolInvocation/invoked": "Done searching",
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
inputSchema,
|
|
175
|
+
outputSchema,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export function searchProductsHandler(input: SearchInput) {
|
|
179
|
+
const results = search(input);
|
|
180
|
+
return {
|
|
181
|
+
structuredContent: results,
|
|
182
|
+
content: [{ type: "text" as const, text: narrate(results) }],
|
|
183
|
+
isError: false,
|
|
184
|
+
};
|
|
185
|
+
}
|