This repository contains ready-to-use UI template to run an own ChatGPT app. It contains the following useful data:
- React template of the ChatGPT app
- Utils to interact with window.openai
- Examples of all required MCP requests and responses.
You have to run own MCP server, which supports the following methods:
- initialize – description of your server, with capabilities. Set
{ "scope": "project", "modes": ["chat"] } - notifications/initialized – just response with http code = 200
- tools/list – declare your tools, with detailed "inputSchema" and "outputSchema". Set
{"_meta": {"openai/widgetAccessible": true}}for all tools, and{"_meta": {"openai/outputTemplate": "ui://widget/my_app.html"}}for the main tool. - tools/call – process a tool call. All data for UI should be sent in
{"structuredContent": {...}} - resources/list – declare your app. Set
{ "uri": "ui://widget/my_app.html", "mimeType": "text/html+skybridge" } - resources/templates/list – the same as in resource/list
- resources/read - response with a simple HTML which loads .css and .js file from your resource. Declare all your domains with static data (js, images, etc) in
{"_meta": {"openai/widgetCSP": {"resource_domains": [...]}}}
Examples on requests and responses are in mcp_request/
src/– Template source, with utils to manage window.openaimcp_request/– Examples of requests and responses for MCP serverbuild-all.mts– Vite build orchestrator that produces hashed bundles for every widget entrypoint.
- Node.js 18+
- pnpm (recommended) or npm/yarn
Clone the repository and install the workspace dependencies:
pnpm installbuild_all.mts– set correct "base" value in createConfig(). Assign it to your server with .js & .css filessrc/index.jsx– set your app name ingetElementById("<your-app-name>")
Add any business-logic in src/app.jsx and any additional files.
The components are bundled into standalone assets appbuild/main.js and appbuild/main.css.
pnpm run buildCopy main.js and main.css to your server with public https:// access.
- Enable developer mode
- Add your app in Settings > Connectors: specify name of your app and endpoint to your MCP server
- Create a new Project, and add the app via "+" button.
- Create your own components and add them to the gallery: drop new entries into
src/and they will be picked up automatically by the build script. - Expand business-logic on MCP server
useOpenAiGlobal (<key name>)- read any key from window.openai.globals. Supported keys:
theme: dark | light
userAgent: { "device': "mobile" | "tablet" | "desktop" }
locale: <5-letters>
maxHeight: number
displayMode: "pip" | "inline" | "fullscreen"
safeArea: SafeArea
toolInput: {}
toolOutput: {}
toolResponseMetadata: {}
widgetState: {}
setOpenAiGlobal (<key name>, <value>)- update any key in window.openai.globals.callTool (<tool name>, <json params>)- run an MCP tool, and store response in globals.toolOutputsendMessage(<message>)- send a message to chatGPT chatbotsetDisplayMode("pip" | "inline" | "fullscreen")openExternalURL(<url>)- open an external URL in a new tab
This project is licensed under the MIT License. See LICENSE for details.