add simple-host example

This commit is contained in:
Olivier Chafik 2025-11-24 16:01:10 +00:00
commit 1f3bc52142
No known key found for this signature in database
3 changed files with 1187 additions and 13 deletions

View file

@ -4,13 +4,13 @@
"private": true,
"type": "module",
"scripts": {
"build:uis": "rm -rf dist && concurrently 'UI=ui-raw.html vite build' 'UI=ui-vanilla.html vite build' 'UI=ui-react.html vite build'",
"build": "concurrently 'INPUT=ui-raw.html vite build' 'INPUT=ui-vanilla.html vite build' 'INPUT=ui-react.html vite build'",
"server": "bun server.ts",
"start": "npm run build:uis && npm run server"
"start": "npm run build && npm run server"
},
"dependencies": {
"@modelcontextprotocol/ext-apps": "../..",
"@modelcontextprotocol/sdk": "^1.22.0",
"@modelcontextprotocol/sdk": "../../../modelcontextprotocol-typescript-sdk",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"zod": "^3.25.0"

View file

@ -8,7 +8,7 @@
* <code>
* npx esbuild src/ui-raw.ts --bundle --outfile=dist/ui-raw.js --minify --sourcemap --platform=browser
* </code>
*
*
* We implement a barebones JSON-RPC message sender/receiver (see `app` object below),
* but without timeouts or runtime type validation of any kind
* (for that, use the Apps SDK / see ui-vanilla.ts or ui-react.ts).

View file

@ -1,16 +1,23 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { viteSingleFile } from "vite-plugin-singlefile";
import { resolve } from "path";
// Get the entry from environment variable, default to ui-react
const uiPath = process.env.UI;
const INPUT = process.env.INPUT;
if (!INPUT) {
throw new Error("INPUT environment variable is not set");
}
const isDevelopment = process.env.NODE_ENV === "development";
export default defineConfig({
plugins: [react(), viteSingleFile()],
build: {
sourcemap: isDevelopment ? "inline" : undefined,
cssMinify: !isDevelopment,
minify: !isDevelopment,
rollupOptions: {
input: uiPath,
input: INPUT,
},
outDir: `dist`,
emptyOutDir: false,