Starter template for building ChatGPT Apps with ChatGPT App Studio.
Note: This template is automatically downloaded when you run
npx chatgpt-app-studio. You don't need to clone this repo directly.
npm install
npm run devOpen http://localhost:3002 — you're in the workbench.
| Command | Description |
|---|---|
npm run dev |
Start workbench (Next.js + MCP server) |
npm run build |
Production build |
npm run export |
Generate widget bundle for ChatGPT |
app/ Next.js pages
components/
├── examples/ Example widgets (POI Map)
├── workbench/ Workbench UI components
└── ui/ Shared UI components
lib/
├── workbench/ React hooks + dev environment
└── export/ Production bundler
server/ MCP server (if included)
// components/my-widget/index.tsx
import { useToolInput, useCallTool, useTheme } from "@/lib/workbench";
export function MyWidget() {
const input = useToolInput<{ query: string }>();
const callTool = useCallTool();
const theme = useTheme();
const handleSearch = async () => {
const result = await callTool("search", { query: input.query });
console.log(result.structuredContent);
};
return (
<div className={theme === "dark" ? "dark" : ""}>
<p>Query: {input.query}</p>
<button onClick={handleSearch}>Search</button>
</div>
);
}Add your component to lib/workbench/component-registry.tsx.
Configure mock tool responses in lib/workbench/mock-config/.
Full documentation: lib/workbench/README.md
Reading state:
useToolInput<T>()— Input from the tool calluseToolOutput<T>()— Response from most recent tool calluseTheme()—"light"or"dark"useDisplayMode()—"inline","pip", or"fullscreen"useWidgetState<T>()— Persistent widget state
Calling methods:
useCallTool()— Call MCP toolsuseRequestDisplayMode()— Request display mode changeuseSendFollowUpMessage()— Send message to ChatGPTuseOpenExternal()— Open URL in new tab
npm run exportGenerates:
export/
├── widget/
│ └── index.html Self-contained widget
├── manifest.json ChatGPT App manifest
└── README.md Deployment instructions
Deploy export/widget/ to any static host:
# Vercel
cd export/widget && vercel deploy
# Netlify
netlify deploy --dir=export/widget
# Or any static host (S3, Cloudflare Pages, etc.)If you have a server/ directory:
cd server
npm run build
# Deploy to Vercel, Railway, Fly.io, etc.- Update
manifest.jsonwith your deployed widget URL - Go to ChatGPT Apps dashboard
- Create a new app and connect your MCP server
- Test in a new ChatGPT conversation
The workbench includes an AI-powered SDK guide. To enable:
# .env.local
OPENAI_API_KEY="your-key"For production, restrict CORS to your widget domain:
# server/.env
CORS_ORIGIN=https://your-widget-domain.comExported widgets inherit the host's theme. Ensure your CSS responds to .dark:
.dark .my-element {
background: #1a1a1a;
}- ChatGPT Apps SDK — Official documentation
- Apps SDK Reference —
window.openaiAPI - MCP Specification — Model Context Protocol