building-chatgpt-apps
OpenAI Apps SDKとMCPサーバーを活用し、ChatGPTのカスタムアプリにインタラクティブなウィジェットや視覚的なUIを組み込み、リッチな体験を開発するSkill。
📜 元の英語説明(参考)
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).
🇯🇵 日本人クリエイター向け解説
OpenAI Apps SDKとMCPサーバーを活用し、ChatGPTのカスタムアプリにインタラクティブなウィジェットや視覚的なUIを組み込み、リッチな体験を開発するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o building-chatgpt-apps.zip https://jpskill.com/download/17286.zip && unzip -o building-chatgpt-apps.zip && rm building-chatgpt-apps.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17286.zip -OutFile "$d\building-chatgpt-apps.zip"; Expand-Archive "$d\building-chatgpt-apps.zip" -DestinationPath $d -Force; ri "$d\building-chatgpt-apps.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
building-chatgpt-apps.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
building-chatgpt-appsフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 6
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
ChatGPT Apps SDK 開発ガイド
概要
ChatGPT の会話内でリッチな UI をレンダリングするインタラクティブなウィジェットを使用して ChatGPT Apps を作成します。Apps は、ツールを提供する MCP サーバーと、window.openai API を介して通信する埋め込み HTML ウィジェットを組み合わせたものです。
window.openai API リファレンス
ウィジェットは、以下の API を通じて ChatGPT と通信します。
sendFollowUpMessage (アクションに推奨)
ユーザーの代わりに、ChatGPT にフォローアッププロンプトを送信します。
// フォローアップの会話をトリガーする
if (window.openai?.sendFollowUpMessage) {
await window.openai.sendFollowUpMessage({
prompt: 'この章を要約してください'
});
}
用途: 次のステップ(要約、説明など)を提案するアクションボタン。
toolOutput
ウィジェットのインタラクションから構造化されたデータを返送します。
// ChatGPT にデータを返送する
if (window.openai?.toolOutput) {
window.openai.toolOutput({
action: 'chapter_selected',
chapter: 1,
title: 'Introduction'
});
}
用途: 選択、フォームの送信、ツールの応答に反映されるユーザーの選択。
callTool
ウィジェット内から別の MCP ツールを呼び出します。
// ツールを直接呼び出す
if (window.openai?.callTool) {
await window.openai.callTool({
name: 'read-chapter',
arguments: { chapter: 2 }
});
}
用途: コンテンツ間のナビゲーション、ツール呼び出しの連鎖。
重要: ボタンのインタラクティビティの制限
重要な発見: ウィジェットのボタンは、インタラクティブな JavaScript ボタンではなく、静的な UI 要素としてレンダリングされる場合があります。ChatGPT は、一部のクリックハンドラーが確実に起動しないサンドボックス化された iframe でウィジェットをレンダリングします。
動作するもの
sendFollowUpMessage- 確実にフォローアッププロンプトをトリガーします。toolOutput呼び出しのための単純なonclickハンドラー- CSS ホバーエフェクトと視覚的なフィードバック
動作しない可能性があるもの
- 複雑なインタラクティブ JavaScript (selection APIs など)
- ボタンからの複数の連鎖的なツール呼び出し
- テキスト選択機能のための
window.getSelection()
推奨されるパターン: サジェスチョンボタン
複雑なインタラクションの代わりに、プロンプトを提案する単純なボタンを使用します。
<div class="action-buttons">
<button class="btn btn-primary" id="summarizeBtn">
📝 章を要約する
</button>
<button class="btn btn-primary" id="explainBtn">
💡 主要な概念を説明する
</button>
</div>
<script>
document.getElementById('summarizeBtn')?.addEventListener('click', async () => {
if (window.openai?.sendFollowUpMessage) {
await window.openai.sendFollowUpMessage({
prompt: 'この章を要約してください'
});
}
});
document.getElementById('explainBtn')?.addEventListener('click', async () => {
if (window.openai?.sendFollowUpMessage) {
await window.openai.sendFollowUpMessage({
prompt: 'この章の主要な概念を説明してください'
});
}
});
</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"] │
└─────────────────────────────────────────────────────────────────┘
クイックスタート
- FastMCP とウィジェットリソースを使用して MCP サーバーを作成します。
window.openai.toolOutputを使用する ウィジェット HTML を定義します。_meta["openai.com/widget"]で 応答メタデータを追加します。- ChatGPT がアクセスできるように ngrok 経由で公開します。
- ChatGPT の開発者モード設定で 登録します。
ウィジェット 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() {
// ChatGPT に通信する
if (window.openai && window.openai.toolOutput) {
window.openai.toolOutput({
action: "button_clicked",
data: { timestamp: Date.now() }
})
(原文がここで切り詰められています) 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
ChatGPT Apps SDK Development Guide
Overview
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.
window.openai API Reference
Widgets communicate with ChatGPT through these APIs:
sendFollowUpMessage (Recommended for Actions)
Send a follow-up prompt to ChatGPT on behalf of the user:
// 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.)
toolOutput
Send structured data back from widget interactions:
// 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.
callTool
Call another MCP tool from within a widget:
// 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.
Critical: Button Interactivity Limitations
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.
What Works
sendFollowUpMessage- Reliably triggers follow-up prompts- Simple onclick handlers for
toolOutputcalls - CSS hover effects and visual feedback
What May Not Work
- Complex interactive JavaScript (selection APIs, etc.)
- Multiple chained tool calls from buttons
window.getSelection()for text selection features
Recommended Pattern: Suggestion Buttons
Instead of complex interactions, use simple buttons that suggest prompts:
<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>
Architecture Summary
┌─────────────────────────────────────────────────────────────────┐
│ 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"] │
└─────────────────────────────────────────────────────────────────┘
Quick Start
- Create MCP server with FastMCP and widget resources
- Define widget HTML that uses
window.openai.toolOutput - Add response metadata with
_meta["openai.com/widget"] - Expose via ngrok for ChatGPT access
- Register in ChatGPT Developer Mode settings
Widget HTML Requirements
Basic Widget Template
<!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>
Key Widget Rules
- Always check
window.openai.toolOutputbefore calling - Use inline styles - external CSS may not load reliably
- Keep widgets self-contained - all HTML/CSS/JS in one file
- Test with actual ChatGPT - browser preview won't have
window.openai
MCP Server Setup (FastMCP Python)
Project Structure
my_chatgpt_app/
├── main.py # FastMCP server with widgets
├── requirements.txt # Dependencies
└── .env # Environment variables
requirements.txt
mcp[cli]>=1.9.2
uvicorn>=0.32.0
httpx>=0.28.0
python-dotenv>=1.0.0
main.py Template
import 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
)
Response Metadata Format
Critical: _meta["openai.com/widget"]
Tool responses MUST include widget metadata:
types.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",
),
)
},
)
structuredContent
Data passed to the widget. The widget can access this via window.openai APIs.
Development Setup
1. Start Local Server
cd my_chatgpt_app
python main.py
# Server runs on http://localhost:8001
2. Start ngrok Tunnel
ngrok http 8001
# Get URL like: https://abc123.ngrok-free.app
3. Register in ChatGPT
- Go to https://chatgpt.com/apps
- Click Settings (gear icon)
- Enable Developer mode
- Click Create app
- Fill in:
- Name: Your App Name
- MCP Server URL:
https://abc123.ngrok-free.app/mcp - Authentication: No Auth (for development)
- Check "I understand and want to continue"
- Click Create
4. Test the App
- Start a new chat in ChatGPT
- Type
@to see available apps - Select your app
- Ask it to use your tool
Common Issues and Solutions
Widget Shows "Loading..." Forever
Cause: Widget HTML not being delivered correctly.
Solution:
- Check server logs for
CallToolRequestprocessing - Verify
_meta["openai.com/widget"]in response - Ensure MIME type is
text/html+skybridge
Cached Widget Not Updating
Cause: ChatGPT caches widgets aggressively.
Solution:
- Delete the app in Settings > Apps
- Kill server and ngrok
- Start fresh ngrok tunnel (new URL)
- Create new app with new URL
- Test in new conversation
Widget JavaScript Errors
Cause: window.openai not available.
Solution: Always check before calling:
if (window.openai && window.openai.toolOutput) {
window.openai.toolOutput({...});
}
Tool Not Showing in @mentions
Cause: MCP server not connected or tools not registered.
Solution:
- Check server is running and accessible via ngrok URL
- Verify ngrok tunnel is active:
curl https://your-url.ngrok-free.app/mcp - Check server logs for
ListToolsRequest
Verification
Run: python3 scripts/verify.py
Expected: ✓ building-chatgpt-apps skill ready
If Verification Fails
- Run diagnostic: Check references/ folder exists
- Check: All reference files present
- Stop and report if still failing
References
- Complete Template - Ready-to-use server + widget template
- Widget Patterns - HTML/CSS/JS widget examples
- Response Structure - Metadata format details
- Debugging Guide - Troubleshooting common issues
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (14,023 bytes)
- 📎 references/complete_template.md (10,654 bytes)
- 📎 references/debugging.md (9,464 bytes)
- 📎 references/response_structure.md (6,485 bytes)
- 📎 references/widget_patterns.md (11,463 bytes)
- 📎 scripts/verify.py (1,676 bytes)