AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
MCP verified Apache-2.0 Self-run

Chatgpt App Template

mcp-amxv-chatgpt-app-template · by amxv

Next.js starter template for ChatGPT Apps SDK apps with an MCP server, widget rendering, and a doctor finder example

No reviews yet
0 installs
28 views
0.0% view→install

Install

$ agentstack add mcp-amxv-chatgpt-app-template

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No 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.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/mcp-amxv-chatgpt-app-template)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
3mo ago

Declared compatibility

Claude CodeClaude DesktopCursorWindsurf

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

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 →
Are you the author of Chatgpt App Template? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

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_doctor MCP tool registered in app/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.pushState and history.replaceState
  • window.fetch origin 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

  1. Deploy the app somewhere publicly reachable, such as Vercel.
  2. In ChatGPT, go to Settings -> Connectors -> Create.
  3. Add your MCP server URL with the /mcp path, for example https://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

  1. ChatGPT invokes the find_doctor tool exposed by app/mcp/route.ts.
  2. The tool searches mock doctor data by symptom or specialty.
  3. The tool response includes structured content plus the widget templateUri.
  4. ChatGPT renders the widget in an iframe.
  5. 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

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.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.