Setup
Configure your project to build and serve the ChatGPT MCP widget example.
Reference Implementation
This block is adapted from the openai-apps-sdk-examples repository and demonstrates how to expose a widget inside ChatGPT using the Apps SDK.
Before you install the frontend or backend blocks, read the official ChatGPT Apps SDK documentation. It covers the platform concepts, hosting requirements, and deployment workflow this example builds on.
What You Get
This example ships a single MCP tool named add. The tool:
- Accepts two numbers as input through the MCP request.
- Returns the structured result
{ a, b, sum }. - Triggers the accompanying widget to render the inputs and their sum inside ChatGPT.
Once the frontend build script runs and the backend starts, ChatGPT will display a card that shows both operands and their computed sum when the add tool is invoked.
End-to-End Flow
Only personal paid ChatGPT Plans work. Business Accounts don't work yet
Github Issue
-
Install the frontend block. Add the chatgpt-app frontend to your project so you get
index.jsx, the widget hooks, andbuild-chatgpt-widgets.ts. -
Build the widget assets. Run the build script to emit hashed HTML, CSS, and JS bundles under your configured
assets/directory:pnpm tsx build-chatgpt-widgets.tsRe-run this command whenever you change the widget UI.
-
Install the backend block. Add the chatgpt-app-backend files so you can host
mcp-server.ts, register theaddtool, and serve the widget HTML. -
Expose the MCP server. Start
mcp-server.ts, then use ngrok (or a similar tunnel) to forward the port:pnpm tsx mcp-server.ts ngrok http 8000Copy the HTTPS ngrok URL and note the
/mcpSSE endpoint. -
Connect the app inside ChatGPT.
- In ChatGPT, open Settings → Apps & Connectors.
- Enable Developer Mode.
- Create a new app and set its URL to your ngrok endpoint, for example
https://your-ngrok-url/mcp.
-
Test the experience. Ask ChatGPT to use your new app. When the
addtool runs, it will prompt for two numbers and render the widget that displays both inputs and their sum.
