create-skybridge 0.0.0-dev.10bf56b → 0.0.0-dev.1139380
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/package.json +1 -1
- package/template/README.md +17 -14
- package/template/_gitignore +1 -2
- package/template/node_modules/.bin/sb +2 -2
- package/template/node_modules/.bin/skybridge +2 -2
- package/template/package.json +2 -2
- package/template/server/src/index.ts +82 -0
- package/template/tsconfig.json +4 -2
- package/template/web/src/helpers.ts +4 -0
- package/template/web/src/widgets/magic-8-ball.tsx +27 -0
- package/template/{vite.config.ts → web/vite.config.ts} +4 -2
- package/template/src/components/ball.tsx +0 -22
- package/template/src/helpers.ts +0 -4
- package/template/src/server.ts +0 -61
- package/template/src/views/magic-8-ball.tsx +0 -10
- /package/template/{src → web/src}/index.css +0 -0
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -44,31 +44,34 @@ This command starts:
|
|
|
44
44
|
#### 3. Project structure
|
|
45
45
|
|
|
46
46
|
```
|
|
47
|
-
├──
|
|
48
|
-
│
|
|
49
|
-
│
|
|
50
|
-
|
|
51
|
-
│ ├──
|
|
52
|
-
│
|
|
53
|
-
├──
|
|
47
|
+
├── server/
|
|
48
|
+
│ └── src/
|
|
49
|
+
│ └── index.ts # Server entry point
|
|
50
|
+
├── web/
|
|
51
|
+
│ ├── src/
|
|
52
|
+
│ │ ├── widgets/ # React components (one per widget)
|
|
53
|
+
│ │ ├── helpers.ts # Shared utilities
|
|
54
|
+
│ │ └── index.css # Global styles
|
|
55
|
+
│ └── vite.config.ts
|
|
54
56
|
├── alpic.json # Deployment config
|
|
57
|
+
├── nodemon.json # Dev server config
|
|
55
58
|
└── package.json
|
|
56
59
|
```
|
|
57
60
|
|
|
58
|
-
### Create your first
|
|
61
|
+
### Create your first widget
|
|
59
62
|
|
|
60
|
-
#### 1. Add a new
|
|
63
|
+
#### 1. Add a new widget
|
|
61
64
|
|
|
62
|
-
- Register a
|
|
63
|
-
- Create a matching React component at `src/
|
|
65
|
+
- Register a widget in `server/src/server.ts` with a unique name (e.g., `my-widget`) using [`registerWidget`](https://docs.skybridge.tech/api-reference/register-widget)
|
|
66
|
+
- Create a matching React component at `web/src/widgets/my-widget.tsx`. **The file name must match the widget name exactly**.
|
|
64
67
|
|
|
65
|
-
#### 2. Edit
|
|
68
|
+
#### 2. Edit widgets with Hot Module Replacement (HMR)
|
|
66
69
|
|
|
67
|
-
Edit and save components in `src/
|
|
70
|
+
Edit and save components in `web/src/widgets/` — changes will appear instantly inside your App.
|
|
68
71
|
|
|
69
72
|
#### 3. Edit server code
|
|
70
73
|
|
|
71
|
-
Modify files in `
|
|
74
|
+
Modify files in `server/` and refresh the connection with your testing MCP Client to see the changes.
|
|
72
75
|
|
|
73
76
|
### Testing your App
|
|
74
77
|
|
package/template/_gitignore
CHANGED
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
|
|
13
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules/skybridge/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
15
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules/skybridge/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../skybridge/bin/run.js" "$@"
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
|
|
13
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules/skybridge/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
15
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules/skybridge/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../skybridge/bin/run.js" "$@"
|
package/template/package.json
CHANGED
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
16
16
|
"react": "^19.2.4",
|
|
17
17
|
"react-dom": "^19.2.4",
|
|
18
|
-
"skybridge": ">=0.0.0
|
|
18
|
+
"skybridge": ">=0.35.14 <1.0.0",
|
|
19
19
|
"vite": "^8.0.3",
|
|
20
20
|
"zod": "^4.3.6"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@skybridge/devtools": ">=0.35.14 <1.0.0",
|
|
24
|
-
"@types/node": "^24.12.0",
|
|
25
24
|
"@types/react": "^19.2.14",
|
|
25
|
+
"@types/node": "^24.12.0",
|
|
26
26
|
"@types/react-dom": "^19.2.3",
|
|
27
27
|
"@vitejs/plugin-react": "^6.0.1",
|
|
28
28
|
"alpic": "^1.104.1",
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { McpServer } from "skybridge/server";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
const Answers = [
|
|
5
|
+
"As I see it, yes",
|
|
6
|
+
"Don't count on it",
|
|
7
|
+
"It is certain",
|
|
8
|
+
"It is decidedly so",
|
|
9
|
+
"Most likely",
|
|
10
|
+
"My reply is no",
|
|
11
|
+
"My sources say no",
|
|
12
|
+
"Outlook good",
|
|
13
|
+
"Outlook not so good",
|
|
14
|
+
"Signs point to yes",
|
|
15
|
+
"Very doubtful",
|
|
16
|
+
"Without a doubt",
|
|
17
|
+
"Yes definitely",
|
|
18
|
+
"Yes",
|
|
19
|
+
"You may rely on it",
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const server = new McpServer(
|
|
23
|
+
{
|
|
24
|
+
name: "alpic-openai-app",
|
|
25
|
+
version: "0.0.1",
|
|
26
|
+
},
|
|
27
|
+
{ capabilities: {} },
|
|
28
|
+
)
|
|
29
|
+
.registerWidget(
|
|
30
|
+
"magic-8-ball",
|
|
31
|
+
{
|
|
32
|
+
description: "Magic 8 Ball",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
description: "For fortune-telling or seeking advice.",
|
|
36
|
+
inputSchema: {
|
|
37
|
+
question: z.string().describe("The user question."),
|
|
38
|
+
maxAnswers: z
|
|
39
|
+
.number()
|
|
40
|
+
.describe("The maximum number of answers to return.")
|
|
41
|
+
.optional(),
|
|
42
|
+
includeRandom: z
|
|
43
|
+
.boolean()
|
|
44
|
+
.describe("Whether to include a random answer.")
|
|
45
|
+
.optional(),
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
async ({ question }) => {
|
|
49
|
+
try {
|
|
50
|
+
// deterministic answer
|
|
51
|
+
const hash = question
|
|
52
|
+
.split("")
|
|
53
|
+
.reduce((acc, char) => acc + char.charCodeAt(0), 0);
|
|
54
|
+
const answer = Answers[hash % Answers.length];
|
|
55
|
+
return {
|
|
56
|
+
structuredContent: { answer },
|
|
57
|
+
content: [],
|
|
58
|
+
isError: false,
|
|
59
|
+
};
|
|
60
|
+
} catch (error) {
|
|
61
|
+
return {
|
|
62
|
+
content: [{ type: "text", text: `Error: ${error}` }],
|
|
63
|
+
isError: true,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
)
|
|
68
|
+
.registerTool(
|
|
69
|
+
"get-answers",
|
|
70
|
+
{
|
|
71
|
+
description: "Get answers",
|
|
72
|
+
},
|
|
73
|
+
async () => {
|
|
74
|
+
return {
|
|
75
|
+
content: [{ type: "text", text: "Answers" }],
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
server.run();
|
|
81
|
+
|
|
82
|
+
export type AppType = typeof server;
|
package/template/tsconfig.json
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
"extends": "skybridge/tsconfig",
|
|
3
3
|
|
|
4
4
|
"compilerOptions": {
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"types": ["node", "vite/client"],
|
|
5
7
|
"paths": {
|
|
6
|
-
"@/*": ["./src/*"]
|
|
8
|
+
"@/*": ["./web/src/*"]
|
|
7
9
|
}
|
|
8
10
|
},
|
|
9
11
|
|
|
10
|
-
"include": ["src", "
|
|
12
|
+
"include": ["server/src", "web/src"]
|
|
11
13
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "@/index.css";
|
|
2
|
+
|
|
3
|
+
import { mountWidget } from "skybridge/web";
|
|
4
|
+
import { useToolInfo } from "../helpers.js";
|
|
5
|
+
|
|
6
|
+
function Magic8Ball() {
|
|
7
|
+
const { input, output } = useToolInfo<"magic-8-ball">();
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<div className="container">
|
|
11
|
+
<div className="ball">
|
|
12
|
+
{output ? (
|
|
13
|
+
<>
|
|
14
|
+
<div className="question">{input.question}</div>
|
|
15
|
+
<div className="answer">{output.answer}</div>
|
|
16
|
+
</>
|
|
17
|
+
) : (
|
|
18
|
+
<div className="question">Shaking...</div>
|
|
19
|
+
)}
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default Magic8Ball;
|
|
26
|
+
|
|
27
|
+
mountWidget(<Magic8Ball />);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import react from "@vitejs/plugin-react";
|
|
3
3
|
import { skybridge } from "skybridge/web";
|
|
4
|
-
import { defineConfig } from "vite";
|
|
4
|
+
import { defineConfig, type PluginOption } from "vite";
|
|
5
5
|
|
|
6
|
+
// https://vite.dev/config/
|
|
6
7
|
export default defineConfig({
|
|
7
|
-
plugins: [skybridge(), react()],
|
|
8
|
+
plugins: [skybridge() as PluginOption, react()],
|
|
9
|
+
root: __dirname,
|
|
8
10
|
resolve: {
|
|
9
11
|
alias: {
|
|
10
12
|
"@": path.resolve(__dirname, "./src"),
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export function Ball({
|
|
2
|
-
question,
|
|
3
|
-
answer,
|
|
4
|
-
}: {
|
|
5
|
-
question?: string;
|
|
6
|
-
answer?: string;
|
|
7
|
-
}) {
|
|
8
|
-
return (
|
|
9
|
-
<div className="container">
|
|
10
|
-
<div className="ball">
|
|
11
|
-
{answer ? (
|
|
12
|
-
<>
|
|
13
|
-
<div className="question">{question}</div>
|
|
14
|
-
<div className="answer">{answer}</div>
|
|
15
|
-
</>
|
|
16
|
-
) : (
|
|
17
|
-
<div className="question">Shaking...</div>
|
|
18
|
-
)}
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
}
|
package/template/src/helpers.ts
DELETED
package/template/src/server.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { McpServer } from "skybridge/server";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
const Answers = [
|
|
5
|
-
"As I see it, yes",
|
|
6
|
-
"Don't count on it",
|
|
7
|
-
"It is certain",
|
|
8
|
-
"It is decidedly so",
|
|
9
|
-
"Most likely",
|
|
10
|
-
"My reply is no",
|
|
11
|
-
"My sources say no",
|
|
12
|
-
"Outlook good",
|
|
13
|
-
"Outlook not so good",
|
|
14
|
-
"Signs point to yes",
|
|
15
|
-
"Very doubtful",
|
|
16
|
-
"Without a doubt",
|
|
17
|
-
"Yes definitely",
|
|
18
|
-
"Yes",
|
|
19
|
-
"You may rely on it",
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
const server = new McpServer(
|
|
23
|
-
{
|
|
24
|
-
name: "alpic-openai-app",
|
|
25
|
-
version: "0.0.1",
|
|
26
|
-
},
|
|
27
|
-
{ capabilities: {} },
|
|
28
|
-
).registerTool(
|
|
29
|
-
{
|
|
30
|
-
name: "magic-8-ball",
|
|
31
|
-
description: "For fortune-telling or seeking advice.",
|
|
32
|
-
inputSchema: {
|
|
33
|
-
question: z.string().describe("The user question."),
|
|
34
|
-
},
|
|
35
|
-
view: {
|
|
36
|
-
component: "magic-8-ball",
|
|
37
|
-
description: "Magic 8 Ball",
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
async ({ question }) => {
|
|
41
|
-
try {
|
|
42
|
-
const hash = question
|
|
43
|
-
.split("")
|
|
44
|
-
.reduce((acc, char) => acc + char.charCodeAt(0), 0);
|
|
45
|
-
const answer = Answers[hash % Answers.length];
|
|
46
|
-
return {
|
|
47
|
-
structuredContent: { answer },
|
|
48
|
-
isError: false,
|
|
49
|
-
};
|
|
50
|
-
} catch (error) {
|
|
51
|
-
return {
|
|
52
|
-
content: [{ type: "text", text: `Error: ${error}` }],
|
|
53
|
-
isError: true,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
server.run();
|
|
60
|
-
|
|
61
|
-
export type AppType = typeof server;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import "@/index.css";
|
|
2
|
-
|
|
3
|
-
import { Ball } from "../components/ball.js";
|
|
4
|
-
import { useToolInfo } from "../helpers.js";
|
|
5
|
-
|
|
6
|
-
export default function Magic8Ball() {
|
|
7
|
-
const { input, output } = useToolInfo<"magic-8-ball">();
|
|
8
|
-
|
|
9
|
-
return <Ball question={input?.question} answer={output?.answer} />;
|
|
10
|
-
}
|
|
File without changes
|