create-skybridge 0.0.0-dev.fd05cd0 → 0.0.0-dev.fddb998
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/LICENSE +21 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +97 -27
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +23 -0
- package/index.js +6 -1
- package/package.json +11 -9
- package/template/README.md +31 -70
- package/template/_gitignore +2 -192
- package/template/node_modules/.bin/mcp-inspector +21 -0
- package/template/node_modules/.bin/nodemon +21 -0
- package/template/node_modules/.bin/shx +21 -0
- package/template/node_modules/.bin/tsc +21 -0
- package/template/node_modules/.bin/tsserver +21 -0
- package/template/node_modules/.bin/tsx +21 -0
- package/template/node_modules/.bin/vite +21 -0
- package/template/nodemon.json +5 -0
- package/template/package.json +30 -11
- package/template/server/src/index.ts +10 -5
- package/template/server/src/server.ts +45 -60
- package/template/tsconfig.json +23 -0
- package/template/tsconfig.server.json +11 -0
- package/template/web/src/helpers.ts +1 -1
- package/template/web/src/index.css +24 -113
- package/template/web/src/widgets/magic-8-ball.tsx +24 -0
- package/template/web/vite.config.ts +2 -3
- 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/pnpm-lock.yaml +0 -317
- package/template/pnpm-workspace.yaml +0 -7
- package/template/server/nodemon.json +0 -5
- package/template/server/package.json +0 -36
- package/template/server/pnpm-lock.yaml +0 -3796
- package/template/server/src/env.ts +0 -12
- package/template/server/src/pokedex.ts +0 -148
- package/template/server/tsconfig.json +0 -17
- package/template/web/components.json +0 -22
- package/template/web/package.json +0 -32
- 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/template/web/tsconfig.app.json +0 -34
- package/template/web/tsconfig.json +0 -13
- package/template/web/tsconfig.node.json +0 -26
|
@@ -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/nodemon@3.1.11/node_modules/nodemon/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/nodemon@3.1.11/node_modules/nodemon/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/nodemon@3.1.11/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/nodemon@3.1.11/node_modules/nodemon/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/nodemon@3.1.11/node_modules/nodemon/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/nodemon@3.1.11/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/../nodemon/bin/nodemon.js" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../nodemon/bin/nodemon.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/shx@0.4.0/node_modules/shx/lib/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/shx@0.4.0/node_modules/shx/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/shx@0.4.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/shx@0.4.0/node_modules/shx/lib/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/shx@0.4.0/node_modules/shx/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/shx@0.4.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/../shx/lib/cli.js" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../shx/lib/cli.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@5.9.3/node_modules/typescript/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@5.9.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@5.9.3/node_modules/typescript/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@5.9.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@5.9.3/node_modules/typescript/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@5.9.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@5.9.3/node_modules/typescript/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@5.9.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.21.0/node_modules/tsx/dist/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/tsx@4.21.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.21.0/node_modules/tsx/dist/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/tsx@4.21.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@7.3.0_@types+node@22.19.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules/vite/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.0_@types+node@22.19.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules/vite/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.0_@types+node@22.19.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.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/vite@7.3.0_@types+node@22.19.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules/vite/bin/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.0_@types+node@22.19.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.0/node_modules/vite/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@7.3.0_@types+node@22.19.3_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_tsx@4.21.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/../vite/bin/vite.js" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../vite/bin/vite.js" "$@"
|
|
21
|
+
fi
|
package/template/package.json
CHANGED
|
@@ -4,18 +4,37 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Alpic MCP Server Template",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"packageManager": "pnpm@10.18.3",
|
|
8
7
|
"scripts": {
|
|
9
|
-
"dev": "
|
|
10
|
-
"build": "
|
|
11
|
-
"start": "
|
|
12
|
-
"inspector": "
|
|
13
|
-
"server:build": "
|
|
14
|
-
"server:start": "
|
|
15
|
-
"web:build": "
|
|
16
|
-
"web:preview": "
|
|
8
|
+
"dev": "nodemon",
|
|
9
|
+
"build": "vite build -c web/vite.config.ts && shx rm -rf server/dist && tsc -p tsconfig.server.json && shx cp -r web/dist server/dist/assets",
|
|
10
|
+
"start": "node server/dist/index.js",
|
|
11
|
+
"inspector": "mcp-inspector http://localhost:3000/mcp",
|
|
12
|
+
"server:build": "tsc -p tsconfig.server.json",
|
|
13
|
+
"server:start": "node server/dist/index.js",
|
|
14
|
+
"web:build": "tsc -b web && vite build -c web/vite.config.ts",
|
|
15
|
+
"web:preview": "vite preview -c web/vite.config.ts"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
19
|
+
"express": "^5.2.1",
|
|
20
|
+
"react": "^19.2.3",
|
|
21
|
+
"react-dom": "^19.2.3",
|
|
22
|
+
"skybridge": ">=0.16.2 <1.0.0",
|
|
23
|
+
"vite": "^7.3.0",
|
|
24
|
+
"zod": "^4.3.5"
|
|
17
25
|
},
|
|
18
26
|
"devDependencies": {
|
|
19
|
-
"
|
|
20
|
-
|
|
27
|
+
"@modelcontextprotocol/inspector": "^0.18.0",
|
|
28
|
+
"@skybridge/devtools": ">=0.16.2 <1.0.0",
|
|
29
|
+
"@types/express": "^5.0.6",
|
|
30
|
+
"@types/node": "^22.19.3",
|
|
31
|
+
"@types/react": "^19.2.7",
|
|
32
|
+
"@types/react-dom": "^19.2.3",
|
|
33
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
34
|
+
"nodemon": "^3.1.11",
|
|
35
|
+
"shx": "^0.4.0",
|
|
36
|
+
"tsx": "^4.21.0",
|
|
37
|
+
"typescript": "^5.9.3"
|
|
38
|
+
},
|
|
39
|
+
"workspaces": []
|
|
21
40
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import express, { type Express } from "express";
|
|
2
|
-
|
|
3
|
-
import { widgetsDevServer } from "skybridge/server";
|
|
2
|
+
import { devtoolsStaticServer, widgetsDevServer } from "skybridge/server";
|
|
4
3
|
import type { ViteDevServer } from "vite";
|
|
5
|
-
import { env } from "./env.js";
|
|
6
4
|
import { mcp } from "./middleware.js";
|
|
7
5
|
import server from "./server.js";
|
|
8
6
|
|
|
@@ -12,7 +10,10 @@ app.use(express.json());
|
|
|
12
10
|
|
|
13
11
|
app.use(mcp(server));
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
const env = process.env.NODE_ENV || "development";
|
|
14
|
+
|
|
15
|
+
if (env !== "production") {
|
|
16
|
+
app.use(await devtoolsStaticServer());
|
|
16
17
|
app.use(await widgetsDevServer());
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -22,10 +23,14 @@ app.listen(3000, (error) => {
|
|
|
22
23
|
process.exit(1);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
console.log(`Server listening on port 3000 - ${env
|
|
26
|
+
console.log(`Server listening on port 3000 - ${env}`);
|
|
26
27
|
console.log(
|
|
27
28
|
"Make your local server accessible with 'ngrok http 3000' and connect to ChatGPT with URL https://xxxxxx.ngrok-free.app/mcp",
|
|
28
29
|
);
|
|
30
|
+
|
|
31
|
+
if (env !== "production") {
|
|
32
|
+
console.log("Devtools available at http://localhost:3000");
|
|
33
|
+
}
|
|
29
34
|
});
|
|
30
35
|
|
|
31
36
|
process.on("SIGINT", async () => {
|
|
@@ -1,6 +1,23 @@
|
|
|
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
|
+
"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
|
+
];
|
|
4
21
|
|
|
5
22
|
const server = new McpServer(
|
|
6
23
|
{
|
|
@@ -8,69 +25,37 @@ const server = new McpServer(
|
|
|
8
25
|
version: "0.0.1",
|
|
9
26
|
},
|
|
10
27
|
{ 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: {},
|
|
28
|
+
).registerWidget(
|
|
29
|
+
"magic-8-ball",
|
|
30
|
+
{
|
|
31
|
+
description: "Magic 8 Ball",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
description: "For fortune-telling or seeking advice.",
|
|
35
|
+
inputSchema: {
|
|
36
|
+
question: z.string().describe("The user question."),
|
|
64
37
|
},
|
|
65
|
-
|
|
38
|
+
},
|
|
39
|
+
async ({ question }) => {
|
|
40
|
+
try {
|
|
41
|
+
// deterministic answer
|
|
42
|
+
const hash = question
|
|
43
|
+
.split("")
|
|
44
|
+
.reduce((acc, char) => acc + char.charCodeAt(0), 0);
|
|
45
|
+
const answer = Answers[hash % Answers.length];
|
|
66
46
|
return {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
],
|
|
47
|
+
structuredContent: { answer },
|
|
48
|
+
content: [],
|
|
70
49
|
isError: false,
|
|
71
50
|
};
|
|
72
|
-
}
|
|
73
|
-
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return {
|
|
53
|
+
content: [{ type: "text", text: `Error: ${error}` }],
|
|
54
|
+
isError: true,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
);
|
|
74
59
|
|
|
75
60
|
export default server;
|
|
76
61
|
export type AppType = typeof server;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
|
|
9
|
+
"strict": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"verbatimModuleSyntax": true,
|
|
14
|
+
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noUnusedParameters": true,
|
|
17
|
+
"noFallthroughCasesInSwitch": true,
|
|
18
|
+
|
|
19
|
+
"noEmit": true
|
|
20
|
+
},
|
|
21
|
+
"include": ["server/src", "web/src", "web/vite.config.ts"],
|
|
22
|
+
"exclude": ["dist", "node_modules"]
|
|
23
|
+
}
|
|
@@ -1,120 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@theme inline {
|
|
7
|
-
--radius-sm: calc(var(--radius) - 4px);
|
|
8
|
-
--radius-md: calc(var(--radius) - 2px);
|
|
9
|
-
--radius-lg: var(--radius);
|
|
10
|
-
--radius-xl: calc(var(--radius) + 4px);
|
|
11
|
-
--color-background: var(--background);
|
|
12
|
-
--color-foreground: var(--foreground);
|
|
13
|
-
--color-card: var(--card);
|
|
14
|
-
--color-card-foreground: var(--card-foreground);
|
|
15
|
-
--color-popover: var(--popover);
|
|
16
|
-
--color-popover-foreground: var(--popover-foreground);
|
|
17
|
-
--color-primary: var(--primary);
|
|
18
|
-
--color-primary-foreground: var(--primary-foreground);
|
|
19
|
-
--color-secondary: var(--secondary);
|
|
20
|
-
--color-secondary-foreground: var(--secondary-foreground);
|
|
21
|
-
--color-muted: var(--muted);
|
|
22
|
-
--color-muted-foreground: var(--muted-foreground);
|
|
23
|
-
--color-accent: var(--accent);
|
|
24
|
-
--color-accent-foreground: var(--accent-foreground);
|
|
25
|
-
--color-destructive: var(--destructive);
|
|
26
|
-
--color-border: var(--border);
|
|
27
|
-
--color-input: var(--input);
|
|
28
|
-
--color-ring: var(--ring);
|
|
29
|
-
--color-chart-1: var(--chart-1);
|
|
30
|
-
--color-chart-2: var(--chart-2);
|
|
31
|
-
--color-chart-3: var(--chart-3);
|
|
32
|
-
--color-chart-4: var(--chart-4);
|
|
33
|
-
--color-chart-5: var(--chart-5);
|
|
34
|
-
--color-sidebar: var(--sidebar);
|
|
35
|
-
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
36
|
-
--color-sidebar-primary: var(--sidebar-primary);
|
|
37
|
-
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
38
|
-
--color-sidebar-accent: var(--sidebar-accent);
|
|
39
|
-
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
40
|
-
--color-sidebar-border: var(--sidebar-border);
|
|
41
|
-
--color-sidebar-ring: var(--sidebar-ring);
|
|
1
|
+
.container {
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: center;
|
|
4
|
+
align-items: center;
|
|
5
|
+
height: 100%;
|
|
42
6
|
}
|
|
43
7
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
--secondary-foreground: oklch(0.205 0 0);
|
|
56
|
-
--muted: oklch(0.97 0 0);
|
|
57
|
-
--muted-foreground: oklch(0.556 0 0);
|
|
58
|
-
--accent: oklch(0.97 0 0);
|
|
59
|
-
--accent-foreground: oklch(0.205 0 0);
|
|
60
|
-
--destructive: oklch(0.577 0.245 27.325);
|
|
61
|
-
--border: oklch(0.922 0 0);
|
|
62
|
-
--input: oklch(0.922 0 0);
|
|
63
|
-
--ring: oklch(0.708 0 0);
|
|
64
|
-
--chart-1: oklch(0.646 0.222 41.116);
|
|
65
|
-
--chart-2: oklch(0.6 0.118 184.704);
|
|
66
|
-
--chart-3: oklch(0.398 0.07 227.392);
|
|
67
|
-
--chart-4: oklch(0.828 0.189 84.429);
|
|
68
|
-
--chart-5: oklch(0.769 0.188 70.08);
|
|
69
|
-
--sidebar: oklch(0.985 0 0);
|
|
70
|
-
--sidebar-foreground: oklch(0.145 0 0);
|
|
71
|
-
--sidebar-primary: oklch(0.205 0 0);
|
|
72
|
-
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
73
|
-
--sidebar-accent: oklch(0.97 0 0);
|
|
74
|
-
--sidebar-accent-foreground: oklch(0.205 0 0);
|
|
75
|
-
--sidebar-border: oklch(0.922 0 0);
|
|
76
|
-
--sidebar-ring: oklch(0.708 0 0);
|
|
8
|
+
.ball {
|
|
9
|
+
background-color: black;
|
|
10
|
+
border-radius: 50%;
|
|
11
|
+
width: 12rem;
|
|
12
|
+
height: 12rem;
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
font-family: monospace;
|
|
18
|
+
text-align: center;
|
|
77
19
|
}
|
|
78
20
|
|
|
79
|
-
.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
--card: oklch(0.205 0 0);
|
|
83
|
-
--card-foreground: oklch(0.985 0 0);
|
|
84
|
-
--popover: oklch(0.205 0 0);
|
|
85
|
-
--popover-foreground: oklch(0.985 0 0);
|
|
86
|
-
--primary: oklch(0.922 0 0);
|
|
87
|
-
--primary-foreground: oklch(0.205 0 0);
|
|
88
|
-
--secondary: oklch(0.269 0 0);
|
|
89
|
-
--secondary-foreground: oklch(0.985 0 0);
|
|
90
|
-
--muted: oklch(0.269 0 0);
|
|
91
|
-
--muted-foreground: oklch(0.708 0 0);
|
|
92
|
-
--accent: oklch(0.269 0 0);
|
|
93
|
-
--accent-foreground: oklch(0.985 0 0);
|
|
94
|
-
--destructive: oklch(0.704 0.191 22.216);
|
|
95
|
-
--border: oklch(1 0 0 / 10%);
|
|
96
|
-
--input: oklch(1 0 0 / 15%);
|
|
97
|
-
--ring: oklch(0.556 0 0);
|
|
98
|
-
--chart-1: oklch(0.488 0.243 264.376);
|
|
99
|
-
--chart-2: oklch(0.696 0.17 162.48);
|
|
100
|
-
--chart-3: oklch(0.769 0.188 70.08);
|
|
101
|
-
--chart-4: oklch(0.627 0.265 303.9);
|
|
102
|
-
--chart-5: oklch(0.645 0.246 16.439);
|
|
103
|
-
--sidebar: oklch(0.205 0 0);
|
|
104
|
-
--sidebar-foreground: oklch(0.985 0 0);
|
|
105
|
-
--sidebar-primary: oklch(0.488 0.243 264.376);
|
|
106
|
-
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
107
|
-
--sidebar-accent: oklch(0.269 0 0);
|
|
108
|
-
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
109
|
-
--sidebar-border: oklch(1 0 0 / 10%);
|
|
110
|
-
--sidebar-ring: oklch(0.556 0 0);
|
|
21
|
+
.question {
|
|
22
|
+
font-size: 0.75rem;
|
|
23
|
+
color: lightgrey;
|
|
111
24
|
}
|
|
112
25
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
@apply bg-background text-foreground;
|
|
119
|
-
}
|
|
26
|
+
.answer {
|
|
27
|
+
font-size: 1.125rem;
|
|
28
|
+
font-weight: bold;
|
|
29
|
+
margin-top: 0.5rem;
|
|
30
|
+
color: aqua;
|
|
120
31
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "@/index.css";
|
|
2
|
+
|
|
3
|
+
import { mountWidget } from "skybridge/web";
|
|
4
|
+
import { useToolInfo } from "../helpers";
|
|
5
|
+
|
|
6
|
+
function Magic8Ball() {
|
|
7
|
+
const { input, output } = useToolInfo<"magic-8-ball">();
|
|
8
|
+
if (!output) {
|
|
9
|
+
return <div>Shaking...</div>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<div className="container">
|
|
14
|
+
<div className="ball">
|
|
15
|
+
<div className="question">{input.question}</div>
|
|
16
|
+
<div className="answer">{output.answer}</div>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default Magic8Ball;
|
|
23
|
+
|
|
24
|
+
mountWidget(<Magic8Ball />);
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import tailwindcss from "@tailwindcss/vite";
|
|
3
2
|
import react from "@vitejs/plugin-react";
|
|
4
3
|
import { skybridge } from "skybridge/web";
|
|
5
4
|
import { defineConfig } from "vite";
|
|
6
5
|
|
|
7
6
|
// https://vite.dev/config/
|
|
8
7
|
export default defineConfig({
|
|
9
|
-
plugins: [skybridge(), react()
|
|
10
|
-
|
|
8
|
+
plugins: [skybridge(), react()],
|
|
9
|
+
root: __dirname,
|
|
11
10
|
resolve: {
|
|
12
11
|
alias: {
|
|
13
12
|
"@": path.resolve(__dirname, "./src"),
|
package/template/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
lts/jod
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
}
|
package/template/docs/demo.gif
DELETED
|
Binary file
|