[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EM0ZAWT6KBPJDDH4STJTMN":3,"skill-same:01M6EM0ZAWT6KBPJDDH4STJTMN":95},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":49,"ownerHtmlUrl":50,"ownerBlogUrl":6,"ownerDescription":51,"updatedAt":52,"install":53,"resources":66},"01M6EM0ZAWT6KBPJDDH4STJTMN","building-chatgpt-apps",null,"Guides creation of ChatGPT Apps with interactive widgets using OpenAI Apps SDK and MCP servers.\nUse when building ChatGPT custom apps with visual UI components, embedded widgets, or rich\ninteractive experiences. Covers widget architecture, MCP server setup with FastMCP, response\nmetadata, and Developer Mode configuration. NOT when building standard MCP servers without\nwidgets (use building-mcp-servers skill instead).","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fasmayaseen\u002Fbuilding-chatgpt-apps\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"building chatgpt apps","apps","chatgpt","chatgpt apps","developer","guides","ui components","creation","widgets","visual","use","interactive","MCP","server","ui","openai","fastmcp","architecture","components","mcp server","2026-11-10 10:12:30",false,"---\r\nname: building-chatgpt-apps\r\ndescription: |\r\n  Guides creation of ChatGPT Apps with interactive widgets using OpenAI Apps SDK and MCP servers.\r\n  Use when building ChatGPT custom apps with visual UI components, embedded widgets, or rich\r\n  interactive experiences. Covers widget architecture, MCP server setup with FastMCP, response\r\n  metadata, and Developer Mode configuration. NOT when building standard MCP servers without\r\n  widgets (use building-mcp-servers skill instead).\r\n---\r\n\r\n# ChatGPT Apps SDK Development Guide\r\n\r\n## Overview\r\n\r\nCreate 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.\r\n\r\n---\r\n\r\n## window.openai API Reference\r\n\r\nWidgets communicate with ChatGPT through these APIs:\r\n\r\n### sendFollowUpMessage (Recommended for Actions)\r\n\r\nSend a follow-up prompt to ChatGPT on behalf of the user:\r\n\r\n```javascript\r\n\u002F\u002F Trigger a follow-up conversation\r\nif (window.openai?.sendFollowUpMessage) {\r\n  await window.openai.sendFollowUpMessage({\r\n    prompt: 'Summarize this chapter for me'\r\n  });\r\n}\r\n```\r\n\r\n**Use for**: Action buttons that suggest next steps (summarize, explain, etc.)\r\n\r\n### toolOutput\r\n\r\nSend structured data back from widget interactions:\r\n\r\n```javascript\r\n\u002F\u002F Send data back to ChatGPT\r\nif (window.openai?.toolOutput) {\r\n  window.openai.toolOutput({\r\n    action: 'chapter_selected',\r\n    chapter: 1,\r\n    title: 'Introduction'\r\n  });\r\n}\r\n```\r\n\r\n**Use for**: Selections, form submissions, user choices that feed into tool responses.\r\n\r\n### callTool\r\n\r\nCall another MCP tool from within a widget:\r\n\r\n```javascript\r\n\u002F\u002F Call a tool directly\r\nif (window.openai?.callTool) {\r\n  await window.openai.callTool({\r\n    name: 'read-chapter',\r\n    arguments: { chapter: 2 }\r\n  });\r\n}\r\n```\r\n\r\n**Use for**: Navigation between content, chaining tool calls.\r\n\r\n---\r\n\r\n## Critical: Button Interactivity Limitations\r\n\r\n**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.\r\n\r\n### What Works\r\n- `sendFollowUpMessage` - Reliably triggers follow-up prompts\r\n- Simple onclick handlers for `toolOutput` calls\r\n- CSS hover effects and visual feedback\r\n\r\n### What May Not Work\r\n- Complex interactive JavaScript (selection APIs, etc.)\r\n- Multiple chained tool calls from buttons\r\n- `window.getSelection()` for text selection features\r\n\r\n### Recommended Pattern: Suggestion Buttons\r\n\r\nInstead of complex interactions, use simple buttons that suggest prompts:\r\n\r\n```html\r\n\u003Cdiv class=\"action-buttons\">\r\n  \u003Cbutton class=\"btn btn-primary\" id=\"summarizeBtn\">\r\n    ? Summarize Chapter\r\n  \u003C\u002Fbutton>\r\n  \u003Cbutton class=\"btn btn-primary\" id=\"explainBtn\">\r\n    ? Explain Key Concepts\r\n  \u003C\u002Fbutton>\r\n\u003C\u002Fdiv>\r\n\r\n\u003Cscript>\r\ndocument.getElementById('summarizeBtn')?.addEventListener('click', async () => {\r\n  if (window.openai?.sendFollowUpMessage) {\r\n    await window.openai.sendFollowUpMessage({\r\n      prompt: 'Summarize this chapter for me'\r\n    });\r\n  }\r\n});\r\n\r\ndocument.getElementById('explainBtn')?.addEventListener('click', async () => {\r\n  if (window.openai?.sendFollowUpMessage) {\r\n    await window.openai.sendFollowUpMessage({\r\n      prompt: 'Explain the key concepts from this chapter'\r\n    });\r\n  }\r\n});\r\n\u003C\u002Fscript>\r\n```\r\n\r\n---\r\n\r\n## Architecture Summary\r\n\r\n```\r\n┌─────────────────────────────────────────────────────────────────┐\r\n│                        ChatGPT UI                                │\r\n│  ┌─────────────────────────────────────────────────────────────┐│\r\n│  │                    Widget (iframe)                          ││\r\n│  │   HTML + CSS + JS                                          ││\r\n│  │   Calls: window.openai.toolOutput({action: \"...\", ...})    ││\r\n│  └─────────────────────────────────────────────────────────────┘│\r\n│                              │                                   │\r\n│                              ▼                                   │\r\n│                     ChatGPT Backend                              │\r\n│                              │                                   │\r\n│                              ▼                                   │\r\n│              MCP Server (FastMCP + HTTP)                         │\r\n│              - Tools: open-book, read-chapter, etc.              │\r\n│              - Resources: widget HTML (text\u002Fhtml+skybridge)      │\r\n│              - Response includes: _meta[\"openai.com\u002Fwidget\"]     │\r\n└─────────────────────────────────────────────────────────────────┘\r\n```\r\n\r\n---\r\n\r\n## Quick Start\r\n\r\n1. **Create MCP server** with FastMCP and widget resources\r\n2. **Define widget HTML** that uses `window.openai.toolOutput`\r\n3. **Add response metadata** with `_meta[\"openai.com\u002Fwidget\"]`\r\n4. **Expose via ngrok** for ChatGPT access\r\n5. **Register in ChatGPT** Developer Mode settings\r\n\r\n---\r\n\r\n## Widget HTML Requirements\r\n\r\n### Basic Widget Template\r\n\r\n```html\r\n\u003C!DOCTYPE html>\r\n\u003Chtml lang=\"en\">\r\n\u003Chead>\r\n  \u003Cmeta charset=\"UTF-8\">\r\n  \u003Cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\r\n  \u003Ctitle>My Widget\u003C\u002Ftitle>\r\n  \u003Cstyle>\r\n    * { margin: 0; padding: 0; box-sizing: border-box; }\r\n    body {\r\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;\r\n      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\r\n      min-height: 100vh;\r\n      padding: 24px;\r\n      color: white;\r\n    }\r\n    .container { max-width: 600px; margin: 0 auto; }\r\n    .card {\r\n      background: rgba(255,255,255,0.95);\r\n      color: #333;\r\n      padding: 24px;\r\n      border-radius: 16px;\r\n      box-shadow: 0 10px 40px rgba(0,0,0,0.2);\r\n    }\r\n    .btn {\r\n      background: #667eea;\r\n      color: white;\r\n      border: none;\r\n      padding: 12px 24px;\r\n      border-radius: 8px;\r\n      cursor: pointer;\r\n      font-size: 16px;\r\n    }\r\n    .btn:hover { background: #5a6fd6; }\r\n  \u003C\u002Fstyle>\r\n\u003C\u002Fhead>\r\n\u003Cbody>\r\n  \u003Cdiv class=\"container\">\r\n    \u003Cdiv class=\"card\">\r\n      \u003Ch1>Widget Title\u003C\u002Fh1>\r\n      \u003Cp>Widget content here\u003C\u002Fp>\r\n      \u003Cbutton class=\"btn\" onclick=\"handleAction()\">Click Me\u003C\u002Fbutton>\r\n    \u003C\u002Fdiv>\r\n  \u003C\u002Fdiv>\r\n  \u003Cscript>\r\n    function handleAction() {\r\n      \u002F\u002F Communicate back to ChatGPT\r\n      if (window.openai && window.openai.toolOutput) {\r\n        window.openai.toolOutput({\r\n          action: \"button_clicked\",\r\n          data: { timestamp: Date.now() }\r\n        });\r\n      }\r\n    }\r\n  \u003C\u002Fscript>\r\n\u003C\u002Fbody>\r\n\u003C\u002Fhtml>\r\n```\r\n\r\n### Key Widget Rules\r\n\r\n1. **Always check `window.openai.toolOutput`** before calling\r\n2. **Use inline styles** - external CSS may not load reliably\r\n3. **Keep widgets self-contained** - all HTML\u002FCSS\u002FJS in one file\r\n4. **Test with actual ChatGPT** - browser preview won't have `window.openai`\r\n\r\n---\r\n\r\n## MCP Server Setup (FastMCP Python)\r\n\r\n### Project Structure\r\n\r\n```\r\nmy_chatgpt_app\u002F\r\n├── main.py              # FastMCP server with widgets\r\n├── requirements.txt     # Dependencies\r\n└── .env                 # Environment variables\r\n```\r\n\r\n### requirements.txt\r\n\r\n```\r\nmcp[cli]>=1.9.2\r\nuvicorn>=0.32.0\r\nhttpx>=0.28.0\r\npython-dotenv>=1.0.0\r\n```\r\n\r\n### main.py Template\r\n\r\n```python\r\nimport mcp.types as types\r\nfrom mcp.server.fastmcp import FastMCP\r\n\r\n# Widget MIME type for ChatGPT\r\nMIME_TYPE = \"text\u002Fhtml+skybridge\"\r\n\r\n# Define your widget HTML\r\nMY_WIDGET = '''\u003C!DOCTYPE html>\r\n\u003Chtml lang=\"en\">\r\n\u003Chead>\r\n  \u003Cmeta charset=\"UTF-8\">\r\n  \u003Cstyle>\r\n    body { font-family: sans-serif; padding: 20px; }\r\n    .container { max-width: 500px; margin: 0 auto; }\r\n  \u003C\u002Fstyle>\r\n\u003C\u002Fhead>\r\n\u003Cbody>\r\n  \u003Cdiv class=\"container\">\r\n    \u003Ch1>Hello from Widget!\u003C\u002Fh1>\r\n    \u003Cp>This content renders inside ChatGPT.\u003C\u002Fp>\r\n  \u003C\u002Fdiv>\r\n\u003C\u002Fbody>\r\n\u003C\u002Fhtml>'''\r\n\r\n# Widget registry\r\nWIDGETS = {\r\n    \"main-widget\": {\r\n        \"uri\": \"ui:\u002F\u002Fwidget\u002Fmain.html\",\r\n        \"html\": MY_WIDGET,\r\n        \"title\": \"My Widget\",\r\n    },\r\n}\r\n\r\n# Create FastMCP server\r\nmcp = FastMCP(\"My ChatGPT App\")\r\n\r\n\r\n@mcp.resource(\r\n    uri=\"ui:\u002F\u002Fwidget\u002F{widget_name}.html\",\r\n    name=\"Widget Resource\",\r\n    mime_type=MIME_TYPE\r\n)\r\ndef widget_resource(widget_name: str) -> str:\r\n    \"\"\"Serve widget HTML.\"\"\"\r\n    widget_key = f\"{widget_name}\"\r\n    if widget_key in WIDGETS:\r\n        return WIDGETS[widget_key][\"html\"]\r\n    return WIDGETS[\"main-widget\"][\"html\"]\r\n\r\n\r\ndef _embedded_widget_resource(widget_id: str) -> types.EmbeddedResource:\r\n    \"\"\"Create embedded widget resource for tool response.\"\"\"\r\n    widget = WIDGETS[widget_id]\r\n    return types.EmbeddedResource(\r\n        type=\"resource\",\r\n        resource=types.TextResourceContents(\r\n            uri=widget[\"uri\"],\r\n            mimeType=MIME_TYPE,\r\n            text=widget[\"html\"],\r\n            title=widget[\"title\"],\r\n        ),\r\n    )\r\n\r\n\r\ndef listing_meta() -> dict:\r\n    \"\"\"Tool metadata for ChatGPT tool listing.\"\"\"\r\n    return {\r\n        \"openai.com\u002Fwidget\": {\r\n            \"uri\": WIDGETS[\"main-widget\"][\"uri\"],\r\n            \"title\": WIDGETS[\"main-widget\"][\"title\"]\r\n        }\r\n    }\r\n\r\n\r\ndef response_meta() -> dict:\r\n    \"\"\"Response metadata with embedded widget.\"\"\"\r\n    return {\r\n        \"openai.com\u002Fwidget\": _embedded_widget_resource(\"main-widget\")\r\n    }\r\n\r\n\r\n@mcp.tool(\r\n    annotations={\r\n        \"title\": \"My Tool\",\r\n        \"readOnlyHint\": True,\r\n        \"openWorldHint\": False,\r\n    },\r\n    _meta=listing_meta(),\r\n)\r\ndef my_tool() -> types.CallToolResult:\r\n    \"\"\"Description of what this tool does.\"\"\"\r\n    return types.CallToolResult(\r\n        content=[\r\n            types.TextContent(\r\n                type=\"text\",\r\n                text=\"Tool executed successfully!\"\r\n            )\r\n        ],\r\n        structuredContent={\r\n            \"status\": \"success\",\r\n            \"message\": \"Data for the widget\"\r\n        },\r\n        _meta=response_meta(),\r\n    )\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    import uvicorn\r\n    print(\"Starting MCP Server on http:\u002F\u002Flocalhost:8001\")\r\n    print(\"Connect via: https:\u002F\u002Fyour-tunnel.ngrok-free.app\u002Fmcp\")\r\n    uvicorn.run(\r\n        \"main:mcp.app\",\r\n        host=\"0.0.0.0\",\r\n        port=8001,\r\n        reload=True\r\n    )\r\n```\r\n\r\n---\r\n\r\n## Response Metadata Format\r\n\r\n### Critical: `_meta[\"openai.com\u002Fwidget\"]`\r\n\r\nTool responses MUST include widget metadata:\r\n\r\n```python\r\ntypes.CallToolResult(\r\n    content=[types.TextContent(type=\"text\", text=\"...\")],\r\n    structuredContent={\"key\": \"value\"},  # Data for widget\r\n    _meta={\r\n        \"openai.com\u002Fwidget\": types.EmbeddedResource(\r\n            type=\"resource\",\r\n            resource=types.TextResourceContents(\r\n                uri=\"ui:\u002F\u002Fwidget\u002Fmy-widget.html\",\r\n                mimeType=\"text\u002Fhtml+skybridge\",\r\n                text=WIDGET_HTML,\r\n                title=\"My Widget\",\r\n            ),\r\n        )\r\n    },\r\n)\r\n```\r\n\r\n### structuredContent\r\n\r\nData passed to the widget. The widget can access this via `window.openai` APIs.\r\n\r\n---\r\n\r\n## Development Setup\r\n\r\n### 1. Start Local Server\r\n\r\n```bash\r\ncd my_chatgpt_app\r\npython main.py\r\n# Server runs on http:\u002F\u002Flocalhost:8001\r\n```\r\n\r\n### 2. Start ngrok Tunnel\r\n\r\n```bash\r\nngrok http 8001\r\n# Get URL like: https:\u002F\u002Fabc123.ngrok-free.app\r\n```\r\n\r\n### 3. Register in ChatGPT\r\n\r\n1. Go to https:\u002F\u002Fchatgpt.com\u002Fapps\r\n2. Click Settings (gear icon)\r\n3. Enable **Developer mode**\r\n4. Click **Create app**\r\n5. Fill in:\r\n   - **Name**: Your App Name\r\n   - **MCP Server URL**: `https:\u002F\u002Fabc123.ngrok-free.app\u002Fmcp`\r\n   - **Authentication**: No Auth (for development)\r\n6. Check \"I understand and want to continue\"\r\n7. Click **Create**\r\n\r\n### 4. Test the App\r\n\r\n1. Start a new chat in ChatGPT\r\n2. Type `@` to see available apps\r\n3. Select your app\r\n4. Ask it to use your tool\r\n\r\n---\r\n\r\n## Common Issues and Solutions\r\n\r\n### Widget Shows \"Loading...\" Forever\r\n\r\n**Cause**: Widget HTML not being delivered correctly.\r\n\r\n**Solution**:\r\n1. Check server logs for `CallToolRequest` processing\r\n2. Verify `_meta[\"openai.com\u002Fwidget\"]` in response\r\n3. Ensure MIME type is `text\u002Fhtml+skybridge`\r\n\r\n### Cached Widget Not Updating\r\n\r\n**Cause**: ChatGPT caches widgets aggressively.\r\n\r\n**Solution**:\r\n1. Delete the app in Settings > Apps\r\n2. Kill server and ngrok\r\n3. Start fresh ngrok tunnel (new URL)\r\n4. Create new app with new URL\r\n5. Test in new conversation\r\n\r\n### Widget JavaScript Errors\r\n\r\n**Cause**: `window.openai` not available.\r\n\r\n**Solution**: Always check before calling:\r\n```javascript\r\nif (window.openai && window.openai.toolOutput) {\r\n  window.openai.toolOutput({...});\r\n}\r\n```\r\n\r\n### Tool Not Showing in @mentions\r\n\r\n**Cause**: MCP server not connected or tools not registered.\r\n\r\n**Solution**:\r\n1. Check server is running and accessible via ngrok URL\r\n2. Verify ngrok tunnel is active: `curl https:\u002F\u002Fyour-url.ngrok-free.app\u002Fmcp`\r\n3. Check server logs for `ListToolsRequest`\r\n\r\n---\r\n\r\n## Verification\r\n\r\nRun: `python3 scripts\u002Fverify.py`\r\n\r\nExpected: `✓ building-chatgpt-apps skill ready`\r\n\r\n## If Verification Fails\r\n\r\n1. Run diagnostic: Check references\u002F folder exists\r\n2. Check: All reference files present\r\n3. **Stop and report** if still failing\r\n\r\n---\r\n\r\n## References\r\n\r\n- [Complete Template](references\u002Fcomplete_template.md) - Ready-to-use server + widget template\r\n- [Widget Patterns](references\u002Fwidget_patterns.md) - HTML\u002FCSS\u002FJS widget examples\r\n- [Response Structure](references\u002Fresponse_structure.md) - Metadata format details\r\n- [Debugging Guide](references\u002Fdebugging.md) - Troubleshooting common issues","# ChatGPT Apps SDK Development Guide\r\n\r\n## Overview\r\n\r\nCreate 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.\r\n\r\n---\r\n\r\n## window.openai API Reference\r\n\r\nWidgets communicate with ChatGPT through these APIs:\r\n\r\n### sendFollowUpMessage (Recommended for Actions)\r\n\r\nSend a follow-up prompt to ChatGPT on behalf of the user:\r\n\r\n```javascript\r\n\u002F\u002F Trigger a follow-up conversation\r\nif (window.openai?.sendFollowUpMessage) {\r\n  await window.openai.sendFollowUpMessage({\r\n    prompt: 'Summarize this chapter for me'\r\n  });\r\n}\r\n```\r\n\r\n**Use for**: Action buttons that suggest next steps (summarize, explain, etc.)\r\n\r\n### toolOutput\r\n\r\nSend structured data back from widget interactions:\r\n\r\n```javascript\r\n\u002F\u002F Send data back to ChatGPT\r\nif (window.openai?.toolOutput) {\r\n  window.openai.toolOutput({\r\n    action: 'chapter_selected',\r\n    chapter: 1,\r\n    title: 'Introduction'\r\n  });\r\n}\r\n```\r\n\r\n**Use for**: Selections, form submissions, user choices that feed into tool responses.\r\n\r\n### callTool\r\n\r\nCall another MCP tool from within a widget:\r\n\r\n```javascript\r\n\u002F\u002F Call a tool directly\r\nif (window.openai?.callTool) {\r\n  await window.openai.callTool({\r\n    name: 'read-chapter',\r\n    arguments: { chapter: 2 }\r\n  });\r\n}\r\n```\r\n\r\n**Use for**: Navigation between content, chaining tool calls.\r\n\r\n---\r\n\r\n## Critical: Button Interactivity Limitations\r\n\r\n**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.\r\n\r\n### What Works\r\n- `sendFollowUpMessage` - Reliably triggers follow-up prompts\r\n- Simple onclick handlers for `toolOutput` calls\r\n- CSS hover effects and visual feedback\r\n\r\n### What May Not Work\r\n- Complex interactive JavaScript (selection APIs, etc.)\r\n- Multiple chained tool calls from buttons\r\n- `window.getSelection()` for text selection features\r\n\r\n### Recommended Pattern: Suggestion Buttons\r\n\r\nInstead of complex interactions, use simple buttons that suggest prompts:\r\n\r\n```html\r\n\u003Cdiv class=\"action-buttons\">\r\n  \u003Cbutton class=\"btn btn-primary\" id=\"summarizeBtn\">\r\n    ? Summarize Chapter\r\n  \u003C\u002Fbutton>\r\n  \u003Cbutton class=\"btn btn-primary\" id=\"explainBtn\">\r\n    ? Explain Key Concepts\r\n  \u003C\u002Fbutton>\r\n\u003C\u002Fdiv>\r\n\r\n\u003Cscript>\r\ndocument.getElementById('summarizeBtn')?.addEventListener('click', async () => {\r\n  if (window.openai?.sendFollowUpMessage) {\r\n    await window.openai.sendFollowUpMessage({\r\n      prompt: 'Summarize this chapter for me'\r\n    });\r\n  }\r\n});\r\n\r\ndocument.getElementById('explainBtn')?.addEventListener('click', async () => {\r\n  if (window.openai?.sendFollowUpMessage) {\r\n    await window.openai.sendFollowUpMessage({\r\n      prompt: 'Explain the key concepts from this chapter'\r\n    });\r\n  }\r\n});\r\n\u003C\u002Fscript>\r\n```\r\n\r\n---\r\n\r\n## Architecture Summary\r\n\r\n```\r\n┌─────────────────────────────────────────────────────────────────┐\r\n│                        ChatGPT UI                                │\r\n│  ┌─────────────────────────────────────────────────────────────┐│\r\n│  │                    Widget (iframe)                          ││\r\n│  │   HTML + CSS + JS                                          ││\r\n│  │   Calls: window.openai.toolOutput({action: \"...\", ...})    ││\r\n│  └─────────────────────────────────────────────────────────────┘│\r\n│                              │                                   │\r\n│                              ▼                                   │\r\n│                     ChatGPT Backend                              │\r\n│                              │                                   │\r\n│                              ▼                                   │\r\n│              MCP Server (FastMCP + HTTP)                         │\r\n│              - Tools: open-book, read-chapter, etc.              │\r\n│              - Resources: widget HTML (text\u002Fhtml+skybridge)      │\r\n│              - Response includes: _meta[\"openai.com\u002Fwidget\"]     │\r\n└─────────────────────────────────────────────────────────────────┘\r\n```\r\n\r\n---\r\n\r\n## Quick Start\r\n\r\n1. **Create MCP server** with FastMCP and widget resources\r\n2. **Define widget HTML** that uses `window.openai.toolOutput`\r\n3. **Add response metadata** with `_meta[\"openai.com\u002Fwidget\"]`\r\n4. **Expose via ngrok** for ChatGPT access\r\n5. **Register in ChatGPT** Developer Mode settings\r\n\r\n---\r\n\r\n## Widget HTML Requirements\r\n\r\n### Basic Widget Template\r\n\r\n```html\r\n\u003C!DOCTYPE html>\r\n\u003Chtml lang=\"en\">\r\n\u003Chead>\r\n  \u003Cmeta charset=\"UTF-8\">\r\n  \u003Cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\r\n  \u003Ctitle>My Widget\u003C\u002Ftitle>\r\n  \u003Cstyle>\r\n    * { margin: 0; padding: 0; box-sizing: border-box; }\r\n    body {\r\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;\r\n      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\r\n      min-height: 100vh;\r\n      padding: 24px;\r\n      color: white;\r\n    }\r\n    .container { max-width: 600px; margin: 0 auto; }\r\n    .card {\r\n      background: rgba(255,255,255,0.95);\r\n      color: #333;\r\n      padding: 24px;\r\n      border-radius: 16px;\r\n      box-shadow: 0 10px 40px rgba(0,0,0,0.2);\r\n    }\r\n    .btn {\r\n      background: #667eea;\r\n      color: white;\r\n      border: none;\r\n      padding: 12px 24px;\r\n      border-radius: 8px;\r\n      cursor: pointer;\r\n      font-size: 16px;\r\n    }\r\n    .btn:hover { background: #5a6fd6; }\r\n  \u003C\u002Fstyle>\r\n\u003C\u002Fhead>\r\n\u003Cbody>\r\n  \u003Cdiv class=\"container\">\r\n    \u003Cdiv class=\"card\">\r\n      \u003Ch1>Widget Title\u003C\u002Fh1>\r\n      \u003Cp>Widget content here\u003C\u002Fp>\r\n      \u003Cbutton class=\"btn\" onclick=\"handleAction()\">Click Me\u003C\u002Fbutton>\r\n    \u003C\u002Fdiv>\r\n  \u003C\u002Fdiv>\r\n  \u003Cscript>\r\n    function handleAction() {\r\n      \u002F\u002F Communicate back to ChatGPT\r\n      if (window.openai && window.openai.toolOutput) {\r\n        window.openai.toolOutput({\r\n          action: \"button_clicked\",\r\n          data: { timestamp: Date.now() }\r\n        });\r\n      }\r\n    }\r\n  \u003C\u002Fscript>\r\n\u003C\u002Fbody>\r\n\u003C\u002Fhtml>\r\n```\r\n\r\n### Key Widget Rules\r\n\r\n1. **Always check `window.openai.toolOutput`** before calling\r\n2. **Use inline styles** - external CSS may not load reliably\r\n3. **Keep widgets self-contained** - all HTML\u002FCSS\u002FJS in one file\r\n4. **Test with actual ChatGPT** - browser preview won't have `window.openai`\r\n\r\n---\r\n\r\n## MCP Server Setup (FastMCP Python)\r\n\r\n### Project Structure\r\n\r\n```\r\nmy_chatgpt_app\u002F\r\n├── main.py              # FastMCP server with widgets\r\n├── requirements.txt     # Dependencies\r\n└── .env                 # Environment variables\r\n```\r\n\r\n### requirements.txt\r\n\r\n```\r\nmcp[cli]>=1.9.2\r\nuvicorn>=0.32.0\r\nhttpx>=0.28.0\r\npython-dotenv>=1.0.0\r\n```\r\n\r\n### main.py Template\r\n\r\n```python\r\nimport mcp.types as types\r\nfrom mcp.server.fastmcp import FastMCP\r\n\r\n# Widget MIME type for ChatGPT\r\nMIME_TYPE = \"text\u002Fhtml+skybridge\"\r\n\r\n# Define your widget HTML\r\nMY_WIDGET = '''\u003C!DOCTYPE html>\r\n\u003Chtml lang=\"en\">\r\n\u003Chead>\r\n  \u003Cmeta charset=\"UTF-8\">\r\n  \u003Cstyle>\r\n    body { font-family: sans-serif; padding: 20px; }\r\n    .container { max-width: 500px; margin: 0 auto; }\r\n  \u003C\u002Fstyle>\r\n\u003C\u002Fhead>\r\n\u003Cbody>\r\n  \u003Cdiv class=\"container\">\r\n    \u003Ch1>Hello from Widget!\u003C\u002Fh1>\r\n    \u003Cp>This content renders inside ChatGPT.\u003C\u002Fp>\r\n  \u003C\u002Fdiv>\r\n\u003C\u002Fbody>\r\n\u003C\u002Fhtml>'''\r\n\r\n# Widget registry\r\nWIDGETS = {\r\n    \"main-widget\": {\r\n        \"uri\": \"ui:\u002F\u002Fwidget\u002Fmain.html\",\r\n        \"html\": MY_WIDGET,\r\n        \"title\": \"My Widget\",\r\n    },\r\n}\r\n\r\n# Create FastMCP server\r\nmcp = FastMCP(\"My ChatGPT App\")\r\n\r\n\r\n@mcp.resource(\r\n    uri=\"ui:\u002F\u002Fwidget\u002F{widget_name}.html\",\r\n    name=\"Widget Resource\",\r\n    mime_type=MIME_TYPE\r\n)\r\ndef widget_resource(widget_name: str) -> str:\r\n    \"\"\"Serve widget HTML.\"\"\"\r\n    widget_key = f\"{widget_name}\"\r\n    if widget_key in WIDGETS:\r\n        return WIDGETS[widget_key][\"html\"]\r\n    return WIDGETS[\"main-widget\"][\"html\"]\r\n\r\n\r\ndef _embedded_widget_resource(widget_id: str) -> types.EmbeddedResource:\r\n    \"\"\"Create embedded widget resource for tool response.\"\"\"\r\n    widget = WIDGETS[widget_id]\r\n    return types.EmbeddedResource(\r\n        type=\"resource\",\r\n        resource=types.TextResourceContents(\r\n            uri=widget[\"uri\"],\r\n            mimeType=MIME_TYPE,\r\n            text=widget[\"html\"],\r\n            title=widget[\"title\"],\r\n        ),\r\n    )\r\n\r\n\r\ndef listing_meta() -> dict:\r\n    \"\"\"Tool metadata for ChatGPT tool listing.\"\"\"\r\n    return {\r\n        \"openai.com\u002Fwidget\": {\r\n            \"uri\": WIDGETS[\"main-widget\"][\"uri\"],\r\n            \"title\": WIDGETS[\"main-widget\"][\"title\"]\r\n        }\r\n    }\r\n\r\n\r\ndef response_meta() -> dict:\r\n    \"\"\"Response metadata with embedded widget.\"\"\"\r\n    return {\r\n        \"openai.com\u002Fwidget\": _embedded_widget_resource(\"main-widget\")\r\n    }\r\n\r\n\r\n@mcp.tool(\r\n    annotations={\r\n        \"title\": \"My Tool\",\r\n        \"readOnlyHint\": True,\r\n        \"openWorldHint\": False,\r\n    },\r\n    _meta=listing_meta(),\r\n)\r\ndef my_tool() -> types.CallToolResult:\r\n    \"\"\"Description of what this tool does.\"\"\"\r\n    return types.CallToolResult(\r\n        content=[\r\n            types.TextContent(\r\n                type=\"text\",\r\n                text=\"Tool executed successfully!\"\r\n            )\r\n        ],\r\n        structuredContent={\r\n            \"status\": \"success\",\r\n            \"message\": \"Data for the widget\"\r\n        },\r\n        _meta=response_meta(),\r\n    )\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    import uvicorn\r\n    print(\"Starting MCP Server on http:\u002F\u002Flocalhost:8001\")\r\n    print(\"Connect via: https:\u002F\u002Fyour-tunnel.ngrok-free.app\u002Fmcp\")\r\n    uvicorn.run(\r\n        \"main:mcp.app\",\r\n        host=\"0.0.0.0\",\r\n        port=8001,\r\n        reload=True\r\n    )\r\n```\r\n\r\n---\r\n\r\n## Response Metadata Format\r\n\r\n### Critical: `_meta[\"openai.com\u002Fwidget\"]`\r\n\r\nTool responses MUST include widget metadata:\r\n\r\n```python\r\ntypes.CallToolResult(\r\n    content=[types.TextContent(type=\"text\", text=\"...\")],\r\n    structuredContent={\"key\": \"value\"},  # Data for widget\r\n    _meta={\r\n        \"openai.com\u002Fwidget\": types.EmbeddedResource(\r\n            type=\"resource\",\r\n            resource=types.TextResourceContents(\r\n                uri=\"ui:\u002F\u002Fwidget\u002Fmy-widget.html\",\r\n                mimeType=\"text\u002Fhtml+skybridge\",\r\n                text=WIDGET_HTML,\r\n                title=\"My Widget\",\r\n            ),\r\n        )\r\n    },\r\n)\r\n```\r\n\r\n### structuredContent\r\n\r\nData passed to the widget. The widget can access this via `window.openai` APIs.\r\n\r\n---\r\n\r\n## Development Setup\r\n\r\n### 1. Start Local Server\r\n\r\n```bash\r\ncd my_chatgpt_app\r\npython main.py\r\n# Server runs on http:\u002F\u002Flocalhost:8001\r\n```\r\n\r\n### 2. Start ngrok Tunnel\r\n\r\n```bash\r\nngrok http 8001\r\n# Get URL like: https:\u002F\u002Fabc123.ngrok-free.app\r\n```\r\n\r\n### 3. Register in ChatGPT\r\n\r\n1. Go to https:\u002F\u002Fchatgpt.com\u002Fapps\r\n2. Click Settings (gear icon)\r\n3. Enable **Developer mode**\r\n4. Click **Create app**\r\n5. Fill in:\r\n   - **Name**: Your App Name\r\n   - **MCP Server URL**: `https:\u002F\u002Fabc123.ngrok-free.app\u002Fmcp`\r\n   - **Authentication**: No Auth (for development)\r\n6. Check \"I understand and want to continue\"\r\n7. Click **Create**\r\n\r\n### 4. Test the App\r\n\r\n1. Start a new chat in ChatGPT\r\n2. Type `@` to see available apps\r\n3. Select your app\r\n4. Ask it to use your tool\r\n\r\n---\r\n\r\n## Common Issues and Solutions\r\n\r\n### Widget Shows \"Loading...\" Forever\r\n\r\n**Cause**: Widget HTML not being delivered correctly.\r\n\r\n**Solution**:\r\n1. Check server logs for `CallToolRequest` processing\r\n2. Verify `_meta[\"openai.com\u002Fwidget\"]` in response\r\n3. Ensure MIME type is `text\u002Fhtml+skybridge`\r\n\r\n### Cached Widget Not Updating\r\n\r\n**Cause**: ChatGPT caches widgets aggressively.\r\n\r\n**Solution**:\r\n1. Delete the app in Settings > Apps\r\n2. Kill server and ngrok\r\n3. Start fresh ngrok tunnel (new URL)\r\n4. Create new app with new URL\r\n5. Test in new conversation\r\n\r\n### Widget JavaScript Errors\r\n\r\n**Cause**: `window.openai` not available.\r\n\r\n**Solution**: Always check before calling:\r\n```javascript\r\nif (window.openai && window.openai.toolOutput) {\r\n  window.openai.toolOutput({...});\r\n}\r\n```\r\n\r\n### Tool Not Showing in @mentions\r\n\r\n**Cause**: MCP server not connected or tools not registered.\r\n\r\n**Solution**:\r\n1. Check server is running and accessible via ngrok URL\r\n2. Verify ngrok tunnel is active: `curl https:\u002F\u002Fyour-url.ngrok-free.app\u002Fmcp`\r\n3. Check server logs for `ListToolsRequest`\r\n\r\n---\r\n\r\n## Verification\r\n\r\nRun: `python3 scripts\u002Fverify.py`\r\n\r\nExpected: `✓ building-chatgpt-apps skill ready`\r\n\r\n## If Verification Fails\r\n\r\n1. Run diagnostic: Check references\u002F folder exists\r\n2. Check: All reference files present\r\n3. **Stop and report** if still failing\r\n\r\n---\r\n\r\n## References\r\n\r\n- [Complete Template](references\u002Fcomplete_template.md) - Ready-to-use server + widget template\r\n- [Widget Patterns](references\u002Fwidget_patterns.md) - HTML\u002FCSS\u002FJS widget examples\r\n- [Response Structure](references\u002Fresponse_structure.md) - Metadata format details\r\n- [Debugging Guide](references\u002Fdebugging.md) - Troubleshooting common issues",{"name":5,"description":7},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Faiskillstore\u002Fmarketplace\u002Fasmayaseen\u002Fbuilding-chatgpt-apps",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill building-chatgpt-apps",{"tool":59,"command":60},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill building-chatgpt-apps",{"tool":62,"command":63},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill building-chatgpt-apps","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fasmayaseen\u002Fbuilding-chatgpt-apps\u002FSKILL.md",true,[67,73,77,81,85,91],{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"references\u002Fcomplete_template.md","REFERENCE","参考文档",10654,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fasmayaseen\u002Fbuilding-chatgpt-apps\u002Freferences\u002Fcomplete_template.md",{"path":74,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":75,"sourceHtmlUrl":76},"references\u002Fdebugging.md",9464,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fasmayaseen\u002Fbuilding-chatgpt-apps\u002Freferences\u002Fdebugging.md",{"path":78,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":79,"sourceHtmlUrl":80},"references\u002Fresponse_structure.md",6485,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fasmayaseen\u002Fbuilding-chatgpt-apps\u002Freferences\u002Fresponse_structure.md",{"path":82,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":83,"sourceHtmlUrl":84},"references\u002Fwidget_patterns.md",11463,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fasmayaseen\u002Fbuilding-chatgpt-apps\u002Freferences\u002Fwidget_patterns.md",{"path":86,"resourceType":87,"resourceTypeDesc":88,"sizeBytes":89,"sourceHtmlUrl":90},"scripts\u002Fverify.py","SCRIPT","脚本",1676,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fasmayaseen\u002Fbuilding-chatgpt-apps\u002Fscripts\u002Fverify.py",{"path":92,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":93,"sourceHtmlUrl":94},"skill-report.json",9808,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Faiskillstore\u002Fmarketplace\u002Fasmayaseen\u002Fbuilding-chatgpt-apps\u002Fskill-report.json",[96,105,113,121,127,133],{"skillNo":97,"name":98,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":39},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[102,103,104],"model","model hierarchy","model hierarchy skill",{"skillNo":106,"name":107,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":39},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[31,111,112],"zoom","zoom mcp",{"skillNo":114,"name":115,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":39},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[119,120,20,111],"sdk","zoom apps sdk",{"skillNo":122,"name":123,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":39},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[123],{"skillNo":128,"name":129,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":130,"categories":131,"keywords":132,"publishedAt":39},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[129],{"skillNo":134,"name":135,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":136,"categories":137,"keywords":138,"publishedAt":39},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[135]]