From 00023ba3e94e9124a2dc64134e80304cae3f194b Mon Sep 17 00:00:00 2001 From: ochafik Date: Sun, 23 Nov 2025 03:15:06 +0000 Subject: [PATCH] npm run prettier:fix --- README.md | 3 +- build.bun.ts | 34 +++++++++++++-------- examples/simple-server/server.ts | 51 +++++++++++++++++++------------- src/react/index.tsx | 2 +- 4 files changed, 53 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 1435ec1..7ef15e3 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,13 @@ This repo contains the SDK and [specification](./specification/draft/apps.mdx) f MCP Apps are proposed standard inspired by [MCP-UI](https://mcpui.dev/) and [OpenAI's Apps SDK](https://developers.openai.com/apps-sdk/) to allow MCP Servers to display interactive UI elements in conversational MCP clients / chatbots. This repo provides: + - [types.ts](./src/types.ts): Types of JSON-RPC messages used to communicate between Apps & their host - Note that MCP Apps also use some standard MCP messages (e.g. `tools/call` for the App to trigger actions on its originating Server - these calls are proxied through the Host), but these types are the additional messages defined by the extension - - [examples/simple-example](./examples/simple-example): Example Server + Apps - [server.ts](./examples/simple-server/server.ts): MCP server with two tools that declare UI resources of Apps to be show in the chat when called - [ui-react.tsx](./examples/simple-server/src/ui-react.tsx): React App returned by the `create-ui-react` tool shows how to use the `useApp` hook to register MCP callbacks - [ui-vanilla.tsx](./examples/simple-server/src/ui-vanilla.ts): vanilla App returned by the `create-ui-vanilla` - - [specification/draft/apps.mdx](./specification/draft/apps.mdx): The Draft Extension Specification. It's still... in flux! Feedback welcome! (also see discussions in [SEP-1865](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/1865)). - [message-transport](./src/message-transport.ts): `PostMessageTransport` class that uses `postMessage` to exchange JSON-RPC messages between windows / iframes diff --git a/build.bun.ts b/build.bun.ts index 66ef840..5e20e69 100644 --- a/build.bun.ts +++ b/build.bun.ts @@ -8,20 +8,28 @@ const isDevelopment = Bun.env.NODE_ENV === "development"; // Build all JavaScript/TypeScript files function buildJs(entrypoint: string, opts: Record = {}) { - return Bun.build({ - entrypoints: [entrypoint], - outdir: "dist", - target: "browser", - minify: !isDevelopment, - ...(isDevelopment ? { - sourcemap: "inline", - } : {}), - ...opts - }) + return Bun.build({ + entrypoints: [entrypoint], + outdir: "dist", + target: "browser", + minify: !isDevelopment, + ...(isDevelopment + ? { + sourcemap: "inline", + } + : {}), + ...opts, + }); } await Promise.all([ buildJs("src/app.ts", { outdir: "dist/src" }), - buildJs("src/app-bridge.ts", { outdir: "dist/src", external: ["@modelcontextprotocol/sdk"] }), - buildJs("src/react/index.tsx", { outdir: "dist/src/react", external: ["react", "react-dom"]}), -]) \ No newline at end of file + buildJs("src/app-bridge.ts", { + outdir: "dist/src", + external: ["@modelcontextprotocol/sdk"], + }), + buildJs("src/react/index.tsx", { + outdir: "dist/src/react", + external: ["react", "react-dom"], + }), +]); diff --git a/examples/simple-server/server.ts b/examples/simple-server/server.ts index e41dec4..ed9e5f2 100644 --- a/examples/simple-server/server.ts +++ b/examples/simple-server/server.ts @@ -61,13 +61,16 @@ const getServer = async () => { }; { - const rawResource = registerResource({ - name: "ui-raw-template", - uri: "ui://raw", - title: "Raw UI Template", - description: "A simple raw HTML UI", - mimeType: "text/html+mcp", - }, rawHtml); + const rawResource = registerResource( + { + name: "ui-raw-template", + uri: "ui://raw", + title: "Raw UI Template", + description: "A simple raw HTML UI", + mimeType: "text/html+mcp", + }, + rawHtml, + ); server.registerTool( "create-ui-raw", @@ -89,13 +92,16 @@ const getServer = async () => { } { - const vanillaResource = registerResource({ - name: "ui-vanilla-template", - uri: "ui://vanilla", - title: "Vanilla UI Template", - description: "A simple vanilla JS UI", - mimeType: "text/html+mcp", - }, vanillaHtml); + const vanillaResource = registerResource( + { + name: "ui-vanilla-template", + uri: "ui://vanilla", + title: "Vanilla UI Template", + description: "A simple vanilla JS UI", + mimeType: "text/html+mcp", + }, + vanillaHtml, + ); server.registerTool( "create-ui-vanilla", @@ -117,13 +123,16 @@ const getServer = async () => { } { - const reactResource = registerResource({ - name: "ui-react-template", - uri: "ui://react", - title: "React UI Template", - description: "A React-based UI", - mimeType: "text/html+mcp", - }, reactHtml); + const reactResource = registerResource( + { + name: "ui-react-template", + uri: "ui://react", + title: "React UI Template", + description: "A React-based UI", + mimeType: "text/html+mcp", + }, + reactHtml, + ); server.registerTool( "create-ui-react", diff --git a/src/react/index.tsx b/src/react/index.tsx index 05abb11..47a326f 100644 --- a/src/react/index.tsx +++ b/src/react/index.tsx @@ -1,2 +1,2 @@ export * from "./useApp"; -export * from "./useAutoResize"; \ No newline at end of file +export * from "./useAutoResize";