Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/simple-host/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<meta http-equiv="refresh" content="0; url=/example-host-react.html">
6 changes: 3 additions & 3 deletions examples/simple-host/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"version": "1.0.0",
"type": "module",
"scripts": {
"start": "NODE_ENV=development npm run build && concurrently 'npm run start:server'",
"start:server": "bun serve.ts",
"build": "concurrently 'INPUT=example-host-vanilla.html vite build' 'INPUT=example-host-react.html vite build' 'INPUT=sandbox.html vite build'"
"start": "vite dev",
"start:server": "vite preview",
"build": "vite build"
},
"dependencies": {
"@modelcontextprotocol/ext-apps": "../..",
Expand Down
80 changes: 0 additions & 80 deletions examples/simple-host/serve.ts

This file was deleted.

6 changes: 5 additions & 1 deletion examples/simple-host/src/example-host-react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { Tool } from "@modelcontextprotocol/sdk/types.js";
import { AppRenderer, AppRendererProps } from "../src/AppRenderer";
import { AppBridge } from "../../../dist/src/app-bridge";

const SANDBOX_PROXY_URL = new URL("http://localhost:8081/sandbox.html");
// We use '[::1]' for the sandbox to ensure it's a different origin from 'localhost'.
const SANDBOX_PROXY_URL = new URL(
"/sandbox.html",
location.href.replace("localhost:", "[::1]:"),
);

/**
* Example React application demonstrating the AppRenderer component.
Expand Down
6 changes: 5 additions & 1 deletion examples/simple-host/src/example-host-vanilla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import {
McpUiSizeChangeNotificationSchema,
} from "@modelcontextprotocol/ext-apps";

const SANDBOX_PROXY_URL = new URL("http://localhost:8081/sandbox.html");
// We use '[::1]' for the sandbox to ensure it's a different origin from 'localhost'.
const SANDBOX_PROXY_URL = new URL(
"/sandbox.html",
location.href.replace("localhost:", "[::1]:"),
);

window.addEventListener("load", async () => {
const client = new Client({
Expand Down
38 changes: 19 additions & 19 deletions examples/simple-host/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { viteSingleFile } from "vite-plugin-singlefile";

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: INPUT,
export default defineConfig(({ mode }) => {
const isDevelopment = mode === "development";
return {
plugins: [react()],
build: {
sourcemap: isDevelopment ? "inline" : undefined,
cssMinify: !isDevelopment,
minify: !isDevelopment,
rollupOptions: {
input: [
"index.html",
"example-host-vanilla.html",
"example-host-react.html",
"sandbox.html",
],
},
outDir: `dist`,
emptyOutDir: false,
},
outDir: `dist`,
emptyOutDir: false,
},
};
});
Loading