Install
$ agentstack add mcp-amxv-chatgpt-app-template ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
ChatGPT Apps SDK Template
Next.js starter template for building an OpenAI Apps SDK app with a Model Context Protocol (MCP) server, ChatGPT widget rendering, and a working end-to-end example.
This repo is meant to be cloned as a starting point for custom ChatGPT apps. It includes the plumbing needed to expose MCP tools to ChatGPT, render a UI inside the ChatGPT iframe, and handle the browser quirks that come with cross-origin widget rendering.
Included Example: Doctor Finder
The starter ships with a small doctor finder demo so the template is easy to understand in a real workflow instead of just abstract SDK code.
The example includes:
- a
find_doctorMCP tool registered inapp/mcp/route.ts - mock doctor data with specialty and symptom matching
- a widget UI that renders doctor cards inside ChatGPT
- structured tool output passed from ChatGPT into the Next.js widget
Use it as a reference for how to build your own vertical-specific app, then swap the sample domain model and UI for your own tools.
Overview
This project shows how to integrate a Next.js application with the ChatGPT Apps SDK using MCP. It includes a working MCP server that exposes tools and resources ChatGPT can call, with responses rendered natively in ChatGPT as an interactive widget.
Key Components
1. MCP Server Route (app/mcp/route.ts)
The MCP server registers tools and widget resources for ChatGPT.
Key pieces:
- tool registration with OpenAI-specific metadata
- resource registration for iframe rendering
- cross-linking between tools and widgets via
templateUri - structured tool output that the widget can read directly
OpenAI-specific metadata:
{
"openai/outputTemplate": widget.templateUri,
"openai/toolInvocation/invoking": "Loading...",
"openai/toolInvocation/invoked": "Loaded",
"openai/widgetAccessible": false,
"openai/resultCanProduceWidget": true
}
Reference: OpenAI Apps SDK MCP documentation
2. Widget UI (app/page.tsx)
The root page is the widget rendered inside ChatGPT. In the sample app it:
- reads structured tool output through the Apps SDK hooks
- renders doctor search results as cards
- supports fullscreen mode
- shows a helpful fallback banner when opened outside ChatGPT
3. Asset Configuration (next.config.ts)
Set assetPrefix so /_next/ static assets load from the correct origin:
const nextConfig: NextConfig = {
assetPrefix: baseURL,
};
Without this, Next.js will try to load assets from the iframe URL and you will get 404s.
4. CORS Middleware (middleware.ts)
The middleware handles browser preflight requests needed for cross-origin React Server Component fetching during client-side navigation:
export function middleware(request: NextRequest) {
if (request.method === "OPTIONS") {
// Return 204 with CORS headers
}
// Add CORS headers to all responses
}
5. SDK Bootstrap (app/layout.tsx)
`` patches browser behavior so the widget works correctly inside the ChatGPT iframe.
It handles:
history.pushStateandhistory.replaceStatewindow.fetchorigin rewriting- `` attribute mutations introduced by the ChatGPT host
Required setup:
{children}
suppressHydrationWarning is currently needed because ChatGPT modifies the initial HTML before hydration.
Getting Started
Installation
bun install
Development
bun run dev
Open http://localhost:3000 to inspect the widget locally.
MCP Endpoint
The MCP server is exposed at:
http://localhost:3000/mcp
Connecting From ChatGPT
- Deploy the app somewhere publicly reachable, such as Vercel.
- In ChatGPT, go to
Settings -> Connectors -> Create. - Add your MCP server URL with the
/mcppath, for examplehttps://your-app.vercel.app/mcp.
Connecting MCP servers to ChatGPT requires developer mode access. See the OpenAI connection guide.
Project Structure
app/
├── components/ # Widget UI components
├── data/ # Sample doctor data
├── hooks/ # Apps SDK widget hooks
├── layout.tsx # Root layout with SDK bootstrap
├── mcp/
│ └── route.ts # MCP server with tool/resource registration
├── page.tsx # ChatGPT widget UI
└── custom-page/ # Example extra route
middleware.ts # CORS handling for RSC
next.config.ts # Asset prefix configuration
How The Doctor Finder Example Works
- ChatGPT invokes the
find_doctortool exposed byapp/mcp/route.ts. - The tool searches mock doctor data by symptom or specialty.
- The tool response includes structured content plus the widget
templateUri. - ChatGPT renders the widget in an iframe.
- The Next.js widget reads the tool result and displays doctor cards.
This is the core pattern to reuse when adapting the template for other workflows such as commerce tools, scheduling, operations dashboards, or internal assistants.
Deployment
This template is designed to work well on Vercel. baseUrl.ts automatically detects Vercel environment variables so the widget can resolve static assets and runtime fetches correctly across production and preview deployments.
The configuration handles:
- production URLs via
VERCEL_PROJECT_PRODUCTION_URL - preview URLs via
VERCEL_BRANCH_URL - asset prefixing for iframe-safe resource loading
Learn More
- OpenAI Apps SDK documentation
- OpenAI Apps SDK MCP server guide
- Model Context Protocol
- Next.js documentation
License
Apache License 2.0
Source & license
This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: amxv
- Source: amxv/chatgpt-app-template
- License: Apache-2.0
- Homepage: https://gg-chatgpt-app.vercel.app
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.