Skip to main content
All posts

How to Build a ChatGPT App: A Complete Technical Plan (October 2026)

Abe Wheeler
ChatGPT AppsMCP AppsMCP App FrameworkChatGPT App FrameworkChatGPT App TestingMCP App TestingGetting Started
How it feels to develop ChatGPT Apps (good).

How it feels to develop ChatGPT Apps (good).

Here is the plan I would follow to build a production ChatGPT App from a blank repo. It starts with a useful MCP server, then adds UI where a person needs to inspect, compare, edit, or confirm data.

TL;DR: Define tools and their data contracts first. Add an MCP Apps resource only to a tool that needs UI, and use _meta.ui.resourceUri on that tool descriptor. Test the protocol, fixture states, and a real server call before live ChatGPT. Deploy the HTTPS MCP server, package the plugin, then submit the reviewed ZIP.

Decide Whether the Workflow Needs UI

OpenAI’s ChatGPT UI guide treats custom UI as optional. A search tool that returns a short list may need only content and structuredContent. A workflow where someone compares rows, edits a draft, or confirms a choice may benefit from a resource rendered in ChatGPT.

Keep data tools useful without the iframe. For example, find-docs can return IDs and summaries for the model. A separate show-docs-results tool can take chosen IDs and return a UI resource when the user needs to browse the list. Attach _meta.ui.resourceUri to the render tool, so a data call does not open or reload a view on every step.

The MCP Apps overview defines the shared UI contract. ChatGPT implements that bridge and offers optional window.openai extensions for host-specific features. Feature-detect those extensions, because another MCP Apps host may not provide them.

The Architecture

A ChatGPT App has four layers:

  1. The MCP server exposes tools, resources, auth, and server metadata.
  2. Tools define actions with names, descriptions, schemas, annotations, and optional UI links.
  3. Resources contain optional HTML UI bundles rendered in sandboxed iframes.
  4. The host bridge carries messages between ChatGPT and a resource iframe.

When the user asks for something, the flow looks like this:

  1. ChatGPT decides a tool is relevant.
  2. ChatGPT calls your MCP server with structured tool arguments.
  3. Your tool returns content, structuredContent, and optional _meta.
  4. If the tool descriptor links to a UI resource through _meta.ui.resourceUri, ChatGPT reads and loads it.
  5. The resource receives tool input, tool results, and host context through the bridge. Host context includes fields such as theme, viewport, and available display modes.
  6. User interactions can call app-visible server tools, send follow-up messages, or update model-visible app state.

That split matters because each layer can break independently. A React component can be correct while the resource URI is wrong. A tool can return good data but omit outputSchema. A fullscreen layout can work in the inspector and fail in picture-in-picture. The technical plan needs to test all of those boundaries.

Choose the Starting Point

For a new app, scaffold the project:

npx sunpeak new chatgpt-app
cd chatgpt-app
pnpm dev

This gives you a TypeScript project with a local MCP server, React resources, tool files, simulation fixtures, and an inspector at localhost:3000.

For an existing MCP server, keep the server where it is and inspect it:

npx sunpeak inspect --server http://localhost:8000/mcp

That path is useful when your server is already written in Python, Go, Rust, TypeScript, or another stack. You can test the MCP tool and UI contract without moving the backend into a new framework.

Define the Tool Contract First

Start with the server contract because the UI depends on it.

A strong tool descriptor has:

  • A literal tool name.
  • A description that says when the model should use the tool.
  • inputSchema for model-supplied arguments.
  • outputSchema when the tool returns structuredContent.
  • annotations such as readOnlyHint for model planning and review.
  • _meta.ui.resourceUri or a framework-level resource link when the tool should render UI.
  • Clear visibility for model-callable vs app-only tools.

In a sunpeak project, a tool file can stay compact while still compiling to the MCP Apps shape:

// src/tools/search-docs.ts
import { z } from 'zod';
import type { AppToolConfig, ToolHandlerExtra } from 'sunpeak/mcp';

export const tool: AppToolConfig = {
  resource: 'docs-search',
  title: 'Search Docs',
  description: 'Search product documentation and show matching pages.',
  annotations: { readOnlyHint: true },
};

export const schema = {
  query: z.string().describe('The documentation search query.'),
};

export const outputSchema = {
  query: z.string(),
  results: z.array(
    z.object({
      id: z.string(),
      title: z.string(),
      url: z.string().url(),
      snippet: z.string(),
    }),
  ),
};

type Args = z.infer<z.ZodObject<typeof schema>>;

export default async function (args: Args, _extra: ToolHandlerExtra) {
  const page = await searchDocs(args.query);

  return {
    content: [{ type: 'text' as const, text: `Found ${page.results.length} docs.` }],
    structuredContent: {
      query: args.query,
      results: page.results.map((result) => ({
        id: result.id,
        title: result.title,
        url: result.url,
        snippet: result.snippet,
      })),
    },
    _meta: {
      nextCursor: page.nextCursor,
    },
  };
}

The important part is the data split:

  • content is short text the model can read.
  • structuredContent is the model-visible JSON object your app renders.
  • _meta is for UI-only helper data when the host supports it.
  • outputSchema describes the shape of structuredContent.

Do not put private tokens, hidden IDs, large raw payloads, or UI-only cursors in structuredContent unless you are comfortable with the model seeing them. A data-only tool can omit the resource link and still return this contract. For more detail, read the guide to tool results, structuredContent, and _meta.

Build the Resource Around Data States

A resource is the UI ChatGPT renders. In sunpeak, it is a React component plus a resource config:

// src/resources/docs-search/docs-search.tsx
import { SafeArea, useDisplayMode, useToolData } from 'sunpeak';
import type { ResourceConfig } from 'sunpeak';

interface SearchOutput {
  query: string;
  results: Array<{
    id: string;
    title: string;
    url: string;
    snippet: string;
  }>;
}

export const resource: ResourceConfig = {
  title: 'Documentation Search',
  description: 'Show documentation search results.',
};

export default function DocsSearchResource() {
  const { output, isLoading, isError, isCancelled } = useToolData<unknown, SearchOutput>(
    undefined,
    undefined,
  );
  const displayMode = useDisplayMode();

  if (isLoading) return <SafeArea className="p-4">Searching docs...</SafeArea>;
  if (isCancelled) return <SafeArea className="p-4">Search cancelled.</SafeArea>;
  if (isError) return <SafeArea className="p-4">Search failed.</SafeArea>;
  if (!output) return null;

  return (
    <SafeArea className="p-4 font-sans">
      <header className="mb-4">
        <p className="text-sm text-gray-500">Search results for</p>
        <h1 className="text-xl font-semibold">{output.query}</h1>
      </header>

      <div className={displayMode === 'fullscreen' ? 'grid gap-3 md:grid-cols-2' : 'space-y-3'}>
        {output.results.map((result) => (
          <article key={result.id} className="rounded-lg border p-3">
            <h2 className="font-medium">{result.title}</h2>
            <p className="text-sm text-gray-600">{result.snippet}</p>
          </article>
        ))}
      </div>
    </SafeArea>
  );
}

Build the resource around states, not just the happy path:

  • Loading before the first tool result arrives.
  • Empty results.
  • Server errors.
  • User-cancelled or approval-gated flows.
  • Long lists, long labels, and missing optional fields.
  • Inline, fullscreen, and picture-in-picture display modes.
  • Light and dark themes.
  • Mobile and desktop widths.

These states are where ChatGPT App bugs usually hide. The app runs in a host-owned iframe, so layout and data timing matter more than in a normal browser tab.

Make Interactivity Explicit

Read-only resources are easy: the tool returns data and the resource renders it.

Interactive apps need one more design pass. Decide which interactions should be visible to the model, which should call server tools, and which should stay local to the UI.

Use these buckets:

InteractionBest pathExample
Local UI stateReact component stateSorting a table, selected tab, draft form fields
Model-visible stateuseAppState or ui/update-model-contextUser selected invoice INV-123
Server action from UIApp-visible MCP toolLoad next page, validate a field, save a draft
Conversation actionui/message or host-specific equivalentAsk ChatGPT to explain the selected result

Keep authoritative business data on the server. A selected tab can disappear with the iframe, while a saved draft or account preference needs durable storage. useAppState shares state with the model; it is not the right place for a private draft field. App-only tools are useful for UI actions such as “load more” that the model should not call directly. Give those tools _meta.ui.visibility: ['app'].

For a deeper look at this pattern, read MCP App actions: callServerTool, sendMessage, and update model context.

Test the Contract Before the UI

Before debugging React, prove the MCP boundary works.

Add contract tests that check:

  • tools/list includes the expected tool.
  • Tool names, descriptions, annotations, and schemas are present.
  • UI-backed tools point at a valid resource.
  • Resource reads return the expected HTML MIME type.
  • Resource metadata includes the CSP and permissions your UI needs.
  • Tool calls return valid content, structuredContent, and _meta.
  • structuredContent matches outputSchema.
  • Write tools are marked and confirmed correctly.

With sunpeak tests, a minimal contract test looks like this:

import { expect, test } from 'sunpeak/test';

test('search-docs exposes a UI resource and valid structured output', async ({ mcp }) => {
  const tools = await mcp.listTools();
  const tool = tools.find((item) => item.name === 'search-docs');

  expect(tool?.title).toBe('Search Docs');
  expect(tool?._meta?.ui?.resourceUri).toEqual(expect.stringMatching(/^ui:\/\//));

  const result = await mcp.callTool('search-docs', { query: 'oauth' });
  expect(result.isError).toBeFalsy();
  await expect(result).toHaveStructuredContent({
    query: 'oauth',
    results: expect.any(Array),
  });
});

This catches the failures that otherwise show up as a blank iframe.

Read the ui:// resource as a separate assertion and check that it returns text/html;profile=mcp-app. The URI must be on the tool descriptor returned by tools/list; putting it only on the tool result will not tell a host which view to load. For data-only tools, assert that no UI resource is attached.

Test the Rendered App Locally

After the server contract works, test the rendered resource in a host replica.

Create simulation files for every meaningful UI state:

{
  "tool": "search-docs",
  "userMessage": "Find docs about OAuth setup",
  "toolInput": {
    "query": "oauth setup"
  },
  "toolResult": {
    "content": [{ "type": "text", "text": "Found 2 docs." }],
    "structuredContent": {
      "query": "oauth setup",
      "results": [
        {
          "id": "auth-quickstart",
          "title": "OAuth quickstart",
          "url": "https://example.com/docs/oauth",
          "snippet": "Set up OAuth 2.1 with PKCE."
        },
        {
          "id": "connector-auth",
          "title": "Connector authentication",
          "url": "https://example.com/docs/connectors/auth",
          "snippet": "Configure remote MCP auth for hosted apps."
        }
      ]
    }
  }
}

Then write Playwright tests against the inspector:

import { expect, test } from 'sunpeak/test';

test('docs search renders in fullscreen dark mode', async ({ inspector }) => {
  const result = await inspector.renderTool('search-docs', undefined, {
    displayMode: 'fullscreen',
    theme: 'dark',
  });

  expect(result.source).toBe('fixture');
  const app = result.app();
  await expect(app.getByText('OAuth quickstart')).toBeVisible();
  await expect(app.getByText('Connector authentication')).toBeVisible();
});

This test exercises the fixture, which is useful for repeatable UI states. Add a second test with tool arguments to call the server and prove the real result reaches the iframe:

test('docs search renders the real server result', async ({ inspector }) => {
  const result = await inspector.renderTool('search-docs', { query: 'oauth setup' });
  expect(result.source).toBe('server');
  expect(result).not.toBeError();
  await expect(result.app().getByText('oauth setup')).toBeVisible();
});

Use seeded data or a predictable test server for that second case. If the resource calls more server tools, add serverTools mock responses to the simulation for fixture tests, then cover at least one real follow-up call in the server path. The sunpeak E2E guide documents both modes.

Run the suite locally and in CI:

pnpm test

For UI-heavy apps, add visual regression tests. For apps where tool selection matters, add evals that check whether models call the right tool with the right arguments. For release readiness, add live tests against ChatGPT or Claude on a slower path.

Plan the Local Development Loop

The loop should be:

  1. Edit resource or tool code.
  2. Run the local MCP server and inspector.
  3. Switch simulation states in the inspector.
  4. Run pnpm test.
  5. Run a small live host check only after local coverage passes.

Avoid using live ChatGPT as your main development loop. It is slower, harder to automate, and more expensive to repeat because every check depends on connector state, model behavior, host cache, network timing, and manual prompts.

sunpeak’s value here is practical: it replicates ChatGPT and Claude style runtimes locally, gives each state a URL, and reuses the same runtime in Playwright. That keeps most feedback in localhost and CI.

Connect to Live ChatGPT

When local tests pass, connect the app to ChatGPT.

For a development server, expose /mcp over public HTTPS or use Secure MCP Tunnel if your workspace supports it. A public endpoint can be forwarded from local development:

ngrok http 8000

In ChatGPT, enable Developer mode under Settings > Security and login, then add the MCP server from ChatGPT Plugins. Enter the HTTPS URL including /mcp, or use the configured tunnel connection. Developer mode availability depends on the account and workspace policy. OpenAI’s connection guide has the current steps.

For live validation, check:

  • The connector registers without metadata errors.
  • Tool descriptions make ChatGPT call the right tool.
  • The resource iframe loads on first use.
  • Display modes behave as expected.
  • Auth, consent, and approval flows match the action.
  • The app works in a fresh chat.
  • Mobile behavior matches the OpenAI testing checklist.
  • A metadata refresh pulls the newest resource bundle when you change server metadata.
  • A direct, indirect, follow-up, write, and unsupported prompt produces the intended tool choice and arguments.

Keep this live pass small. The local tests should already cover data states, visual states, and basic interactions.

Deploy

A production ChatGPT App needs two deployed pieces:

  • A public HTTPS MCP server.
  • Production resource bundles served by that server.

Run:

pnpm build

Then deploy to your Node host, serverless platform, container, or existing backend. The important requirements are not specific to one host:

  • Stable HTTPS endpoint.
  • Correct MCP transport.
  • Strict resource CSP and permissions.
  • Auth that works in a host-initiated flow.
  • Logs that separate tool calls, resource reads, and app-originated tool calls.
  • Versioned resource output or a clear metadata refresh path.

For more detail, read how to deploy an MCP App and MCP App observability for production debugging.

Package and Submit the Plugin

OpenAI distributes Apps inside Plugins. The MCP server still owns tools and UI resources; the plugin package gives the integration its listing, configuration, and review material. Follow OpenAI’s package guide for a root plugin.json and mcp.json that points to your deployed server. The package can include skills when the workflow needs them, but UI remains attached to MCP tools and resources.

In the OpenAI Platform Plugins portal, upload the plugin ZIP, resolve package findings, connect and scan the MCP server, and complete the domain challenge shown for your server. Before review, prepare:

  • Plugin name, short and long descriptions, logo, category, and publisher details.
  • Public HTTPS MCP server URL in the package configuration.
  • Website, support, privacy policy, and terms URLs.
  • Apps Management write access and a verified individual or business identity.
  • Domain verification through the generated /.well-known/openai-apps-challenge URL.
  • Exact CSP domains and accurate readOnlyHint, openWorldHint, and destructiveHint values for every tool.
  • Exactly five positive test cases and three negative test cases for initial MCP app review.
  • A reviewer-accessible video walkthrough of the test cases and plugin behavior.
  • Review credentials without MFA, SMS, email confirmation, or private-network access.
  • Country or region availability and release notes.

Put test cases and release notes in the package when you want them imported with the ZIP. Enter reviewer credentials in the portal’s private review form, not in the ZIP. After approval, choose when to publish. OpenAI’s submission guide is the final source for portal fields and review requirements, which can change independently of the MCP Apps protocol.

The Build Order I Would Use

This is the sequence I would put in an issue tracker:

  1. Define the user job and the tool list.
  2. Write tool schemas, annotations, and output schemas.
  3. Design structuredContent for each UI-backed tool.
  4. Add simulation files for happy, empty, error, cancelled, and large-data states.
  5. Build the first resource against simulations.
  6. Add MCP contract tests.
  7. Add inspector E2E tests across display modes and themes.
  8. Add app-only tools for pagination, validation, or follow-up actions.
  9. Add visual tests for important screens.
  10. Add a server-backed render test alongside fixture tests.
  11. Connect to live ChatGPT and fix host-specific gaps.
  12. Deploy a production MCP server and run a live regression pass.
  13. Package the plugin ZIP with the server configuration and review material.
  14. Submit the plugin for review.

The order matters. If you start with the live ChatGPT connector, you will spend too much time refreshing and guessing. If you start with the contract and simulations, the UI, tests, and live validation all have a stable base.

Where sunpeak Fits

sunpeak is an open-source MCP App framework, ChatGPT App framework, Claude Connector framework, inspector, and testing framework. It is useful when you want the standard path to be boring:

  • npx sunpeak new for a complete MCP App project.
  • npx sunpeak inspect --server <url> for an existing MCP server.
  • React hooks for tool data, host context, display mode, app state, and actions.
  • Simulation fixtures for deterministic app states.
  • Playwright tests through the inspector.
  • Visual regression tests for layout drift.
  • Live host tests for final ChatGPT and Claude validation.
  • Evals for tool-calling quality.

You can build the app without a framework, especially for a small prototype. The reason to use a framework is not that React is hard. The hard parts are the MCP boundary, host bridge, resource metadata, iframe constraints, test matrix, and release loop.

If you are starting today, start with sunpeak’s quickstart, use OpenAI’s ChatGPT UI guide for host behavior, check the plugin submission guide for review requirements, and keep the MCP Apps overview open for the shared contract.

Get Started

Documentation →
npx sunpeak new

Further Reading

Frequently Asked Questions

What is the best technical plan for building a ChatGPT App in 2026?

Start with an MCP server and tools that work without custom UI. Add MCP Apps UI resources only for tasks that benefit from visual inspection or interaction, and link the render tool with _meta.ui.resourceUri. Define inputSchema, outputSchema, structuredContent, resource metadata, and a local test loop before connecting to live ChatGPT. A framework such as sunpeak can provide scaffolding, inspection, fixtures, and automated tests.

What is the architecture of a ChatGPT App?

A ChatGPT App uses an MCP server, with optional MCP Apps UI. The server exposes tools and, for visual workflows, HTML UI resources. ChatGPT calls a tool and receives content and structuredContent. If the tool descriptor has _meta.ui.resourceUri, ChatGPT loads that resource in a sandboxed iframe, then exchanges host context, tool input, results, and actions through a postMessage JSON-RPC bridge.

Should new ChatGPT Apps use window.openai or MCP Apps APIs?

Use the MCP Apps standard first: _meta.ui.resourceUri, ui/* bridge messages, tools/call, ui/message, ui/update-model-context, content, structuredContent, and outputSchema. Use window.openai only for ChatGPT-specific extensions when the standard does not cover the feature, and feature-detect it so your app still works in other MCP App hosts.

Do I need a paid ChatGPT account to develop a ChatGPT App?

No for most development. You can build and test the app locally with sunpeak at localhost:3000 and an MCP server at localhost:8000. You only need live ChatGPT access when you are ready to validate developer-mode setup, real host metadata, authentication, submission behavior, and final user flows.

How should I test a ChatGPT App?

Use layered tests. Check tools/list, tools/call, inputSchema, outputSchema, resource reads, CSP, and annotations at the MCP boundary. Render fixture states in Playwright, then call the real server with input and assert that the rendered result came from the server. Add visual tests where layout matters, live ChatGPT checks before release, and evals for tool selection.

What data should a ChatGPT App tool return?

Return short model-readable content, UI-ready structuredContent, and optional _meta for UI-only helper data when the host supports it. Declare outputSchema for structuredContent so the server, host, model, resource, and tests all share the same contract. Keep private tokens, cursors that should not be model-visible, and large raw payloads out of structuredContent.

Can one ChatGPT App also work in Claude and other MCP App hosts?

Yes, if the app is built against the MCP Apps standard instead of one host-specific surface. Core APIs such as tool data, host context, display modes, app state, and resource metadata map to the standard. Host-specific features can still be added behind optional imports or feature checks.

How do I deploy and submit a ChatGPT App?

Deploy a public HTTPS MCP server with production UI resources and authentication if needed. Package the plugin with its MCP server configuration and listing metadata, then upload the ZIP in the OpenAI Platform Plugins portal. Connect and scan the server, complete domain verification, and prepare five positive cases, three negative cases, a video walkthrough, release notes, and reviewer credentials when sign-in is required.