Skip to content
VercelLogotypeVercelLogotype
LoginSign Up

MCP Apps Next.js Starter

MCP Apps are similar to ChatGPT apps, but are a provider-agnostic open standard for embedded UIs.

DeployView Demo

MCP Apps — Minimal Next.js Starter

A minimal Next.js starter for building MCP Apps — interactive UIs that MCP hosts render alongside tool calls.

How it works

The Next.js app serves two roles:

  1. MCP server (app/mcp/route.ts) — registers tools and resources via mcp-handler and @modelcontextprotocol/ext-apps.
  2. Widget UI (app/page.tsx) — a React page that MCP hosts render inside a sandboxed iframe. The MCP route self-fetches the rendered page HTML and serves it as an MCP resource.

The useMcpApp hook (app/hooks/use-mcp-app.ts) connects to the host via the App class from @modelcontextprotocol/ext-apps and provides tool input/result data as React state.

Getting started

pnpm install

Local development with a tunnel

MCP Apps need a public HTTPS URL. Use ngrok (or any tunnel):

ngrok http 3000

Copy the HTTPS URL and set it in .env:

BASE_URL=https://xxxx-xxx-xxx.ngrok-free.app

Then start the dev server:

pnpm dev

Connect to a host

Add your MCP server URL to any MCP host that supports Apps:

https://xxxx-xxx-xxx.ngrok-free.app/mcp

For example, in ChatGPT, Cursor, or Claude.ai: Settings > Apps > add the URL above.

Project structure

app/
page.tsx — Homepage (widget UI)
about/page.tsx — Example sub-page (navigation demo)
counter/page.tsx — Example sub-page (interactivity demo)
mcp/route.ts — MCP server endpoint
hooks/use-mcp-app.ts — React hook for the MCP Apps bridge
layout.tsx — Root layout with iframe bootstrap patches
baseUrl.ts — Public URL resolver (tunnel / Vercel)
middleware.ts — CORS headers for cross-origin iframe access
next.config.ts — assetPrefix for iframe asset loading

Key files

  • app/mcp/route.ts — Define your tools and resources here. The greet tool is a minimal example.
  • app/page.tsx — Your widget UI. Edit this like any Next.js page. It receives tool data via useMcpApp().
  • app/hooks/use-mcp-app.ts — Singleton App bridge with sessionStorage persistence. Provides toolInput, toolResult, and connected state.

Deploy

Deploy to Vercel — no additional configuration needed. The BASE_URL is automatically derived from Vercel's environment variables in production.

Once deployed, connect it to any MCP host using:

https://your-app.vercel.app/mcp

For example, in ChatGPT, Cursor, or Claude.ai: Settings > Apps > add the URL above as a connector.

Learn more

  • MCP Apps specification
  • @modelcontextprotocol/ext-apps
  • mcp-handler
GitHub
Ownervercel-labs
Repositorymcp-apps-nextjs-starter
Use Cases
AI
Starter
Stack
Next.js
Tailwind

Related Templates

eve Sanity Copilot

A Slack-based Sanity copilot built on eve. It queries and edits content with GROQ, shapes schemas, manages releases, and drafts into Notion.
eve Sanity Copilot thumbnail

eve Chat Template

A persisted Next.js chat template for eve, built with shadcn/ui, Tailwind CSS, Streamdown, Better Auth, Drizzle, and Neon.
eve Chat Template thumbnail

Next.js Boilerplate

Get started with Next.js and React in seconds.
Next.js Boilerplate thumbnail

Agent Stack

  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • ConnectNew
  • PassportNew
  • eveNew

Core Platform

  • CI/CD
  • Content Delivery
  • Fluid Compute
  • Observability

Security

  • Platform Security
  • WAF
  • Bot Management
  • Bot ID

Tools

  • Vercel DropNew
  • Vercel Agent
  • Vercel PluginNew
  • Agent Skills
  • Next.js
  • Domains
  • v0

Frameworks

  • eveNew
  • Nuxt
  • SvelteKit
  • Nitro
  • Turborepo
  • Tanstack Start
  • FastAPI
  • xmcp
  • All frameworks

SDKs

  • Vercel SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDKNew
  • Queues SDKNew
  • Streamdown

Build

  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
  • Platform Engineers
  • Design Engineers

Learn

  • Docs
  • Blog
  • Changelog
  • Knowledge Base
  • Academy
  • Articles
  • Community

Explore

  • Customers
  • Marketplace
  • Templates
  • Partner Finder
  • Vercel + AWS

Company

  • About
  • Careers
  • Press
  • Events
  • Startups
  • Shipped on Vercel
  • Open Source Program
  • Enterprise
  • Pricing
  • Help

Legal & Trust

  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • DPA
  • Acceptable Use Policy
  • Legal (all documents)
  • Trust Center
  • Status

Social

  • GitHub
  • X
  • LinkedIn
  • YouTube
  • Instagram
  • VercelVercel
Agent Stack
  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • Passport
  • eve
Core Platform
  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • CI/CD
Tools
  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • Domains↗
  • v0↗
Learn
  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base
Build
  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
Explore
  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community↗
EnterprisePricing
Contact
Log InSign Up
Dashboard

Products

Agent Stack

  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • Passport
  • eve

Core Platform

  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • CI/CD

Tools

  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • Domains↗
  • v0↗
Resources

Learn

  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base

Build

  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce

Explore

  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community↗
Enterprise
Pricing
Sign UpLog In
Contact
DeployView Demo

Loading status…

Select a display theme: