create-skybridge 0.0.0-dev.ac28c6f → 0.0.0-dev.bc56028
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.d.ts +1 -1
- package/dist/index.js +16 -20
- package/index.js +1 -6
- package/package.json +2 -5
- package/template/README.md +19 -69
- package/template/_gitignore +2 -192
- package/template/server/package.json +0 -2
- package/template/server/src/server.ts +59 -60
- package/template/web/package.json +1 -9
- package/template/web/src/helpers.ts +1 -1
- package/template/web/src/index.css +23 -113
- package/template/web/src/widgets/magic-8-ball.tsx +22 -0
- package/template/web/vite.config.ts +1 -2
- package/dist/index.test.d.ts +0 -1
- package/dist/index.test.js +0 -19
- package/template/.cursor/mcp.json +0 -7
- package/template/.nvmrc +0 -1
- package/template/.vscode/launch.json +0 -16
- package/template/.vscode/settings.json +0 -3
- package/template/.vscode/tasks.json +0 -14
- package/template/docs/demo.gif +0 -0
- package/template/server/pnpm-lock.yaml +0 -3796
- package/template/server/src/pokedex.ts +0 -148
- package/template/web/components.json +0 -22
- package/template/web/pnpm-lock.yaml +0 -2629
- package/template/web/src/components/ui/shadcn-io/spinner/index.tsx +0 -272
- package/template/web/src/utils.ts +0 -6
- package/template/web/src/widgets/pokemon.tsx +0 -203
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,11 @@ import path from "node:path";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import * as prompts from "@clack/prompts";
|
|
5
5
|
import mri from "mri";
|
|
6
|
+
const argv = mri(process.argv.slice(2), {
|
|
7
|
+
boolean: ["help", "overwrite"],
|
|
8
|
+
alias: { h: "help" },
|
|
9
|
+
});
|
|
10
|
+
const cwd = process.cwd();
|
|
6
11
|
const defaultProjectName = "skybridge-project";
|
|
7
12
|
// prettier-ignore
|
|
8
13
|
const helpMessage = `\
|
|
@@ -18,13 +23,9 @@ Examples:
|
|
|
18
23
|
create-skybridge my-app
|
|
19
24
|
create-skybridge . --overwrite
|
|
20
25
|
`;
|
|
21
|
-
|
|
22
|
-
const argv = mri(args, {
|
|
23
|
-
boolean: ["help", "overwrite"],
|
|
24
|
-
alias: { h: "help" },
|
|
25
|
-
});
|
|
26
|
+
async function init() {
|
|
26
27
|
const argTargetDir = argv._[0]
|
|
27
|
-
?
|
|
28
|
+
? formatTargetDir(String(argv._[0]))
|
|
28
29
|
: undefined;
|
|
29
30
|
const argOverwrite = argv.overwrite;
|
|
30
31
|
const help = argv.help;
|
|
@@ -43,14 +44,14 @@ export async function init(args = process.argv.slice(2)) {
|
|
|
43
44
|
defaultValue: defaultProjectName,
|
|
44
45
|
placeholder: defaultProjectName,
|
|
45
46
|
validate: (value) => {
|
|
46
|
-
return value.length === 0 ||
|
|
47
|
+
return value.length === 0 || formatTargetDir(value).length > 0
|
|
47
48
|
? undefined
|
|
48
49
|
: "Invalid project name";
|
|
49
50
|
},
|
|
50
51
|
});
|
|
51
52
|
if (prompts.isCancel(projectName))
|
|
52
53
|
return cancel();
|
|
53
|
-
targetDir =
|
|
54
|
+
targetDir = formatTargetDir(projectName);
|
|
54
55
|
}
|
|
55
56
|
else {
|
|
56
57
|
targetDir = defaultProjectName;
|
|
@@ -94,7 +95,7 @@ export async function init(args = process.argv.slice(2)) {
|
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
|
-
const root = path.join(
|
|
98
|
+
const root = path.join(cwd, targetDir);
|
|
98
99
|
// 3. Copy the repository
|
|
99
100
|
prompts.log.step(`Copying template...`);
|
|
100
101
|
try {
|
|
@@ -120,17 +121,8 @@ export async function init(args = process.argv.slice(2)) {
|
|
|
120
121
|
process.exit(1);
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
|
-
function
|
|
124
|
-
return (
|
|
125
|
-
.trim()
|
|
126
|
-
// Only keep alphanumeric, dash, underscore, dot, @, /
|
|
127
|
-
.replace(/[^a-zA-Z0-9\-_.@/]/g, "")
|
|
128
|
-
// Prevent path traversal
|
|
129
|
-
.replace(/\.\./g, "")
|
|
130
|
-
// Collapse multiple slashes
|
|
131
|
-
.replace(/\/+/g, "/")
|
|
132
|
-
// Remove leading/trailing slashes
|
|
133
|
-
.replace(/^\/+|\/+$/g, ""));
|
|
124
|
+
function formatTargetDir(targetDir) {
|
|
125
|
+
return targetDir.trim().replace(/\/+$/g, "");
|
|
134
126
|
}
|
|
135
127
|
function isEmpty(path) {
|
|
136
128
|
const files = fs.readdirSync(path);
|
|
@@ -147,3 +139,7 @@ function emptyDir(dir) {
|
|
|
147
139
|
fs.rmSync(path.resolve(dir, file), { recursive: true, force: true });
|
|
148
140
|
}
|
|
149
141
|
}
|
|
142
|
+
init().catch((e) => {
|
|
143
|
+
console.error(e);
|
|
144
|
+
process.exit(1);
|
|
145
|
+
});
|
package/index.js
CHANGED
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.bc56028",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Alpic",
|
|
@@ -18,8 +18,6 @@
|
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tsc",
|
|
21
|
-
"test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
|
|
22
|
-
"test:unit": "vitest run",
|
|
23
21
|
"test:type": "tsc --noEmit",
|
|
24
22
|
"test:format": "biome ci",
|
|
25
23
|
"prepublishOnly": "pnpm run build"
|
|
@@ -30,7 +28,6 @@
|
|
|
30
28
|
},
|
|
31
29
|
"devDependencies": {
|
|
32
30
|
"@types/node": "^25.0.3",
|
|
33
|
-
"typescript": "^5.9.3"
|
|
34
|
-
"vitest": "^2.1.9"
|
|
31
|
+
"typescript": "^5.9.3"
|
|
35
32
|
}
|
|
36
33
|
}
|
package/template/README.md
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
# ChatGPT Apps SDK Alpic Starter
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-

|
|
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.
|
|
3
|
+
A minimal TypeScript template for building OpenAI Apps SDK compatible MCP servers with widget rendering in ChatGPT.
|
|
10
4
|
|
|
11
5
|
## Getting Started
|
|
12
6
|
|
|
13
7
|
### Prerequisites
|
|
14
8
|
|
|
15
|
-
- Node.js 22+
|
|
9
|
+
- Node.js 22+
|
|
16
10
|
- pnpm (install with `npm install -g pnpm`)
|
|
17
|
-
-
|
|
11
|
+
- HTTP tunnel such as [ngrok](https://ngrok.com/download)
|
|
18
12
|
|
|
19
|
-
### Local Development
|
|
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.
|
|
13
|
+
### Local Development
|
|
22
14
|
|
|
23
15
|
#### 1. Install
|
|
24
16
|
|
|
@@ -26,7 +18,7 @@ This project uses Vite for React widget development with full HMR support, allow
|
|
|
26
18
|
pnpm install
|
|
27
19
|
```
|
|
28
20
|
|
|
29
|
-
#### 2. Start
|
|
21
|
+
#### 2. Start your local server
|
|
30
22
|
|
|
31
23
|
Run the development server from the root directory:
|
|
32
24
|
|
|
@@ -36,79 +28,37 @@ pnpm dev
|
|
|
36
28
|
|
|
37
29
|
This command starts an Express server on port 3000. This server packages:
|
|
38
30
|
|
|
39
|
-
- an MCP endpoint on `/mcp`
|
|
40
|
-
- a React application on Vite HMR dev server
|
|
41
|
-
|
|
42
|
-
#### 3. Expose Your Local Server
|
|
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)
|
|
43
33
|
|
|
44
|
-
|
|
34
|
+
#### 3. Connect to ChatGPT
|
|
45
35
|
|
|
36
|
+
- ChatGPT requires connectors to be publicly accessible. To expose your server on the Internet, run:
|
|
46
37
|
```bash
|
|
47
38
|
ngrok http 3000
|
|
48
39
|
```
|
|
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`)
|
|
49
41
|
|
|
50
|
-
|
|
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
|
|
42
|
+
### Create your first widget
|
|
64
43
|
|
|
65
|
-
|
|
66
|
-
- Select your newly created connector using **the + button → Your connector**
|
|
67
|
-
- Try prompting the model (e.g., "Show me pikachu details")
|
|
44
|
+
#### 1. Add a new widget
|
|
68
45
|
|
|
69
|
-
|
|
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
|
|
70
48
|
|
|
71
|
-
|
|
49
|
+
#### 2. Edit widgets with Hot Module Replacement (HMR)
|
|
72
50
|
|
|
73
|
-
|
|
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
|
|
51
|
+
Edit and save components in `web/src/widgets/` — changes appear instantly in ChatGPT
|
|
77
52
|
|
|
78
|
-
|
|
53
|
+
#### 3. Edit server code
|
|
79
54
|
|
|
80
|
-
|
|
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.
|
|
55
|
+
Modify files in `server/` and reload your ChatGPT connector in **Settings → Connectors → [Your connector] → Reload**
|
|
90
56
|
|
|
91
57
|
## Deploy to Production
|
|
92
58
|
|
|
93
|
-
Use Alpic to deploy your OpenAI App to production
|
|
94
|
-
|
|
95
|
-
[](https://app.alpic.ai/new/clone?repositoryUrl=https%3A%2F%2Fgithub.com%2Falpic-ai%2Fapps-sdk-template)
|
|
96
|
-
|
|
59
|
+
- Use [Alpic](https://alpic.ai/) to deploy your OpenAI App to production
|
|
97
60
|
- In ChatGPT, navigate to **Settings → Connectors → Create** and add your MCP server URL (e.g., `https://your-app-name.alpic.live`)
|
|
98
61
|
|
|
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
|
-
|
|
112
62
|
## Resources
|
|
113
63
|
|
|
114
64
|
- [Apps SDK Documentation](https://developers.openai.com/apps-sdk)
|
package/template/_gitignore
CHANGED
|
@@ -1,194 +1,4 @@
|
|
|
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
|
-
# =============================================================================
|
|
15
1
|
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/
|
|
102
2
|
dist/
|
|
103
|
-
|
|
104
|
-
|
|
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
|
|
3
|
+
.env*
|
|
4
|
+
.DS_store
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"@t3-oss/env-core": "^0.13.8",
|
|
20
20
|
"dotenv": "^17.2.3",
|
|
21
21
|
"express": "^5.1.0",
|
|
22
|
-
"lodash": "^4.17.21",
|
|
23
22
|
"skybridge": "catalog:",
|
|
24
23
|
"vite": "^7.1.11",
|
|
25
24
|
"zod": "^4.1.13"
|
|
@@ -27,7 +26,6 @@
|
|
|
27
26
|
"devDependencies": {
|
|
28
27
|
"@modelcontextprotocol/inspector": "^0.17.5",
|
|
29
28
|
"@types/express": "^5.0.3",
|
|
30
|
-
"@types/lodash": "^4.17.20",
|
|
31
29
|
"@types/node": "^22.15.30",
|
|
32
30
|
"nodemon": "^3.1.10",
|
|
33
31
|
"tsx": "^4.19.2",
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import { McpServer } from "skybridge/server";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
const Answers = [
|
|
5
|
+
"As I see it, yes",
|
|
6
|
+
"Ask again later",
|
|
7
|
+
"Better not tell you now",
|
|
8
|
+
"Cannot predict now",
|
|
9
|
+
"Concentrate and ask again",
|
|
10
|
+
"Don't count on it",
|
|
11
|
+
"It is certain",
|
|
12
|
+
"It is decidedly so",
|
|
13
|
+
"Most likely",
|
|
14
|
+
"My reply is no",
|
|
15
|
+
"My sources say no",
|
|
16
|
+
"Outlook good",
|
|
17
|
+
"Outlook not so good",
|
|
18
|
+
"Reply hazy, try again",
|
|
19
|
+
"Signs point to yes",
|
|
20
|
+
"Very doubtful",
|
|
21
|
+
"Without a doubt",
|
|
22
|
+
"Yes definitely",
|
|
23
|
+
"Yes",
|
|
24
|
+
"You may rely on it",
|
|
25
|
+
];
|
|
4
26
|
|
|
5
27
|
const server = new McpServer(
|
|
6
28
|
{
|
|
@@ -8,69 +30,46 @@ const server = new McpServer(
|
|
|
8
30
|
version: "0.0.1",
|
|
9
31
|
},
|
|
10
32
|
{ capabilities: {} },
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
inputSchema: {
|
|
21
|
-
name: z.string().describe("Pokemon name, always in english"),
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
async ({ name }) => {
|
|
25
|
-
try {
|
|
26
|
-
const { id, description, ...pokemon } = await getPokemon(name);
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
/**
|
|
30
|
-
* Arbitrary JSON passed only to the component.
|
|
31
|
-
* Use it for data that should not influence the model’s reasoning, like the full set of locations that backs a dropdown.
|
|
32
|
-
* _meta is never shown to the model.
|
|
33
|
-
*/
|
|
34
|
-
_meta: { id },
|
|
35
|
-
/**
|
|
36
|
-
* Structured data that is used to hydrate your component.
|
|
37
|
-
* ChatGPT injects this object into your iframe as window.openai.toolOutput
|
|
38
|
-
*/
|
|
39
|
-
structuredContent: { name, description, ...pokemon },
|
|
40
|
-
/**
|
|
41
|
-
* Optional free-form text that the model receives verbatim
|
|
42
|
-
*/
|
|
43
|
-
content: [
|
|
44
|
-
{
|
|
45
|
-
type: "text",
|
|
46
|
-
text: description ?? `A pokemon named ${name}.`,
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
isError: false,
|
|
50
|
-
};
|
|
51
|
-
} catch (error) {
|
|
52
|
-
return {
|
|
53
|
-
content: [{ type: "text", text: `Error: ${error}` }],
|
|
54
|
-
isError: true,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
)
|
|
59
|
-
.registerTool(
|
|
60
|
-
"capture",
|
|
61
|
-
{
|
|
62
|
-
description: "Capture a pokemon",
|
|
63
|
-
inputSchema: {},
|
|
33
|
+
).registerWidget(
|
|
34
|
+
"magic-8-ball",
|
|
35
|
+
{
|
|
36
|
+
description: "Magic 8 Ball",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
description: "For fortune-telling or seeking advice.",
|
|
40
|
+
inputSchema: {
|
|
41
|
+
question: z.string().describe("The user question."),
|
|
64
42
|
},
|
|
65
|
-
|
|
43
|
+
},
|
|
44
|
+
async ({ question }) => {
|
|
45
|
+
try {
|
|
46
|
+
const answer = Answers[Math.floor(Math.random() * Answers.length)];
|
|
66
47
|
return {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Arbitrary JSON passed only to the component.
|
|
50
|
+
* Use it for data that should not influence the model’s reasoning, like the full set of locations that backs a dropdown.
|
|
51
|
+
* _meta is never shown to the model.
|
|
52
|
+
*/
|
|
53
|
+
_meta: {},
|
|
54
|
+
/**
|
|
55
|
+
* Structured data that is used to hydrate your component.
|
|
56
|
+
* ChatGPT injects this object into your iframe as window.openai.toolOutput
|
|
57
|
+
*/
|
|
58
|
+
structuredContent: { question, answer },
|
|
59
|
+
/**
|
|
60
|
+
* Optional free-form text that the model receives verbatim
|
|
61
|
+
*/
|
|
62
|
+
content: [],
|
|
70
63
|
isError: false,
|
|
71
64
|
};
|
|
72
|
-
}
|
|
73
|
-
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return {
|
|
67
|
+
content: [{ type: "text", text: `Error: ${error}` }],
|
|
68
|
+
isError: true,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
);
|
|
74
73
|
|
|
75
74
|
export default server;
|
|
76
75
|
export type AppType = typeof server;
|
|
@@ -10,22 +10,14 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"skybridge": "catalog:",
|
|
13
|
-
"class-variance-authority": "^0.7.1",
|
|
14
|
-
"clsx": "^2.1.1",
|
|
15
|
-
"glob": "^11.0.3",
|
|
16
|
-
"lucide-react": "^0.546.0",
|
|
17
13
|
"react": "^19.1.1",
|
|
18
|
-
"react-dom": "^19.1.1"
|
|
19
|
-
"tailwind-merge": "^3.3.1",
|
|
20
|
-
"tailwindcss": "^4.1.14"
|
|
14
|
+
"react-dom": "^19.1.1"
|
|
21
15
|
},
|
|
22
16
|
"devDependencies": {
|
|
23
|
-
"@tailwindcss/vite": "^4.1.14",
|
|
24
17
|
"@types/node": "^24.6.0",
|
|
25
18
|
"@types/react": "^19.1.16",
|
|
26
19
|
"@types/react-dom": "^19.1.9",
|
|
27
20
|
"@vitejs/plugin-react": "^5.0.4",
|
|
28
|
-
"tw-animate-css": "^1.4.0",
|
|
29
21
|
"typescript": "~5.9.3",
|
|
30
22
|
"vite": "^7.1.11"
|
|
31
23
|
}
|