create-skybridge 0.0.0-dev.edc0ede → 0.0.0-dev.eea25a3

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
@@ -1,10 +1,8 @@
1
- import { spawnSync } from "node:child_process";
2
1
  import fs from "node:fs";
3
2
  import path from "node:path";
4
3
  import { fileURLToPath } from "node:url";
5
4
  import * as prompts from "@clack/prompts";
6
5
  import mri from "mri";
7
- const minimumPnpmVersion = 10;
8
6
  const defaultProjectName = "skybridge-project";
9
7
  // prettier-ignore
10
8
  const helpMessage = `\
@@ -15,22 +13,20 @@ Create a new Skybridge project by copying the starter template.
15
13
  Options:
16
14
  -h, --help show this help message
17
15
  --overwrite remove existing files in target directory
18
- --immediate install dependencies and start development server
19
16
 
20
17
  Examples:
21
18
  create-skybridge my-app
22
- create-skybridge . --overwrite --immediate
19
+ create-skybridge . --overwrite
23
20
  `;
24
21
  export async function init(args = process.argv.slice(2)) {
25
22
  const argv = mri(args, {
26
- boolean: ["help", "overwrite", "immediate"],
23
+ boolean: ["help", "overwrite"],
27
24
  alias: { h: "help" },
28
25
  });
29
26
  const argTargetDir = argv._[0]
30
27
  ? sanitizeTargetDir(String(argv._[0]))
31
28
  : undefined;
32
29
  const argOverwrite = argv.overwrite;
33
- const argImmediate = argv.immediate;
34
30
  const help = argv.help;
35
31
  if (help) {
36
32
  console.log(helpMessage);
@@ -104,10 +100,7 @@ export async function init(args = process.argv.slice(2)) {
104
100
  try {
105
101
  const templateDir = fileURLToPath(new URL("../template", import.meta.url));
106
102
  // Copy template to target directory
107
- fs.cpSync(templateDir, root, {
108
- recursive: true,
109
- filter: (src) => !src.endsWith(".npmrc"),
110
- });
103
+ fs.cpSync(templateDir, root, { recursive: true });
111
104
  // Rename _gitignore to .gitignore
112
105
  fs.renameSync(path.join(root, "_gitignore"), path.join(root, ".gitignore"));
113
106
  // Update project name in package.json
@@ -119,72 +112,13 @@ export async function init(args = process.argv.slice(2)) {
119
112
  fs.writeFileSync(pkgPath, fixed);
120
113
  }
121
114
  prompts.log.success(`Project created in ${root}`);
115
+ prompts.outro(`Done! Next steps:\n\n cd ${targetDir}\n pnpm install\n pnpm dev`);
122
116
  }
123
117
  catch (error) {
124
118
  prompts.log.error("Failed to copy repository");
125
119
  console.error(error);
126
120
  process.exit(1);
127
121
  }
128
- // 4. Ask about immediate installation
129
- let immediate = argImmediate;
130
- if (immediate === undefined) {
131
- if (interactive) {
132
- const immediateResult = await prompts.confirm({
133
- message: `Install with pnpm and start now?`,
134
- });
135
- if (prompts.isCancel(immediateResult)) {
136
- return cancel();
137
- }
138
- immediate = immediateResult;
139
- }
140
- else {
141
- immediate = false;
142
- }
143
- }
144
- const installCmd = ["pnpm", "install"];
145
- const runCmd = ["pnpm", "dev"];
146
- if (!immediate) {
147
- prompts.outro(`Done! Next steps:
148
- cd ${targetDir}
149
- ${installCmd.join(" ")}
150
- ${runCmd.join(" ")}
151
- `);
152
- return;
153
- }
154
- // check if pnpm is installed
155
- const result = spawnSync("pnpm", ["--version"], { encoding: "utf-8" });
156
- if (result.error || result.status !== 0) {
157
- console.error("Error: pnpm is not installed. Please install pnpm first.");
158
- process.exit(1);
159
- }
160
- // check if pnpm major is greater or equal to the one set in package.json packageManager, which should do the trick
161
- const version = result.stdout.trim();
162
- const major = Number(version.split(".")[0]);
163
- if (Number.isNaN(major) || major < minimumPnpmVersion) {
164
- console.error(`Error: pnpm version ${version} is too old. Minimum required version is ${minimumPnpmVersion}.`);
165
- process.exit(1);
166
- }
167
- prompts.log.step(`Installing dependencies with pnpm...`);
168
- run(installCmd, {
169
- stdio: "inherit",
170
- cwd: root,
171
- });
172
- prompts.log.step("Starting dev server...");
173
- run(runCmd, {
174
- stdio: "inherit",
175
- cwd: root,
176
- });
177
- }
178
- function run([command, ...args], options) {
179
- const { status, error } = spawnSync(command, args, options);
180
- if (status != null && status > 0) {
181
- process.exit(status);
182
- }
183
- if (error) {
184
- console.error(`\n${command} ${args.join(" ")} error!`);
185
- console.error(error);
186
- process.exit(1);
187
- }
188
122
  }
189
123
  function sanitizeTargetDir(targetDir) {
190
124
  return (targetDir
@@ -1,7 +1,7 @@
1
1
  import { randomBytes } from "node:crypto";
2
2
  import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
- import { afterEach, beforeEach, describe, expect, it } from "vitest";
4
+ import { afterEach, beforeEach, describe, it } from "vitest";
5
5
  import { init } from "./index.js";
6
6
  describe("create-skybridge", () => {
7
7
  let tempDirName;
@@ -18,6 +18,5 @@ describe("create-skybridge", () => {
18
18
  const name = `../../${tempDirName}//project$`;
19
19
  await init([name]);
20
20
  await fs.access(path.join(process.cwd(), tempDirName, "project", ".gitignore"));
21
- expect(fs.access(path.join(process.cwd(), tempDirName, "project", ".npmrc"))).rejects.toThrowError();
22
21
  });
23
22
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-skybridge",
3
- "version": "0.0.0-dev.edc0ede",
3
+ "version": "0.0.0-dev.eea25a3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Alpic",
@@ -0,0 +1,7 @@
1
+ {
2
+ "mcpServers": {
3
+ "local": {
4
+ "url": "http://localhost:3000/mcp"
5
+ }
6
+ }
7
+ }
@@ -0,0 +1 @@
1
+ lts/jod
@@ -0,0 +1,16 @@
1
+ {
2
+ "version": "0.0.1",
3
+ "configurations": [
4
+ {
5
+ "name": "Debug MCP Server",
6
+ "type": "node",
7
+ "request": "launch",
8
+ "program": "${workspaceFolder}/dist/index.js",
9
+ "console": "integratedTerminal",
10
+ "sourceMaps": true,
11
+ "outFiles": ["${workspaceFolder}/dist/**/*.js"],
12
+ "preLaunchTask": "npm: build",
13
+ "stopOnEntry": false
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "editor.formatOnSave": true
3
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "tasks": [
4
+ {
5
+ "type": "shell",
6
+ "command": "npm",
7
+ "args": ["build"],
8
+ "group": "build",
9
+ "label": "npm: build",
10
+ "detail": "npm build",
11
+ "problemMatcher": ["$tsc"]
12
+ }
13
+ ]
14
+ }
@@ -1,16 +1,24 @@
1
1
  # ChatGPT Apps SDK Alpic Starter
2
2
 
3
- A minimal TypeScript template for building OpenAI Apps SDK compatible MCP servers with widget rendering in ChatGPT.
3
+ This repository is a minimal Typescript application demonstrating how to build an OpenAI Apps SDK compatible MCP server with widget rendering in ChatGPT.
4
+
5
+ ![Demo](docs/demo.gif)
6
+
7
+ ## Overview
8
+
9
+ This project shows how to integrate a Typescript express application with the ChatGPT Apps SDK using the Model Context Protocol (MCP). It includes a working MCP server that exposes tools and resources that can be called from ChatGPT, with responses rendered natively in ChatGPT. It also includes MCP tools without UI widgets.
4
10
 
5
11
  ## Getting Started
6
12
 
7
13
  ### Prerequisites
8
14
 
9
- - Node.js 22+
15
+ - Node.js 22+ (see `.nvmrc` for exact version)
10
16
  - pnpm (install with `npm install -g pnpm`)
11
- - HTTP tunnel such as [ngrok](https://ngrok.com/download)
17
+ - Ngrok
12
18
 
13
- ### Local Development
19
+ ### Local Development with Hot Module Replacement (HMR)
20
+
21
+ This project uses Vite for React widget development with full HMR support, allowing you to see changes in real-time, directly within ChatGPT conversation, without restarting the server.
14
22
 
15
23
  #### 1. Install
16
24
 
@@ -18,7 +26,7 @@ A minimal TypeScript template for building OpenAI Apps SDK compatible MCP server
18
26
  pnpm install
19
27
  ```
20
28
 
21
- #### 2. Start your local server
29
+ #### 2. Start the Development Server
22
30
 
23
31
  Run the development server from the root directory:
24
32
 
@@ -28,37 +36,79 @@ pnpm dev
28
36
 
29
37
  This command starts an Express server on port 3000. This server packages:
30
38
 
31
- - an MCP endpoint on `/mcp` (the app backend)
32
- - a React application on Vite HMR dev server (the UI elements to be displayed in ChatGPT)
39
+ - an MCP endpoint on `/mcp` - aka the ChatGPT App Backend
40
+ - a React application on Vite HMR dev server - aka the ChatGPT App Frontend
41
+
42
+ #### 3. Expose Your Local Server
33
43
 
34
- #### 3. Connect to ChatGPT
44
+ In a separate terminal, expose your local server using ngrok:
35
45
 
36
- - ChatGPT requires connectors to be publicly accessible. To expose your server on the Internet, run:
37
46
  ```bash
38
47
  ngrok http 3000
39
48
  ```
40
- - 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`)
41
49
 
42
- ### Create your first widget
50
+ Copy the forwarding URL from ngrok output:
51
+
52
+ ```bash
53
+ Forwarding https://3785c5ddc4b6.ngrok-free.app -> http://localhost:3000
54
+ ```
55
+
56
+ #### 4. Connect to ChatGPT
57
+
58
+ - Enable **Settings → Connectors → Advanced → Developer mode** in the ChatGPT client
59
+ - Navigate to **Settings → Connectors → Create**
60
+ - Enter your ngrok URL with the `/mcp` path (e.g., `https://3785c5ddc4b6.ngrok-free.app/mcp`)
61
+ - Click **Create**
62
+
63
+ #### 5. Test Your Integration
43
64
 
44
- #### 1. Add a new widget
65
+ - Start a new conversation in ChatGPT
66
+ - Select your newly created connector using **the + button → Your connector**
67
+ - Try prompting the model (e.g., "Show me pikachu details")
45
68
 
46
- - Register a widget in `server/server.ts` with a unique name (e.g., `my-widget`)
47
- - Create a matching React component at `web/src/widgets/my-widget.tsx`. The file name must match the widget name exactly
69
+ #### 6. Develop with HMR
48
70
 
49
- #### 2. Edit widgets with Hot Module Replacement (HMR)
71
+ Now you can edit React components in `web` and see changes instantly:
50
72
 
51
- Edit and save components in `web/src/widgets/` — changes appear instantly in ChatGPT
73
+ - Make changes to any component
74
+ - Save the file
75
+ - The widget will automatically update in ChatGPT without refreshing or reconnecting
76
+ - The Express server and MCP server continue running without interruption
52
77
 
53
- #### 3. Edit server code
78
+ **Note:** When you modify widget components, changes will be reflected immediately. If you modify MCP server code (in `src/`), you may need to reload your connector in **Settings → Connectors → [Your connector] → Reload**.
54
79
 
55
- Modify files in `server/` and reload your ChatGPT connector in **Settings → Connectors → [Your connector] → Reload**
80
+ ## Widget Naming Convention
81
+
82
+ **Important:** For a widget to work properly, the name of the endpoint in your MCP server must match the file name of the corresponding React component in `web/src/widgets/`.
83
+
84
+ For example:
85
+
86
+ - If you create a widget endpoint named `pokemon-card`, you must create a corresponding React component file at `web/src/widgets/pokemon-card.tsx`
87
+ - The endpoint name and the widget file name (without the `.tsx` extension) must be identical
88
+
89
+ This naming convention allows the system to automatically map widget requests to their corresponding React components.
56
90
 
57
91
  ## Deploy to Production
58
92
 
59
- - Use [Alpic](https://alpic.ai/) to deploy your OpenAI App to production
93
+ Use Alpic to deploy your OpenAI App to production.
94
+
95
+ [![Deploy on Alpic](https://assets.alpic.ai/button.svg)](https://app.alpic.ai/new/clone?repositoryUrl=https%3A%2F%2Fgithub.com%2Falpic-ai%2Fapps-sdk-template)
96
+
60
97
  - In ChatGPT, navigate to **Settings → Connectors → Create** and add your MCP server URL (e.g., `https://your-app-name.alpic.live`)
61
98
 
99
+ ## Project Structure
100
+
101
+ ```
102
+ .
103
+ ├── server/
104
+ │ ├── app.ts # OpenAI App extension class with widget API implementation
105
+ │ ├── server.ts # MCP server with tool/resource/prompt registration
106
+ │ └── index.ts # Express server definition
107
+ └── web/
108
+ └── src/
109
+ └── widgets/ # React widget components (must match endpoint names)
110
+ ```
111
+
62
112
  ## Resources
63
113
 
64
114
  - [Apps SDK Documentation](https://developers.openai.com/apps-sdk)
@@ -1,4 +1,194 @@
1
+ # =============================================================================
2
+ # OPERATING SYSTEM FILES
3
+ # =============================================================================
4
+ .DS_Store
5
+ .DS_Store?
6
+ ._*
7
+ .Spotlight-V100
8
+ .Trashes
9
+ ehthumbs.db
10
+ Thumbs.db
11
+
12
+ # =============================================================================
13
+ # NODE.JS & PACKAGE MANAGERS
14
+ # =============================================================================
1
15
  node_modules/
16
+ npm-debug.log*
17
+ yarn-debug.log*
18
+ yarn-error.log*
19
+ .pnpm-debug.log*
20
+ .npm
21
+ .pnp.js
22
+ .pnp.cjs
23
+ .pnp.mjs
24
+ .pnp.json
25
+ .pnp.ts
26
+
27
+ # =============================================================================
28
+ # TYPESCRIPT & JAVASCRIPT
29
+ # =============================================================================
30
+ *.tsbuildinfo
31
+ .tscache/
32
+ *.js.map
33
+ *.mjs.map
34
+ *.cjs.map
35
+ *.d.ts.map
36
+ *.d.ts
37
+ !*.d.ts.template
38
+ *.tgz
39
+ .eslintcache
40
+ .rollup.cache
41
+
42
+ # =============================================================================
43
+ # PYTHON
44
+ # =============================================================================
45
+ __pycache__/
46
+ *.py[cod]
47
+ *$py.class
48
+ *.so
49
+ .Python
50
+ develop-eggs/
51
+ eggs/
52
+ .eggs/
53
+ lib/
54
+ lib64/
55
+ parts/
56
+ sdist/
57
+ var/
58
+ wheels/
59
+ *.egg-info/
60
+ .installed.cfg
61
+ *.egg
62
+ .pytest_cache/
63
+ .coverage
64
+ htmlcov/
65
+ .tox/
66
+ .venv
67
+ venv/
68
+ ENV/
69
+
70
+ # =============================================================================
71
+ # JAVA
72
+ # =============================================================================
73
+ *.class
74
+ *.jar
75
+ *.war
76
+ *.nar
77
+ *.ear
78
+ hs_err_pid*
79
+ target/
80
+ .gradle/
81
+
82
+ # =============================================================================
83
+ # RUBY
84
+ # =============================================================================
85
+ *.gem
86
+ *.rbc
87
+ /.config
88
+ /coverage/
89
+ /InstalledFiles
90
+ /pkg/
91
+ /spec/reports/
92
+ /spec/examples.txt
93
+ /test/tmp/
94
+ /test/version_tmp/
95
+ /tmp/
96
+ .byebug_history
97
+
98
+ # =============================================================================
99
+ # BUILD & DISTRIBUTION
100
+ # =============================================================================
101
+ build/
2
102
  dist/
3
- .env*
4
- .DS_store
103
+ dist-ssr/
104
+ out/
105
+
106
+ # =============================================================================
107
+ # COMPILED FILES
108
+ # =============================================================================
109
+ *.com
110
+ *.dll
111
+ *.exe
112
+ *.o
113
+
114
+ # =============================================================================
115
+ # PACKAGE & ARCHIVE FILES
116
+ # =============================================================================
117
+ *.7z
118
+ *.dmg
119
+ *.gz
120
+ *.iso
121
+ *.rar
122
+ *.tar
123
+ *.tar.gz
124
+ *.zip
125
+
126
+ # =============================================================================
127
+ # LOGS & DATABASES
128
+ # =============================================================================
129
+ *.log
130
+ *.sql
131
+ *.sqlite
132
+ *.sqlite3
133
+ logs/
134
+
135
+ # =============================================================================
136
+ # TESTING & COVERAGE
137
+ # =============================================================================
138
+ coverage/
139
+ .nyc_output/
140
+
141
+ # =============================================================================
142
+ # CACHE & TEMPORARY FILES
143
+ # =============================================================================
144
+ .cache/
145
+ .parcel-cache/
146
+ *.bak
147
+
148
+ # =============================================================================
149
+ # ENVIRONMENT & CONFIGURATION
150
+ # =============================================================================
151
+ .env
152
+ .env.local
153
+ .env.development.local
154
+ .env.test.local
155
+ .env.production.local
156
+ .sample-env
157
+ sample.*
158
+ !sample.template.*
159
+ *.local
160
+ mcp-servers.json
161
+ mcp-config.json
162
+
163
+ # =============================================================================
164
+ # DEMO & EXAMPLE DIRECTORIES
165
+ # =============================================================================
166
+ demo/
167
+ demos/
168
+ example/
169
+ examples/
170
+ samples/
171
+
172
+ # =============================================================================
173
+ # GENERATED DOCUMENTATION
174
+ # =============================================================================
175
+ docs/api/
176
+
177
+ # =============================================================================
178
+ # EDITOR DIRECTORIES AND FILES
179
+ # =============================================================================
180
+ .vscode/*
181
+ !.vscode/extensions.json
182
+ .idea
183
+ *.suo
184
+ *.ntvs*
185
+ *.njsproj
186
+ *.sln
187
+ *.sw?
188
+
189
+ # =============================================================================
190
+ # APPLICATION SPECIFIC
191
+ # =============================================================================
192
+ repomix-output*
193
+ duckdata/
194
+ .claude
Binary file