VercelLogotypeVercelLogotype
LoginSign Up
Back to Templates

MCP Apps Next.js Starter

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

DeployView Demo
cursor mcp apps

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 Repovercel-labs/mcp-apps-nextjs-starter
Use Cases
AIStarter
Stack
Next.jsTailwind

Get Started

  • Templates
  • Supported frameworks
  • Marketplace
  • Domains

Build

  • Next.js on Vercel
  • Turborepo
  • v0

Scale

  • Content delivery network
  • Fluid compute
  • CI/CD
  • Observability
  • AI GatewayNew
  • Vercel AgentNew

Secure

  • Platform security
  • Web Application Firewall
  • Bot management
  • BotID
  • SandboxNew

Resources

  • Pricing
  • Customers
  • Enterprise
  • Articles
  • Startups
  • Solution partners

Learn

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

Frameworks

  • Next.js
  • Nuxt
  • Svelte
  • Nitro
  • Turbo

SDKs

  • AI SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDK
  • Streamdown AINew

Use Cases

  • Composable commerce
  • Multi-tenant platforms
  • Web apps
  • Marketing sites
  • Platform engineers
  • Design engineers

Company

  • About
  • Careers
  • Help
  • Press
  • Legal
  • Privacy Policy

Community

  • Open source program
  • Events
  • Shipped on Vercel
  • GitHub
  • LinkedIn
  • X
  • YouTube

Loading status…

Select a display theme:
    • AI Cloud
      • v0

        Build applications with AI

      • AI SDK

        The AI Toolkit for TypeScript

      • AI Gateway

        One endpoint, all your models

      • Vercel Agent

        An agent that knows your stack

      • Sandbox

        AI workflows in live environments

    • Core Platform
      • CI/CD

        Helping teams ship 6× faster

      • Content Delivery

        Fast, scalable, and reliable

      • Fluid Compute

        Servers, in serverless form

      • Observability

        Trace every step

    • Security
      • Bot Management

        Scalable bot protection

      • BotID

        Invisible CAPTCHA

      • Platform Security

        DDoS Protection, Firewall

      • Web Application Firewall

        Granular, custom protection

    • Company
      • Customers

        Trusted by the best teams

      • Blog

        The latest posts and changes

      • Changelog

        See what shipped

      • Press

        Read the latest news

      • Events

        Join us at an event

    • Learn
      • Docs

        Vercel documentation

      • Academy

        Linear courses to level up

      • Knowledge Base

        Find help quickly

      • Community

        Join the conversation

    • Open Source
      • Next.js

        The native Next.js platform

      • Nuxt

        The progressive web framework

      • Svelte

        The web’s efficient UI framework

      • Turborepo

        Speed with Enterprise scale

    • Use Cases
      • AI Apps

        Deploy at the speed of AI

      • Composable Commerce

        Power storefronts that convert

      • Marketing Sites

        Launch campaigns fast

      • Multi-tenant Platforms

        Scale apps with one codebase

      • Web Apps

        Ship features, not infrastructure

    • Tools
      • Marketplace

        Extend and automate workflows

      • Templates

        Jumpstart app development

      • Partner Finder

        Get help from solution partners

    • Users
      • Platform Engineers

        Automate away repetition

      • Design Engineers

        Deploy for every idea

  • Enterprise
  • Pricing
Log InContact
Sign Up
Sign Up
Back to Templates
DeployView Demo
v0

Build applications with AI

AI SDK

The AI Toolkit for TypeScript

AI Gateway

One endpoint, all your models

Vercel Agent

An agent that knows your stack

Sandbox

AI workflows in live environments

CI/CD

Helping teams ship 6× faster

Content Delivery

Fast, scalable, and reliable

Fluid Compute

Servers, in serverless form

Observability

Trace every step

Bot Management

Scalable bot protection

BotID

Invisible CAPTCHA

Platform Security

DDoS Protection, Firewall

Web Application Firewall

Granular, custom protection

Customers

Trusted by the best teams

Blog

The latest posts and changes

Changelog

See what shipped

Press

Read the latest news

Events

Join us at an event

Docs

Vercel documentation

Academy

Linear courses to level up

Knowledge Base

Find help quickly

Community

Join the conversation

Next.js

The native Next.js platform

Nuxt

The progressive web framework

Svelte

The web’s efficient UI framework

Turborepo

Speed with Enterprise scale

AI Apps

Deploy at the speed of AI

Composable Commerce

Power storefronts that convert

Marketing Sites

Launch campaigns fast

Multi-tenant Platforms

Scale apps with one codebase

Web Apps

Ship features, not infrastructure

Marketplace

Extend and automate workflows

Templates

Jumpstart app development

Partner Finder

Get help from solution partners

Platform Engineers

Automate away repetition

Design Engineers

Deploy for every idea