Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Guides creation of ChatGPT Apps with interactive widgets using OpenAI Apps SDK and MCP servers. Use when building ChatGPT custom apps with visual UI components, embedded widgets, or rich interactive experiences. Covers widget architecture, MCP server setup with FastMCP, response metadata, and Developer Mode configuration. NOT when building standard MCP servers without widgets (use building-mcp-servers skill instead).
.claude/skills/aiskillstore-building-chatgpt-apps/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 73% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 95% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 99% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 125% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 81% | 0% |
Create ChatGPT Apps with interactive widgets that render rich UI inside ChatGPT conversations. Apps combine MCP servers (providing tools) with embedded HTML widgets that communicate via the window.openai API.
Widgets communicate with ChatGPT through these APIs:
Send a follow-up prompt to ChatGPT on behalf of the user:
javascript// Trigger a follow-up conversation if (window.openai?.sendFollowUpMessage) { await window.openai.sendFollowUpMessage({ prompt: 'Summarize this chapter for me' }); }
Use for: Action buttons that suggest next steps (summarize, explain, etc.)
Send structured data back from widget interactions:
javascript// Send data back to ChatGPT if (window.openai?.toolOutput) { window.openai.toolOutput({ action: 'chapter_selected', chapter: 1, title: 'Introduction' }); }
Use for: Selections, form submissions, user choices that feed into tool responses.
Call another MCP tool from within a widget:
javascript// Call a tool directly if (window.openai?.callTool) { await window.openai.callTool({ name: 'read-chapter', arguments: { chapter: 2 } }); }
Use for: Navigation between content, chaining tool calls.
Important Discovery: Widget buttons may render as static UI elements rather than interactive JavaScript buttons. ChatGPT renders widgets in a sandboxed iframe where some click handlers don't fire reliably.
sendFollowUpMessage - Reliably triggers follow-up promptstoolOutput callswindow.getSelection() for text selection featuresInstead of complex interactions, use simple buttons that suggest prompts:
html<div class="action-buttons"> <button class="btn btn-primary" id="summarizeBtn"> 📝 Summarize Chapter </button> <button class="btn btn-primary" id="explainBtn"> 💡 Explain Key Concepts </button> </div> <script> document.getElementById('summarizeBtn')?.addEventListener('click', async () => { if (window.openai?.sendFollowUpMessage) { await window.openai.sendFollowUpMessage({ prompt: 'Summarize this chapter for me' }); } }); document.getElementById('explainBtn')?.addEventListener('click', async () => { if (window.openai?.sendFollowUpMessage) { await window.openai.sendFollowUpMessage({ prompt: 'Explain the key concepts from this chapter' }); } }); </script>
┌─────────────────────────────────────────────────────────────────┐
│ ChatGPT UI │
│ ┌─────────────────────────────────────────────────────────────┐│
│ │ Widget (iframe) ││
│ │ HTML + CSS + JS ││
│ │ Calls: window.openai.toolOutput({action: "...", ...}) ││
│ └─────────────────────────────────────────────────────────────┘│
│ │ │
│ ▼ │
│ ChatGPT Backend │
│ │ │
│ ▼ │
│ MCP Server (FastMCP + HTTP) │
│ - Tools: open-book, read-chapter, etc. │
│ - Resources: widget HTML (text/html+skybridge) │
│ - Response includes: _meta["openai.com/widget"] │
└─────────────────────────────────────────────────────────────────┘window.openai.toolOutput_meta["openai.com/widget"]html<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My Widget</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; padding: 24px; color: white; } .container { max-width: 600px; margin: 0 auto; } .card { background: rgba(255,255,255,0.95); color: #333; padding: 24px; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); } .btn { background: #667eea; color: white; border: none; padding: 12px 24px; border-radius: 8px; cursor: pointer; font-size: 16px; } .btn:hover { background: #5a6fd6; } </style> </head> <body> <div class="container"> <div class="card"> <h1>Widget Title</h1> <p>Widget content here</p> <button class="btn" onclick="handleAction()">Click Me</button> </div> </div> <script> function handleAction() { // Communicate back to ChatGPT if (window.openai && window.openai.toolOutput) { window.openai.toolOutput({ action: "button_clicked", data: { timestamp: Date.now() } }); } } </script> </body> </html>
window.openai.toolOutput before callingwindow.openaimy_chatgpt_app/
├── main.py # FastMCP server with widgets
├── requirements.txt # Dependencies
└── .env # Environment variablesmcp[cli]>=1.9.2
uvicorn>=0.32.0
httpx>=0.28.0
python-dotenv>=1.0.0pythonimport mcp.types as types from mcp.server.fastmcp import FastMCP # Widget MIME type for ChatGPT MIME_TYPE = "text/html+skybridge" # Define your widget HTML MY_WIDGET = '''<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> body { font-family: sans-serif; padding: 20px; } .container { max-width: 500px; margin: 0 auto; } </style> </head> <body> <div class="container"> <h1>Hello from Widget!</h1> <p>This content renders inside ChatGPT.</p> </div> </body> </html>''' # Widget registry WIDGETS = { "main-widget": { "uri": "ui://widget/main.html", "html": MY_WIDGET, "title": "My Widget", }, } # Create FastMCP server mcp = FastMCP("My ChatGPT App") @mcp.resource( uri="ui://widget/{widget_name}.html", name="Widget Resource", mime_type=MIME_TYPE ) def widget_resource(widget_name: str) -> str: """Serve widget HTML.""" widget_key = f"{widget_name}" if widget_key in WIDGETS: return WIDGETS[widget_key]["html"] return WIDGETS["main-widget"]["html"] def _embedded_widget_resource(widget_id: str) -> types.EmbeddedResource: """Create embedded widget resource for tool response.""" widget = WIDGETS[widget_id] return types.EmbeddedResource( type="resource", resource=types.TextResourceContents( uri=widget["uri"], mimeType=MIME_TYPE, text=widget["html"], title=widget["title"], ), ) def listing_meta() -> dict: """Tool metadata for ChatGPT tool listing.""" return { "openai.com/widget": { "uri": WIDGETS["main-widget"]["uri"], "title": WIDGETS["main-widget"]["title"] } } def response_meta() -> dict: """Response metadata with embedded widget.""" return { "openai.com/widget": _embedded_widget_resource("main-widget") } @mcp.tool( annotations={ "title": "My Tool", "readOnlyHint": True, "openWorldHint": False, }, _meta=listing_meta(), ) def my_tool() -> types.CallToolResult: """Description of what this tool does.""" return types.CallToolResult( content=[ types.TextContent( type="text", text="Tool executed successfully!" ) ], structuredContent={ "status": "success", "message": "Data for the widget" }, _meta=response_meta(), ) if __name__ == "__main__": import uvicorn print("Starting MCP Server on http://localhost:8001") print("Connect via: https://your-tunnel.ngrok-free.app/mcp") uvicorn.run( "main:mcp.app", host="0.0.0.0", port=8001, reload=True )
_meta["openai.com/widget"]Tool responses MUST include widget metadata:
pythontypes.CallToolResult( content=[types.TextContent(type="text", text="...")], structuredContent={"key": "value"}, # Data for widget _meta={ "openai.com/widget": types.EmbeddedResource( type="resource", resource=types.TextResourceContents( uri="ui://widget/my-widget.html", mimeType="text/html+skybridge", text=WIDGET_HTML, title="My Widget", ), ) }, )
Data passed to the widget. The widget can access this via window.openai APIs.
bashcd my_chatgpt_app python main.py # Server runs on http://localhost:8001
bashngrok http 8001 # Get URL like: https://abc123.ngrok-free.app
https://abc123.ngrok-free.app/mcp@ to see available appsCause: Widget HTML not being delivered correctly.
Solution:
CallToolRequest processing_meta["openai.com/widget"] in responsetext/html+skybridgeCause: ChatGPT caches widgets aggressively.
Solution:
Cause: window.openai not available.
Solution: Always check before calling:
javascriptif (window.openai && window.openai.toolOutput) { window.openai.toolOutput({...}); }
Cause: MCP server not connected or tools not registered.
Solution:
curl https://your-url.ngrok-free.app/mcpListToolsRequestRun: python3 scripts/verify.py
Expected: ✓ building-chatgpt-apps skill ready
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 21,027 | 22,531 | +7% | 1 | 1 | 0% | 4,168 | 7,231 | +73% | 0 | 0 | — |
case-02 | fail→pass | 20,914 | 18,194 | -13% | 1 | 1 | 0% | 3,155 | 6,153 | +95% | 0 | 0 | — |
case-03 | fail→pass | 18,240 | 17,857 | -2% | 1 | 1 | 0% | 2,794 | 5,571 | +99% | 0 | 0 | — |
case-04 | pass→pass | 13,209 | 14,237 | +8% | 1 | 1 | 0% | 2,066 | 5,082 | +146% | 0 | 0 | — |
case-05 | fail→pass | 15,660 | 4,372 | -72% | 1 | 1 | 0% | 1,897 | 4,270 | +125% | 0 | 0 | — |
case-06 | fail→pass | 19,096 | 16,094 | -16% | 1 | 1 | 0% | 2,961 | 5,349 | +81% | 0 | 0 | — |
case-07 | fail→pass | 17,976 | 12,617 | -30% | 1 | 1 | 0% | 2,159 | 4,906 | +127% | 0 | 0 | — |
case-08 | fail→pass | 25,369 | 4,653 | -82% | 1 | 1 | 0% | 3,324 | 4,322 | +30% | 0 | 0 | — |
case-09 | fail→pass | 20,675 | 10,518 | -49% | 1 | 1 | 0% | 2,643 | 5,356 | +103% | 0 | 0 | — |
case-10 | fail→pass | 18,313 | 12,145 | -34% | 1 | 1 | 0% | 2,188 | 4,716 | +116% | 0 | 0 | — |
case-11 | fail→pass | 14,548 | 4,816 | -67% | 1 | 1 | 0% | 2,326 | 4,405 | +89% | 0 | 0 | — |
case-12 | fail→pass | 17,469 | 19,754 | +13% | 1 | 1 | 0% | 2,927 | 5,828 | +99% | 0 | 0 | — |
case-13 | pass→pass | 15,394 | 6,099 | -60% | 1 | 1 | 0% | 1,886 | 4,450 | +136% | 0 | 0 | — |
case-14 | pass→pass | 20,827 | 15,850 | -24% | 1 | 1 | 0% | 2,760 | 5,234 | +90% | 0 | 0 | — |
case-15 | fail→pass | 16,296 | 6,504 | -60% | 1 | 1 | 0% | 1,893 | 4,565 | +141% | 0 | 0 | — |
case-16 | fail→pass | 24,170 | 43,264 | +79% | 1 | 1 | 0% | 3,135 | 7,252 | +131% | 0 | 0 | — |
case-17 | fail→pass | 9,639 | 9,443 | -2% | 1 | 1 | 0% | 1,123 | 4,246 | +278% | 0 | 0 | — |
case-18 | fail→pass | 12,027 | 14,512 | +21% | 1 | 1 | 0% | 1,980 | 4,942 | +150% | 0 | 0 | — |
case-19 | fail→pass | 26,338 | 4,845 | -82% | 1 | 1 | 0% | 2,286 | 4,189 | +83% | 0 | 0 | — |
case-20 | pass→pass | 8,834 | 12,630 | +43% | 1 | 1 | 0% | 1,655 | 4,788 | +189% | 0 | 0 | — |
case-21 | pass→pass | 14,690 | 10,631 | -28% | 1 | 1 | 0% | 2,190 | 5,419 | +147% | 0 | 0 | — |
case-22 | pass→pass | 17,327 | 14,858 | -14% | 1 | 1 | 0% | 2,379 | 5,192 | +118% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +73 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.